private void MoveThumb_DragDelta1111(object sender, DragDeltaEventArgs e) { //Initialize if (bIsMousePressMove == false) { AdornerLayer adornerLayer = AdornerLayer.GetAdornerLayer(designerCanvas); if (adornerLayer != null) { adorner = new PreveiwMoveAdorner(designerCanvas); if (adorner != null) { adornerLayer.Add(adorner); } } foreach (ContentControl item in this.designerCanvas.SelectedItemandGroups) { ContentPresenter wrapper = VisualTreeHelper.GetParent(item) as ContentPresenter; if (wrapper == null) { continue; } minLeft = Math.Min(Canvas.GetLeft(wrapper), minLeft); minTop = Math.Min(Canvas.GetTop(wrapper), minTop); } } bIsMousePressMove = true; if (this.designerItem == null || this.designerCanvas == null) { return; } //Get x/y offset Point dragDelta = new Point(e.HorizontalChange, e.VerticalChange); RotateTransform rotateTransform = designerItem.RenderTransform as RotateTransform; if (rotateTransform != null) { dragDelta = rotateTransform.Transform(dragDelta); } double deltaHorizontal = Math.Max(-minLeft, dragDelta.X); double deltaVertical = Math.Max(-minTop, dragDelta.Y); if (adorner != null) { adorner.PreviewMove(deltaHorizontal, deltaVertical); } e.Handled = true; }
private void MoveThumb_DragDelta(object sender, DragDeltaEventArgs e) { //Initialize to avoid exception if (this.designerItem == null || this.designerCanvas == null) { return; } //Initialize the selected widgets' context when first move if (bIsMousePressMove == false) { designerItem.IsAfterDraged = true; if (designerItem.IsSelected == false) { designerItem.SelectCurrentWidget(); } if (Keyboard.IsKeyDown(Key.LeftCtrl) == true || Keyboard.IsKeyDown(Key.RightCtrl) == true) { IsCtrlPressed = true; } else { IsCtrlPressed = false; } if (IsCtrlPressed == true && Mouse.LeftButton == MouseButtonState.Pressed) { //Cursor = CopyCur; //designerItem.IsStyleBrushModel = null; if (designerItem == null) { return; } WidgetViewModBase wVM = designerItem.DataContext as WidgetViewModBase; wVM.IsBrushModel = null; } AdornerLayer adornerLayer = AdornerLayer.GetAdornerLayer(designerCanvas); if (adornerLayer != null) { adorner = new PreveiwMoveAdorner(designerCanvas); if (adorner != null) { adornerLayer.Add(adorner); } } IPagePropertyData Page = designerCanvas.DataContext as IPagePropertyData; foreach (WidgetViewModBase item in Page.GetSelectedwidgets()) { if (item.IsLocked == true) { continue; } if (item.IsGroup == true) { GroupViewModel group = item as GroupViewModel; if (group == null) { continue; } // Create a property memento when drag start foreach (WidgetViewModBase child in group.WidgetChildren) { child.CreateNewPropertyMementos(); child.PropertyMementos.AddPropertyMemento(new PropertyMemento("Left", child.Raw_Left, child.Raw_Left)); child.PropertyMementos.AddPropertyMemento(new PropertyMemento("Top", child.Raw_Top, child.Raw_Top)); _infoItems.Add(child); } _groups.Add(group); } else { item.CreateNewPropertyMementos(); item.PropertyMementos.AddPropertyMemento(new PropertyMemento("Left", item.Raw_Left, item.Raw_Left)); item.PropertyMementos.AddPropertyMemento(new PropertyMemento("Top", item.Raw_Top, item.Raw_Top)); if (item.WidgetType == WidgetType.Toast && item.Top == 0) { item.PropertyMementos.AddPropertyMemento(new PropertyMemento("DisplayPosition", ToastDisplayPosition.Top, ToastDisplayPosition.Top)); } _infoItems.Add(item); } } bIsMousePressMove = true; } SendFirePositionEvent(false); //Move adorner to show drag process MoveAdorner(sender, e); //Move Widgets, the older solution, discarded //if (_infoItems.Count > 0 || _groups.Count > 0) //{ // MoveSelectedWidgets(sender,e); //} //set routed event is handled e.Handled = true; }