Changeset 928 for trunk/sources/HeuristicLab.Visualization
- Timestamp:
- 12/09/08 20:19:42 (16 years ago)
- Location:
- trunk/sources/HeuristicLab.Visualization
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Visualization/LineChart.Designer.cs
r869 r928 41 41 this.canvasUI1.TabIndex = 0; 42 42 this.canvasUI1.Text = "canvasUI1"; 43 this.canvasUI1.MouseDown += new System.Windows.Forms.MouseEventHandler(this.canvasUI1_MouseDown); 43 44 // 44 45 // LineChart -
trunk/sources/HeuristicLab.Visualization/LineChart.cs
r870 r928 1 1 using System; 2 2 using System.Collections.Generic; 3 using System.Diagnostics; 4 using System.Drawing; 5 using System.Windows.Forms; 3 6 using HeuristicLab.Core; 4 7 … … 19 22 /// <param name="model">Referenz to the model, for data</param> 20 23 public LineChart(IChartDataRowsModel model) : this() { 21 if (model == null) 24 if (model == null) { 22 25 throw new NullReferenceException("Model cannot be null."); 26 } 23 27 24 28 //TODO: correct Rectangle to fit … … 26 30 canvasUI1.MainCanvas.WorldShape = new WorldShape(clientRectangle, clientRectangle); 27 31 32 CreateMouseEventListeners(); 33 28 34 this.model = model; 29 this.Item = (IItem)model;35 Item = (IItem)model; 30 36 } 31 37 … … 85 91 List<LineShape> lineShapes = rowToLineShapes[row]; 86 92 87 if (index > lineShapes.Count +1)93 if (index > lineShapes.Count + 1) { 88 94 throw new NotImplementedException(); 95 } 89 96 90 97 // new value was added 91 if (index > 0 && index == lineShapes.Count +1) {98 if (index > 0 && index == lineShapes.Count + 1) { 92 99 LineShape lineShape = new LineShape(index - 1, row[index - 1], index, row[index], 0, row.Color, row.Thickness); 93 100 lineShapes.Add(lineShape); … … 97 104 98 105 // not the first value 99 if (index > 0) 100 lineShapes[index-1].Y2 = value; 106 if (index > 0) { 107 lineShapes[index - 1].Y2 = value; 108 } 101 109 102 110 // not the last value 103 if (index > 0 && index < row.Count -1)111 if (index > 0 && index < row.Count - 1) { 104 112 lineShapes[index].Y1 = value; 113 } 105 114 106 115 canvasUI1.Invalidate(); … … 114 123 } 115 124 116 private void OnModelChanged() { 117 } 125 private void OnModelChanged() {} 118 126 119 127 #endregion … … 128 136 129 137 public void EndUpdate() { 130 if (beginUpdateCount == 0) 138 if (beginUpdateCount == 0) { 131 139 throw new InvalidOperationException("Too many EndUpdates."); 140 } 132 141 133 142 beginUpdateCount--; 134 143 135 if (beginUpdateCount == 0) 144 if (beginUpdateCount == 0) { 136 145 Invalidate(); 146 } 137 147 } 138 148 139 149 #endregion 150 151 private MouseEventListener panListener; 152 153 private void CreateMouseEventListeners() { 154 panListener = new MouseEventListener(); 155 panListener.OnMouseMove += Pan_OnMouseMove; 156 panListener.OnMouseUp += Pan_OnMouseUp; 157 } 158 159 160 private RectangleD startClippingArea; 161 162 private void canvasUI1_MouseDown(object sender, MouseEventArgs e) { 163 panListener.StartPoint = e.Location; 164 canvasUI1.MouseEventListener = panListener; 165 166 startClippingArea = canvasUI1.MainCanvas.WorldShape.ClippingArea; 167 } 168 169 private void Pan_OnMouseUp(Point startPoint, Point actualPoint) { 170 canvasUI1.MouseEventListener = null; 171 } 172 173 private void Pan_OnMouseMove(Point startPoint, Point actualPoint) { 174 Rectangle viewPort = canvasUI1.ClientRectangle; 175 176 PointD worldStartPoint = Transform.ToWorld(startPoint, viewPort, startClippingArea); 177 PointD worldActualPoint = Transform.ToWorld(actualPoint, viewPort, startClippingArea); 178 179 double xDiff = worldActualPoint.X - worldStartPoint.X; 180 double yDiff = worldActualPoint.Y - worldStartPoint.Y; 181 182 RectangleD newClippingArea = new RectangleD(); 183 newClippingArea.X1 = startClippingArea.X1 - xDiff; 184 newClippingArea.X2 = startClippingArea.X2 - xDiff; 185 newClippingArea.Y1 = startClippingArea.Y1 - yDiff; 186 newClippingArea.Y2 = startClippingArea.Y2 - yDiff; 187 188 canvasUI1.MainCanvas.WorldShape.ClippingArea = newClippingArea; 189 panListener.StartPoint = startPoint; 190 191 canvasUI1.Invalidate(); 192 } 140 193 } 141 194 } -
trunk/sources/HeuristicLab.Visualization/WorldShape.cs
r862 r928 36 36 } 37 37 38 public RectangleD ClippingArea { 39 get { return clippingArea; } 40 set { clippingArea = value; } 41 } 42 38 43 /// <summary> 39 44 /// adds a shape to the WorldShape
Note: See TracChangeset
for help on using the changeset viewer.