bool processDragDropControl(IObservable <Point> dragDrop) { bool beginControlKey = ControlKey() && !ShiftKey(); bool beginShiftKey = !ControlKey() && ShiftKey(); if (beginControlKey || beginShiftKey) { _chartStatus = activatingStatus.ChartStatus; activatingStatus.ChartStatus = ChartsStatus.缩放海图; Mouse.Capture(this); Point pointBegin = Mouse.GetPosition(this); Point point = new Point(); rect.Margin = new Thickness(pointBegin.X, pointBegin.Y, 0, 0); rect.Width = 0; rect.Height = 0; rect.Visibility = System.Windows.Visibility.Visible; dragDrop = dragDrop.Skip(1).Zip(dragDrop, (i1, i2) => new Point(i1.X - i2.X, i1.Y - i2.Y)); dragDrop.Subscribe( p => { if (activatingStatus.ChartStatus == ChartsStatus.缩放海图) { point.X += p.X; point.Y += p.Y; rect.Width = Math.Abs(point.X); rect.Height = Math.Abs(point.Y); if (point.X < 0 || point.Y < 0) { rect.Margin = new Thickness(pointBegin.X + Math.Min(0, point.X), pointBegin.Y + Math.Min(0, point.Y), 0, 0); } } }, async() => { Mouse.Capture(null); MapPoint position = map.Locator.ScreenToMap(pointBegin.X + point.X / 2, pointBegin.Y + point.Y / 2); double zoom = Math.Max(Math.Abs(point.X) / this.ActualWidth, Math.Abs(point.Y) / this.ActualHeight); double scale = map.Locator.Scale; zoom = Math.Max(zoom, 0.01); scale = beginControlKey ? scale * zoom : scale / zoom; await map.Locator.Locate(scale, position); activatingStatus.ChartStatus = _chartStatus; rect.Visibility = System.Windows.Visibility.Collapsed; }); return(true); } return(false); }
private ActivatingStatus() { _chartStatus = ChartsStatus.移动海图; _tragStatus = TraggingStatus.海图模式; }