using System; using System.Collections.Generic; using System.ComponentModel; using System.Drawing; using System.Data; using System.Text; using System.Windows.Forms; using VEPROMS.CSLA.Library; namespace Volian.Controls.Library { public partial class AnnotationSearch : UserControl { #region Properties private AnnotationDetails _AnnotationDetails = null; private bool _LoadingList = false; public bool LoadingList { get { return _LoadingList; } set { _LoadingList = value; } } private DisplayTabControl _TabControl; #endregion #region Constructors public AnnotationSearch() { InitializeComponent(); } #endregion #region Events private void cbAnnoType_SelectedValueChanged(object sender, EventArgs e) { UpdateAnnotationSearchResults(); } private void lbResults_SelectedValueChanged(object sender, EventArgs e) { if (!_LoadingList) { _AnnotationDetails.CurrentAnnotation = lbResults.SelectedValue as AnnotationInfo; if (_AnnotationDetails.CurrentAnnotation != null) _TabControl.OpenItem(_AnnotationDetails.CurrentAnnotation.MyItem); // open the corresponding procedure text _AnnotationDetails.FindCurrentAnnotation(); // position to corresponding row in annotation grid } } private int LastResultsMouseOverIndex = -1; private void lbResults_MouseMove(object sender, MouseEventArgs e) { int ResultsMouseOverIndex = lbResults.IndexFromPoint(e.Location); if (ResultsMouseOverIndex != -1 && ResultsMouseOverIndex != LastResultsMouseOverIndex) { AnnotationInfo ai = lbResults.Items[ResultsMouseOverIndex] as AnnotationInfo; toolTip1.SetToolTip(lbResults, ai.MyItem.Path); // display location of corresponding procedure text in a tooltip LastResultsMouseOverIndex = ResultsMouseOverIndex; } } #endregion #region LoadControlData public void SetupAnnotationSearch(AnnotationDetails annotationDetails, DisplayTabControl tc) { _AnnotationDetails = annotationDetails; cbAnnoType.DisplayMember = "Name"; cbAnnoType.DataSource = AnnotationTypeInfoList.Get(); lbResults.MouseMove += new MouseEventHandler(lbResults_MouseMove); _TabControl = tc; } #endregion #region VariousSupportMethods public void UpdateAnnotationSearchResults() { AnnotationTypeInfo ati = cbAnnoType.SelectedValue as AnnotationTypeInfo; _LoadingList = true; lbResults.DisplayMember = "SearchText"; lbResults.DataSource = ati.AnnotationTypeAnnotations; lbResults.SelectedIndex = -1; LastResultsMouseOverIndex = -1; _LoadingList = false; } #endregion } }