示例#1
0
        protected override void OnPreviewMouseDown(MouseButtonEventArgs e)
        {
            base.OnPreviewMouseDown(e);

            //更新选择项。
            var designer = DesignerCanvas.GetOwnerCanvas(this);

            if (designer != null)
            {
                designer.HandleMouseSelection(this);
            }

            e.Handled = false;
        }
示例#2
0
        private DesignerItemContainer[] GetSelectedContainers()
        {
            DesignerItemContainer[] selectedDesignerItems = null;

            var designerItem = this.DataContext as DesignerItemContainer;

            if (designerItem != null && designerItem.IsSelected)
            {
                var designer = DesignerCanvas.GetOwnerCanvas(designerItem);
                if (designer != null)
                {
                    // only resize DesignerItems
                    selectedDesignerItems = designer.SelectedItems.OfType <DesignerItemContainer>().ToArray();
                }
            }
            return(selectedDesignerItems);
        }
示例#3
0
文件: DragThumb.cs 项目: yungtau/oea
        void DragThumb_DragDelta(object sender, DragDeltaEventArgs e)
        {
            var designerItem = DesignerItemContainer.GetItemContainer(this);

            if (designerItem != null && designerItem.IsSelected)
            {
                var designer = DesignerCanvas.GetOwnerCanvas(designerItem);
                if (designer != null)
                {
                    //只移动 DesignerItem
                    var designerItems = designer.SelectedItems.OfType <DesignerItemContainer>();

                    //以下代码不知何意,暂留。
                    //double minLeft = double.MaxValue;
                    //double minTop = double.MaxValue;

                    //foreach (var item in designerItems)
                    //{
                    //    double left = GetDouble(item, Canvas.LeftProperty);
                    //    double top = GetDouble(item, Canvas.TopProperty);

                    //    minLeft = Math.Min(left, minLeft);
                    //    minTop = Math.Min(top, minTop);
                    //}

                    //double deltaHorizontal = Math.Max(-minLeft, e.HorizontalChange);
                    //double deltaVertical = Math.Max(-minTop, e.VerticalChange);

                    double deltaHorizontal = e.HorizontalChange;
                    double deltaVertical   = e.VerticalChange;

                    foreach (var item in designerItems)
                    {
                        double left = GetDouble(item, Canvas.LeftProperty);
                        double top  = GetDouble(item, Canvas.TopProperty);

                        Canvas.SetLeft(item, left + deltaHorizontal);
                        Canvas.SetTop(item, top + deltaVertical);
                    }

                    designer.InvalidateMeasure();

                    e.Handled = true;
                }
            }
        }