private void RenderCanvas_MouseMove(object sender, System.Windows.Forms.MouseEventArgs e) { Input.MousePosition = e.Location; bool updateSurface = false; if (Input.IsDrag) { double deltaPixel = e.X - Input.DragPosition.X; double deltaUnit = Scroll.PixelToUnitLength(deltaPixel); Scroll.ViewUnit.Left -= deltaUnit; Scroll.ViewUnit.Normalize(); UpdateBar(); updateSurface = true; Input.DragPosition = e.Location; } else if (Input.IsMeasure) { Input.MeasureInterval.Finish = Scroll.PixelToTime(e.X).Start; updateSurface = true; } else { ThreadRow row = GetRow(e.Y); if (row != null) { row.OnMouseMove(new Point(e.X, e.Y - row.Offset), Scroll); } updateSurface = true; } if (updateSurface) { UpdateSurface(); } }
private void RenderCanvas_MouseWheel(object sender, System.Windows.Forms.MouseEventArgs e) { if (e.Delta != 0) { double delta = e.Delta * ZoomSpeed; double scale = delta > 0.0 ? 1 / delta : -delta; double ratio = (double)e.X / surface.RenderCanvas.Width; double prevWidth = Scroll.ViewUnit.Width; Scroll.ViewUnit.Width *= scale; Scroll.ViewUnit.Left += (prevWidth - Scroll.ViewUnit.Width) * ratio; Scroll.ViewUnit.Normalize(); ThreadRow row = GetRow(e.Y); if (row != null) { row.OnMouseMove(new Point(e.X, e.Y - row.Offset), Scroll); } UpdateBar(); UpdateSurface(); } }