Changeset 7372 for branches/HeuristicLab.TreeSimplifierView/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.Views
- Timestamp:
- 01/19/12 17:04:32 (12 years ago)
- Location:
- branches/HeuristicLab.TreeSimplifierView/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.Views/3.4
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/HeuristicLab.TreeSimplifierView/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.Views/3.4/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.Views-3.4.csproj
r7365 r7372 135 135 <HintPath>..\..\..\..\trunk\sources\bin\HeuristicLab.PluginInfrastructure-3.3.dll</HintPath> 136 136 </Reference> 137 <Reference Include="HeuristicLab.Problems.DataAnalysis.Symbolic-3.4, Version=3.4.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL" /> 137 138 <Reference Include="HeuristicLab.Random-3.3"> 138 139 <HintPath>..\..\..\..\trunk\sources\bin\HeuristicLab.Random-3.3.dll</HintPath> … … 232 233 <Install>true</Install> 233 234 </BootstrapperPackage> 235 </ItemGroup> 236 <ItemGroup> 237 <EmbeddedResource Include="SymbolicExpressionTreeChart.resx"> 238 <DependentUpon>SymbolicExpressionTreeChart.cs</DependentUpon> 239 </EmbeddedResource> 234 240 </ItemGroup> 235 241 <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> -
branches/HeuristicLab.TreeSimplifierView/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.Views/3.4/SymbolicExpressionTreeChart.Designer.cs
r7259 r7372 19 19 */ 20 20 #endregion 21 22 using System; 23 using System.Windows.Forms; 24 using HeuristicLab.Common; 21 25 22 26 namespace HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.Views { … … 49 53 this.contextMenuStrip = new System.Windows.Forms.ContextMenuStrip(this.components); 50 54 this.saveImageToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); 55 this.changeValueToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); 51 56 this.saveFileDialog = new System.Windows.Forms.SaveFileDialog(); 52 57 this.contextMenuStrip.SuspendLayout(); … … 56 61 // 57 62 this.contextMenuStrip.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { 58 this.saveImageToolStripMenuItem}); 63 this.saveImageToolStripMenuItem, 64 this.changeValueToolStripMenuItem}); 59 65 this.contextMenuStrip.Name = "contextMenuStrip"; 60 this.contextMenuStrip.Size = new System.Drawing.Size(135, 26); 66 this.contextMenuStrip.Size = new System.Drawing.Size(153, 70); 67 this.contextMenuStrip.Opened += new System.EventHandler(this.contextMenuStrip_Opened); 61 68 // 62 69 // saveImageToolStripMenuItem 63 70 // 64 71 this.saveImageToolStripMenuItem.Name = "saveImageToolStripMenuItem"; 65 this.saveImageToolStripMenuItem.Size = new System.Drawing.Size(1 34, 22);72 this.saveImageToolStripMenuItem.Size = new System.Drawing.Size(152, 22); 66 73 this.saveImageToolStripMenuItem.Text = "Save Image"; 67 74 this.saveImageToolStripMenuItem.Click += new System.EventHandler(this.saveImageToolStripMenuItem_Click); 75 // 76 // changeValueToolStripMenuItem 77 // 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); 68 83 // 69 84 // saveFileDialog 70 85 // 71 86 this.saveFileDialog.Filter = "Bitmap (*.bmp)|*.bmp|EMF (*.emf)|*.emf"; 72 this.saveFileDialog.FilterIndex = 1;87 // 73 88 // SymbolicExpressionTreeChart 74 89 // … … 93 108 private System.Windows.Forms.ToolStripMenuItem saveImageToolStripMenuItem; 94 109 private System.Windows.Forms.SaveFileDialog saveFileDialog; 110 private System.Windows.Forms.ToolStripMenuItem changeValueToolStripMenuItem; 95 111 } 96 112 } -
branches/HeuristicLab.TreeSimplifierView/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.Views/3.4/SymbolicExpressionTreeChart.cs
r7259 r7372 25 25 using System.Drawing.Imaging; 26 26 using System.Windows.Forms; 27 using System.Windows.Forms.VisualStyles; 27 28 28 29 namespace HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.Views { … … 32 33 private Dictionary<ISymbolicExpressionTreeNode, VisualSymbolicExpressionTreeNode> visualTreeNodes; 33 34 private Dictionary<Tuple<ISymbolicExpressionTreeNode, ISymbolicExpressionTreeNode>, VisualSymbolicExpressionTreeNodeConnection> visualLines; 35 private VisualSymbolicExpressionTreeNode selectedNode; 34 36 35 37 public SymbolicExpressionTreeChart() { … … 43 45 this.backgroundColor = Color.White; 44 46 this.textFont = new Font("Times New Roman", 8); 47 selectedNode = null; 45 48 } 46 49 … … 347 350 } 348 351 #endregion 352 353 private void contextMenuStrip_Opened(object sender, EventArgs e) { 354 var menu = sender as ContextMenuStrip; 355 if (menu == null) return; 356 var point = menu.SourceControl.PointToClient(Cursor.Position); 357 selectedNode = FindVisualSymbolicExpressionTreeNodeAt(point.X, point.Y); 358 if (selectedNode != null) { 359 OnSymbolicExpressionTreeNodeClicked(selectedNode, new MouseEventArgs(MouseButtons.Right, 1, point.X, point.Y, 0)); 360 } 361 } 362 363 private void changeValueToolStripMenuItem_Click(object sender, EventArgs e) { 364 var treeNode = selectedNode.SymbolicExpressionTreeNode; 365 // textbox as a popup/tooltip 366 var dialog = new Core.Views.TextDialog("Change value", String.Empty, false); 367 dialog.AutoSize = true; 368 dialog.ShowDialog(this); 369 double newValue; 370 if (double.TryParse(dialog.Text, out newValue)) { 371 if (treeNode.Symbol is Problems.DataAnalysis.Symbolic.Constant) { 372 var node = treeNode as Problems.DataAnalysis.Symbolic.ConstantTreeNode; 373 node.Value = newValue; 374 } else if (treeNode.Symbol is Problems.DataAnalysis.Symbolic.Variable) { 375 var node = treeNode as Problems.DataAnalysis.Symbolic.VariableTreeNode; 376 node.Weight = newValue; 377 } 378 } 379 this.Repaint(); 380 } 349 381 } 350 382 }
Note: See TracChangeset
for help on using the changeset viewer.