Example #1
0
        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);
        }