Пример #1
0
 public override void LeaveContainer(PlacementOperation operation)
 {
     GrayOutDesignerExceptActiveArea.Stop(ref grayOut);
     base.LeaveContainer(operation);
     foreach (PlacementInformation info in operation.PlacedItems)
     {
         info.Item.Properties.GetAttachedProperty(Canvas.LeftProperty).Reset();
         info.Item.Properties.GetAttachedProperty(Canvas.TopProperty).Reset();
     }
 }
Пример #2
0
        public override void SetPosition(PlacementInformation info)
        {
            base.SetPosition(info);
            info.Item.Properties[FrameworkElement.MarginProperty].Reset();

            UIElement child       = info.Item.View;
            Rect      newPosition = info.Bounds;

            if (IsPropertySet(child, Canvas.LeftProperty) || !IsPropertySet(child, Canvas.RightProperty))
            {
                if (newPosition.Left != GetCanvasProperty(child, Canvas.LeftProperty))
                {
                    info.Item.Properties.GetAttachedProperty(Canvas.LeftProperty).SetValue(newPosition.Left);
                }
            }
            else
            {
                var newR = extendedComponent.ActualWidth - newPosition.Right;
                if (newR != GetCanvasProperty(child, Canvas.RightProperty))
                {
                    info.Item.Properties.GetAttachedProperty(Canvas.RightProperty).SetValue(newR);
                }
            }


            if (IsPropertySet(child, Canvas.TopProperty) || !IsPropertySet(child, Canvas.BottomProperty))
            {
                if (newPosition.Top != GetCanvasProperty(child, Canvas.TopProperty))
                {
                    info.Item.Properties.GetAttachedProperty(Canvas.TopProperty).SetValue(newPosition.Top);
                }
            }
            else
            {
                var newB = extendedComponent.ActualHeight - newPosition.Bottom;
                if (newB != GetCanvasProperty(child, Canvas.BottomProperty))
                {
                    info.Item.Properties.GetAttachedProperty(Canvas.BottomProperty).SetValue(newB);
                }
            }

            if (info.Item == Services.Selection.PrimarySelection)
            {
                var b = new Rect(0, 0, extendedView.ActualWidth, extendedView.ActualHeight);
                // only for primary selection:
                if (grayOut != null)
                {
                    grayOut.AnimateActiveAreaRectTo(b);
                }
                else
                {
                    GrayOutDesignerExceptActiveArea.Start(ref grayOut, this.Services, this.ExtendedItem.View, b);
                }
            }
        }
Пример #3
0
 protected override void OnStopped()
 {
     if (adornerPanel != null)
     {
         designPanel.Adorners.Remove(adornerPanel);
         adornerPanel = null;
     }
     GrayOutDesignerExceptActiveArea.Stop(ref grayOut);
     selectionFrame = null;
     base.OnStopped();
 }
Пример #4
0
        protected override void OnDragStarted(MouseEventArgs e)
        {
            adornerPanel = new AdornerPanel();
            adornerPanel.SetAdornedElement(container.View, container);

            selectionFrame = new SelectionFrame();
            adornerPanel.Children.Add(selectionFrame);

            designPanel.Adorners.Add(adornerPanel);

            GrayOutDesignerExceptActiveArea.Start(ref grayOut, services, container.View);
        }
Пример #5
0
        public override void LeaveContainer(PlacementOperation operation)
        {
            GrayOutDesignerExceptActiveArea.Stop(ref grayOut);
            base.LeaveContainer(operation);
            foreach (PlacementInformation info in operation.PlacedItems)
            {
                if (info.Item.ComponentType == typeof(ColumnDefinition))
                {
                    // TODO: combine the width of the deleted column with the previous column
                    this.ExtendedItem.Properties["ColumnDefinitions"].CollectionElements.Remove(info.Item);
                }
                else if (info.Item.ComponentType == typeof(RowDefinition))
                {
                    this.ExtendedItem.Properties["RowDefinitions"].CollectionElements.Remove(info.Item);
                }
                else
                {
                    info.Item.Properties.GetAttachedProperty(Grid.RowProperty).Reset();
                    info.Item.Properties.GetAttachedProperty(Grid.ColumnProperty).Reset();
                    info.Item.Properties.GetAttachedProperty(Grid.RowSpanProperty).Reset();
                    info.Item.Properties.GetAttachedProperty(Grid.ColumnSpanProperty).Reset();

                    HorizontalAlignment ha = (HorizontalAlignment)info.Item
                                             .Properties[FrameworkElement.HorizontalAlignmentProperty]
                                             .ValueOnInstance;
                    VerticalAlignment va = (VerticalAlignment)info.Item
                                           .Properties[FrameworkElement.VerticalAlignmentProperty]
                                           .ValueOnInstance;

                    if (ha == HorizontalAlignment.Stretch)
                    {
                        info.Item.Properties[FrameworkElement.WidthProperty].SetValue(info.Bounds.Width);
                    }
                    if (va == VerticalAlignment.Stretch)
                    {
                        info.Item.Properties[FrameworkElement.HeightProperty].SetValue(info.Bounds.Height);
                    }
                }
            }
        }
Пример #6
0
 public override void EndPlacement(PlacementOperation operation)
 {
     GrayOutDesignerExceptActiveArea.Stop(ref grayOut);
     base.EndPlacement(operation);
 }
Пример #7
0
        public override void SetPosition(PlacementInformation info)
        {
            base.SetPosition(info);
            int leftColumnIndex  = GetColumnIndex(info.Bounds.Left);
            int rightColumnIndex = GetEndColumnIndex(info.Bounds.Right);

            if (rightColumnIndex < leftColumnIndex)
            {
                rightColumnIndex = leftColumnIndex;
            }
            SetColumn(info.Item, leftColumnIndex, rightColumnIndex - leftColumnIndex + 1);
            int topRowIndex    = GetRowIndex(info.Bounds.Top);
            int bottomRowIndex = GetEndRowIndex(info.Bounds.Bottom);

            if (bottomRowIndex < topRowIndex)
            {
                bottomRowIndex = topRowIndex;
            }
            SetRow(info.Item, topRowIndex, bottomRowIndex - topRowIndex + 1);

            Rect availableSpaceRect = new Rect(
                new Point(GetColumnOffset(leftColumnIndex), GetRowOffset(topRowIndex)),
                new Point(GetColumnOffset(rightColumnIndex + 1), GetRowOffset(bottomRowIndex + 1))
                );

            if (info.Item == Services.Selection.PrimarySelection)
            {
                // only for primary selection:
                if (grayOut != null)
                {
                    grayOut.AnimateActiveAreaRectTo(availableSpaceRect);
                }
                else
                {
                    GrayOutDesignerExceptActiveArea.Start(ref grayOut, this.Services, this.ExtendedItem.View,
                                                          availableSpaceRect);
                }
            }

            HorizontalAlignment ha = (HorizontalAlignment)info.Item
                                     .Properties[FrameworkElement.HorizontalAlignmentProperty]
                                     .ValueOnInstance;
            VerticalAlignment va = (VerticalAlignment)info.Item.Properties[FrameworkElement.VerticalAlignmentProperty]
                                   .ValueOnInstance;

            if (enteredIntoNewContainer)
            {
                ha = SuggestHorizontalAlignment(info.Bounds, availableSpaceRect);
                va = SuggestVerticalAlignment(info.Bounds, availableSpaceRect);
            }
            info.Item.Properties[FrameworkElement.HorizontalAlignmentProperty].SetValue(ha);
            info.Item.Properties[FrameworkElement.VerticalAlignmentProperty].SetValue(va);

            Thickness margin = new Thickness(0, 0, 0, 0);

            if (ha == HorizontalAlignment.Left || ha == HorizontalAlignment.Stretch)
            {
                margin.Left = info.Bounds.Left - GetColumnOffset(leftColumnIndex);
            }
            if (va == VerticalAlignment.Top || va == VerticalAlignment.Stretch)
            {
                margin.Top = info.Bounds.Top - GetRowOffset(topRowIndex);
            }
            if (ha == HorizontalAlignment.Right || ha == HorizontalAlignment.Stretch)
            {
                margin.Right = GetColumnOffset(rightColumnIndex + 1) - info.Bounds.Right;
            }
            if (va == VerticalAlignment.Bottom || va == VerticalAlignment.Stretch)
            {
                margin.Bottom = GetRowOffset(bottomRowIndex + 1) - info.Bounds.Bottom;
            }
            info.Item.Properties[FrameworkElement.MarginProperty].SetValue(margin);

            if (ha == HorizontalAlignment.Stretch)
            {
                info.Item.Properties[FrameworkElement.WidthProperty].Reset();
            }
            //else
            //    info.Item.Properties[FrameworkElement.WidthProperty].SetValue(info.Bounds.Width);

            if (va == VerticalAlignment.Stretch)
            {
                info.Item.Properties[FrameworkElement.HeightProperty].Reset();
            }
            //else
            //    info.Item.Properties[FrameworkElement.HeightProperty].SetValue(info.Bounds.Height);
        }
Пример #8
0
 public override void EndPlacement(PlacementOperation operation)
 {
     GrayOutDesignerExceptActiveArea.Stop(ref grayOut);
     enteredIntoNewContainer = false;
     base.EndPlacement(operation);
 }