private void ClickGroupChildInUnselected() { ClickInitialStatus = GroupStatus.UnSelect; DesignerCanvas designer = VisualTreeHelper.GetParent(VisualTreeHelper.GetParent(VisualTreeHelper.GetParent(this))) as DesignerCanvas; IGroupOperation pageVM = designer.DataContext as IGroupOperation; //this is option for the common widget if ((Keyboard.Modifiers & (ModifierKeys.Shift | ModifierKeys.Control)) != ModifierKeys.None) { foreach (BaseWidgetItem item in designer.SelectedItems) { if (item.IsSelected == true && item.ParentID != Guid.Empty) { return; } } pageVM.SetGroupStatus(ParentID, GroupStatus.Selected); } else { designer.DeselectAll(); pageVM.DeselectAllGroups(); pageVM.SetGroupStatus(ParentID, GroupStatus.Selected); } }
protected override void OnMouseDoubleClick(MouseButtonEventArgs e) { base.OnMouseDoubleClick(e); IsInEditModel = true; if (this.IsGroup != true) { IsSelected = true; DesignerCanvas designer = VisualTreeHelper.GetParent(VisualTreeHelper.GetParent(VisualTreeHelper.GetParent(this))) as DesignerCanvas; IGroupOperation pageVM = designer.DataContext as IGroupOperation; if (this.ParentID != Guid.Empty) { if (pageVM != null) { pageVM.SetGroupStatus(ParentID, GroupStatus.Edit); } } else { if (pageVM != null) { pageVM.DeselectAllGroups(); } } } //Event should can continue it's route to let canvas DeSelect all other widgets selected e.Handled = false; }
private void DeselectAllWidgets() { if (_pageVM != null) { foreach (IWidgetPropertyData widget in _pageVM.GetSelectedwidgets()) { WidgetViewModBase widgetVM = widget as WidgetViewModBase; if (widgetVM != null) { if (widgetVM.IsGroup) { // Group VM has IsSelected and GroupStatus.UnSelect property, set GroupStatus will also set IsSelected, but set // set IsSelected will not set status, they are not synchronized. We use status to set group selection in undo/redo. // See SelectCommand. IGroupOperation pageVM = _pageVM as IGroupOperation; if (pageVM != null) { pageVM.SetGroupStatus(widgetVM.widgetGID, GroupStatus.UnSelect); } } else { widgetVM.Raw_IsSelected = false; } } } } }
private void UpdateSelection() { selectionService.AllowWdgPropertyNotify(false); Rect rubberBand = new Rect(this.startPoint.Value, this.endPoint.Value); foreach (ContentPresenter item in this.designerCanvas.Children) { if (item == null) { continue; } //Rect itemRect = new Rect(item.RenderSize); //Rect itemBounds = item.TransformToAncestor(designerCanvas).TransformBounds(itemRect); BaseWidgetItem widget = VisualTreeHelper.GetChild(VisualTreeHelper.GetChild(item, 0), 0) as BaseWidgetItem; if (widget == null || widget.Visibility != Visibility.Visible) { continue; } if (rubberBand.Contains(widget.GetBoundingRect())) // Select Contained Mode //if (rubberBand.IntersectsWith(itemBounds)) // Select Intersected Mode { if (widget.ParentID != Guid.Empty) { continue; } if (widget.IsGroup == true) { GroupViewModel groupVM = widget.DataContext as GroupViewModel; IGroupOperation pageVM = designerCanvas.DataContext as IGroupOperation; Guid groupID = groupVM.widgetGID; pageVM.SetGroupStatus(groupID, GroupStatus.Selected); } else { widget.IsSelected = true; } } else { if (widget.IsGroup == true) { GroupViewModel groupVM = widget.DataContext as GroupViewModel; IGroupOperation pageVM = designerCanvas.DataContext as IGroupOperation; Guid groupID = groupVM.widgetGID; pageVM.SetGroupStatus(groupID, GroupStatus.UnSelect); } else { widget.IsSelected = false; } } } selectionService.AllowWdgPropertyNotify(true); }
//protected override void OnMouseUp(MouseButtonEventArgs e) //{ // base.OnMouseUp(e); //} //protected override void OnPreviewMouseLeftButtonUp(MouseButtonEventArgs e) //{ // base.OnPreviewMouseLeftButtonUp(e); //} #region Public function called bye Move Thumb public void OnGroupChildMouseUp() { DesignerCanvas designer = VisualTreeHelper.GetParent(VisualTreeHelper.GetParent(VisualTreeHelper.GetParent(this))) as DesignerCanvas; if (designer == null) { return; } //e.Handled = false; IGroupOperation pageVM = designer.DataContext as IGroupOperation; GroupStatus groupStatus = pageVM.GetGroupStatus(ParentID); if (ClickInitialStatus == GroupStatus.UnSelect && groupStatus == GroupStatus.Selected) { return; } //this is option for the group's child widget if (groupStatus == GroupStatus.UnSelect) { //if ((Keyboard.Modifiers & (ModifierKeys.Shift | ModifierKeys.Control)) != ModifierKeys.None) //{ // pageVM.SetGroupStatus(ParentID, GroupStatus.Selected); //} //else //{ // designer.DeselectAll(); // pageVM.DeselectAllGroups(); // pageVM.SetGroupStatus(ParentID, GroupStatus.Selected); //} } else if (groupStatus == GroupStatus.Selected) { if ((Keyboard.Modifiers & (ModifierKeys.Shift | ModifierKeys.Control)) != ModifierKeys.None) { pageVM.SetGroupStatus(ParentID, GroupStatus.UnSelect); } else { designer.DeselectAll(); pageVM.DeselectAllGroups(); pageVM.SetGroupStatus(ParentID, GroupStatus.Edit); this.IsSelected = true; } } else { //this is option for the common widget if ((Keyboard.Modifiers & (ModifierKeys.Shift | ModifierKeys.Control)) != ModifierKeys.None) { return; } else { if (_isSelectedDone == false) { if (IsSelected == true && designer.SelectedItems.Count() == 1) { return; } pageVM.DeselectAllChildren(ParentID); this.IsSelected = true; } } } }