use layout transform on root element
This commit is contained in:
Родитель
6a808c6fd1
Коммит
90160c8060
|
@ -66,8 +66,8 @@ namespace ICSharpCode.WpfDesign.Designer
|
||||||
this.AddCommandHandler(Commands.AlignCenterCommand, () => ModelTools.ArrangeItems(this.DesignContext.Services.Selection.SelectedItems, ArrangeDirection.HorizontalMiddle), () => this.DesignContext.Services.Selection.SelectedItems.Count() > 1);
|
this.AddCommandHandler(Commands.AlignCenterCommand, () => ModelTools.ArrangeItems(this.DesignContext.Services.Selection.SelectedItems, ArrangeDirection.HorizontalMiddle), () => this.DesignContext.Services.Selection.SelectedItems.Count() > 1);
|
||||||
this.AddCommandHandler(Commands.AlignRightCommand, () => ModelTools.ArrangeItems(this.DesignContext.Services.Selection.SelectedItems, ArrangeDirection.Right), () => this.DesignContext.Services.Selection.SelectedItems.Count() > 1);
|
this.AddCommandHandler(Commands.AlignRightCommand, () => ModelTools.ArrangeItems(this.DesignContext.Services.Selection.SelectedItems, ArrangeDirection.Right), () => this.DesignContext.Services.Selection.SelectedItems.Count() > 1);
|
||||||
|
|
||||||
this.AddCommandHandler(Commands.RotateLeftCommand, () => ModelTools.ApplyTransform(this.DesignContext.Services.Selection.PrimarySelection, new RotateTransform(-90)), () => this.DesignContext.Services.Selection.PrimarySelection != null);
|
this.AddCommandHandler(Commands.RotateLeftCommand, () => ModelTools.ApplyTransform(this.DesignContext.Services.Selection.PrimarySelection, new RotateTransform(-90), true, this.DesignContext.RootItem == this.DesignContext.Services.Selection.PrimarySelection ? LayoutTransformProperty : RenderTransformProperty), () => this.DesignContext.Services.Selection.PrimarySelection != null);
|
||||||
this.AddCommandHandler(Commands.RotateRightCommand, () => ModelTools.ApplyTransform(this.DesignContext.Services.Selection.PrimarySelection, new RotateTransform(90)), () => this.DesignContext.Services.Selection.PrimarySelection != null);
|
this.AddCommandHandler(Commands.RotateRightCommand, () => ModelTools.ApplyTransform(this.DesignContext.Services.Selection.PrimarySelection, new RotateTransform(90), true, this.DesignContext.RootItem == this.DesignContext.Services.Selection.PrimarySelection ? LayoutTransformProperty : RenderTransformProperty), () => this.DesignContext.Services.Selection.PrimarySelection != null);
|
||||||
|
|
||||||
this.AddCommandHandler(Commands.StretchToSameWidthCommand, () => ModelTools.StretchItems(this.DesignContext.Services.Selection.SelectedItems, StretchDirection.Width), () => this.DesignContext.Services.Selection.SelectedItems.Count() > 1);
|
this.AddCommandHandler(Commands.StretchToSameWidthCommand, () => ModelTools.StretchItems(this.DesignContext.Services.Selection.SelectedItems, StretchDirection.Width), () => this.DesignContext.Services.Selection.SelectedItems.Count() > 1);
|
||||||
this.AddCommandHandler(Commands.StretchToSameHeightCommand, () => ModelTools.StretchItems(this.DesignContext.Services.Selection.SelectedItems, StretchDirection.Height), () => this.DesignContext.Services.Selection.SelectedItems.Count() > 1);
|
this.AddCommandHandler(Commands.StretchToSameHeightCommand, () => ModelTools.StretchItems(this.DesignContext.Services.Selection.SelectedItems, StretchDirection.Height), () => this.DesignContext.Services.Selection.SelectedItems.Count() > 1);
|
||||||
|
|
|
@ -501,13 +501,14 @@ namespace ICSharpCode.WpfDesign.Designer
|
||||||
operation.Commit();
|
operation.Commit();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void ApplyTransform(DesignItem designItem, Transform transform, bool relative = true)
|
public static void ApplyTransform(DesignItem designItem, Transform transform, bool relative = true, DependencyProperty transformProperty = null)
|
||||||
{
|
{
|
||||||
var changeGroup = designItem.OpenGroup("Apply Transform");
|
var changeGroup = designItem.OpenGroup("Apply Transform");
|
||||||
|
|
||||||
|
transformProperty = transformProperty ?? FrameworkElement.RenderTransformProperty;
|
||||||
Transform oldTransform = null;
|
Transform oldTransform = null;
|
||||||
if (designItem.Properties.GetProperty(FrameworkElement.RenderTransformProperty).IsSet) {
|
if (designItem.Properties.GetProperty(transformProperty).IsSet) {
|
||||||
oldTransform = designItem.Properties.GetProperty(FrameworkElement.RenderTransformProperty).ValueOnInstance as Transform;
|
oldTransform = designItem.Properties.GetProperty(transformProperty).ValueOnInstance as Transform;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (oldTransform is MatrixTransform) {
|
if (oldTransform is MatrixTransform) {
|
||||||
|
@ -538,22 +539,22 @@ namespace ICSharpCode.WpfDesign.Designer
|
||||||
|
|
||||||
if (oldTransform is RotateTransform || oldTransform == null) {
|
if (oldTransform is RotateTransform || oldTransform == null) {
|
||||||
if (rotateTransform.Angle != 0) {
|
if (rotateTransform.Angle != 0) {
|
||||||
designItem.Properties.GetProperty(FrameworkElement.RenderTransformProperty).SetValue(transform);
|
designItem.Properties.GetProperty(transformProperty).SetValue(transform);
|
||||||
var angle = rotateTransform.Angle;
|
var angle = rotateTransform.Angle;
|
||||||
if (relative && oldTransform != null) {
|
if (relative && oldTransform != null) {
|
||||||
angle = rotateTransform.Angle + ((RotateTransform)oldTransform).Angle;
|
angle = rotateTransform.Angle + ((RotateTransform)oldTransform).Angle;
|
||||||
}
|
}
|
||||||
designItem.Properties.GetProperty(FrameworkElement.RenderTransformProperty).Value.Properties.GetProperty(RotateTransform.AngleProperty).SetValue(angle);
|
designItem.Properties.GetProperty(transformProperty).Value.Properties.GetProperty(RotateTransform.AngleProperty).SetValue(angle);
|
||||||
if (rotateTransform.CenterX != 0.0)
|
if (rotateTransform.CenterX != 0.0)
|
||||||
designItem.Properties.GetProperty(FrameworkElement.RenderTransformProperty).Value.Properties.GetProperty(RotateTransform.CenterXProperty).SetValue(rotateTransform.CenterX);
|
designItem.Properties.GetProperty(transformProperty).Value.Properties.GetProperty(RotateTransform.CenterXProperty).SetValue(rotateTransform.CenterX);
|
||||||
if (rotateTransform.CenterY != 0.0)
|
if (rotateTransform.CenterY != 0.0)
|
||||||
designItem.Properties.GetProperty(FrameworkElement.RenderTransformProperty).Value.Properties.GetProperty(RotateTransform.CenterYProperty).SetValue(rotateTransform.CenterY);
|
designItem.Properties.GetProperty(transformProperty).Value.Properties.GetProperty(RotateTransform.CenterYProperty).SetValue(rotateTransform.CenterY);
|
||||||
|
|
||||||
if (oldTransform == null)
|
if (oldTransform == null)
|
||||||
designItem.Properties.GetProperty(FrameworkElement.RenderTransformOriginProperty).SetValue(new Point(0.5, 0.5));
|
designItem.Properties.GetProperty(FrameworkElement.RenderTransformOriginProperty).SetValue(new Point(0.5, 0.5));
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
designItem.Properties.GetProperty(FrameworkElement.RenderTransformProperty).Reset();
|
designItem.Properties.GetProperty(transformProperty).Reset();
|
||||||
designItem.Properties.GetProperty(FrameworkElement.RenderTransformOriginProperty).Reset();
|
designItem.Properties.GetProperty(FrameworkElement.RenderTransformOriginProperty).Reset();
|
||||||
}
|
}
|
||||||
} else if (oldTransform is TransformGroup) {
|
} else if (oldTransform is TransformGroup) {
|
||||||
|
@ -572,7 +573,7 @@ namespace ICSharpCode.WpfDesign.Designer
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (rotateTransform.Angle != 0) {
|
if (rotateTransform.Angle != 0) {
|
||||||
designItem.Properties.GetProperty(FrameworkElement.RenderTransformProperty).SetValue(transform);
|
designItem.Properties.GetProperty(transformProperty).SetValue(transform);
|
||||||
if (oldTransform == null)
|
if (oldTransform == null)
|
||||||
designItem.Properties.GetProperty(FrameworkElement.RenderTransformOriginProperty).SetValue(new Point(0.5, 0.5));
|
designItem.Properties.GetProperty(FrameworkElement.RenderTransformOriginProperty).SetValue(new Point(0.5, 0.5));
|
||||||
}
|
}
|
||||||
|
|
Загрузка…
Ссылка в новой задаче