/// <summary> /// 方向键移动位置 /// </summary> /// <param name="p_x"></param> /// <param name="p_y"></param> void MoveStep(double p_x, double p_y) { List <FrameworkElement> ls = new List <FrameworkElement>(); ls.AddRange(_owner.SelectionClerk.Selection); SketchMoveCmdArgs args = new SketchMoveCmdArgs(ls, p_x, p_y); _owner.CmdMove.Execute(args); }
void UndoRedo(SketchMoveCmdArgs p_args, bool p_isUndo) { var clerk = _owner.SelectionClerk; clerk.Clear(); clerk.Select(p_args.Items); if (p_isUndo) { clerk.Move(-p_args.DeltaX, -p_args.DeltaY); } else { clerk.Move(p_args.DeltaX, p_args.DeltaY); } }
/// <summary> /// 释放 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> void OnPointerReleased(object sender, PointerRoutedEventArgs e) { if (!_isCaptured || _pointerId != e.Pointer.PointerId) { return; } var clerk = _owner.SelectionClerk; if (_isDragging) { clerk.AlignGrid(); _owner.CalcPageSize(); _owner.HideTipLines(); // 记录移动历史 if (clerk.Selection.Count > 0) { Point pos = clerk.GetCurrentPos(); if (pos.X != _selectionStart.X || pos.Y != _selectionStart.Y) { List <FrameworkElement> ls = new List <FrameworkElement>(); ls.AddRange(clerk.Selection); SketchMoveCmdArgs args = new SketchMoveCmdArgs(ls, pos.X - _selectionStart.X, pos.Y - _selectionStart.Y); _owner.His.RecordAction(new CmdAction(_owner.CmdMove, args)); } } } else { double left = Canvas.GetLeft(_rect); double top = Canvas.GetTop(_rect); var ls = _owner.GetItemsByRegion(left, top, left + _rect.Width, top + _rect.Height); if (ls.Count > 0) { clerk.Select(ls); } else { _owner.OnSelectionChanged(); } HideSelRect(); } _grid.ReleasePointerCapture(e.Pointer); e.Handled = true; _isCaptured = false; _isDragging = false; _pointerId = null; }