Changeset 984 for trunk/sources/HeuristicLab.Visualization
- Timestamp:
- 12/12/08 18:48:01 (16 years ago)
- Location:
- trunk/sources/HeuristicLab.Visualization
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
TabularUnified trunk/sources/HeuristicLab.Visualization/LineChart.cs ¶
r983 r984 192 192 193 193 private MouseEventListener panListener; 194 private MouseEventListener zoomListener; 194 195 195 196 private void CreateMouseEventListeners() { … … 197 198 panListener.OnMouseMove += Pan_OnMouseMove; 198 199 panListener.OnMouseUp += Pan_OnMouseUp; 199 } 200 200 201 zoomListener = new MouseEventListener(); 202 zoomListener.OnMouseMove += Zoom_OnMouseMove; 203 zoomListener.OnMouseUp += Zoom_OnMouseUp; 204 } 201 205 202 206 private RectangleD startClippingArea; 203 207 204 208 private void canvasUI1_MouseDown(object sender, MouseEventArgs e) { 205 panListener.StartPoint = e.Location; 206 canvasUI1.MouseEventListener = panListener; 207 208 startClippingArea = root.ClippingArea; 209 if (ModifierKeys == Keys.Control) { 210 zoomListener.StartPoint = e.Location; 211 canvasUI1.MouseEventListener = zoomListener; 212 213 r = Rectangle.Empty; 214 rectangleShape = new RectangleShape(e.X, e.Y, e.X, e.Y, 1000, Color.Blue); 215 216 root.AddShape(rectangleShape); 217 } else { 218 panListener.StartPoint = e.Location; 219 canvasUI1.MouseEventListener = panListener; 220 221 startClippingArea = root.ClippingArea; 222 } 209 223 } 210 224 211 225 private void Pan_OnMouseUp(Point startPoint, Point actualPoint) { 212 226 canvasUI1.MouseEventListener = null; 213 227 } 214 228 … … 231 245 panListener.StartPoint = startPoint; 232 246 233 this.zoomFullView = false; //user wants to pan => no full view 234 247 zoomFullView = false; //user wants to pan => no full view 248 249 canvasUI1.Invalidate(); 250 } 251 252 private void Zoom_OnMouseUp(Point startPoint, Point actualPoint) { 253 canvasUI1.MouseEventListener = null; 254 255 RectangleD newClippingArea = Transform.ToWorld(r, canvasUI1.ClientRectangle, root.ClippingArea); 256 root.ClippingArea = newClippingArea; 257 root.RemoveShape(rectangleShape); 258 259 zoomFullView = false; //user wants to pan => no full view 260 261 canvasUI1.Invalidate(); 262 } 263 264 private Rectangle r; 265 private RectangleShape rectangleShape; 266 267 private void Zoom_OnMouseMove(Point startPoint, Point actualPoint) { 268 r = new Rectangle(); 269 270 if (startPoint.X < actualPoint.X) { 271 r.X = startPoint.X; 272 r.Width = actualPoint.X - startPoint.X; 273 } else { 274 r.X = actualPoint.X; 275 r.Width = startPoint.X - actualPoint.X; 276 } 277 278 if (startPoint.Y < actualPoint.Y) { 279 r.Y = startPoint.Y; 280 r.Height = actualPoint.Y - startPoint.Y; 281 } else { 282 r.Y = actualPoint.Y; 283 r.Height = startPoint.Y - actualPoint.Y; 284 } 285 286 rectangleShape.Rectangle = Transform.ToWorld(r, canvasUI1.ClientRectangle, root.ClippingArea); 235 287 canvasUI1.Invalidate(); 236 288 } -
TabularUnified trunk/sources/HeuristicLab.Visualization/RectangleShape.cs ¶
r635 r984 3 3 namespace HeuristicLab.Visualization { 4 4 public class RectangleShape : IShape { 5 private RectangleD rect ;5 private RectangleD rectangle; 6 6 private double z; 7 7 private Color color; 8 private int opacity = 100; 8 9 9 10 public RectangleShape(double x1, double y1, double x2, double y2, double z, Color color) { 10 this.rect= new RectangleD(x1, y1, x2, y2);11 rectangle = new RectangleD(x1, y1, x2, y2); 11 12 this.z = z; 12 13 this.color = color; … … 14 15 15 16 public RectangleD BoundingBox { 16 get { return rect ; }17 get { return rectangle; } 17 18 } 18 19 19 20 public void Draw(Graphics graphics, Rectangle viewport, RectangleD clippingArea) { 21 Color brushColor = Color.FromArgb(50, color); 22 20 23 using (Pen pen = new Pen(color, 1)) 21 using (Brush brush = new SolidBrush( color)) {22 Rectangle screenRect = Transform.ToScreen(rect , viewport, clippingArea);24 using (Brush brush = new SolidBrush(brushColor)) { 25 Rectangle screenRect = Transform.ToScreen(rectangle, viewport, clippingArea); 23 26 24 27 graphics.DrawRectangle(pen, screenRect); … … 31 34 set { z = value; } 32 35 } 36 37 public RectangleD Rectangle { 38 get { return rectangle; } 39 set { rectangle = value; } 40 } 33 41 } 34 42 } -
TabularUnified trunk/sources/HeuristicLab.Visualization/WorldShape.cs ¶
r928 r984 21 21 22 22 graphics.SetClip(innerViewport); 23 23 24 24 foreach (IShape shape in shapes) { 25 25 shape.Draw(graphics, innerViewport, this.clippingArea); 26 26 } 27 27 28 28 graphics.Restore(gstate); 29 29 } … … 48 48 shapes.Add(shape); 49 49 } 50 51 public bool RemoveShape(IShape shape) { 52 return shapes.Remove(shape); 53 } 50 54 } 51 55 }
Note: See TracChangeset
for help on using the changeset viewer.