protected override void OnMouseMove(MouseEventArgs e) { base.OnMouseMove(e); switch (cstatus) { case CURSOR_MOUSEDOWN: Cursor.Visibility = Visibility.Visible; Point p = e.GetPosition(this); csex = p.X; csey = p.Y; if (EndLine.Opacity > 0.0) { csex = EndLine.X1; } double x1 = Math.Min(cssx, csex); double x2 = Math.Max(cssx, csex); double y1 = Math.Min(cssy, csey); double y2 = Math.Max(cssy, csey); y1 = Math.Max(((int)(y1)) / 40, 0) * 40; y2 = Math.Min(((int)(y2 + 40)) / 40, SDCModels.Count()) * 40; Canvas.SetTop(Cursor, y1); Canvas.SetLeft(Cursor, x1); Cursor.Width = x2 - x1; Cursor.Height = y2 - y1; break; case CURSOR_LOCK: Cursor.Visibility = Visibility.Visible; break; case CURSOR_FREE: Cursor.Visibility = Visibility.Hidden; break; } }
private LinkedListNode <SimulateDataChartModel> CursorNodeEnd() { int id = (int)(Math.Max(cssy, csey) / 40); if (id >= SDCModels.Count()) { id = SDCModels.Count() - 1; } SimulateDataChartModel sdcmodel = SDCModels.ElementAt(id); LinkedListNode <SimulateDataChartModel> node = SDCModels.Find(sdcmodel); return(node); }
protected override void OnMouseDoubleClick(MouseButtonEventArgs e) { base.OnMouseDoubleClick(e); isdoubleclick = true; cstatus = CURSOR_LOCK; Cursor.Visibility = Visibility.Visible; Point p = e.GetPosition(this); cssx = 0; cssy = p.Y; csex = ActualWidth; csey = p.Y; if (StartLine.Opacity > 0.0) { cssx = StartLine.X1; } if (EndLine.Opacity > 0.0) { csex = EndLine.X1; } double x1 = Math.Min(cssx, csex); double x2 = Math.Max(cssx, csex); double y1 = Math.Min(cssy, csey); double y2 = Math.Max(cssy, csey); y1 = Math.Max(((int)(y1)) / 40, 0) * 40; y2 = Math.Min(((int)(y2 + 40)) / 40, SDCModels.Count()) * 40; if (x2 - x1 > 0 && y2 - y1 > 0) { Canvas.SetTop(Cursor, y1); Canvas.SetLeft(Cursor, x1); Cursor.Width = x2 - x1; Cursor.Height = y2 - y1; } this.Focus(); }