search logic
This commit is contained in:
@@ -12,8 +12,11 @@ namespace Volian.Controls.Library
|
||||
public partial class AnnotationDetails : UserControl
|
||||
{
|
||||
#region Properties
|
||||
private ItemInfo _CurrentItem = null;
|
||||
private AnnotationSearch _AnnotationSearch;
|
||||
private bool _LoadingAnnotation = false;
|
||||
private bool _LoadingGrid = false;
|
||||
|
||||
private ItemInfo _CurrentItem = null;
|
||||
private DisplaySearch _AnnotationSearch;
|
||||
|
||||
private AnnotationInfoList _Annotations;
|
||||
public AnnotationInfoList Annotations
|
||||
@@ -43,7 +46,7 @@ namespace Volian.Controls.Library
|
||||
}
|
||||
_CurrentAnnotation = value;
|
||||
InitializeAnnotation();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private bool _AnnotationDirty = false;
|
||||
@@ -94,9 +97,10 @@ namespace Volian.Controls.Library
|
||||
private bool _AddingAnnotation = false;
|
||||
private void btnAddAnnotation_Click(object sender, EventArgs e)
|
||||
{
|
||||
c1AnnotationGrid.Row = -1;
|
||||
dgAnnotations.ClearSelection();
|
||||
CurrentAnnotation = null;
|
||||
_AddingAnnotation = true;
|
||||
rtxbComment.Focus();
|
||||
}
|
||||
|
||||
private void btnRemoveAnnotation_Click(object sender, EventArgs e)
|
||||
@@ -143,18 +147,16 @@ namespace Volian.Controls.Library
|
||||
AnnotationDirty = true;
|
||||
}
|
||||
|
||||
private bool _LoadingAnnotation = false;
|
||||
private bool _LoadingGrid = false;
|
||||
private void c1AnnotationGrid_EnterCell(object sender, EventArgs e)
|
||||
{
|
||||
if (!_LoadingGrid) // Only set the Current Annotation when not loading the grid
|
||||
{
|
||||
if ((_Annotations != null) && (c1AnnotationGrid.Row > 0))
|
||||
CurrentAnnotation = _Annotations[c1AnnotationGrid.Row - 1];
|
||||
else
|
||||
CurrentAnnotation = null;
|
||||
}
|
||||
}
|
||||
private void dgAnnotations_CellClick(object sender, DataGridViewCellEventArgs e)
|
||||
{
|
||||
if (!_LoadingGrid) // Only set the Current Annotation when not loading the grid
|
||||
{
|
||||
if ((_Annotations != null) && (dgAnnotations.Rows.Count > 0))
|
||||
CurrentAnnotation = _Annotations[dgAnnotations.CurrentRow.Index];
|
||||
else
|
||||
CurrentAnnotation = null;
|
||||
}
|
||||
}
|
||||
|
||||
private void rtxbComment_TextChanged(object sender, EventArgs e)
|
||||
{
|
||||
@@ -166,15 +168,17 @@ namespace Volian.Controls.Library
|
||||
|
||||
#region LoadControlData
|
||||
|
||||
public void SetupAnnotations(AnnotationSearch annotation)
|
||||
{
|
||||
_AnnotationSearch = annotation; // reference the Annotation Search to update its lists
|
||||
public void SetupAnnotations(DisplaySearch annosrch)
|
||||
{
|
||||
_LoadingAnnotation = true;
|
||||
_AnnotationSearch = annosrch; // reference the Annotation Search to update its lists
|
||||
|
||||
cbGridAnnoType.DisplayMember = "Name";
|
||||
cbGridAnnoType.ValueMember = "TypeId";
|
||||
cbGridAnnoType.DataSource = AnnotationTypeInfoList.Get().Clone();
|
||||
cbGridAnnoType.SelectedIndex = -1; //don't pre-select an annotation type
|
||||
}
|
||||
cbGridAnnoType.DisplayMember = "Name";
|
||||
cbGridAnnoType.ValueMember = "TypeId";
|
||||
cbGridAnnoType.DataSource = AnnotationTypeInfoList.Get().Clone();
|
||||
cbGridAnnoType.SelectedIndex = -1; //don't pre-select an annotation type
|
||||
_LoadingAnnotation = false;
|
||||
}
|
||||
|
||||
private void InitializeAnnotation()
|
||||
{
|
||||
@@ -195,8 +199,8 @@ namespace Volian.Controls.Library
|
||||
}
|
||||
_LoadingAnnotation = false;
|
||||
AnnotationDirty = false;
|
||||
if (!_LoadingGrid)
|
||||
rtxbComment.Focus(); // Set the focus to the comment text
|
||||
if (!_LoadingGrid)
|
||||
rtxbComment.Focus(); // Set the focus to the comment text
|
||||
}
|
||||
|
||||
#endregion
|
||||
@@ -219,6 +223,7 @@ namespace Volian.Controls.Library
|
||||
_LoadingGrid = true;
|
||||
_Annotations = (_CurrentItem == null) ? null : _CurrentItem.ItemAnnotations;
|
||||
itemAnnotationsBindingSource.DataSource = _Annotations;
|
||||
dgAnnotations.Refresh();
|
||||
if ((CurrentAnnotation == null || (_CurrentItem.ItemID != CurrentAnnotation.ItemID)))
|
||||
{
|
||||
if (_Annotations != null && _Annotations.Count > 0)
|
||||
@@ -237,21 +242,23 @@ namespace Volian.Controls.Library
|
||||
public void FindCurrentAnnotation()
|
||||
{
|
||||
int row = 0;
|
||||
if (CurrentAnnotation != null)
|
||||
{
|
||||
if (_Annotations != null)
|
||||
{
|
||||
foreach (AnnotationInfo ai in _Annotations)
|
||||
{
|
||||
if (ai.AnnotationID == CurrentAnnotation.AnnotationID)
|
||||
{
|
||||
row = _Annotations.IndexOf(ai) + 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
c1AnnotationGrid.Select(row, 0, true); // position to the corresponding grid row
|
||||
if (CurrentAnnotation != null)
|
||||
{
|
||||
if (_Annotations != null)
|
||||
{
|
||||
foreach (AnnotationInfo ai in _Annotations)
|
||||
{
|
||||
if (ai.AnnotationID == CurrentAnnotation.AnnotationID)
|
||||
{
|
||||
row = _Annotations.IndexOf(ai);// +1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
dgAnnotations.Rows[row].Selected = true;
|
||||
if (!_LoadingGrid)
|
||||
dgAnnotations.FirstDisplayedScrollingRowIndex = row;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void SaveAnnotation()
|
||||
@@ -290,5 +297,6 @@ namespace Volian.Controls.Library
|
||||
}
|
||||
#endregion
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user