Changeset 7784 for branches/HeuristicLab.TreeSimplifierView/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.Views/3.4
- Timestamp:
- 05/08/12 10:10:14 (12 years ago)
- Location:
- branches/HeuristicLab.TreeSimplifierView/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.Views/3.4
- Files:
-
- 10 added
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/HeuristicLab.TreeSimplifierView/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.Views/3.4/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.Views-3.4.csproj
r7388 r7784 159 159 </ItemGroup> 160 160 <ItemGroup> 161 <Compile Include="InteractiveSymbolicExpressionTreeChart.cs"> 162 <SubType>UserControl</SubType> 163 </Compile> 164 <Compile Include="InteractiveSymbolicExpressionTreeChart.Designer.cs"> 165 <DependentUpon>InteractiveSymbolicExpressionTreeChart.cs</DependentUpon> 166 </Compile> 161 167 <Compile Include="Plugin.cs" /> 162 168 <Compile Include="SymbolicExpressionGrammarAllowedChildSymbolsControl.cs"> … … 183 189 <Compile Include="SymbolicExpressionGrammarView.Designer.cs"> 184 190 <DependentUpon>SymbolicExpressionGrammarView.cs</DependentUpon> 191 </Compile> 192 <Compile Include="SymbolicExpressionTreeNodeChangeValueDialog.cs"> 193 <SubType>Form</SubType> 194 </Compile> 195 <Compile Include="SymbolicExpressionTreeNodeChangeValueDialog.Designer.cs"> 196 <DependentUpon>SymbolicExpressionTreeNodeChangeValueDialog.cs</DependentUpon> 197 </Compile> 198 <Compile Include="SymbolicExpressionTreeNodeInsertDialog.cs"> 199 <SubType>Form</SubType> 200 </Compile> 201 <Compile Include="SymbolicExpressionTreeNodeInsertDialog.Designer.cs"> 202 <DependentUpon>SymbolicExpressionTreeNodeInsertDialog.cs</DependentUpon> 185 203 </Compile> 186 204 <Compile Include="SymbolView.cs"> … … 233 251 <Install>true</Install> 234 252 </BootstrapperPackage> 253 </ItemGroup> 254 <ItemGroup> 255 <EmbeddedResource Include="InteractiveSymbolicExpressionTreeChart.resx"> 256 <DependentUpon>InteractiveSymbolicExpressionTreeChart.cs</DependentUpon> 257 </EmbeddedResource> 258 <EmbeddedResource Include="SymbolicExpressionTreeChart.resx"> 259 <DependentUpon>SymbolicExpressionTreeChart.cs</DependentUpon> 260 </EmbeddedResource> 261 <EmbeddedResource Include="SymbolicExpressionTreeNodeChangeValueDialog.resx"> 262 <DependentUpon>SymbolicExpressionTreeNodeChangeValueDialog.cs</DependentUpon> 263 </EmbeddedResource> 264 <EmbeddedResource Include="SymbolicExpressionTreeNodeInsertDialog.resx"> 265 <DependentUpon>SymbolicExpressionTreeNodeInsertDialog.cs</DependentUpon> 266 </EmbeddedResource> 235 267 </ItemGroup> 236 268 <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> -
branches/HeuristicLab.TreeSimplifierView/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.Views/3.4/SymbolView.cs
r7259 r7784 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 { -
branches/HeuristicLab.TreeSimplifierView/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.Views/3.4/SymbolicExpressionGrammarEditorView.Designer.cs
r7148 r7784 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 -
branches/HeuristicLab.TreeSimplifierView/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.Views/3.4/SymbolicExpressionGrammarEditorView.cs
r7259 r7784 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 } -
branches/HeuristicLab.TreeSimplifierView/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.Views/3.4/SymbolicExpressionTreeChart.Designer.cs
r7372 r7784 20 20 #endregion 21 21 22 using System;23 using System.Windows.Forms;24 using HeuristicLab.Common;25 22 26 23 namespace HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.Views { … … 53 50 this.contextMenuStrip = new System.Windows.Forms.ContextMenuStrip(this.components); 54 51 this.saveImageToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); 55 this.changeValueToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();56 52 this.saveFileDialog = new System.Windows.Forms.SaveFileDialog(); 57 53 this.contextMenuStrip.SuspendLayout(); … … 61 57 // 62 58 this.contextMenuStrip.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { 63 this.saveImageToolStripMenuItem, 64 this.changeValueToolStripMenuItem}); 59 this.saveImageToolStripMenuItem}); 65 60 this.contextMenuStrip.Name = "contextMenuStrip"; 66 this.contextMenuStrip.Size = new System.Drawing.Size(153, 70); 67 this.contextMenuStrip.Opened += new System.EventHandler(this.contextMenuStrip_Opened); 61 this.contextMenuStrip.Size = new System.Drawing.Size(153, 48); 68 62 // 69 63 // saveImageToolStripMenuItem … … 73 67 this.saveImageToolStripMenuItem.Text = "Save Image"; 74 68 this.saveImageToolStripMenuItem.Click += new System.EventHandler(this.saveImageToolStripMenuItem_Click); 75 //76 // changeValueToolStripMenuItem77 //78 this.changeValueToolStripMenuItem.Enabled = false;79 this.changeValueToolStripMenuItem.Name = "changeValueToolStripMenuItem";80 this.changeValueToolStripMenuItem.Size = new System.Drawing.Size(152, 22);81 this.changeValueToolStripMenuItem.Text = "Change Value";82 this.changeValueToolStripMenuItem.Click += new System.EventHandler(this.changeValueToolStripMenuItem_Click);83 69 // 84 70 // saveFileDialog … … 105 91 106 92 private System.Windows.Forms.ToolTip toolTip; 107 private System.Windows.Forms.ContextMenuStrip contextMenuStrip;108 93 private System.Windows.Forms.ToolStripMenuItem saveImageToolStripMenuItem; 109 94 private System.Windows.Forms.SaveFileDialog saveFileDialog; 110 private System.Windows.Forms.ToolStripMenuItem changeValueToolStripMenuItem;95 internal System.Windows.Forms.ContextMenuStrip contextMenuStrip; 111 96 } 112 97 } -
branches/HeuristicLab.TreeSimplifierView/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.Views/3.4/SymbolicExpressionTreeChart.cs
r7411 r7784 27 27 28 28 namespace HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.Views { 29 public sealedpartial class SymbolicExpressionTreeChart : UserControl {29 public partial class SymbolicExpressionTreeChart : UserControl { 30 30 private Image image; 31 31 private StringFormat stringFormat; 32 private Dictionary<ISymbolicExpressionTreeNode, VisualSymbolicExpressionTreeNode> visualTreeNodes; 33 private Dictionary<Tuple<ISymbolicExpressionTreeNode, ISymbolicExpressionTreeNode>, VisualSymbolicExpressionTreeNodeConnection> visualLines; 34 private VisualSymbolicExpressionTreeNode selectedNode; 32 protected Dictionary<ISymbolicExpressionTreeNode, VisualSymbolicExpressionTreeNode> visualTreeNodes; 33 protected Dictionary<Tuple<ISymbolicExpressionTreeNode, ISymbolicExpressionTreeNode>, VisualSymbolicExpressionTreeNodeConnection> visualLines; 35 34 36 35 public SymbolicExpressionTreeChart() { … … 44 43 this.backgroundColor = Color.White; 45 44 this.textFont = new Font("Times New Roman", 8); 46 selectedNode = null;47 45 } 48 46 … … 158 156 159 157 #region events 160 public event EventHandler SymbolicExpressionTreeNodeChanged;161 private void OnSymbolicExpressionTreeNodeChanged(object sender, EventArgs e) {162 var changed = SymbolicExpressionTreeNodeChanged;163 if (changed != null) {164 changed(sender, e);165 }166 }167 168 158 public event MouseEventHandler SymbolicExpressionTreeNodeClicked; 169 pr ivatevoid OnSymbolicExpressionTreeNodeClicked(object sender, MouseEventArgs e) {159 protected void OnSymbolicExpressionTreeNodeClicked(object sender, MouseEventArgs e) { 170 160 var clicked = SymbolicExpressionTreeNodeClicked; 171 161 if (clicked != null) … … 173 163 } 174 164 175 pr ivatevoid SymbolicExpressionTreeChart_MouseClick(object sender, MouseEventArgs e) {165 protected virtual void SymbolicExpressionTreeChart_MouseClick(object sender, MouseEventArgs e) { 176 166 VisualSymbolicExpressionTreeNode visualTreeNode = FindVisualSymbolicExpressionTreeNodeAt(e.X, e.Y); 177 if (visualTreeNode != null) 167 if (visualTreeNode != null) { 178 168 OnSymbolicExpressionTreeNodeClicked(visualTreeNode, e); 169 } 179 170 } 180 171 181 172 public event MouseEventHandler SymbolicExpressionTreeNodeDoubleClicked; 182 pr ivatevoid OnSymbolicExpressionTreeNodeDoubleClicked(object sender, MouseEventArgs e) {173 protected void OnSymbolicExpressionTreeNodeDoubleClicked(object sender, MouseEventArgs e) { 183 174 var doubleClicked = SymbolicExpressionTreeNodeDoubleClicked; 184 175 if (doubleClicked != null) … … 193 184 194 185 public event ItemDragEventHandler SymbolicExpressionTreeNodeDrag; 195 pr ivatevoid OnSymbolicExpressionTreeNodeDragDrag(object sender, ItemDragEventArgs e) {186 protected void OnSymbolicExpressionTreeNodeDragDrag(object sender, ItemDragEventArgs e) { 196 187 var dragged = SymbolicExpressionTreeNodeDrag; 197 188 if (dragged != null) … … 244 235 /// 245 236 /// </summary> 246 /// <param name="functionTree"> function tree to draw</param>237 /// <param name="functionTree"> function tree to draw</param> 247 238 /// <param name="graphics">graphics object to draw on</param> 248 239 /// <param name="x">x coordinate of drawing area</param> … … 357 348 } 358 349 #endregion 359 360 private void contextMenuStrip_Opened(object sender, EventArgs e) {361 var menu = sender as ContextMenuStrip;362 if (menu == null) return;363 var point = menu.SourceControl.PointToClient(Cursor.Position);364 selectedNode = FindVisualSymbolicExpressionTreeNodeAt(point.X, point.Y);365 if (selectedNode != null) {366 OnSymbolicExpressionTreeNodeClicked(selectedNode, new MouseEventArgs(MouseButtons.Right, 1, point.X, point.Y, 0));367 }368 }369 370 private void changeValueToolStripMenuItem_Click(object sender, EventArgs e) {371 if (selectedNode != null) // this should never be null anyway372 OnSymbolicExpressionTreeNodeChanged(selectedNode, e);373 }374 350 } 375 351 }
Note: See TracChangeset
for help on using the changeset viewer.