Changeset 13132
- Timestamp:
- 11/10/15 14:32:39 (9 years ago)
- Location:
- branches/HeuristicLab.Visualization/HeuristicLab.Visualization/3.3
- Files:
-
- 1 added
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/HeuristicLab.Visualization/HeuristicLab.Visualization/3.3/ChartControl.cs
r13122 r13132 388 388 }; 389 389 390 rb.CheckedChanged += (sender, args) => { if (rb.Checked) Mode = chartMode; };390 rb.CheckedChanged += (sender, args) => { if (rb.Checked) chartMode.Select(); }; 391 391 392 392 return rb; … … 400 400 }; 401 401 402 mi.CheckedChanged += (sender, args) => { if (mi.Checked) Mode = chartMode; };402 mi.CheckedChanged += (sender, args) => { if (mi.Checked) chartMode.Select(); }; 403 403 404 404 return mi; -
branches/HeuristicLab.Visualization/HeuristicLab.Visualization/3.3/ChartMode.cs
r13122 r13132 41 41 } 42 42 43 private bool selected; 44 public bool Selected { 45 get { return selected; } 46 set { 47 if (selected == value) return; 48 selected = value; 49 if (selected) { 50 chartControl.Mode = this; 51 OnSelected(); 52 } else { 53 if (chartControl.Mode == this) 54 chartControl.Mode = null; 55 OnDeselected(); 56 } 57 OnSelectedChanged(); 58 } 59 } 60 43 61 protected ChartMode(ChartControl control) { 44 62 chartControl = control; 63 chartControl.ModeChanged += (sender, args) => Selected = chartControl.Mode == this; 45 64 } 46 65 47 public void Select() { chartControl.Mode = this; } 48 public void Deselect() { chartControl.Mode = null; } 66 public void Select() { Selected = true; } 67 public void Deselect() { Selected = false; } 68 69 protected virtual void OnSelected() { } 70 protected virtual void OnDeselected() { } 49 71 50 72 public virtual void HandleOnKeyDown(object sender, KeyEventArgs e) { … … 75 97 public virtual void HandleOnMouseLeave(object sender, EventArgs e) { } 76 98 public virtual void HandleOnClick(object sender, EventArgs e) { } 99 100 public event EventHandler SelectedChanged; 101 protected virtual void OnSelectedChanged() { 102 var handler = SelectedChanged; 103 if (handler != null) handler(this, EventArgs.Empty); 104 } 77 105 } 78 106 } -
branches/HeuristicLab.Visualization/HeuristicLab.Visualization/3.3/ChartModes/RulerChartMode.cs
r13115 r13132 85 85 } 86 86 87 #region Helpers 87 88 protected virtual void DrawCross(Graphics graphics, Point point) { 88 89 using (var pen = new Pen(Color.Red)) { … … 112 113 graphics.DrawRectangle(Pens.Red, location.X, location.Y, width, height); 113 114 graphics.DrawString(text, SystemFonts.DefaultFont, Brushes.Black, location.X, location.Y + 2); 114 115 115 } 116 #endregion 116 117 } 117 118 } -
branches/HeuristicLab.Visualization/HeuristicLab.Visualization/3.3/ChartModes/SelectChartMode.cs
r13122 r13132 33 33 public SelectChartMode(ChartControl control) : base(control) { } 34 34 35 protected override void OnDeselected() { 36 try { 37 chartControl.SuspendRendering(); 38 foreach (var p in chartControl.Chart.Group.SelectedPrimitives) 39 p.Selected = false; 40 } finally { 41 chartControl.ResumeRendering(); 42 base.OnDeselected(); 43 } 44 } 45 35 46 public override void HandleOnKeyDown(object sender, KeyEventArgs e) { 36 47 try { … … 39 50 try { 40 51 chartControl.SuspendRendering(); 41 foreach (var p rimitivein chartControl.Chart.Group.SelectedPrimitives)42 chartControl.Chart.Group.Remove(p rimitive);52 foreach (var p in chartControl.Chart.Group.SelectedPrimitives) 53 chartControl.Chart.Group.Remove(p); 43 54 } finally { chartControl.ResumeRendering(); } 44 45 55 break; 46 56 } … … 57 67 chartControl.SuspendRendering(); 58 68 var worldLocation = chartControl.Chart.TransformPixelToWorld(e.Location); 59 foreach (var sp in chartControl.Chart.Group.SelectedPrimitives.Where(x => !x.ContainsPoint(worldLocation)))60 sp.Selected = false;61 var p = chartControl.Chart.GetPrimitive(e.Location);62 if ( p != null)p.Selected = true;69 foreach (var p in chartControl.Chart.Group.SelectedPrimitives.Where(x => !x.ContainsPoint(worldLocation))) 70 p.Selected = false; 71 var sp = chartControl.Chart.GetPrimitive(e.Location); 72 if (sp != null) sp.Selected = true; 63 73 } finally { chartControl.ResumeRendering(); } 64 74 break; … … 80 90 try { 81 91 chartControl.SuspendRendering(); 82 foreach (var p rimitivein chartControl.Chart.Group.SelectedPrimitives.Where(p => p.ContainsPoint(previousWorldLocation)))83 p rimitive.Move(previousWorldLocation, offset);92 foreach (var p in chartControl.Chart.Group.SelectedPrimitives.Where(p => p.ContainsPoint(previousWorldLocation))) 93 p.Move(previousWorldLocation, offset); 84 94 } finally { chartControl.ResumeRendering(); } 85 95 break; -
branches/HeuristicLab.Visualization/HeuristicLab.Visualization/3.3/HeuristicLab.Visualization-3.3.csproj
r13112 r13132 132 132 <Compile Include="ChartModes\PanChartMode.cs" /> 133 133 <Compile Include="ChartModes\RulerChartMode.cs" /> 134 <Compile Include="PrimitiveAttribute.cs" /> 134 135 <Compile Include="Primitives\Grid.cs" /> 135 136 <Compile Include="Properties\Resources.Designer.cs">
Note: See TracChangeset
for help on using the changeset viewer.