Beispiel #1
0
        //更新当前选择的图元的集合
        private void UpdateSelection()
        {
            designerCanvas.SelectionService.ClearSelection();

            if (startPoint != null && endPoint != null)
            {
                Rect rubberBand = new Rect(startPoint.Value, endPoint.Value);
                foreach (FrameworkElement item in designerCanvas.Children)
                {
                    DesignerContainer di = item as DesignerContainer;
                    if (di == null || !di.Editable)
                    {
                        continue;
                    }
                    //Rect itemRect = VisualTreeHelper.GetDescendantBounds(Item);
                    //Rect itemBounds = Item.TransformToAncestor(designerCanvas).TransformBounds(itemRect);
                    FrameworkElement content = di.Item;
                    if (content == null)
                    {
                        continue;
                    }
                    Rect itemRect   = VisualTreeHelper.GetDescendantBounds(content);
                    Rect itemBounds = content.TransformToAncestor(designerCanvas).TransformBounds(itemRect);

                    if (!rubberBand.Contains(itemBounds))
                    {
                        continue;
                    }
                    //if (Item is Connection)
                    //    designerCanvas.SelectionService.AddToSelection(Item as ISelectable);
                    //else
                    //{
                    //DesignerItem di = Item as DesignerItem;
                    int idx = Panel.GetZIndex(di);
                    if (idx == int.MinValue)
                    {
                        continue;
                    }
                    if (di.ParentID == Guid.Empty)
                    {
                        designerCanvas.SelectionService.AddToSelection(di);
                    }
                    //}
                }
            }


            if (designerCanvas.SelectionService.SelectedDesignerContainer.Count > 0)
            {
                PropertyView pv = designerCanvas.FindName("pv") as PropertyView;
                if (pv != null)
                {
                    pv.ShowProView(false);
                }
            }
        }