- Timestamp:
- 03/07/12 16:08:50 (13 years ago)
- Location:
- trunk/sources/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.Views/3.4
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.Views/3.4/SymbolView.cs
r7259 r7581 29 29 namespace HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.Views { 30 30 [View("Symbol View")] 31 [Content(typeof(ISymbol), false)]31 [Content(typeof(ISymbol), true)] 32 32 public partial class SymbolView : NamedItemView { 33 33 public new ISymbol Content { -
trunk/sources/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.Views/3.4/SymbolicExpressionGrammarEditorView.Designer.cs
r7148 r7581 170 170 this.symbolsTreeView.KeyDown += new System.Windows.Forms.KeyEventHandler(this.symbolsTreeView_KeyDown); 171 171 this.symbolsTreeView.MouseDown += new System.Windows.Forms.MouseEventHandler(this.symbolsTreeView_MouseDown); 172 this.symbolsTreeView.NodeMouseDoubleClick += new System.Windows.Forms.TreeNodeMouseClickEventHandler(symbolsTreeView_NodeMouseDoubleClick); 172 173 // 173 174 // imageList -
trunk/sources/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.Views/3.4/SymbolicExpressionGrammarEditorView.cs
r7259 r7581 62 62 copyButton.Enabled = false; 63 63 treeViewBackColor = symbolsTreeView.BackColor; 64 symbolsTreeView.BackColor = Color.FromArgb(255, 240,240,240);64 symbolsTreeView.BackColor = Color.FromArgb(255, 240, 240, 240); 65 65 } else { 66 66 addButton.Enabled = true; … … 125 125 #endregion 126 126 127 private bool internalTreeViewUpdateInProgress = false;128 127 private void UpdateSymbolsTreeView() { 129 internalTreeViewUpdateInProgress = true;130 128 var symbols = Content.Symbols.ToList(); 131 129 foreach (var treeNode in IterateTreeNodes().ToList()) { … … 140 138 141 139 RebuildImageList(); 142 internalTreeViewUpdateInProgress = false;143 140 } 144 141 … … 181 178 182 179 private void symbolsTreeView_BeforeCheck(object sender, TreeViewCancelEventArgs e) { 183 if (internalTreeViewUpdateInProgress) return;184 180 if (Content == null || Content.ReadOnly) e.Cancel = true; 185 181 if (ReadOnly || Locked) e.Cancel = true; … … 187 183 188 184 #region drag & drop operations 189 private GroupSymbol parentOfDraggedSymbol;190 185 private void symbolsTreeView_ItemDrag(object sender, ItemDragEventArgs e) { 191 186 if (!Locked) { 192 187 var treeNode = e.Item as TreeNode; 193 if (treeNode.Parent != null) parentOfDraggedSymbol = treeNode.Parent.Tag as GroupSymbol;194 188 var data = new DataObject(); 195 189 data.SetData(HeuristicLab.Common.Constants.DragDropDataFormat, treeNode.Tag); … … 257 251 } 258 252 253 private void symbolsTreeView_NodeMouseDoubleClick(object sender, TreeNodeMouseClickEventArgs e) { 254 var symbol = e.Node.Tag as ISymbol; 255 if (symbol == null) return; 256 if (e.Button != MouseButtons.Left) return; 257 if (e.X < e.Node.Bounds.Left - symbolsTreeView.ImageList.Images[e.Node.ImageIndex].Width || e.X > e.Node.Bounds.Right) return; 258 MainFormManager.MainForm.ShowContent(symbol); 259 e.Node.Toggle(); 260 } 261 259 262 private void symbolsTreeView_KeyDown(object sender, KeyEventArgs e) { 260 263 if (Content == null || Content.ReadOnly || ReadOnly || Locked) return; … … 424 427 425 428 //this class is necessary to prevent double clicks which do not fire the checkbox checked event 429 //workaround taken from http://connect.microsoft.com/VisualStudio/feedback/details/374516/treeview-control-does-not-fire-events-reliably-when-double-clicking-on-checkbox 426 430 internal class CheckBoxTreeView : TreeView { 427 431 protected override void WndProc(ref Message m) { 428 432 // Suppress WM_LBUTTONDBLCLK 429 if (m.Msg == 0x203) { m.Result = IntPtr.Zero; } else base.WndProc(ref m); 433 if (m.Msg == 0x203 && IsOnCheckBox(m)) { m.Result = IntPtr.Zero; } else base.WndProc(ref m); 434 } 435 436 private int GetXLParam(IntPtr lParam) { 437 return lParam.ToInt32() & 0xffff; 438 } 439 440 private int GetYLParam(IntPtr lParam) { 441 return lParam.ToInt32() >> 16; 442 } 443 444 private bool IsOnCheckBox(Message m) { 445 int x = GetXLParam(m.LParam); 446 int y = GetYLParam(m.LParam); 447 TreeNode node = this.GetNodeAt(x, y); 448 return ((x <= node.Bounds.Left - 20) && (x >= node.Bounds.Left - 32)); 430 449 } 431 450 }
Note: See TracChangeset
for help on using the changeset viewer.