Changeset 13115
- Timestamp:
- 11/04/15 15:56:08 (9 years ago)
- 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 48 48 this.pictureBox = new System.Windows.Forms.PictureBox(); 49 49 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(); 50 52 this.oneLayerUpToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); 51 53 this.oneLayerDownToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); 52 54 this.intoForegroundToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); 53 55 this.intoBackgroundToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); 54 this.toolStrip MenuItem1= new System.Windows.Forms.ToolStripSeparator();56 this.toolStripSeparator2 = new System.Windows.Forms.ToolStripSeparator(); 55 57 this.propertiesToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); 58 this.toolStripSeparator3 = new System.Windows.Forms.ToolStripSeparator(); 59 this.saveImageToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); 56 60 this.toolTip = new System.Windows.Forms.ToolTip(this.components); 57 this.buttonPanel = new System.Windows.Forms.FlowLayoutPanel();58 61 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(); 61 63 ((System.ComponentModel.ISupportInitialize)(this.pictureBox)).BeginInit(); 62 64 this.pictureBoxContextMenuStrip.SuspendLayout(); 63 this.buttonPanel.SuspendLayout(); 65 ((System.ComponentModel.ISupportInitialize)(this.splitContainer)).BeginInit(); 66 this.splitContainer.Panel2.SuspendLayout(); 67 this.splitContainer.SuspendLayout(); 64 68 this.SuspendLayout(); 65 69 // 66 70 // pictureBox 67 71 // 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)));71 72 this.pictureBox.BackColor = System.Drawing.Color.White; 72 73 this.pictureBox.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; 73 74 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); 75 77 this.pictureBox.Name = "pictureBox"; 76 this.pictureBox.Size = new System.Drawing.Size(68 5, 500);78 this.pictureBox.Size = new System.Drawing.Size(686, 500); 77 79 this.pictureBox.TabIndex = 0; 78 80 this.pictureBox.TabStop = false; … … 94 96 // 95 97 this.pictureBoxContextMenuStrip.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { 98 this.modeToolStripMenuItem, 99 this.toolStripSeparator1, 96 100 this.oneLayerUpToolStripMenuItem, 97 101 this.oneLayerDownToolStripMenuItem, 98 102 this.intoForegroundToolStripMenuItem, 99 103 this.intoBackgroundToolStripMenuItem, 100 this.toolStrip MenuItem1,104 this.toolStripSeparator2, 101 105 this.propertiesToolStripMenuItem, 102 this.toolStrip MenuItem2,106 this.toolStripSeparator3, 103 107 this.saveImageToolStripMenuItem}); 104 108 this.pictureBoxContextMenuStrip.Name = "pictureBoxContextMenuStrip"; 105 this.pictureBoxContextMenuStrip.Size = new System.Drawing.Size(163, 1 70);109 this.pictureBoxContextMenuStrip.Size = new System.Drawing.Size(163, 198); 106 110 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); 107 122 // 108 123 // oneLayerUpToolStripMenuItem … … 138 153 this.intoBackgroundToolStripMenuItem.Click += new System.EventHandler(this.intoBackgroundToolStripMenuItem_Click); 139 154 // 140 // toolStrip MenuItem1141 // 142 this.toolStrip MenuItem1.Name = "toolStripMenuItem1";143 this.toolStrip MenuItem1.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); 144 159 // 145 160 // propertiesToolStripMenuItem … … 151 166 this.propertiesToolStripMenuItem.Click += new System.EventHandler(this.propertiesToolStripMenuItem_Click); 152 167 // 153 // toolStrip MenuItem2154 // 155 this.toolStrip MenuItem2.Name = "toolStripMenuItem2";156 this.toolStrip MenuItem2.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); 157 172 // 158 173 // saveImageToolStripMenuItem … … 169 184 this.saveFileDialog.Filter = "Bitmap (*.bmp)|*.bmp|JPEG (*.jpg)|*.jpg|EMF (*.emf)|*.emf|PNG (*.png)|*.png|GIF (" + 170 185 "*.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; 177 201 // 178 202 // ChartControl … … 180 204 this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Inherit; 181 205 this.BackColor = System.Drawing.SystemColors.Control; 182 this.Controls.Add(this.buttonPanel); 183 this.Controls.Add(this.pictureBox); 206 this.Controls.Add(this.splitContainer); 184 207 this.DoubleBuffered = true; 185 208 this.Name = "ChartControl"; … … 190 213 ((System.ComponentModel.ISupportInitialize)(this.pictureBox)).EndInit(); 191 214 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); 193 218 this.ResumeLayout(false); 194 219 … … 206 231 protected System.Windows.Forms.ToolStripMenuItem intoForegroundToolStripMenuItem; 207 232 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; 211 237 protected System.Windows.Forms.SaveFileDialog saveFileDialog; 238 protected System.Windows.Forms.SplitContainer splitContainer; 239 212 240 } 213 241 } -
branches/HeuristicLab.Visualization/HeuristicLab.Visualization/3.3/ChartControl.cs
r13114 r13115 37 37 private bool SuppressRender { get; set; } 38 38 39 public bool ShowToolBar { 40 get { return !splitContainer.Panel1Collapsed; } 41 set { splitContainer.Panel1Collapsed = !value; } 42 } 43 39 44 private IChart chart; 40 45 public IChart Chart { … … 55 60 if (mode == value) return; 56 61 mode = value; 57 SetButtonCheckedSate(); 62 SetModeButtonCheckedState(); 63 SetModeMenuItemCheckedState(); 58 64 SetPictureBoxCursor(GetPictureBoxCursor()); 59 65 OnModeChanged(); … … 79 85 Modes.Add(chartMode.GetType(), chartMode); 80 86 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(); 95 89 } 96 90 … … 116 110 } 117 111 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>()) 120 141 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; 121 147 } 122 148 … … 126 152 127 153 protected virtual Cursor GetPictureBoxCursor() { 128 if (mode == null) return null; 129 130 return mode.Cursor; 154 return mode != null ? mode.Cursor : null; 131 155 } 132 156 … … 163 187 164 188 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); 167 191 } 168 192 169 193 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); 172 196 } 173 197 174 198 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); 177 201 } 178 202 179 203 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); 182 206 } 183 207 184 208 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); 187 211 } 188 212 189 213 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); 192 216 } 193 217 194 218 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); 197 221 198 222 if (Chart == null) return; … … 214 238 if (toolTip.GetToolTip(pictureBox) != toolTipText) toolTip.SetToolTip(pictureBox, toolTipText); 215 239 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()); 221 244 } 222 245 } … … 227 250 return; 228 251 } 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); 234 256 } 235 257 236 258 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); 239 261 } 240 262 241 263 protected virtual void PictureBoxOnClick(object sender, EventArgs e) { 242 264 if (InvokeRequired) { 243 Invoke((Action< Object, MouseEventArgs>)PictureBoxOnClick, sender, e);265 Invoke((Action<object, MouseEventArgs>)PictureBoxOnClick, sender, e); 244 266 return; 245 267 } 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); 251 272 } 252 273 #endregion … … 368 389 return rb; 369 390 } 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 } 370 403 #endregion 371 404 } -
branches/HeuristicLab.Visualization/HeuristicLab.Visualization/3.3/ChartMode.cs
r13108 r13115 33 33 34 34 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; } } 36 38 37 39 public virtual Cursor Cursor { -
branches/HeuristicLab.Visualization/HeuristicLab.Visualization/3.3/ChartModes/PanChartMode.cs
r13114 r13115 27 27 public class PanChartMode : ChartMode { 28 28 public override Image Image { get { return VSImageLibrary.Breakpoint; } } 29 public override string T oolTip { get { return "Pan"; } }30 29 public override string Text { get { return "&Pan"; } } 30 public override string ToolTipText { get { return "Pan"; } } 31 31 public override Cursor Cursor { 32 32 get { return cursor ?? (cursor = new Cursor(typeof(ChartControl), "Resources.Hand.cur")); } -
branches/HeuristicLab.Visualization/HeuristicLab.Visualization/3.3/ChartModes/RulerChartMode.cs
r13114 r13115 29 29 protected Point? startPoint; 30 30 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; } } 42 35 43 36 public RulerChartMode(ChartControl control) : base(control) { } … … 45 38 public override void HandleOnMouseDown(object sender, MouseEventArgs e) { 46 39 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 } 54 51 } finally { 55 52 base.HandleOnMouseDown(sender, e); -
branches/HeuristicLab.Visualization/HeuristicLab.Visualization/3.3/ChartModes/SelectChartMode.cs
r13114 r13115 28 28 public class SelectChartMode : ChartMode { 29 29 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"; } } 31 32 32 33 public SelectChartMode(ChartControl control) : base(control) { } -
branches/HeuristicLab.Visualization/HeuristicLab.Visualization/3.3/ChartModes/ZoomInChartMode.cs
r13114 r13115 29 29 public class ZoomInChartMode : ChartMode { 30 30 public override Image Image { get { return VSImageLibrary.ZoomIn; } } 31 public override string T oolTip { get { return "ZoomIn"; } }32 31 public override string Text { get { return "Zoom &In"; } } 32 public override string ToolTipText { get { return "Zoom In"; } } 33 33 public override Cursor Cursor { 34 34 get { return cursor ?? (cursor = new Cursor(typeof(ChartControl), "Resources.ZoomIn.cur")); } -
branches/HeuristicLab.Visualization/HeuristicLab.Visualization/3.3/ChartModes/ZoomOutChartMode.cs
r13114 r13115 27 27 public class ZoomOutChartMode : ChartMode { 28 28 public override Image Image { get { return VSImageLibrary.ZoomOut; } } 29 public override string T oolTip { get { return "ZoomOut"; } }30 29 public override string Text { get { return "Zoom &Out"; } } 30 public override string ToolTipText { get { return "Zoom Out"; } } 31 31 public override Cursor Cursor { 32 32 get { return cursor ?? (cursor = new Cursor(typeof(ChartControl), "Resources.ZoomOut.cur")); }
Note: See TracChangeset
for help on using the changeset viewer.