private PlacementOperation(DesignItem[] items, PlacementType type) { PlacementInformation[] information = new PlacementInformation[items.Length]; for (int i = 0; i < information.Length; i++) { information[i] = new PlacementInformation(items[i], this); } this.placedItems = new ReadOnlyCollection<PlacementInformation>(information); this.type = type; this.currentContainer = items[0].Parent; this.currentContainerBehavior = GetPlacementBehavior(items); this.changeGroup = items[0].Context.OpenGroup(type.ToString(), items); }
public virtual bool CanPlaceItem(PlacementInformation info) { return true; }
public virtual void SetPosition(PlacementInformation info) { if (info.Operation.Type != PlacementType.Move && info.Operation.Type != PlacementType.MovePoint) ModelTools.Resize(info.Item, info.Bounds.Width, info.Bounds.Height); //if (info.Operation.Type == PlacementType.MovePoint) // ModelTools.Resize(info.Item, info.Bounds.Width, info.Bounds.Height); }
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); } } }
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); }
public override void SetPosition(PlacementInformation info) { base.SetPosition(info); var resizeExtensions = info.Item.Extensions.OfType<ResizeThumbExtension>(); if (resizeExtensions != null && resizeExtensions.Count() != 0) { var resizeExtension = resizeExtensions.First(); _isItemGettingResized = resizeExtension.IsResizing; } if (_stackPanel != null && !_isItemGettingResized) { if (_stackPanel.Orientation == Orientation.Vertical) { var offset = FindHorizontalRectanglePlacementOffset(info.Bounds); DrawHorizontalRectangle(offset); } else { var offset = FindVerticalRectanglePlacementOffset(info.Bounds); DrawVerticalRectangle(offset); } ChangePositionTo(info.Item, _indexToInsert); } }