Changeset 1059


Ignore:
Timestamp:
12/23/08 16:18:41 (11 years ago)
Author:
bspisic
Message:

#424
Implemented history stack for clipping areas - by pressing the "back" button the antecedent clipping area will be set

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

Legend:

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

    r1058 r1059  
    4545          this.canvas.MouseDown += new System.Windows.Forms.MouseEventHandler(this.canvasUI1_MouseDown);
    4646          this.canvas.MouseWheel += new System.Windows.Forms.MouseEventHandler(this.canvasUI1_MouseWheel);
     47          this.canvas.KeyDown += new System.Windows.Forms.KeyEventHandler(this.canvasUI1_KeyDown);
    4748          //
    4849          // LineChart
  • trunk/sources/HeuristicLab.Visualization/LineChart.cs

    r1058 r1059  
    161161
    162162      SetLineClippingArea(newClippingArea);
     163      historyStack.Push(newClippingArea);
    163164    }
    164165
     
    273274    #endregion
    274275
     276    #region Zooming / Panning
     277
     278    private readonly Stack<RectangleD> historyStack = new Stack<RectangleD>();
    275279    private RectangleShape rectangleShape;
     280
     281    private void canvasUI1_KeyDown(object sender, KeyEventArgs e) {
     282      if(e.KeyCode == Keys.Back && historyStack.Count > 1) {
     283        historyStack.Pop();
     284
     285        RectangleD clippingArea = historyStack.Peek();
     286 
     287        SetNewClippingArea(clippingArea);
     288        canvas.Invalidate();
     289      }
     290    }
    276291
    277292    private void canvasUI1_MouseDown(object sender, MouseEventArgs e) {
     
    312327      canvas.MouseEventListener = null;
    313328
    314       SetLineClippingArea(rectangleShape.Rectangle);
     329      RectangleD clippingArea = rectangleShape.Rectangle;
     330
     331      SetLineClippingArea(clippingArea);
     332      historyStack.Push(clippingArea);
     333
    315334      linesShape.RemoveShape(rectangleShape);
    316335
     
    329348
    330349      panListener.SetNewClippingArea += SetNewClippingArea;
    331       panListener.OnMouseUp += delegate { canvas.MouseEventListener = null; };
     350      panListener.OnMouseUp += delegate {
     351        historyStack.Push(linesShape.ClippingArea);
     352        canvas.MouseEventListener = null;
     353      };
    332354
    333355      canvas.MouseEventListener = panListener;
     
    340362      canvas.Invalidate();
    341363    }
     364
     365    #endregion
    342366  }
    343367}
Note: See TracChangeset for help on using the changeset viewer.