Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
12/23/08 15:44:47 (16 years ago)
Author:
bspisic
Message:

#424
Implemented zooming by holding the control key + scrolling

Location:
trunk/sources/HeuristicLab.Visualization
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Visualization/LineChart.Designer.cs

    r1038 r1058  
    1 namespace HeuristicLab.Visualization
     1using System.Windows.Forms;
     2
     3namespace HeuristicLab.Visualization
    24{
    35    partial class LineChart
     
    4244          this.canvas.Text = "canvas";
    4345          this.canvas.MouseDown += new System.Windows.Forms.MouseEventHandler(this.canvasUI1_MouseDown);
     46          this.canvas.MouseWheel += new System.Windows.Forms.MouseEventHandler(this.canvasUI1_MouseWheel);
    4447          //
    4548          // LineChart
  • trunk/sources/HeuristicLab.Visualization/LineChart.cs

    r1049 r1058  
    6363      root.AddShape(linesShape);
    6464
    65       legendShape = new LegendShape(0,0,0,0,0,Color.Black);
     65      legendShape = new LegendShape(0, 0, 0, 0, 0, Color.Black);
    6666      //legendShape.AddLegendItem(new LegendItem("test", Color.Red, 5));
    6767      //legendShape.AddLegendItem(new LegendItem("test1", Color.Blue, 5));
     
    7474      titleShape = new TextShape(0, 0, "Title", 15);
    7575      root.AddShape(titleShape);
    76 
    7776
    7877
     
    277276
    278277    private void canvasUI1_MouseDown(object sender, MouseEventArgs e) {
     278      Focus();
     279
    279280      if (ModifierKeys == Keys.Control) {
    280281        CreateZoomListener(e);
     
    284285    }
    285286
     287    private void canvasUI1_MouseWheel(object sender, MouseEventArgs e) {
     288      if (ModifierKeys == Keys.Control) {
     289        double zoomFactor = (e.Delta > 0) ? 0.9 : 1.1;
     290
     291        RectangleD clippingArea = ZoomListener.ZoomClippingArea(linesShape.ClippingArea, zoomFactor);
     292
     293        SetLineClippingArea(clippingArea);
     294        canvas.Invalidate();
     295      }
     296    }
     297
    286298    private void CreateZoomListener(MouseEventArgs e) {
    287299      ZoomListener zoomListener = new ZoomListener(e.Location);
  • trunk/sources/HeuristicLab.Visualization/ZoomListener.cs

    r1055 r1058  
    5353
    5454    #endregion
     55
     56    public static RectangleD ZoomClippingArea(RectangleD clippingArea, double zoomFactor) {
     57      double x1, x2, y1, y2, width, height;
     58
     59      width = clippingArea.Width * zoomFactor;
     60      height = clippingArea.Height * zoomFactor;
     61
     62      x1 = clippingArea.X1 - (width - clippingArea.Width) / 2;
     63      y1 = clippingArea.Y1 - (height - clippingArea.Height) / 2;
     64      x2 = width + x1;
     65      y2 = height + y1;
     66
     67      return new RectangleD(x1, y1, x2, y2);
     68    }
    5569  }
    5670}
Note: See TracChangeset for help on using the changeset viewer.