Front View plug-in does not init if no sensor added.
Fixing some format to make strings shorter.
Now trying to start SoundGraphAccess.exe process from same directory.
Packed mode now can display three sensors along with the current time.
2 using System.Collections.Generic;
4 using Aga.Controls.Tree.NodeControls;
5 using System.ComponentModel;
7 using System.Windows.Forms;
9 namespace Aga.Controls.Tree
11 internal class IncrementalSearch
13 private const int SearchTimeout = 300; //end of incremental search timeot in msec
15 private TreeViewAdv _tree;
16 private TreeNodeAdv _currentNode;
17 private string _searchString = "";
18 private DateTime _lastKeyPressed = DateTime.Now;
20 public IncrementalSearch(TreeViewAdv tree)
25 public void Search(Char value)
27 if (!Char.IsControl(value))
29 Char ch = Char.ToLowerInvariant(value);
30 DateTime dt = DateTime.Now;
31 TimeSpan ts = dt - _lastKeyPressed;
33 if (ts.TotalMilliseconds < SearchTimeout)
35 if (_searchString == value.ToString())
47 private void ContinuousSearch(Char value)
49 if (value == ' ' && String.IsNullOrEmpty(_searchString))
50 return; //Ingnore leading space
52 _searchString += value;
56 private void FirstCharSearch(Char value)
61 _searchString = value.ToString();
62 TreeNodeAdv node = null;
63 if (_tree.SelectedNode != null)
64 node = _tree.SelectedNode.NextVisibleNode;
66 node = _tree.Root.NextVisibleNode;
69 foreach (string label in IterateNodeLabels(node))
71 if (label.StartsWith(_searchString))
73 _tree.SelectedNode = _currentNode;
79 public virtual void EndSearch()
85 protected IEnumerable<string> IterateNodeLabels(TreeNodeAdv start)
88 while(_currentNode != null)
90 foreach (string label in GetNodeLabels(_currentNode))
93 _currentNode = _currentNode.NextVisibleNode;
94 if (_currentNode == null)
95 _currentNode = _tree.Root;
97 if (start == _currentNode)
102 private IEnumerable<string> GetNodeLabels(TreeNodeAdv node)
104 foreach (NodeControl nc in _tree.NodeControls)
106 BindableControl bc = nc as BindableControl;
107 if (bc != null && bc.IncrementalSearchEnabled)
109 object obj = bc.GetValue(node);
111 yield return obj.ToString().ToLowerInvariant();
116 private bool DoContinuousSearch()
119 if (!String.IsNullOrEmpty(_searchString))
121 TreeNodeAdv node = null;
122 if (_tree.SelectedNode != null)
123 node = _tree.SelectedNode;
125 node = _tree.Root.NextVisibleNode;
127 if (!String.IsNullOrEmpty(_searchString))
129 foreach (string label in IterateNodeLabels(node))
131 if (label.StartsWith(_searchString))
134 _tree.SelectedNode = _currentNode;