Changeset 13115


Ignore:
Timestamp:
11/04/15 15:56:08 (4 years ago)
Author:
jkarder
Message:

#1265: worked on visualization

  • added context menu item for chart modes
  • added ShowToolBar to ChartControl
  • updated chart modes
Location:
branches/HeuristicLab.Visualization/HeuristicLab.Visualization/3.3
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • branches/HeuristicLab.Visualization/HeuristicLab.Visualization/3.3/ChartControl.Designer.cs

    r13076 r13115  
    4848      this.pictureBox = new System.Windows.Forms.PictureBox();
    4949      this.pictureBoxContextMenuStrip = new System.Windows.Forms.ContextMenuStrip(this.components);
     50      this.modeToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
     51      this.toolStripSeparator1 = new System.Windows.Forms.ToolStripSeparator();
    5052      this.oneLayerUpToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
    5153      this.oneLayerDownToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
    5254      this.intoForegroundToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
    5355      this.intoBackgroundToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
    54       this.toolStripMenuItem1 = new System.Windows.Forms.ToolStripSeparator();
     56      this.toolStripSeparator2 = new System.Windows.Forms.ToolStripSeparator();
    5557      this.propertiesToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
     58      this.toolStripSeparator3 = new System.Windows.Forms.ToolStripSeparator();
     59      this.saveImageToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
    5660      this.toolTip = new System.Windows.Forms.ToolTip(this.components);
    57       this.buttonPanel = new System.Windows.Forms.FlowLayoutPanel();
    5861      this.saveFileDialog = new System.Windows.Forms.SaveFileDialog();
    59       this.saveImageToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
    60       this.toolStripMenuItem2 = new System.Windows.Forms.ToolStripSeparator();
     62      this.splitContainer = new System.Windows.Forms.SplitContainer();
    6163      ((System.ComponentModel.ISupportInitialize)(this.pictureBox)).BeginInit();
    6264      this.pictureBoxContextMenuStrip.SuspendLayout();
    63       this.buttonPanel.SuspendLayout();
     65      ((System.ComponentModel.ISupportInitialize)(this.splitContainer)).BeginInit();
     66      this.splitContainer.Panel2.SuspendLayout();
     67      this.splitContainer.SuspendLayout();
    6468      this.SuspendLayout();
    6569      //
    6670      // pictureBox
    6771      //
    68       this.pictureBox.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
    69             | System.Windows.Forms.AnchorStyles.Left)
    70             | System.Windows.Forms.AnchorStyles.Right)));
    7172      this.pictureBox.BackColor = System.Drawing.Color.White;
    7273      this.pictureBox.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
    7374      this.pictureBox.ContextMenuStrip = this.pictureBoxContextMenuStrip;
    74       this.pictureBox.Location = new System.Drawing.Point(35, 0);
     75      this.pictureBox.Dock = System.Windows.Forms.DockStyle.Fill;
     76      this.pictureBox.Location = new System.Drawing.Point(0, 0);
    7577      this.pictureBox.Name = "pictureBox";
    76       this.pictureBox.Size = new System.Drawing.Size(685, 500);
     78      this.pictureBox.Size = new System.Drawing.Size(686, 500);
    7779      this.pictureBox.TabIndex = 0;
    7880      this.pictureBox.TabStop = false;
     
    9496      //
    9597      this.pictureBoxContextMenuStrip.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
     98            this.modeToolStripMenuItem,
     99            this.toolStripSeparator1,
    96100            this.oneLayerUpToolStripMenuItem,
    97101            this.oneLayerDownToolStripMenuItem,
    98102            this.intoForegroundToolStripMenuItem,
    99103            this.intoBackgroundToolStripMenuItem,
    100             this.toolStripMenuItem1,
     104            this.toolStripSeparator2,
    101105            this.propertiesToolStripMenuItem,
    102             this.toolStripMenuItem2,
     106            this.toolStripSeparator3,
    103107            this.saveImageToolStripMenuItem});
    104108      this.pictureBoxContextMenuStrip.Name = "pictureBoxContextMenuStrip";
    105       this.pictureBoxContextMenuStrip.Size = new System.Drawing.Size(163, 170);
     109      this.pictureBoxContextMenuStrip.Size = new System.Drawing.Size(163, 198);
    106110      this.pictureBoxContextMenuStrip.Opening += new System.ComponentModel.CancelEventHandler(this.PictureBoxContextMenuStripOnOpening);
     111      //
     112      // modeToolStripMenuItem
     113      //
     114      this.modeToolStripMenuItem.Name = "modeToolStripMenuItem";
     115      this.modeToolStripMenuItem.Size = new System.Drawing.Size(162, 22);
     116      this.modeToolStripMenuItem.Text = "&Mode";
     117      //
     118      // toolStripSeparator1
     119      //
     120      this.toolStripSeparator1.Name = "toolStripSeparator1";
     121      this.toolStripSeparator1.Size = new System.Drawing.Size(159, 6);
    107122      //
    108123      // oneLayerUpToolStripMenuItem
     
    138153      this.intoBackgroundToolStripMenuItem.Click += new System.EventHandler(this.intoBackgroundToolStripMenuItem_Click);
    139154      //
    140       // toolStripMenuItem1
    141       //
    142       this.toolStripMenuItem1.Name = "toolStripMenuItem1";
    143       this.toolStripMenuItem1.Size = new System.Drawing.Size(159, 6);
     155      // toolStripSeparator2
     156      //
     157      this.toolStripSeparator2.Name = "toolStripSeparator2";
     158      this.toolStripSeparator2.Size = new System.Drawing.Size(159, 6);
    144159      //
    145160      // propertiesToolStripMenuItem
     
    151166      this.propertiesToolStripMenuItem.Click += new System.EventHandler(this.propertiesToolStripMenuItem_Click);
    152167      //
    153       // toolStripMenuItem2
    154       //
    155       this.toolStripMenuItem2.Name = "toolStripMenuItem2";
    156       this.toolStripMenuItem2.Size = new System.Drawing.Size(159, 6);
     168      // toolStripSeparator3
     169      //
     170      this.toolStripSeparator3.Name = "toolStripSeparator3";
     171      this.toolStripSeparator3.Size = new System.Drawing.Size(159, 6);
    157172      //
    158173      // saveImageToolStripMenuItem
     
    169184      this.saveFileDialog.Filter = "Bitmap (*.bmp)|*.bmp|JPEG (*.jpg)|*.jpg|EMF (*.emf)|*.emf|PNG (*.png)|*.png|GIF (" +
    170185    "*.gif)|*.gif|TIFF (*.tif)|*.tif";
    171       this.buttonPanel.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
    172             | System.Windows.Forms.AnchorStyles.Left)));
    173       this.buttonPanel.Location = new System.Drawing.Point(0, 0);
    174       this.buttonPanel.Name = "buttonPanel";
    175       this.buttonPanel.Size = new System.Drawing.Size(32, 500);
    176       this.buttonPanel.TabIndex = 2;
     186      //
     187      // splitContainer
     188      //
     189      this.splitContainer.Dock = System.Windows.Forms.DockStyle.Fill;
     190      this.splitContainer.FixedPanel = System.Windows.Forms.FixedPanel.Panel1;
     191      this.splitContainer.IsSplitterFixed = true;
     192      this.splitContainer.Location = new System.Drawing.Point(0, 0);
     193      this.splitContainer.Name = "splitContainer";
     194      //
     195      // splitContainer.Panel2
     196      //
     197      this.splitContainer.Panel2.Controls.Add(this.pictureBox);
     198      this.splitContainer.Size = new System.Drawing.Size(720, 500);
     199      this.splitContainer.SplitterDistance = 30;
     200      this.splitContainer.TabIndex = 1;
    177201      //
    178202      // ChartControl
     
    180204      this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Inherit;
    181205      this.BackColor = System.Drawing.SystemColors.Control;
    182       this.Controls.Add(this.buttonPanel);
    183       this.Controls.Add(this.pictureBox);
     206      this.Controls.Add(this.splitContainer);
    184207      this.DoubleBuffered = true;
    185208      this.Name = "ChartControl";
     
    190213      ((System.ComponentModel.ISupportInitialize)(this.pictureBox)).EndInit();
    191214      this.pictureBoxContextMenuStrip.ResumeLayout(false);
    192       this.buttonPanel.ResumeLayout(false);
     215      this.splitContainer.Panel2.ResumeLayout(false);
     216      ((System.ComponentModel.ISupportInitialize)(this.splitContainer)).EndInit();
     217      this.splitContainer.ResumeLayout(false);
    193218      this.ResumeLayout(false);
    194219
     
    206231    protected System.Windows.Forms.ToolStripMenuItem intoForegroundToolStripMenuItem;
    207232    protected System.Windows.Forms.ToolStripMenuItem intoBackgroundToolStripMenuItem;
    208     protected System.Windows.Forms.ToolStripSeparator toolStripMenuItem1;
    209     protected System.Windows.Forms.ToolStripSeparator toolStripMenuItem2;
    210     protected System.Windows.Forms.FlowLayoutPanel buttonPanel;
     233    protected System.Windows.Forms.ToolStripMenuItem modeToolStripMenuItem;
     234    protected System.Windows.Forms.ToolStripSeparator toolStripSeparator1;
     235    protected System.Windows.Forms.ToolStripSeparator toolStripSeparator2;
     236    protected System.Windows.Forms.ToolStripSeparator toolStripSeparator3;
    211237    protected System.Windows.Forms.SaveFileDialog saveFileDialog;
     238    protected System.Windows.Forms.SplitContainer splitContainer;
     239
    212240  }
    213241}
  • branches/HeuristicLab.Visualization/HeuristicLab.Visualization/3.3/ChartControl.cs

    r13114 r13115  
    3737    private bool SuppressRender { get; set; }
    3838
     39    public bool ShowToolBar {
     40      get { return !splitContainer.Panel1Collapsed; }
     41      set { splitContainer.Panel1Collapsed = !value; }
     42    }
     43
    3944    private IChart chart;
    4045    public IChart Chart {
     
    5560        if (mode == value) return;
    5661        mode = value;
    57         SetButtonCheckedSate();
     62        SetModeButtonCheckedState();
     63        SetModeMenuItemCheckedState();
    5864        SetPictureBoxCursor(GetPictureBoxCursor());
    5965        OnModeChanged();
     
    7985        Modes.Add(chartMode.GetType(), chartMode);
    8086
    81       RebuildButtonPanel();
    82     }
    83 
    84     protected virtual void RebuildButtonPanel() {
    85       buttonPanel.Controls.Clear();
    86 
    87       int locationY = 3;
    88       foreach (var chartMode in Modes.Values) {
    89         var rb = CreateChartModeRadioButton(chartMode);
    90         rb.Location = new Point(3, locationY);
    91         toolTip.SetToolTip(rb, chartMode.ToolTip);
    92         buttonPanel.Controls.Add(rb);
    93         locationY += rb.Height + rb.Margin.Vertical;
    94       }
     87      ReloadModeToolBar();
     88      ReloadModeContextMenu();
    9589    }
    9690
     
    116110    }
    117111
    118     protected virtual void SetButtonCheckedSate() {
    119       foreach (var rb in buttonPanel.Controls.OfType<RadioButton>())
     112    protected virtual void ReloadModeToolBar() {
     113      splitContainer.Panel1.Controls.Clear();
     114
     115      var chartModes = Modes.Values.ToList();
     116      for (int i = 0; i < chartModes.Count; i++) {
     117        var chartMode = chartModes[i];
     118        var rb = CreateChartModeRadioButton(chartMode);
     119        rb.Location = new Point(3, 3 + i * (rb.Height + rb.Margin.Vertical));
     120        rb.TabIndex = i;
     121        toolTip.SetToolTip(rb, chartMode.ToolTipText);
     122        splitContainer.Panel1.Controls.Add(rb);
     123      }
     124
     125      SetModeButtonCheckedState();
     126    }
     127
     128    protected virtual void ReloadModeContextMenu() {
     129      modeToolStripMenuItem.DropDownItems.Clear();
     130
     131      foreach (var chartMode in Modes.Values) {
     132        var mi = CreateChartModeMenuItem(chartMode);
     133        modeToolStripMenuItem.DropDownItems.Add(mi);
     134      }
     135
     136      SetModeMenuItemCheckedState();
     137    }
     138
     139    protected virtual void SetModeButtonCheckedState() {
     140      foreach (var rb in splitContainer.Panel1.Controls.OfType<RadioButton>())
    120141        rb.Checked = rb.Tag == Mode;
     142    }
     143
     144    protected virtual void SetModeMenuItemCheckedState() {
     145      foreach (var mi in modeToolStripMenuItem.DropDownItems.OfType<ToolStripMenuItem>())
     146        mi.Checked = mi.Tag == Mode;
    121147    }
    122148
     
    126152
    127153    protected virtual Cursor GetPictureBoxCursor() {
    128       if (mode == null) return null;
    129 
    130       return mode.Cursor;
     154      return mode != null ? mode.Cursor : null;
    131155    }
    132156
     
    163187
    164188    protected virtual void PictureBoxOnMouseClick(object sender, MouseEventArgs e) {
    165       if (mode == null) return;
    166       mode.HandleOnMouseClick(sender, e);
     189      if (mode != null)
     190        mode.HandleOnMouseClick(sender, e);
    167191    }
    168192
    169193    protected virtual void PictureBoxOnMouseDoubleClick(object sender, MouseEventArgs e) {
    170       if (mode == null) return;
    171       mode.HandleOnMouseDoubleClick(sender, e);
     194      if (mode != null)
     195        mode.HandleOnMouseDoubleClick(sender, e);
    172196    }
    173197
    174198    protected virtual void OnKeyDown(object sender, KeyEventArgs e) {
    175       if (mode == null) return;
    176       mode.HandleOnKeyDown(sender, e);
     199      if (mode != null)
     200        mode.HandleOnKeyDown(sender, e);
    177201    }
    178202
    179203    protected virtual void OnKeyUp(object sender, KeyEventArgs e) {
    180       if (mode == null) return;
    181       mode.HandleOnKeyUp(sender, e);
     204      if (mode != null)
     205        mode.HandleOnKeyUp(sender, e);
    182206    }
    183207
    184208    protected virtual void PictureBoxOnMouseWheel(object sender, MouseEventArgs e) {
    185       if (mode == null) return;
    186       mode.HandleOnMouseWheel(sender, e);
     209      if (mode != null)
     210        mode.HandleOnMouseWheel(sender, e);
    187211    }
    188212
    189213    protected virtual void PictureBoxOnMouseDown(object sender, MouseEventArgs e) {
    190       if (mode == null) return;
    191       mode.HandleOnMouseDown(sender, e);
     214      if (mode != null)
     215        mode.HandleOnMouseDown(sender, e);
    192216    }
    193217
    194218    protected virtual void PictureBoxOnMouseUp(object sender, MouseEventArgs e) {
    195       if (mode == null) return;
    196       mode.HandleOnMouseUp(sender, e);
     219      if (mode != null)
     220        mode.HandleOnMouseUp(sender, e);
    197221
    198222      if (Chart == null) return;
     
    214238        if (toolTip.GetToolTip(pictureBox) != toolTipText) toolTip.SetToolTip(pictureBox, toolTipText);
    215239
    216         if (mode == null) return;
    217 
    218         mode.HandleOnMouseMove(sender, e);
    219 
    220         SetPictureBoxCursor(mode.Cursor);
     240        if (mode != null)
     241          mode.HandleOnMouseMove(sender, e);
     242
     243        SetPictureBoxCursor(GetPictureBoxCursor());
    221244      }
    222245    }
     
    227250        return;
    228251      }
    229       if (!Focused) this.pictureBox.Focus();
    230 
    231       if (mode == null) return;
    232 
    233       mode.HandleOnMouseEnter(sender, e);
     252      if (!Focused) pictureBox.Focus();
     253
     254      if (mode != null)
     255        mode.HandleOnMouseEnter(sender, e);
    234256    }
    235257
    236258    protected virtual void PictureBoxOnMouseLeave(object sender, EventArgs e) {
    237       if (mode == null) return;
    238       mode.HandleOnMouseLeave(sender, e);
     259      if (mode != null)
     260        mode.HandleOnMouseLeave(sender, e);
    239261    }
    240262
    241263    protected virtual void PictureBoxOnClick(object sender, EventArgs e) {
    242264      if (InvokeRequired) {
    243         Invoke((Action<Object, MouseEventArgs>)PictureBoxOnClick, sender, e);
     265        Invoke((Action<object, MouseEventArgs>)PictureBoxOnClick, sender, e);
    244266        return;
    245267      }
    246       if (!Focused) this.pictureBox.Focus();
    247 
    248       if (mode == null) return;
    249 
    250       mode.HandleOnClick(sender, e);
     268      if (!Focused) pictureBox.Focus();
     269
     270      if (mode != null)
     271        mode.HandleOnClick(sender, e);
    251272    }
    252273    #endregion
     
    368389      return rb;
    369390    }
     391
     392    private ToolStripMenuItem CreateChartModeMenuItem(ChartMode chartMode) {
     393      var mi = new ToolStripMenuItem(chartMode.Text) {
     394        CheckOnClick = true,
     395        Image = chartMode.Image,
     396        Tag = chartMode
     397      };
     398
     399      mi.CheckedChanged += (sender, args) => { if (mi.Checked) Mode = chartMode; };
     400
     401      return mi;
     402    }
    370403    #endregion
    371404  }
  • branches/HeuristicLab.Visualization/HeuristicLab.Visualization/3.3/ChartMode.cs

    r13108 r13115  
    3333
    3434    public abstract Image Image { get; }
    35     public abstract string ToolTip { get; }
     35    public abstract string Text { get; }
     36
     37    public virtual string ToolTipText { get { return Text; } }
    3638
    3739    public virtual Cursor Cursor {
  • branches/HeuristicLab.Visualization/HeuristicLab.Visualization/3.3/ChartModes/PanChartMode.cs

    r13114 r13115  
    2727  public class PanChartMode : ChartMode {
    2828    public override Image Image { get { return VSImageLibrary.Breakpoint; } }
    29     public override string ToolTip { get { return "Pan"; } }
    30 
     29    public override string Text { get { return "&Pan"; } }
     30    public override string ToolTipText { get { return "Pan"; } }
    3131    public override Cursor Cursor {
    3232      get { return cursor ?? (cursor = new Cursor(typeof(ChartControl), "Resources.Hand.cur")); }
  • branches/HeuristicLab.Visualization/HeuristicLab.Visualization/3.3/ChartModes/RulerChartMode.cs

    r13114 r13115  
    2929    protected Point? startPoint;
    3030
    31     public override Image Image {
    32       get { return VSImageLibrary.TrackBar; }
    33     }
    34 
    35     public override string ToolTip {
    36       get { return "Ruler"; }
    37     }
    38 
    39     public override Cursor Cursor {
    40       get { return Cursors.Cross; }
    41     }
     31    public override Image Image { get { return VSImageLibrary.TrackBar; } }
     32    public override string Text { get { return "&Ruler"; } }
     33    public override string ToolTipText { get { return "Ruler"; } }
     34    public override Cursor Cursor { get { return Cursors.Cross; } }
    4235
    4336    public RulerChartMode(ChartControl control) : base(control) { }
     
    4538    public override void HandleOnMouseDown(object sender, MouseEventArgs e) {
    4639      try {
    47         if (startPoint.HasValue) {
    48           if (startPoint.Value == e.Location) {
    49             startPoint = null;
    50             chartControl.RefreshPicture();
    51           }
    52         } else
    53           startPoint = e.Location;
     40        switch (e.Button) {
     41          case MouseButtons.Left:
     42            if (startPoint.HasValue) {
     43              if (startPoint.Value == e.Location) {
     44                startPoint = null;
     45                chartControl.RefreshPicture();
     46              }
     47            } else
     48              startPoint = e.Location;
     49            break;
     50        }
    5451      } finally {
    5552        base.HandleOnMouseDown(sender, e);
  • branches/HeuristicLab.Visualization/HeuristicLab.Visualization/3.3/ChartModes/SelectChartMode.cs

    r13114 r13115  
    2828  public class SelectChartMode : ChartMode {
    2929    public override Image Image { get { return VSImageLibrary.Pointer; } }
    30     public override string ToolTip { get { return "Select"; } }
     30    public override string Text { get { return "&Select"; } }
     31    public override string ToolTipText { get { return "Select"; } }
    3132
    3233    public SelectChartMode(ChartControl control) : base(control) { }
  • branches/HeuristicLab.Visualization/HeuristicLab.Visualization/3.3/ChartModes/ZoomInChartMode.cs

    r13114 r13115  
    2929  public class ZoomInChartMode : ChartMode {
    3030    public override Image Image { get { return VSImageLibrary.ZoomIn; } }
    31     public override string ToolTip { get { return "Zoom In"; } }
    32 
     31    public override string Text { get { return "Zoom &In"; } }
     32    public override string ToolTipText { get { return "Zoom In"; } }
    3333    public override Cursor Cursor {
    3434      get { return cursor ?? (cursor = new Cursor(typeof(ChartControl), "Resources.ZoomIn.cur")); }
  • branches/HeuristicLab.Visualization/HeuristicLab.Visualization/3.3/ChartModes/ZoomOutChartMode.cs

    r13114 r13115  
    2727  public class ZoomOutChartMode : ChartMode {
    2828    public override Image Image { get { return VSImageLibrary.ZoomOut; } }
    29     public override string ToolTip { get { return "Zoom Out"; } }
    30 
     29    public override string Text { get { return "Zoom &Out"; } }
     30    public override string ToolTipText { get { return "Zoom Out"; } }
    3131    public override Cursor Cursor {
    3232      get { return cursor ?? (cursor = new Cursor(typeof(ChartControl), "Resources.ZoomOut.cur")); }
Note: See TracChangeset for help on using the changeset viewer.