Browse Source

Fixes to Path Handler

Fixes Resizing when Rotated/Zommed, etc and Basic work so all Thumbs could be corrected
pull/633/head
jogibear9988 11 years ago
parent
commit
739ebc75e8
  1. 2
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Controls/ContainerDragHandle.cs
  2. 6
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Controls/ControlStyles.xaml
  3. 12
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Controls/DragListener.cs
  4. 2
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Controls/PanelMoveAdorner.cs
  5. 2
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Controls/QuickOperationMenu.cs
  6. 2
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Controls/Thumbs/DesignerThumb.cs
  7. 4
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/DesignPanel.cs
  8. 2
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Extensions/LineHandlerExtension.cs
  9. 83
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Extensions/PathHandlerExtension.cs
  10. 2
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Extensions/PolyLineHandlerExtension.cs
  11. 18
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Extensions/ResizeThumbExtension.cs
  12. 2
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Extensions/SkewThumbExtension.cs
  13. 2
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Extensions/TextBlockRightClickContextMenu.xaml.cs
  14. 20
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/ModelTools.cs
  15. 2
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/OutlineView/OutlineTreeView.cs
  16. 2
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/PropertyGrid/Editors/FormatedTextEditor/FormatedTextEditor.xaml.cs
  17. 2
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/ThumbnailView/ThumbnailView.cs
  18. 1
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/WpfDesign.Designer.csproj
  19. 18
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/DesignItem.cs
  20. 40
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/UIExtensions/UIHelpers.cs
  21. 4
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/WpfDesign.csproj

2
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Controls/ContainerDragHandle.cs

@ -27,7 +27,7 @@ using ICSharpCode.WpfDesign.Extensions;
using ICSharpCode.WpfDesign.Designer.Converters; using ICSharpCode.WpfDesign.Designer.Converters;
using System.Globalization; using System.Globalization;
using System.Windows.Data; using System.Windows.Data;
using ICSharpCode.WpfDesign.Designer.UIExtensions; using ICSharpCode.WpfDesign.UIExtensions;
namespace ICSharpCode.WpfDesign.Designer.Controls namespace ICSharpCode.WpfDesign.Designer.Controls
{ {

6
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Controls/ControlStyles.xaml

@ -82,6 +82,12 @@
<Setter.Value> <Setter.Value>
<ControlTemplate TargetType="{x:Type Controls:PointThumb}"> <ControlTemplate TargetType="{x:Type Controls:PointThumb}">
<Grid> <Grid>
<Grid.Resources>
<Style TargetType="MenuItem">
<Setter Property="HorizontalContentAlignment" Value="Left" />
<Setter Property="VerticalContentAlignment" Value="Center" />
</Style>
</Grid.Resources>
<Line HorizontalAlignment="Left" VerticalAlignment="Top" Stroke="{TemplateBinding Foreground}" StrokeThickness="1" StrokeDashArray="2 2" X1="3.5" Y1="3.5" X2="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=RelativeToPoint.X}" Y2="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=RelativeToPoint.Y}" Visibility="{Binding Path=RelativeToPoint, RelativeSource={RelativeSource TemplatedParent}, Converter={x:Static Converters:CollapsedWhenNull.Instance}}" /> <Line HorizontalAlignment="Left" VerticalAlignment="Top" Stroke="{TemplateBinding Foreground}" StrokeThickness="1" StrokeDashArray="2 2" X1="3.5" Y1="3.5" X2="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=RelativeToPoint.X}" Y2="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=RelativeToPoint.Y}" Visibility="{Binding Path=RelativeToPoint, RelativeSource={RelativeSource TemplatedParent}, Converter={x:Static Converters:CollapsedWhenNull.Instance}}" />
<Rectangle HorizontalAlignment="Left" VerticalAlignment="Top" Width="7" Height="7" Name="thumbRectangle" SnapsToDevicePixels="True" Stroke="{TemplateBinding Foreground}" Fill="White" RadiusX="1.414" RadiusY="1.414" /> <Rectangle HorizontalAlignment="Left" VerticalAlignment="Top" Width="7" Height="7" Name="thumbRectangle" SnapsToDevicePixels="True" Stroke="{TemplateBinding Foreground}" Fill="White" RadiusX="1.414" RadiusY="1.414" />
<Ellipse HorizontalAlignment="Left" VerticalAlignment="Top" Width="7" Height="7" Name="thumbElipse" Stroke="{TemplateBinding Foreground}" SnapsToDevicePixels="True" Fill="White" Visibility="Collapsed" /> <Ellipse HorizontalAlignment="Left" VerticalAlignment="Top" Width="7" Height="7" Name="thumbElipse" Stroke="{TemplateBinding Foreground}" SnapsToDevicePixels="True" Fill="White" Visibility="Collapsed" />

12
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Controls/DragListener.cs

@ -23,6 +23,7 @@ using System.Text;
using System.Windows; using System.Windows;
using System.Windows.Input; using System.Windows.Input;
using System.Diagnostics; using System.Diagnostics;
using System.Windows.Media;
namespace ICSharpCode.WpfDesign.Designer.Controls namespace ICSharpCode.WpfDesign.Designer.Controls
{ {
@ -35,6 +36,8 @@ namespace ICSharpCode.WpfDesign.Designer.Controls
InputManager.Current.PostProcessInput += new ProcessInputEventHandler(PostProcessInput); InputManager.Current.PostProcessInput += new ProcessInputEventHandler(PostProcessInput);
} }
public Transform Transform { get; set; }
public DragListener(IInputElement target) public DragListener(IInputElement target)
{ {
Target = target; Target = target;
@ -141,7 +144,14 @@ namespace ICSharpCode.WpfDesign.Designer.Controls
public bool IsCanceled { get; private set; } public bool IsCanceled { get; private set; }
public Vector Delta { public Vector Delta {
get { return CurrentPoint - StartPoint; } get {
if (Transform != null) {
var matrix = Transform.Value;
matrix.Invert();
return matrix.Transform(CurrentPoint - StartPoint);
}
return CurrentPoint - StartPoint;
}
} }
} }
} }

2
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Controls/PanelMoveAdorner.cs

@ -28,7 +28,7 @@ using System.Windows.Media;
using ICSharpCode.WpfDesign.Designer.Converters; using ICSharpCode.WpfDesign.Designer.Converters;
using System.Globalization; using System.Globalization;
using System.Windows.Data; using System.Windows.Data;
using ICSharpCode.WpfDesign.Designer.UIExtensions; using ICSharpCode.WpfDesign.UIExtensions;
namespace ICSharpCode.WpfDesign.Designer.Controls namespace ICSharpCode.WpfDesign.Designer.Controls
{ {

2
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Controls/QuickOperationMenu.cs

@ -23,7 +23,7 @@ using System.Windows.Controls;
using System.Windows.Media; using System.Windows.Media;
using ICSharpCode.WpfDesign.Designer.Converters; using ICSharpCode.WpfDesign.Designer.Converters;
using System.Windows.Data; using System.Windows.Data;
using ICSharpCode.WpfDesign.Designer.UIExtensions; using ICSharpCode.WpfDesign.UIExtensions;
namespace ICSharpCode.WpfDesign.Designer.Controls namespace ICSharpCode.WpfDesign.Designer.Controls

2
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Controls/Thumbs/DesignerThumb.cs

@ -16,7 +16,7 @@
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE. // DEALINGS IN THE SOFTWARE.
using ICSharpCode.WpfDesign.Designer.UIExtensions; using ICSharpCode.WpfDesign.UIExtensions;
using System.Windows; using System.Windows;
using System.Windows.Controls; using System.Windows.Controls;
using System.Windows.Controls.Primitives; using System.Windows.Controls.Primitives;

4
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/DesignPanel.cs

@ -32,7 +32,7 @@ using System.Windows.Threading;
using ICSharpCode.WpfDesign.Adorners; using ICSharpCode.WpfDesign.Adorners;
using ICSharpCode.WpfDesign.Designer.Controls; using ICSharpCode.WpfDesign.Designer.Controls;
using ICSharpCode.WpfDesign.Designer.UIExtensions; using ICSharpCode.WpfDesign.UIExtensions;
using ICSharpCode.WpfDesign.Designer.Xaml; using ICSharpCode.WpfDesign.Designer.Xaml;
using ICSharpCode.WpfDesign.Extensions; using ICSharpCode.WpfDesign.Extensions;
using System.Linq; using System.Linq;
@ -511,7 +511,7 @@ namespace ICSharpCode.WpfDesign.Designer
PropertyChangedEventHandler handler = PropertyChanged; PropertyChangedEventHandler handler = PropertyChanged;
if (handler != null) handler(this, new PropertyChangedEventArgs(propertyName)); if (handler != null) handler(this, new PropertyChangedEventArgs(propertyName));
} }
#region ContextMenu #region ContextMenu
private Dictionary<ContextMenu, Tuple<int,List<object>>> contextMenusAndEntries = new Dictionary<ContextMenu, Tuple<int,List<object>>>(); private Dictionary<ContextMenu, Tuple<int,List<object>>> contextMenusAndEntries = new Dictionary<ContextMenu, Tuple<int,List<object>>>();

2
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Extensions/LineHandlerExtension.cs

@ -24,7 +24,7 @@ using System.Windows.Input;
using System.Windows.Media; using System.Windows.Media;
using System.Windows.Shapes; using System.Windows.Shapes;
using System.Windows.Controls; using System.Windows.Controls;
using ICSharpCode.WpfDesign.Designer.UIExtensions; using ICSharpCode.WpfDesign.UIExtensions;
namespace ICSharpCode.WpfDesign.Designer.Extensions namespace ICSharpCode.WpfDesign.Designer.Extensions
{ {
/// <summary> /// <summary>

83
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Extensions/PathHandlerExtension.cs

@ -28,7 +28,7 @@ using System.Windows.Controls;
using System.Collections.Generic; using System.Collections.Generic;
using System.Diagnostics; using System.Diagnostics;
using System.Linq; using System.Linq;
using ICSharpCode.WpfDesign.Designer.UIExtensions; using ICSharpCode.WpfDesign.UIExtensions;
using DragListener = ICSharpCode.WpfDesign.Designer.Controls.DragListener; using DragListener = ICSharpCode.WpfDesign.Designer.Controls.DragListener;
using System.Windows.Data; using System.Windows.Data;
using System.ComponentModel; using System.ComponentModel;
@ -142,39 +142,39 @@ namespace ICSharpCode.WpfDesign.Designer.Extensions
MenuItem menuItem = null; MenuItem menuItem = null;
if (pathpoint.TargetPathPoint == null && (pathpoint.Object is LineSegment || pathpoint.Object is PolyLineSegment || pathpoint.Object is BezierSegment || pathpoint.Object is QuadraticBezierSegment || pathpoint.Object is ArcSegment)) { if (pathpoint.TargetPathPoint == null && (pathpoint.Object is LineSegment || pathpoint.Object is PolyLineSegment || pathpoint.Object is BezierSegment || pathpoint.Object is QuadraticBezierSegment || pathpoint.Object is ArcSegment)) {
menuItem = new MenuItem() { Header = "insert Point" }; menuItem = new MenuItem() { Header = "insert Point", HorizontalContentAlignment = HorizontalAlignment.Left, VerticalContentAlignment = VerticalAlignment.Center };
menuItem.Click += (s, e) => ConvertPart(((DependencyObject)s).TryFindParent<PathThumb>(), PathPartConvertType.insertPoint); menuItem.Click += (s, e) => ConvertPart(((DependencyObject)s).TryFindParent<PathThumb>(), PathPartConvertType.insertPoint);
menuList.Add(menuItem); menuList.Add(menuItem);
menuItem = new MenuItem() { Header = "to Line Segment" }; menuItem = new MenuItem() { Header = "to Line Segment", HorizontalContentAlignment = HorizontalAlignment.Left, VerticalContentAlignment = VerticalAlignment.Center };
menuItem.Click += (s, e) => ConvertPart(((DependencyObject)s).TryFindParent<PathThumb>(), PathPartConvertType.ToLineSegment); menuItem.Click += (s, e) => ConvertPart(((DependencyObject)s).TryFindParent<PathThumb>(), PathPartConvertType.ToLineSegment);
menuList.Add(menuItem); menuList.Add(menuItem);
menuItem = new MenuItem() {Header = "to Bezier Segment"}; menuItem = new MenuItem() {Header = "to Bezier Segment", HorizontalContentAlignment = HorizontalAlignment.Left, VerticalContentAlignment = VerticalAlignment.Center };
menuItem.Click += (s, e) => ConvertPart(((DependencyObject)s).TryFindParent<PathThumb>(), PathPartConvertType.ToBezierSegment); menuItem.Click += (s, e) => ConvertPart(((DependencyObject)s).TryFindParent<PathThumb>(), PathPartConvertType.ToBezierSegment);
menuList.Add(menuItem); menuList.Add(menuItem);
menuItem = new MenuItem() {Header = "to Quadric Bezier Segment"}; menuItem = new MenuItem() {Header = "to Quadric Bezier Segment", HorizontalContentAlignment = HorizontalAlignment.Left, VerticalContentAlignment = VerticalAlignment.Center };
menuItem.Click += (s, e) => ConvertPart(((DependencyObject)s).TryFindParent<PathThumb>(), PathPartConvertType.ToQuadricBezierSegment); menuItem.Click += (s, e) => ConvertPart(((DependencyObject)s).TryFindParent<PathThumb>(), PathPartConvertType.ToQuadricBezierSegment);
menuList.Add(menuItem); menuList.Add(menuItem);
menuItem = new MenuItem() { Header = "to Arc Segment" }; menuItem = new MenuItem() { Header = "to Arc Segment", HorizontalContentAlignment = HorizontalAlignment.Left, VerticalContentAlignment = VerticalAlignment.Center };
menuItem.Click += (s, e) => ConvertPart(((DependencyObject)s).TryFindParent<PathThumb>(), PathPartConvertType.ToArcSegment); menuItem.Click += (s, e) => ConvertPart(((DependencyObject)s).TryFindParent<PathThumb>(), PathPartConvertType.ToArcSegment);
menuList.Add(menuItem); menuList.Add(menuItem);
menuList.Add(new Separator()); menuList.Add(new Separator());
menuItem = new MenuItem() { Header = "is Stroked", IsChecked = ((PathSegment)pathpoint.Object).IsStroked }; menuItem = new MenuItem() { Header = "is Stroked", IsChecked = ((PathSegment)pathpoint.Object).IsStroked, HorizontalContentAlignment = HorizontalAlignment.Left, VerticalContentAlignment = VerticalAlignment.Center };
menuItem.Click += (s, e) => ChangeIsStroked(((DependencyObject)s).TryFindParent<PathThumb>(), (MenuItem)s); menuItem.Click += (s, e) => ChangeIsStroked(((DependencyObject)s).TryFindParent<PathThumb>(), (MenuItem)s);
menuList.Add(menuItem); menuList.Add(menuItem);
menuItem = new MenuItem() { Header = "is Smooth Join", IsChecked = ((PathSegment)pathpoint.Object).IsSmoothJoin }; menuItem = new MenuItem() { Header = "is Smooth Join", IsChecked = ((PathSegment)pathpoint.Object).IsSmoothJoin, HorizontalContentAlignment = HorizontalAlignment.Left, VerticalContentAlignment = VerticalAlignment.Center };
menuList.Add(menuItem); menuList.Add(menuItem);
} }
if (pathpoint.Object is ArcSegment) { if (pathpoint.Object is ArcSegment) {
menuItem = new MenuItem() { Header = "is large Arc", IsChecked = ((ArcSegment)pathpoint.Object).IsLargeArc }; menuItem = new MenuItem() { Header = "is large Arc", IsChecked = ((ArcSegment)pathpoint.Object).IsLargeArc, HorizontalContentAlignment = HorizontalAlignment.Left, VerticalContentAlignment = VerticalAlignment.Center };
menuList.Add(menuItem); menuList.Add(menuItem);
menuItem = new MenuItem() { Header = "Rotation Angle", IsChecked = true }; menuItem = new MenuItem() { Header = "Rotation Angle", IsChecked = true, HorizontalContentAlignment = HorizontalAlignment.Left, VerticalContentAlignment = VerticalAlignment.Center };
menuList.Add(menuItem); menuList.Add(menuItem);
menuItem = new MenuItem() { Header = "Clockwise SweepDirection", IsChecked = ((ArcSegment)pathpoint.Object).SweepDirection == SweepDirection.Clockwise }; menuItem = new MenuItem() { Header = "Clockwise SweepDirection", IsChecked = ((ArcSegment)pathpoint.Object).SweepDirection == SweepDirection.Clockwise, HorizontalContentAlignment = HorizontalAlignment.Left, VerticalContentAlignment = VerticalAlignment.Center };
menuList.Add(menuItem); menuList.Add(menuItem);
} }
if (pathpoint.Object is PathFigure) { if (pathpoint.Object is PathFigure) {
menuItem = new MenuItem() { Header = "is Closed", IsChecked = ((PathFigure)pathpoint.Object).IsClosed }; menuItem = new MenuItem() { Header = "is Closed", IsChecked = ((PathFigure)pathpoint.Object).IsClosed, HorizontalContentAlignment = HorizontalAlignment.Left, VerticalContentAlignment = VerticalAlignment.Center };
menuItem.Click += (s, e) => ChangeIsClosed(((DependencyObject)s).TryFindParent<PathThumb>(), (MenuItem)s); menuItem.Click += (s, e) => ChangeIsClosed(((DependencyObject)s).TryFindParent<PathThumb>(), (MenuItem)s);
menuList.Add(menuItem); menuList.Add(menuItem);
} }
@ -249,7 +249,7 @@ namespace ICSharpCode.WpfDesign.Designer.Extensions
pathFigure.Segments.RemoveAt(idx); pathFigure.Segments.RemoveAt(idx);
var midp = senderThumb.PathPoint.ParentPathPoint.Point - ((senderThumb.PathPoint.ParentPathPoint.Point - point) / 2); var midp = senderThumb.PathPoint.ParentPathPoint.Point - ((senderThumb.PathPoint.ParentPathPoint.Point - point) / 2);
PathSegment newSegment = null; PathSegment newSegment = null;
switch (convertType) switch (convertType)
{ {
@ -382,9 +382,9 @@ namespace ICSharpCode.WpfDesign.Designer.Extensions
// result.Height = ys.Max() - ys.Min(); // result.Height = ys.Max() - ys.Min();
// //
// info.Bounds = result.Round(); // info.Bounds = result.Round();
// //
// //
// //
// operation.CurrentContainerBehavior.BeforeSetPosition(operation); // operation.CurrentContainerBehavior.BeforeSetPosition(operation);
// operation.CurrentContainerBehavior.SetPosition(info); // operation.CurrentContainerBehavior.SetPosition(info);
// } // }
@ -420,13 +420,11 @@ namespace ICSharpCode.WpfDesign.Designer.Extensions
protected void drag_Changed(DragListener drag) protected void drag_Changed(DragListener drag)
{ {
var mprt = drag.Target as PathThumb; var mprt = drag.Target as PathThumb;
if (mprt != null) if (mprt != null) {
{
double dx = 0; double dx = 0;
double dy = 0; double dy = 0;
//if has zoomed //if has zoomed
if (_zoom != null) if (_zoom != null) {
{
dx = drag.Delta.X * (1 / _zoom.CurrentZoom); dx = drag.Delta.X * (1 / _zoom.CurrentZoom);
dy = drag.Delta.Y * (1 / _zoom.CurrentZoom); dy = drag.Delta.Y * (1 / _zoom.CurrentZoom);
} }
@ -440,14 +438,10 @@ namespace ICSharpCode.WpfDesign.Designer.Extensions
protected void drag_Completed(DragListener drag) protected void drag_Completed(DragListener drag)
{ {
var mprt = drag.Target as PathThumb; var mprt = drag.Target as PathThumb;
if (mprt != null) if (mprt != null) {
{ if (operation != null && drag.IsCanceled) {
if (operation != null && drag.IsCanceled)
{
operation.Abort(); operation.Abort();
} } else if (drag.IsCanceled) {
else if (drag.IsCanceled)
{
changeGroup.Abort(); changeGroup.Abort();
} }
CommitOperation(); CommitOperation();
@ -463,8 +457,7 @@ namespace ICSharpCode.WpfDesign.Designer.Extensions
pathPoints = GetPoints(); pathPoints = GetPoints();
resizeThumbs = new List<DesignerThumb>(); resizeThumbs = new List<DesignerThumb>();
for (int i = 0; i < pathPoints.Count; i++) for (int i = 0; i < pathPoints.Count; i++) {
{
CreateThumb(PlacementAlignment.BottomRight, Cursors.Cross, i, pathPoints[i]); CreateThumb(PlacementAlignment.BottomRight, Cursors.Cross, i, pathPoints[i]);
} }
@ -500,12 +493,15 @@ namespace ICSharpCode.WpfDesign.Designer.Extensions
var g = geometry as CombinedGeometry; var g = geometry as CombinedGeometry;
AddGeometryPoints(list, g.Geometry1); AddGeometryPoints(list, g.Geometry1);
AddGeometryPoints(list, g.Geometry2); AddGeometryPoints(list, g.Geometry2);
} else if (geometry is GeometryGroup) } else if (geometry is GeometryGroup) {
{
var gg = geometry as GeometryGroup; var gg = geometry as GeometryGroup;
foreach (var g in gg.Children) { foreach (var g in gg.Children) {
AddGeometryPoints(list, g); AddGeometryPoints(list, g);
} }
} else if (geometry is StreamGeometry) {
var sg = geometry as StreamGeometry;
var pg = sg.GetFlattenedPathGeometry().Clone();
AddGeometryPoints(list, pg);
} else if (geometry is PathGeometry) { } else if (geometry is PathGeometry) {
var g = geometry as PathGeometry; var g = geometry as PathGeometry;
if (geometry!=null) { if (geometry!=null) {
@ -515,8 +511,7 @@ namespace ICSharpCode.WpfDesign.Designer.Extensions
var parentp = list.Last(); var parentp = list.Last();
if (s is LineSegment) if (s is LineSegment)
list.Add(new PathPoint(((LineSegment)s).Point, s, figure, (p) => ((LineSegment)s).Point = p){ParentPathPoint = parentp}); list.Add(new PathPoint(((LineSegment)s).Point, s, figure, (p) => ((LineSegment)s).Point = p){ParentPathPoint = parentp});
else if (s is PolyLineSegment) else if (s is PolyLineSegment) {
{
var poly = s as PolyLineSegment; var poly = s as PolyLineSegment;
for (int n = 0; n < poly.Points.Count; n++) for (int n = 0; n < poly.Points.Count; n++)
{ {
@ -524,23 +519,17 @@ namespace ICSharpCode.WpfDesign.Designer.Extensions
list.Add(new PathPoint(poly.Points[closure_n], s, figure, (p) => poly.Points[closure_n] = p) { PolyLineIndex = closure_n, ParentPathPoint = parentp }); list.Add(new PathPoint(poly.Points[closure_n], s, figure, (p) => poly.Points[closure_n] = p) { PolyLineIndex = closure_n, ParentPathPoint = parentp });
parentp = list.Last(); parentp = list.Last();
} }
} } else if (s is BezierSegment) {
else if (s is BezierSegment)
{
var pathp = new PathPoint(((BezierSegment)s).Point3, s, figure, (p) => ((BezierSegment)s).Point3 = p){ParentPathPoint = parentp}; var pathp = new PathPoint(((BezierSegment)s).Point3, s, figure, (p) => ((BezierSegment)s).Point3 = p){ParentPathPoint = parentp};
var previous = list.Last(); var previous = list.Last();
list.Add(new PathPoint(((BezierSegment)s).Point1, s, figure, (p) => ((BezierSegment)s).Point1 = p) { TargetPathPoint = previous }); list.Add(new PathPoint(((BezierSegment)s).Point1, s, figure, (p) => ((BezierSegment)s).Point1 = p) { TargetPathPoint = previous });
list.Add(new PathPoint(((BezierSegment)s).Point2, s, figure, (p) => ((BezierSegment)s).Point2 = p) { TargetPathPoint = pathp }); list.Add(new PathPoint(((BezierSegment)s).Point2, s, figure, (p) => ((BezierSegment)s).Point2 = p) { TargetPathPoint = pathp });
list.Add(pathp); list.Add(pathp);
} } else if (s is QuadraticBezierSegment) {
else if (s is QuadraticBezierSegment)
{
var pathp = new PathPoint(((QuadraticBezierSegment)s).Point2, s, figure, (p) => ((QuadraticBezierSegment)s).Point2 = p){ParentPathPoint = parentp}; var pathp = new PathPoint(((QuadraticBezierSegment)s).Point2, s, figure, (p) => ((QuadraticBezierSegment)s).Point2 = p){ParentPathPoint = parentp};
list.Add(new PathPoint(((QuadraticBezierSegment)s).Point1, s, figure, (p) => ((QuadraticBezierSegment)s).Point1 = p) { TargetPathPoint = pathp }); list.Add(new PathPoint(((QuadraticBezierSegment)s).Point1, s, figure, (p) => ((QuadraticBezierSegment)s).Point1 = p) { TargetPathPoint = pathp });
list.Add(pathp); list.Add(pathp);
} } else if (s is ArcSegment) {
else if (s is ArcSegment)
{
var arc = ((ArcSegment)s); var arc = ((ArcSegment)s);
var pathp = new PathPoint(arc.Point, s, figure, (p) => arc.Point = p){ParentPathPoint = parentp}; var pathp = new PathPoint(arc.Point, s, figure, (p) => arc.Point = p){ParentPathPoint = parentp};
list.Add(new PathPoint(arc.Point - new Vector(arc.Size.Width, arc.Size.Height), s, figure, (p) => arc.Size = new Size(Math.Abs(arc.Point.X - p.X), Math.Abs(arc.Point.Y - p.Y))) { TargetPathPoint = pathp }); list.Add(new PathPoint(arc.Point - new Vector(arc.Size.Width, arc.Size.Height), s, figure, (p) => arc.Size = new Size(Math.Abs(arc.Point.X - p.X), Math.Abs(arc.Point.Y - p.Y))) { TargetPathPoint = pathp });
@ -568,8 +557,7 @@ namespace ICSharpCode.WpfDesign.Designer.Extensions
List<PathPoint> MovePoints(List<PathPoint> pc, double displacementX, double displacementY) List<PathPoint> MovePoints(List<PathPoint> pc, double displacementX, double displacementY)
{ {
//iterate all selected points //iterate all selected points
foreach (int i in _selectedThumbs.Keys) foreach (int i in _selectedThumbs.Keys) {
{
Point p = pc[i].Point; Point p = pc[i].Point;
//x and y is calculated from the currentl point //x and y is calculated from the currentl point
@ -594,14 +582,13 @@ namespace ICSharpCode.WpfDesign.Designer.Extensions
public void KeyDownAction(object sender, KeyEventArgs e) public void KeyDownAction(object sender, KeyEventArgs e)
{ {
Debug.WriteLine("KeyDown"); Debug.WriteLine("KeyDown");
if (IsArrowKey(e.Key)) if (IsArrowKey(e.Key)) {
if (operation == null) if (operation == null) {
{
SetOperation(); SetOperation();
_movingDistance = 0; _movingDistance = 0;
}
} }
var dx1 = (e.Key == Key.Left) ? Keyboard.IsKeyDown(Key.LeftShift) ? _movingDistance - 10 : _movingDistance - 1 : 0; var dx1 = (e.Key == Key.Left) ? Keyboard.IsKeyDown(Key.LeftShift) ? _movingDistance - 10 : _movingDistance - 1 : 0;
var dy1 = (e.Key == Key.Up) ? Keyboard.IsKeyDown(Key.LeftShift) ? _movingDistance - 10 : _movingDistance - 1 : 0; var dy1 = (e.Key == Key.Up) ? Keyboard.IsKeyDown(Key.LeftShift) ? _movingDistance - 10 : _movingDistance - 1 : 0;
var dx2 = (e.Key == Key.Right) ? Keyboard.IsKeyDown(Key.LeftShift) ? _movingDistance + 10 : _movingDistance + 1 : 0; var dx2 = (e.Key == Key.Right) ? Keyboard.IsKeyDown(Key.LeftShift) ? _movingDistance + 10 : _movingDistance + 1 : 0;

2
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Extensions/PolyLineHandlerExtension.cs

@ -31,7 +31,7 @@ using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Diagnostics; using System.Diagnostics;
using System.Linq; using System.Linq;
using ICSharpCode.WpfDesign.Designer.UIExtensions; using ICSharpCode.WpfDesign.UIExtensions;
namespace ICSharpCode.WpfDesign.Designer.Extensions namespace ICSharpCode.WpfDesign.Designer.Extensions
{ {

18
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Extensions/ResizeThumbExtension.cs

@ -26,7 +26,7 @@ using ICSharpCode.WpfDesign.Adorners;
using ICSharpCode.WpfDesign.Designer.Controls; using ICSharpCode.WpfDesign.Designer.Controls;
using ICSharpCode.WpfDesign.Extensions; using ICSharpCode.WpfDesign.Extensions;
using System.Collections.Generic; using System.Collections.Generic;
using ICSharpCode.WpfDesign.Designer.UIExtensions; using ICSharpCode.WpfDesign.UIExtensions;
namespace ICSharpCode.WpfDesign.Designer.Extensions namespace ICSharpCode.WpfDesign.Designer.Extensions
{ {
@ -119,14 +119,10 @@ namespace ICSharpCode.WpfDesign.Designer.Extensions
} }
Size oldSize; Size oldSize;
ZoomControl zoom;
// TODO : Remove all hide/show extensions from here. // TODO : Remove all hide/show extensions from here.
void drag_Started(DragListener drag) void drag_Started(DragListener drag)
{ {
var designPanel = ExtendedItem.Services.DesignPanel as DesignPanel;
zoom = designPanel.TryFindParent<ZoomControl>();
/* Abort editing Text if it was editing, because it interferes with the undo stack. */ /* Abort editing Text if it was editing, because it interferes with the undo stack. */
foreach(var extension in this.ExtendedItem.Extensions){ foreach(var extension in this.ExtendedItem.Extensions){
if(extension is InPlaceEditorExtension){ if(extension is InPlaceEditorExtension){
@ -134,6 +130,8 @@ namespace ICSharpCode.WpfDesign.Designer.Extensions
} }
} }
drag.Transform = this.ExtendedItem.GetCompleteAppliedTransformationToView();
oldSize = new Size(ModelTools.GetWidth(ExtendedItem.View), ModelTools.GetHeight(ExtendedItem.View)); oldSize = new Size(ModelTools.GetWidth(ExtendedItem.View), ModelTools.GetHeight(ExtendedItem.View));
if (resizeBehavior != null) if (resizeBehavior != null)
operation = PlacementOperation.Start(extendedItemArray, PlacementType.Resize); operation = PlacementOperation.Start(extendedItemArray, PlacementType.Resize);
@ -152,10 +150,6 @@ namespace ICSharpCode.WpfDesign.Designer.Extensions
var delta = drag.Delta; var delta = drag.Delta;
var transform = this.ExtendedItem.View.RenderTransform;
if (transform != null)
delta = (Vector)transform.Inverse.Transform((Point)delta);
if (alignment.Horizontal == HorizontalAlignment.Left) dx = -delta.X; if (alignment.Horizontal == HorizontalAlignment.Left) dx = -delta.X;
if (alignment.Horizontal == HorizontalAlignment.Right) dx = delta.X; if (alignment.Horizontal == HorizontalAlignment.Right) dx = delta.X;
if (alignment.Vertical == VerticalAlignment.Top) dy = -delta.Y; if (alignment.Vertical == VerticalAlignment.Top) dy = -delta.Y;
@ -170,12 +164,6 @@ namespace ICSharpCode.WpfDesign.Designer.Extensions
else else
dy = dx; dy = dx;
} }
if (zoom != null)
{
dx = dx * (1 / zoom.CurrentZoom);
dy = dy * (1 / zoom.CurrentZoom);
}
var newWidth = Math.Max(0, oldSize.Width + dx); var newWidth = Math.Max(0, oldSize.Width + dx);
var newHeight = Math.Max(0, oldSize.Height + dy); var newHeight = Math.Max(0, oldSize.Height + dy);

2
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Extensions/SkewThumbExtension.cs

@ -27,7 +27,7 @@ using ICSharpCode.WpfDesign.Adorners;
using ICSharpCode.WpfDesign.Designer.Controls; using ICSharpCode.WpfDesign.Designer.Controls;
using ICSharpCode.WpfDesign.Extensions; using ICSharpCode.WpfDesign.Extensions;
using System.Collections.Generic; using System.Collections.Generic;
using ICSharpCode.WpfDesign.Designer.UIExtensions; using ICSharpCode.WpfDesign.UIExtensions;
namespace ICSharpCode.WpfDesign.Designer.Extensions namespace ICSharpCode.WpfDesign.Designer.Extensions
{ {

2
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Extensions/TextBlockRightClickContextMenu.xaml.cs

@ -20,7 +20,7 @@ using System;
using System.Linq; using System.Linq;
using System.Windows; using System.Windows;
using ICSharpCode.WpfDesign.Designer.PropertyGrid.Editors.FormatedTextEditor; using ICSharpCode.WpfDesign.Designer.PropertyGrid.Editors.FormatedTextEditor;
using ICSharpCode.WpfDesign.Designer.UIExtensions; using ICSharpCode.WpfDesign.UIExtensions;
using ICSharpCode.WpfDesign.Designer.themes; using ICSharpCode.WpfDesign.Designer.themes;
namespace ICSharpCode.WpfDesign.Designer.Extensions namespace ICSharpCode.WpfDesign.Designer.Extensions

20
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/ModelTools.cs

@ -26,6 +26,7 @@ using System.Windows.Documents;
using System.Windows.Markup; using System.Windows.Markup;
using System.Windows.Media; using System.Windows.Media;
using System.Windows.Media.Imaging; using System.Windows.Media.Imaging;
using System.Windows.Shapes;
using System.Windows.Xps.Serialization; using System.Windows.Xps.Serialization;
using ICSharpCode.WpfDesign.Designer.Xaml; using ICSharpCode.WpfDesign.Designer.Xaml;
@ -589,5 +590,24 @@ namespace ICSharpCode.WpfDesign.Designer
operation.Commit(); operation.Commit();
} }
// public static class Path {
//
// public static PathGeometry ConvertToPathGeometry(this TextBlock textBlock)
// {
// //var ft = new FormatedText();
// return null;
// }
//
// public static PathGeometry ConvertToPathGeometry(this Rectangle rectangle)
// {
// return null;
// }
//
// public static PathGeometry ConvertToPathGeometry(this Ellipse ellipse)
// {
// return null;
// }
// }
} }
} }

2
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/OutlineView/OutlineTreeView.cs

@ -20,7 +20,7 @@ using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
using ICSharpCode.WpfDesign.Designer.UIExtensions; using ICSharpCode.WpfDesign.UIExtensions;
namespace ICSharpCode.WpfDesign.Designer.OutlineView namespace ICSharpCode.WpfDesign.Designer.OutlineView
{ {

2
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/PropertyGrid/Editors/FormatedTextEditor/FormatedTextEditor.xaml.cs

@ -24,7 +24,7 @@ using System.Windows.Controls;
using System.Windows.Documents; using System.Windows.Documents;
using System.Windows.Media; using System.Windows.Media;
using ICSharpCode.WpfDesign.Designer.Xaml; using ICSharpCode.WpfDesign.Designer.Xaml;
using ICSharpCode.WpfDesign.Designer.UIExtensions; using ICSharpCode.WpfDesign.UIExtensions;
using ICSharpCode.WpfDesign.Designer.themes; using ICSharpCode.WpfDesign.Designer.themes;
namespace ICSharpCode.WpfDesign.Designer.PropertyGrid.Editors.FormatedTextEditor namespace ICSharpCode.WpfDesign.Designer.PropertyGrid.Editors.FormatedTextEditor

2
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/ThumbnailView/ThumbnailView.cs

@ -27,7 +27,7 @@ using System.Windows.Controls.Primitives;
using System.Windows.Media; using System.Windows.Media;
using System.Diagnostics; using System.Diagnostics;
using ICSharpCode.WpfDesign.Designer.Controls; using ICSharpCode.WpfDesign.Designer.Controls;
using ICSharpCode.WpfDesign.Designer.UIExtensions; using ICSharpCode.WpfDesign.UIExtensions;
namespace ICSharpCode.WpfDesign.Designer.ThumbnailView namespace ICSharpCode.WpfDesign.Designer.ThumbnailView
{ {

1
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/WpfDesign.Designer.csproj

@ -300,7 +300,6 @@
<Compile Include="Services\XamlErrorService.cs" /> <Compile Include="Services\XamlErrorService.cs" />
<Compile Include="SharedInstances.cs" /> <Compile Include="SharedInstances.cs" />
<Compile Include="ThumbnailView\ThumbnailView.cs" /> <Compile Include="ThumbnailView\ThumbnailView.cs" />
<Compile Include="UIExtensions\UIHelpers.cs" />
<Compile Include="Xaml\XamlEditOperations.cs" /> <Compile Include="Xaml\XamlEditOperations.cs" />
<Compile Include="Xaml\XamlLoadSettings.cs" /> <Compile Include="Xaml\XamlLoadSettings.cs" />
<Compile Include="Xaml\XamlModelCollectionElementsCollection.cs" /> <Compile Include="Xaml\XamlModelCollectionElementsCollection.cs" />

18
src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/DesignItem.cs

@ -22,6 +22,8 @@ using System.ComponentModel;
using System.Diagnostics; using System.Diagnostics;
using System.Windows; using System.Windows;
using System.Windows.Media;
using ICSharpCode.WpfDesign.UIExtensions;
using ICSharpCode.WpfDesign.Extensions; using ICSharpCode.WpfDesign.Extensions;
using System.Linq; using System.Linq;
@ -291,5 +293,21 @@ namespace ICSharpCode.WpfDesign
/// Creates a copy of this design item. /// Creates a copy of this design item.
/// </summary> /// </summary>
public abstract DesignItem Clone(); public abstract DesignItem Clone();
public Transform GetCompleteAppliedTransformationToView()
{
var retVal = new TransformGroup();
var fe = this.View as FrameworkElement;
while (fe != null) {
if (fe.LayoutTransform != null)
retVal.Children.Add(fe.LayoutTransform);
if (fe.RenderTransform != null)
retVal.Children.Add(fe.RenderTransform);
fe = fe.TryFindParent<FrameworkElement>(true);
}
return retVal;
}
} }
} }

40
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/UIExtensions/UIHelpers.cs → src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/UIExtensions/UIHelpers.cs

@ -23,37 +23,39 @@ using System.Text;
using System.Windows; using System.Windows;
using System.Windows.Media; using System.Windows.Media;
namespace ICSharpCode.WpfDesign.Designer.UIExtensions namespace ICSharpCode.WpfDesign.UIExtensions
{ {
public static class UIHelpers public static class UIHelpers
{ {
public static DependencyObject GetParentObject(this DependencyObject child) public static DependencyObject GetParentObject(this DependencyObject child, bool searchCompleteVisualTree)
{ {
if (child == null) return null; if (child == null) return null;
var contentElement = child as ContentElement; if (!searchCompleteVisualTree) {
if (contentElement != null) var contentElement = child as ContentElement;
{ if (contentElement != null)
DependencyObject parent = ContentOperations.GetParent(contentElement); {
if (parent != null) return parent; DependencyObject parent = ContentOperations.GetParent(contentElement);
if (parent != null) return parent;
var fce = contentElement as FrameworkContentElement;
return fce != null ? fce.Parent : null; var fce = contentElement as FrameworkContentElement;
} return fce != null ? fce.Parent : null;
}
var frameworkElement = child as FrameworkElement;
if (frameworkElement != null) var frameworkElement = child as FrameworkElement;
{ if (frameworkElement != null)
DependencyObject parent = frameworkElement.Parent; {
if (parent != null) return parent; DependencyObject parent = frameworkElement.Parent;
if (parent != null) return parent;
}
} }
return VisualTreeHelper.GetParent(child); return VisualTreeHelper.GetParent(child);
} }
public static T TryFindParent<T>(this DependencyObject child) where T : DependencyObject public static T TryFindParent<T>(this DependencyObject child, bool searchCompleteVisualTree = false) where T : DependencyObject
{ {
DependencyObject parentObject = GetParentObject(child); DependencyObject parentObject = GetParentObject(child, searchCompleteVisualTree);
if (parentObject == null) return null; if (parentObject == null) return null;

4
src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/WpfDesign.csproj

@ -116,8 +116,12 @@
<Compile Include="ServiceRequiredException.cs" /> <Compile Include="ServiceRequiredException.cs" />
<Compile Include="Services.cs" /> <Compile Include="Services.cs" />
<Compile Include="Tools.cs" /> <Compile Include="Tools.cs" />
<Compile Include="UIExtensions\UIHelpers.cs" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<CodeAnalysisDictionary Include="Configuration\CodeAnalysisDictionary.xml" /> <CodeAnalysisDictionary Include="Configuration\CodeAnalysisDictionary.xml" />
</ItemGroup> </ItemGroup>
<ItemGroup>
<Folder Include="UIExtensions" />
</ItemGroup>
</Project> </Project>
Loading…
Cancel
Save