Free cookie consent management tool by TermsFeed Policy Generator

Changeset 7581 for trunk/sources


Ignore:
Timestamp:
03/07/12 16:08:50 (13 years ago)
Author:
mkommend
Message:

#1790: Opened a new symbol view on double click in the GrammarEditor and set the SymbolView as default view for ISymbols.

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  
    2929namespace HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.Views {
    3030  [View("Symbol View")]
    31   [Content(typeof(ISymbol), false)]
     31  [Content(typeof(ISymbol), true)]
    3232  public partial class SymbolView : NamedItemView {
    3333    public new ISymbol Content {
  • trunk/sources/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.Views/3.4/SymbolicExpressionGrammarEditorView.Designer.cs

    r7148 r7581  
    170170      this.symbolsTreeView.KeyDown += new System.Windows.Forms.KeyEventHandler(this.symbolsTreeView_KeyDown);
    171171      this.symbolsTreeView.MouseDown += new System.Windows.Forms.MouseEventHandler(this.symbolsTreeView_MouseDown);
     172      this.symbolsTreeView.NodeMouseDoubleClick += new System.Windows.Forms.TreeNodeMouseClickEventHandler(symbolsTreeView_NodeMouseDoubleClick);
    172173      //
    173174      // imageList
  • trunk/sources/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.Views/3.4/SymbolicExpressionGrammarEditorView.cs

    r7259 r7581  
    6262        copyButton.Enabled = false;
    6363        treeViewBackColor = symbolsTreeView.BackColor;
    64         symbolsTreeView.BackColor = Color.FromArgb(255,240,240,240);
     64        symbolsTreeView.BackColor = Color.FromArgb(255, 240, 240, 240);
    6565      } else {
    6666        addButton.Enabled = true;
     
    125125    #endregion
    126126
    127     private bool internalTreeViewUpdateInProgress = false;
    128127    private void UpdateSymbolsTreeView() {
    129       internalTreeViewUpdateInProgress = true;
    130128      var symbols = Content.Symbols.ToList();
    131129      foreach (var treeNode in IterateTreeNodes().ToList()) {
     
    140138
    141139      RebuildImageList();
    142       internalTreeViewUpdateInProgress = false;
    143140    }
    144141
     
    181178
    182179    private void symbolsTreeView_BeforeCheck(object sender, TreeViewCancelEventArgs e) {
    183       if (internalTreeViewUpdateInProgress) return;     
    184180      if (Content == null || Content.ReadOnly) e.Cancel = true;
    185181      if (ReadOnly || Locked) e.Cancel = true;
     
    187183
    188184    #region drag & drop operations
    189     private GroupSymbol parentOfDraggedSymbol;
    190185    private void symbolsTreeView_ItemDrag(object sender, ItemDragEventArgs e) {
    191186      if (!Locked) {
    192187        var treeNode = e.Item as TreeNode;
    193         if (treeNode.Parent != null) parentOfDraggedSymbol = treeNode.Parent.Tag as GroupSymbol;
    194188        var data = new DataObject();
    195189        data.SetData(HeuristicLab.Common.Constants.DragDropDataFormat, treeNode.Tag);
     
    257251    }
    258252
     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
    259262    private void symbolsTreeView_KeyDown(object sender, KeyEventArgs e) {
    260263      if (Content == null || Content.ReadOnly || ReadOnly || Locked) return;
     
    424427
    425428  //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
    426430  internal class CheckBoxTreeView : TreeView {
    427431    protected override void WndProc(ref Message m) {
    428432      // 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));
    430449    }
    431450  }
Note: See TracChangeset for help on using the changeset viewer.