Browse Source

Merge pull request #61 from jogibear9988/master

XAML Designer fixes...
pull/62/merge
Siegfried Oleg Pammer 13 years ago
parent
commit
6e8e02860f
  1. 10
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Extensions/RenderTransformOriginExtension.cs
  2. 13
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Extensions/RotateThumbExtension.cs
  3. 208
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.XamlDom/Project/DesignTimeProperties.cs
  4. 32
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.XamlDom/Project/MarkupCompatibilityProperties.cs
  5. 8
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/Extensions/CustomInstanceFactory.cs

10
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Extensions/RenderTransformOriginExtension.cs

@ -47,16 +47,24 @@ namespace ICSharpCode.WpfDesign.Designer.Extensions
adornerPanel.Children.Add(renderTransformOriginThumb); adornerPanel.Children.Add(renderTransformOriginThumb);
renderTransformOriginThumb.DragDelta += new DragDeltaEventHandler(renderTransformOriginThumb_DragDelta); renderTransformOriginThumb.DragDelta += new DragDeltaEventHandler(renderTransformOriginThumb_DragDelta);
renderTransformOriginThumb.DragCompleted += new DragCompletedEventHandler(renderTransformOriginThumb_DragCompleted);
} }
void renderTransformOriginThumb_DragCompleted(object sender, DragCompletedEventArgs e)
{
this.ExtendedItem.Properties.GetProperty(FrameworkElement.RenderTransformOriginProperty).SetValue(new Point(Math.Round(renderTransformOrigin.X, 4), Math.Round(renderTransformOrigin.Y, 4)));
}
void renderTransformOriginThumb_DragDelta(object sender, DragDeltaEventArgs e) void renderTransformOriginThumb_DragDelta(object sender, DragDeltaEventArgs e)
{ {
var p = AdornerPanel.GetPlacement(renderTransformOriginThumb) as RelativePlacement; var p = AdornerPanel.GetPlacement(renderTransformOriginThumb) as RelativePlacement;
var pointAbs = adornerPanel.RelativeToAbsolute(new Vector(p.XRelativeToContentWidth, p.YRelativeToContentHeight)); var pointAbs = adornerPanel.RelativeToAbsolute(new Vector(p.XRelativeToContentWidth, p.YRelativeToContentHeight));
var pointAbsNew = pointAbs + new Vector(e.HorizontalChange, e.VerticalChange); var pointAbsNew = pointAbs + new Vector(e.HorizontalChange, e.VerticalChange);
var pRel = adornerPanel.AbsoluteToRelative(pointAbsNew); var pRel = adornerPanel.AbsoluteToRelative(pointAbsNew);
renderTransformOrigin = new Point(pRel.X, pRel.Y);
this.ExtendedItem.Properties.GetProperty(FrameworkElement.RenderTransformOriginProperty).SetValue(new Point(Math.Round(pRel.X, 4), Math.Round(pRel.Y, 4))); this.ExtendedItem.View.SetValue(FrameworkElement.RenderTransformOriginProperty, renderTransformOrigin);
//this.ExtendedItem.Properties.GetProperty(FrameworkElement.RenderTransformOriginProperty).SetValue(new Point(Math.Round(pRel.X, 4), Math.Round(pRel.Y, 4)));
} }
Point renderTransformOrigin = new Point(0.5, 0.5); Point renderTransformOrigin = new Point(0.5, 0.5);

13
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Extensions/RotateThumbExtension.cs

@ -26,16 +26,6 @@ namespace ICSharpCode.WpfDesign.Designer.Extensions
readonly DesignItem[] extendedItemArray = new DesignItem[1]; readonly DesignItem[] extendedItemArray = new DesignItem[1];
IPlacementBehavior resizeBehavior; IPlacementBehavior resizeBehavior;
PlacementOperation operation; PlacementOperation operation;
ChangeGroup changeGroup;
bool _isResizing;
/// <summary>
/// Gets whether this extension is resizing any element.
/// </summary>
public bool IsResizing{
get { return _isResizing; }
}
public RotateThumbExtension() public RotateThumbExtension()
{ {
@ -62,15 +52,12 @@ namespace ICSharpCode.WpfDesign.Designer.Extensions
return rotateThumb; return rotateThumb;
} }
Size oldSize;
#region Rotate #region Rotate
private Point centerPoint; private Point centerPoint;
private UIElement parent; private UIElement parent;
private Vector startVector; private Vector startVector;
private RotateTransform rotateTransform; private RotateTransform rotateTransform;
private Point renderTransformOrigin;
private double initialAngle; private double initialAngle;
private DesignItem rtTransform; private DesignItem rtTransform;
private double angle; private double angle;

208
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.XamlDom/Project/DesignTimeProperties.cs

@ -9,108 +9,108 @@ namespace ICSharpCode.WpfDesign.XamlDom
/// <summary> /// <summary>
/// Helper Class for the Design Time Properties used by VS and Blend /// Helper Class for the Design Time Properties used by VS and Blend
/// </summary> /// </summary>
public class DesignTimeProperties : FrameworkElement public class DesignTimeProperties : FrameworkElement
{ {
#region IsHidden #region IsHidden
public static bool GetIsHidden(DependencyObject obj) public static bool GetIsHidden(DependencyObject obj)
{ {
return (bool)obj.GetValue(IsHiddenProperty); return (bool)obj.GetValue(IsHiddenProperty);
} }
public static void SetIsHidden(DependencyObject obj, bool value) public static void SetIsHidden(DependencyObject obj, bool value)
{ {
obj.SetValue(IsHiddenProperty, value); obj.SetValue(IsHiddenProperty, value);
} }
public static readonly DependencyProperty IsHiddenProperty = public static readonly DependencyProperty IsHiddenProperty =
DependencyProperty.RegisterAttached("IsHidden", typeof(bool), typeof(DesignTimeProperties)); DependencyProperty.RegisterAttached("IsHidden", typeof(bool), typeof(DesignTimeProperties));
#endregion #endregion
#region IsLocked #region IsLocked
public static bool GetIsLocked(DependencyObject obj) public static bool GetIsLocked(DependencyObject obj)
{ {
return (bool)obj.GetValue(IsLockedProperty); return (bool)obj.GetValue(IsLockedProperty);
} }
public static void SetIsLocked(DependencyObject obj, bool value) public static void SetIsLocked(DependencyObject obj, bool value)
{ {
obj.SetValue(IsLockedProperty, value); obj.SetValue(IsLockedProperty, value);
} }
public static readonly DependencyProperty IsLockedProperty = public static readonly DependencyProperty IsLockedProperty =
DependencyProperty.RegisterAttached("IsLocked", typeof(bool), typeof(DesignTimeProperties)); DependencyProperty.RegisterAttached("IsLocked", typeof(bool), typeof(DesignTimeProperties));
#endregion #endregion
#region DataContext #region DataContext
public static object GetDataContext(DependencyObject obj) public static object GetDataContext(DependencyObject obj)
{ {
return (object)obj.GetValue(DataContextProperty); return (object)obj.GetValue(DataContextProperty);
} }
public static void SetDataContext(DependencyObject obj, bool value) public static void SetDataContext(DependencyObject obj, bool value)
{ {
obj.SetValue(DataContextProperty, value); obj.SetValue(DataContextProperty, value);
} }
public static readonly DependencyProperty DataContextProperty = public static readonly DependencyProperty DataContextProperty =
DependencyProperty.RegisterAttached("DataContext", typeof(object), typeof(DesignTimeProperties)); DependencyProperty.RegisterAttached("DataContext", typeof(object), typeof(DesignTimeProperties));
#endregion #endregion
#region DesignSource #region DesignSource
public static object GetDesignSource(DependencyObject obj) public static object GetDesignSource(DependencyObject obj)
{ {
return (object)obj.GetValue(DesignSourceProperty); return (object)obj.GetValue(DesignSourceProperty);
} }
public static void SetDesignSource(DependencyObject obj, bool value) public static void SetDesignSource(DependencyObject obj, bool value)
{ {
obj.SetValue(DesignSourceProperty, value); obj.SetValue(DesignSourceProperty, value);
} }
public static readonly DependencyProperty DesignSourceProperty = public static readonly DependencyProperty DesignSourceProperty =
DependencyProperty.RegisterAttached("DesignSource", typeof(object), typeof(DesignTimeProperties)); DependencyProperty.RegisterAttached("DesignSource", typeof(object), typeof(DesignTimeProperties));
#endregion #endregion
#region DesignWidth #region DesignWidth
public static double GetDesignWidth(DependencyObject obj) public static double GetDesignWidth(DependencyObject obj)
{ {
return (double)obj.GetValue(DesignWidthProperty); return (double)obj.GetValue(DesignWidthProperty);
} }
public static void SetDesignWidth(DependencyObject obj, double value) public static void SetDesignWidth(DependencyObject obj, double value)
{ {
obj.SetValue(DesignWidthProperty, value); obj.SetValue(DesignWidthProperty, value);
} }
public static readonly DependencyProperty DesignWidthProperty = public static readonly DependencyProperty DesignWidthProperty =
DependencyProperty.RegisterAttached("DesignWidth", typeof(double), typeof(DesignTimeProperties)); DependencyProperty.RegisterAttached("DesignWidth", typeof(double), typeof(DesignTimeProperties));
#endregion #endregion
#region DesignHeight #region DesignHeight
public static double GetDesignHeight(DependencyObject obj) public static double GetDesignHeight(DependencyObject obj)
{ {
return (double)obj.GetValue(DesignHeightProperty); return (double)obj.GetValue(DesignHeightProperty);
} }
public static void SetDesignHeight(DependencyObject obj, double value) public static void SetDesignHeight(DependencyObject obj, double value)
{ {
obj.SetValue(DesignHeightProperty, value); obj.SetValue(DesignHeightProperty, value);
} }
public static readonly DependencyProperty DesignHeightProperty = public static readonly DependencyProperty DesignHeightProperty =
DependencyProperty.RegisterAttached("DesignHeight", typeof(double), typeof(DesignTimeProperties)); DependencyProperty.RegisterAttached("DesignHeight", typeof(double), typeof(DesignTimeProperties));
#endregion #endregion
} }
} }

32
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.XamlDom/Project/MarkupCompatibilityProperties.cs

@ -9,23 +9,23 @@ namespace ICSharpCode.WpfDesign.XamlDom
/// <summary> /// <summary>
/// Helper Class for the Markup Compatibility Properties used by VS and Blend /// Helper Class for the Markup Compatibility Properties used by VS and Blend
/// </summary> /// </summary>
public class MarkupCompatibilityProperties : FrameworkElement public class MarkupCompatibilityProperties : FrameworkElement
{ {
#region Ignorable #region Ignorable
public static string GetIgnorable(DependencyObject obj) public static string GetIgnorable(DependencyObject obj)
{ {
return (string)obj.GetValue(IgnorableProperty); return (string)obj.GetValue(IgnorableProperty);
} }
public static void SetIgnorable(DependencyObject obj, string value) public static void SetIgnorable(DependencyObject obj, string value)
{ {
obj.SetValue(IgnorableProperty, value); obj.SetValue(IgnorableProperty, value);
} }
public static readonly DependencyProperty IgnorableProperty = public static readonly DependencyProperty IgnorableProperty =
DependencyProperty.RegisterAttached("Ignorable", typeof(string), typeof(MarkupCompatibilityProperties)); DependencyProperty.RegisterAttached("Ignorable", typeof(string), typeof(MarkupCompatibilityProperties));
#endregion #endregion
} }
} }

8
src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/Extensions/CustomInstanceFactory.cs

@ -2,6 +2,8 @@
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt) // This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
using System; using System;
using System.ComponentModel;
using System.Windows;
namespace ICSharpCode.WpfDesign.Extensions namespace ICSharpCode.WpfDesign.Extensions
{ {
@ -33,7 +35,11 @@ namespace ICSharpCode.WpfDesign.Extensions
/// </summary> /// </summary>
public virtual object CreateInstance(Type type, params object[] arguments) public virtual object CreateInstance(Type type, params object[] arguments)
{ {
return Activator.CreateInstance(type, arguments); var instance = Activator.CreateInstance(type, arguments);
var uiElement = instance as UIElement;
if (uiElement != null)
DesignerProperties.SetIsInDesignMode(uiElement, true);
return instance;
} }
} }

Loading…
Cancel
Save