Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
05/08/12 10:10:14 (12 years ago)
Author:
bburlacu
Message:

#1832: Moved replacement and impact values calculation code from view to separate files. Implemented simplifier actions: copy, cut, delete, insert node/subtree.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/HeuristicLab.TreeSimplifierView/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.Views/3.4/SymbolicExpressionTreeChart.cs

    r7411 r7784  
    2727
    2828namespace HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.Views {
    29   public sealed partial class SymbolicExpressionTreeChart : UserControl {
     29  public partial class SymbolicExpressionTreeChart : UserControl {
    3030    private Image image;
    3131    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;
    3534
    3635    public SymbolicExpressionTreeChart() {
     
    4443      this.backgroundColor = Color.White;
    4544      this.textFont = new Font("Times New Roman", 8);
    46       selectedNode = null;
    4745    }
    4846
     
    158156
    159157    #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 
    168158    public event MouseEventHandler SymbolicExpressionTreeNodeClicked;
    169     private void OnSymbolicExpressionTreeNodeClicked(object sender, MouseEventArgs e) {
     159    protected void OnSymbolicExpressionTreeNodeClicked(object sender, MouseEventArgs e) {
    170160      var clicked = SymbolicExpressionTreeNodeClicked;
    171161      if (clicked != null)
     
    173163    }
    174164
    175     private void SymbolicExpressionTreeChart_MouseClick(object sender, MouseEventArgs e) {
     165    protected virtual void SymbolicExpressionTreeChart_MouseClick(object sender, MouseEventArgs e) {
    176166      VisualSymbolicExpressionTreeNode visualTreeNode = FindVisualSymbolicExpressionTreeNodeAt(e.X, e.Y);
    177       if (visualTreeNode != null)
     167      if (visualTreeNode != null) {
    178168        OnSymbolicExpressionTreeNodeClicked(visualTreeNode, e);
     169      }
    179170    }
    180171
    181172    public event MouseEventHandler SymbolicExpressionTreeNodeDoubleClicked;
    182     private void OnSymbolicExpressionTreeNodeDoubleClicked(object sender, MouseEventArgs e) {
     173    protected void OnSymbolicExpressionTreeNodeDoubleClicked(object sender, MouseEventArgs e) {
    183174      var doubleClicked = SymbolicExpressionTreeNodeDoubleClicked;
    184175      if (doubleClicked != null)
     
    193184
    194185    public event ItemDragEventHandler SymbolicExpressionTreeNodeDrag;
    195     private void OnSymbolicExpressionTreeNodeDragDrag(object sender, ItemDragEventArgs e) {
     186    protected void OnSymbolicExpressionTreeNodeDragDrag(object sender, ItemDragEventArgs e) {
    196187      var dragged = SymbolicExpressionTreeNodeDrag;
    197188      if (dragged != null)
     
    244235    ///
    245236    /// </summary>
    246     /// <param name="functionTree"> functiontree to draw</param>
     237    /// <param name="functionTree"> function tree to draw</param>
    247238    /// <param name="graphics">graphics object to draw on</param>
    248239    /// <param name="x">x coordinate of drawing area</param>
     
    357348    }
    358349    #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 anyway
    372         OnSymbolicExpressionTreeNodeChanged(selectedNode, e);
    373     }
    374350  }
    375351}
Note: See TracChangeset for help on using the changeset viewer.