Changeset 7780 for branches/HeuristicLab.Visualization/HeuristicLab.Visualization/3.3/ChartControl.cs
- Timestamp:
- 05/04/12 13:35:59 (12 years ago)
- Location:
- branches/HeuristicLab.Visualization
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/HeuristicLab.Visualization
- Property svn:ignore
-
old new 1 1 *.suo 2 2 CustomPostBuild.cmd 3 _ReSharper.HeuristicLab.Visualization
-
- Property svn:ignore
-
branches/HeuristicLab.Visualization/HeuristicLab.Visualization/3.3/ChartControl.cs
r7617 r7780 81 81 mouseClickCount = e.Clicks; 82 82 } 83 pr ivatevoid pictureBox_MouseUp(object sender, MouseEventArgs e) {83 protected virtual void pictureBox_MouseUp(object sender, MouseEventArgs e) { 84 84 if (e.Button == MouseButtons.Left) { 85 85 if (Chart.Mode == ChartMode.Zoom) { 86 86 pictureBox.Refresh(); 87 Point lowerLeft = new Point(Math.Min(e.X, buttonDownPoint.X), 88 Math.Max(e.Y, buttonDownPoint.Y)); 89 Point upperRight = new Point(Math.Max(e.X, buttonDownPoint.X), 90 Math.Min(e.Y, buttonDownPoint.Y)); 87 // some code to preserve the aspect ratio when zooming 88 // +---------------------+ (Width,Height) 89 // | (x1,y1) | 90 // | +-------+ | 91 // | | | | 92 // | | | | 93 // | +-------+ | 94 // | (x2,y2) | 95 // (0,0) +---------------------+ 96 // 97 double aspectRatio = (double)Width / Height; 98 double x1 = Math.Min(e.X, buttonDownPoint.X); 99 double y1 = Math.Max(e.Y, buttonDownPoint.Y); 100 double x2 = Math.Max(e.X, buttonDownPoint.X); 101 double y2 = Math.Min(e.Y, buttonDownPoint.Y); 102 // consider the relative ratios between the X and Y dimensions of the selection 103 // area and the Width and Height, respectively. The "dominant" dimension is the 104 // one with a ratio closer to 1, and it stays fixed while the other is adjusted 105 // in order to preserve the aspect ratio 106 if ((x2 - x1) / Width > (y1 - y2) / Height) { 107 y1 = y2 + (x2 - x1) / aspectRatio; 108 } else { 109 x2 = aspectRatio * (y1 - y2) + x1; 110 } 111 var lowerLeft = new Point((int)x1, (int)y1); 112 var upperRight = new Point((int)x2, (int)y2); 91 113 if ((lowerLeft.X != upperRight.X) && (lowerLeft.Y != upperRight.Y)) { 92 114 Chart.ZoomIn(lowerLeft, upperRight); … … 112 134 } 113 135 } 136 114 137 private void pictureBox_MouseMove(object sender, MouseEventArgs e) { 115 toolTip.SetToolTip(pictureBox, Chart.GetToolTipText(e.Location)); 138 var text = Chart.GetToolTipText(e.Location); 139 if (toolTip.GetToolTip(pictureBox) != text) 140 toolTip.SetToolTip(pictureBox, text); 116 141 Cursor cursor = Chart.GetCursor(e.Location); 117 142 if (cursor != null) pictureBox.Cursor = cursor;
Note: See TracChangeset
for help on using the changeset viewer.