本文整理汇总了C#中PlacementOperation类的典型用法代码示例。如果您正苦于以下问题:C# PlacementOperation类的具体用法?C# PlacementOperation怎么用?C# PlacementOperation使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
PlacementOperation类属于命名空间,在下文中一共展示了PlacementOperation类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: LeaveContainer
public override void LeaveContainer(PlacementOperation operation)
{
base.LeaveContainer(operation);
/* Hide the rectangle in case switching to the other container
* otherwise it will show up intersecting with the container */
_rectangle.Visibility = Visibility.Hidden;
}
示例2: BeforeSetPosition
public override void BeforeSetPosition(PlacementOperation operation)
{
base.BeforeSetPosition(operation);
if (surface == null) return;
DesignPanel designPanel = ExtendedItem.Services.DesignPanel as DesignPanel;
if (designPanel == null || !designPanel.UseRasterPlacement)
return;
if (Keyboard.IsKeyDown(Key.LeftCtrl))
{
surface.Children.Clear();
rasterDrawn = false;
return;
}
drawRaster();
var bounds = operation.PlacedItems[0].Bounds;
bounds.Y = ((int)bounds.Y/raster)*raster;
bounds.X = ((int)bounds.X/raster)*raster;
bounds.Width = Convert.ToInt32((bounds.Width/raster))*raster;
bounds.Height = Convert.ToInt32((bounds.Height/raster))*raster;
operation.PlacedItems[0].Bounds = bounds;
}
示例3: GetPosition
public override Rect GetPosition(PlacementOperation operation, DesignItem item)
{
UIElement child = item.View;
if (child == null)
return Rect.Empty;
double x, y;
if (IsPropertySet(child, Canvas.LeftProperty) || !IsPropertySet(child, Canvas.RightProperty)) {
x = GetCanvasProperty(child, Canvas.LeftProperty);
} else {
x = extendedComponent.ActualWidth - GetCanvasProperty(child, Canvas.RightProperty) - PlacementOperation.GetRealElementSize(child).Width;
}
if (IsPropertySet(child, Canvas.TopProperty) || !IsPropertySet(child, Canvas.BottomProperty)) {
y = GetCanvasProperty(child, Canvas.TopProperty);
} else {
y = extendedComponent.ActualHeight - GetCanvasProperty(child, Canvas.BottomProperty) - PlacementOperation.GetRealElementSize(child).Height;
}
var p = new Point(x, y);
//Fixes, Empty Image Resized to 0
//return new Rect(p, child.RenderSize);
return new Rect(p, PlacementOperation.GetRealElementSize(item.View));
}
示例4: GetPosition
public virtual Rect GetPosition(PlacementOperation operation, DesignItem item)
{
if (item.View == null)
return Rect.Empty;
var p = item.View.TranslatePoint(new Point(), operation.CurrentContainer.View);
return new Rect(p, item.View.RenderSize);
}
示例5: EndPlacement
public virtual void EndPlacement(PlacementOperation operation)
{
InfoTextEnterArea.Stop(ref infoTextEnterArea);
this.ExtendedItem.Services.Selection.SetSelectedComponents(null);
this.ExtendedItem.Services.Selection.SetSelectedComponents(operation.PlacedItems.Select(x => x.Item).ToList());
}
示例6: LeaveContainer
public override void LeaveContainer(PlacementOperation operation)
{
base.LeaveContainer(operation);
foreach (PlacementInformation info in operation.PlacedItems) {
info.Item.Properties.GetAttachedProperty(Canvas.LeftProperty).Reset();
info.Item.Properties.GetAttachedProperty(Canvas.TopProperty).Reset();
}
}
示例7: LeaveContainer
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();
}
}
示例8: EnterContainer
public override void EnterContainer(PlacementOperation operation)
{
base.EnterContainer(operation);
foreach (PlacementInformation info in operation.PlacedItems) {
info.Item.Properties[FrameworkElement.HorizontalAlignmentProperty].Reset();
info.Item.Properties[FrameworkElement.VerticalAlignmentProperty].Reset();
info.Item.Properties[FrameworkElement.MarginProperty].Reset();
}
}
示例9: EnterContainer
public override void EnterContainer(PlacementOperation operation)
{
base.EnterContainer(operation);
foreach (var info in operation.PlacedItems) {
info.Item.Properties[FrameworkElement.MarginProperty].Reset();
info.Item.Properties[FrameworkElement.HorizontalAlignmentProperty].Reset();
info.Item.Properties[FrameworkElement.VerticalAlignmentProperty].Reset();
}
_rectangle.Visibility = Visibility.Visible;
}
示例10: BeginPlacement
public override void BeginPlacement(PlacementOperation operation)
{
base.BeginPlacement(operation);
DesignPanel designPanel = ExtendedItem.Services.DesignPanel as DesignPanel;
if (designPanel != null)
raster = designPanel.RasterWidth;
CreateSurface(operation);
}
示例11: Start
public void Start(Point p)
{
startPoint = p;
IPlacementBehavior b = PlacementOperation.GetPlacementBehavior(selectedItems);
if (b != null && b.CanPlace(selectedItems, PlacementType.Move, PlacementAlignment.TopLeft)) {
List<DesignItem> sortedSelectedItems = new List<DesignItem>(selectedItems);
sortedSelectedItems.Sort(ModelTools.ComparePositionInModelFile);
selectedItems = sortedSelectedItems;
operation = PlacementOperation.Start(selectedItems, PlacementType.Move);
}
}
示例12: CreateSurface
void CreateSurface(PlacementOperation operation)
{
if (ExtendedItem.Services.GetService<IDesignPanel>() != null)
{
surface = new Canvas();
adornerPanel = new AdornerPanel();
adornerPanel.SetAdornedElement(ExtendedItem.View, ExtendedItem);
AdornerPanel.SetPlacement(surface, AdornerPlacement.FillContent);
adornerPanel.Children.Add(surface);
ExtendedItem.Services.DesignPanel.Adorners.Add(adornerPanel);
}
}
示例13: CanEnterContainer
public virtual bool CanEnterContainer(PlacementOperation operation, bool shouldAlwaysEnter)
{
var canEnter = internalCanEnterContainer(operation);
if (canEnter && !shouldAlwaysEnter && !Keyboard.IsKeyDown(Key.LeftAlt) && !Keyboard.IsKeyDown(Key.RightAlt))
{
var b = new Rect(0, 0, ((FrameworkElement)this.ExtendedItem.View).ActualWidth, ((FrameworkElement)this.ExtendedItem.View).ActualHeight);
InfoTextEnterArea.Start(ref infoTextEnterArea, this.Services, this.ExtendedItem.View, b, Translations.Instance.PressAltText);
return false;
}
return canEnter;
}
示例14: BeginPlacement
public override void BeginPlacement(PlacementOperation operation)
{
base.BeginPlacement(operation);
if (_rects.Count > 0)
_rects.Clear();
/* Add Rect of all children to _rects */
var children = this.ExtendedItem.ContentProperty.CollectionElements;
foreach (var child in children) {
Point p = child.View.TranslatePoint(new Point(0, 0), this.ExtendedItem.View);
_rects.Add(new Rect(p, child.View.RenderSize));
}
if (_adornerPanel != null && this.ExtendedItem.Services.DesignPanel.Adorners.Contains(_adornerPanel))
this.ExtendedItem.Services.DesignPanel.Adorners.Remove(_adornerPanel);
/* Place the Rectangle */
_adornerPanel = new AdornerPanel();
_rectangle = new Rectangle();
_adornerPanel.SetAdornedElement(this.ExtendedItem.View, this.ExtendedItem);
_adornerPanel.Children.Add(_rectangle);
this.ExtendedItem.Services.DesignPanel.Adorners.Add(_adornerPanel);
}
示例15: EnterContainer
public override void EnterContainer(PlacementOperation operation)
{
base.EnterContainer(operation);
foreach (PlacementInformation info in operation.PlacedItems) {
info.Item.Properties[FrameworkElement.HorizontalAlignmentProperty].Reset();
info.Item.Properties[FrameworkElement.VerticalAlignmentProperty].Reset();
info.Item.Properties[FrameworkElement.MarginProperty].Reset();
if (operation.Type == PlacementType.PasteItem) {
if (!double.IsNaN((double)info.Item.Properties.GetAttachedProperty(Canvas.LeftProperty).ValueOnInstance)) {
info.Item.Properties.GetAttachedProperty(Canvas.LeftProperty)
.SetValue(((double) info.Item.Properties.GetAttachedProperty(Canvas.LeftProperty).ValueOnInstance) +
PlacementOperation.PasteOffset);
}
if (!double.IsNaN((double)info.Item.Properties.GetAttachedProperty(Canvas.TopProperty).ValueOnInstance)) {
info.Item.Properties.GetAttachedProperty(Canvas.TopProperty)
.SetValue(((double) info.Item.Properties.GetAttachedProperty(Canvas.TopProperty).ValueOnInstance) +
PlacementOperation.PasteOffset);
}
}
}
}