Adding SoundGraphDisplay and SensorFrontView classes.
They were respectively based on SystemTray and SensorNotifyIcon.
SoundGraphDisplay is now able to load iMONDisplay.dll providing it lives on your PATH.
Adding option to sensor context menu for adding it into FrontView.
2 using System.Collections.Generic;
4 using System.Windows.Forms;
5 using Aga.Controls.Tree.NodeControls;
8 namespace Aga.Controls.Tree
10 partial class TreeViewAdv
12 private TreeNodeAdv _editingNode;
14 public EditableControl CurrentEditorOwner { get; private set; }
15 public Control CurrentEditor { get; private set; }
17 public void HideEditor()
19 if (CurrentEditorOwner != null)
20 CurrentEditorOwner.EndEdit(false);
23 internal void DisplayEditor(Control editor, EditableControl owner)
25 if (editor == null || owner == null || CurrentNode == null)
26 throw new ArgumentNullException();
30 CurrentEditor = editor;
31 CurrentEditorOwner = owner;
32 _editingNode = CurrentNode;
34 editor.Validating += EditorValidating;
39 owner.UpdateEditor(editor);
42 internal bool HideEditor(bool applyChanges)
44 if (CurrentEditor != null)
52 //Check once more if editor was closed in ApplyChanges
53 if (CurrentEditor != null)
55 CurrentEditor.Validating -= EditorValidating;
56 CurrentEditorOwner.DoDisposeEditor(CurrentEditor);
58 CurrentEditor.Parent = null;
59 CurrentEditor.Dispose();
62 CurrentEditorOwner = null;
69 private bool ApplyChanges()
73 CurrentEditorOwner.ApplyChanges(_editingNode, CurrentEditor);
74 _errorProvider.Clear();
77 catch (ArgumentException ex)
79 _errorProvider.SetError(CurrentEditor, ex.Message);
80 /*CurrentEditor.Validating -= EditorValidating;
81 MessageBox.Show(this, ex.Message, "Value is not valid", MessageBoxButtons.OK, MessageBoxIcon.Warning);
82 CurrentEditor.Focus();
83 CurrentEditor.Validating += EditorValidating;*/
88 void EditorValidating(object sender, System.ComponentModel.CancelEventArgs e)
90 e.Cancel = !ApplyChanges();
93 public void UpdateEditorBounds()
95 if (CurrentEditor != null)
97 EditorContext context = new EditorContext();
98 context.Owner = CurrentEditorOwner;
99 context.CurrentNode = CurrentNode;
100 context.Editor = CurrentEditor;
101 context.DrawContext = _measureContext;
102 SetEditorBounds(context);
106 private void SetEditorBounds(EditorContext context)
108 foreach (NodeControlInfo info in GetNodeControls(context.CurrentNode))
110 if (context.Owner == info.Control && info.Control is EditableControl)
112 Point p = info.Bounds.Location;
113 p.X += info.Control.LeftMargin;
115 p.Y -= (_rowLayout.GetRowBounds(FirstVisibleRow).Y - ColumnHeaderHeight);
116 int width = DisplayRectangle.Width - p.X;
117 if (UseColumns && info.Control.ParentColumn != null && Columns.Contains(info.Control.ParentColumn))
119 Rectangle rect = GetColumnBounds(info.Control.ParentColumn.Index);
120 width = rect.Right - OffsetX - p.X;
122 context.Bounds = new Rectangle(p.X, p.Y, width, info.Bounds.Height);
123 ((EditableControl)info.Control).SetEditorBounds(context);
129 private Rectangle GetColumnBounds(int column)
132 for (int i = 0; i < Columns.Count; i++)
134 if (Columns[i].IsVisible)
137 x += Columns[i].Width;
139 return new Rectangle(x, 0, Columns[i].Width, 0);
142 return Rectangle.Empty;