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; @@ -27,7 +27,7 @@ using ICSharpCode.WpfDesign.Extensions;
using ICSharpCode.WpfDesign.Designer.Converters;
using System.Globalization;
using System.Windows.Data;
using ICSharpCode.WpfDesign.Designer.UIExtensions;
using ICSharpCode.WpfDesign.UIExtensions;
namespace ICSharpCode.WpfDesign.Designer.Controls
{

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

@ -82,6 +82,12 @@ @@ -82,6 +82,12 @@
<Setter.Value>
<ControlTemplate TargetType="{x:Type Controls:PointThumb}">
<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}}" />
<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" />

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

@ -23,6 +23,7 @@ using System.Text; @@ -23,6 +23,7 @@ using System.Text;
using System.Windows;
using System.Windows.Input;
using System.Diagnostics;
using System.Windows.Media;
namespace ICSharpCode.WpfDesign.Designer.Controls
{
@ -35,6 +36,8 @@ namespace ICSharpCode.WpfDesign.Designer.Controls @@ -35,6 +36,8 @@ namespace ICSharpCode.WpfDesign.Designer.Controls
InputManager.Current.PostProcessInput += new ProcessInputEventHandler(PostProcessInput);
}
public Transform Transform { get; set; }
public DragListener(IInputElement target)
{
Target = target;
@ -141,7 +144,14 @@ namespace ICSharpCode.WpfDesign.Designer.Controls @@ -141,7 +144,14 @@ namespace ICSharpCode.WpfDesign.Designer.Controls
public bool IsCanceled { get; private set; }
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; @@ -28,7 +28,7 @@ using System.Windows.Media;
using ICSharpCode.WpfDesign.Designer.Converters;
using System.Globalization;
using System.Windows.Data;
using ICSharpCode.WpfDesign.Designer.UIExtensions;
using ICSharpCode.WpfDesign.UIExtensions;
namespace ICSharpCode.WpfDesign.Designer.Controls
{

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

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

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

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

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

@ -32,7 +32,7 @@ using System.Windows.Threading; @@ -32,7 +32,7 @@ using System.Windows.Threading;
using ICSharpCode.WpfDesign.Adorners;
using ICSharpCode.WpfDesign.Designer.Controls;
using ICSharpCode.WpfDesign.Designer.UIExtensions;
using ICSharpCode.WpfDesign.UIExtensions;
using ICSharpCode.WpfDesign.Designer.Xaml;
using ICSharpCode.WpfDesign.Extensions;
using System.Linq;
@ -511,7 +511,7 @@ namespace ICSharpCode.WpfDesign.Designer @@ -511,7 +511,7 @@ namespace ICSharpCode.WpfDesign.Designer
PropertyChangedEventHandler handler = PropertyChanged;
if (handler != null) handler(this, new PropertyChangedEventArgs(propertyName));
}
#region ContextMenu
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; @@ -24,7 +24,7 @@ using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Shapes;
using System.Windows.Controls;
using ICSharpCode.WpfDesign.Designer.UIExtensions;
using ICSharpCode.WpfDesign.UIExtensions;
namespace ICSharpCode.WpfDesign.Designer.Extensions
{
/// <summary>

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

@ -28,7 +28,7 @@ using System.Windows.Controls; @@ -28,7 +28,7 @@ using System.Windows.Controls;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using ICSharpCode.WpfDesign.Designer.UIExtensions;
using ICSharpCode.WpfDesign.UIExtensions;
using DragListener = ICSharpCode.WpfDesign.Designer.Controls.DragListener;
using System.Windows.Data;
using System.ComponentModel;
@ -142,39 +142,39 @@ namespace ICSharpCode.WpfDesign.Designer.Extensions @@ -142,39 +142,39 @@ namespace ICSharpCode.WpfDesign.Designer.Extensions
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)) {
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);
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);
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);
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);
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);
menuList.Add(menuItem);
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);
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);
}
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);
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);
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);
}
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);
menuList.Add(menuItem);
}
@ -249,7 +249,7 @@ namespace ICSharpCode.WpfDesign.Designer.Extensions @@ -249,7 +249,7 @@ namespace ICSharpCode.WpfDesign.Designer.Extensions
pathFigure.Segments.RemoveAt(idx);
var midp = senderThumb.PathPoint.ParentPathPoint.Point - ((senderThumb.PathPoint.ParentPathPoint.Point - point) / 2);
PathSegment newSegment = null;
switch (convertType)
{
@ -382,9 +382,9 @@ namespace ICSharpCode.WpfDesign.Designer.Extensions @@ -382,9 +382,9 @@ namespace ICSharpCode.WpfDesign.Designer.Extensions
// result.Height = ys.Max() - ys.Min();
//
// info.Bounds = result.Round();
//
//
//
//
//
//
// operation.CurrentContainerBehavior.BeforeSetPosition(operation);
// operation.CurrentContainerBehavior.SetPosition(info);
// }
@ -420,13 +420,11 @@ namespace ICSharpCode.WpfDesign.Designer.Extensions @@ -420,13 +420,11 @@ namespace ICSharpCode.WpfDesign.Designer.Extensions
protected void drag_Changed(DragListener drag)
{
var mprt = drag.Target as PathThumb;
if (mprt != null)
{
if (mprt != null) {
double dx = 0;
double dy = 0;
//if has zoomed
if (_zoom != null)
{
if (_zoom != null) {
dx = drag.Delta.X * (1 / _zoom.CurrentZoom);
dy = drag.Delta.Y * (1 / _zoom.CurrentZoom);
}
@ -440,14 +438,10 @@ namespace ICSharpCode.WpfDesign.Designer.Extensions @@ -440,14 +438,10 @@ namespace ICSharpCode.WpfDesign.Designer.Extensions
protected void drag_Completed(DragListener drag)
{
var mprt = drag.Target as PathThumb;
if (mprt != null)
{
if (operation != null && drag.IsCanceled)
{
if (mprt != null) {
if (operation != null && drag.IsCanceled) {
operation.Abort();
}
else if (drag.IsCanceled)
{
} else if (drag.IsCanceled) {
changeGroup.Abort();
}
CommitOperation();
@ -463,8 +457,7 @@ namespace ICSharpCode.WpfDesign.Designer.Extensions @@ -463,8 +457,7 @@ namespace ICSharpCode.WpfDesign.Designer.Extensions
pathPoints = GetPoints();
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]);
}
@ -500,12 +493,15 @@ namespace ICSharpCode.WpfDesign.Designer.Extensions @@ -500,12 +493,15 @@ namespace ICSharpCode.WpfDesign.Designer.Extensions
var g = geometry as CombinedGeometry;
AddGeometryPoints(list, g.Geometry1);
AddGeometryPoints(list, g.Geometry2);
} else if (geometry is GeometryGroup)
{
} else if (geometry is GeometryGroup) {
var gg = geometry as GeometryGroup;
foreach (var g in gg.Children) {
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) {
var g = geometry as PathGeometry;
if (geometry!=null) {
@ -515,8 +511,7 @@ namespace ICSharpCode.WpfDesign.Designer.Extensions @@ -515,8 +511,7 @@ namespace ICSharpCode.WpfDesign.Designer.Extensions
var parentp = list.Last();
if (s is LineSegment)
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;
for (int n = 0; n < poly.Points.Count; n++)
{
@ -524,23 +519,17 @@ namespace ICSharpCode.WpfDesign.Designer.Extensions @@ -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 });
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 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).Point2, s, figure, (p) => ((BezierSegment)s).Point2 = p) { TargetPathPoint = 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};
list.Add(new PathPoint(((QuadraticBezierSegment)s).Point1, s, figure, (p) => ((QuadraticBezierSegment)s).Point1 = p) { TargetPathPoint = pathp });
list.Add(pathp);
}
else if (s is ArcSegment)
{
} else if (s is ArcSegment) {
var arc = ((ArcSegment)s);
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 });
@ -568,8 +557,7 @@ namespace ICSharpCode.WpfDesign.Designer.Extensions @@ -568,8 +557,7 @@ namespace ICSharpCode.WpfDesign.Designer.Extensions
List<PathPoint> MovePoints(List<PathPoint> pc, double displacementX, double displacementY)
{
//iterate all selected points
foreach (int i in _selectedThumbs.Keys)
{
foreach (int i in _selectedThumbs.Keys) {
Point p = pc[i].Point;
//x and y is calculated from the currentl point
@ -594,14 +582,13 @@ namespace ICSharpCode.WpfDesign.Designer.Extensions @@ -594,14 +582,13 @@ namespace ICSharpCode.WpfDesign.Designer.Extensions
public void KeyDownAction(object sender, KeyEventArgs e)
{
Debug.WriteLine("KeyDown");
if (IsArrowKey(e.Key))
if (operation == null)
{
if (IsArrowKey(e.Key)) {
if (operation == null) {
SetOperation();
_movingDistance = 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 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; @@ -31,7 +31,7 @@ using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using ICSharpCode.WpfDesign.Designer.UIExtensions;
using ICSharpCode.WpfDesign.UIExtensions;
namespace ICSharpCode.WpfDesign.Designer.Extensions
{

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

@ -26,7 +26,7 @@ using ICSharpCode.WpfDesign.Adorners; @@ -26,7 +26,7 @@ using ICSharpCode.WpfDesign.Adorners;
using ICSharpCode.WpfDesign.Designer.Controls;
using ICSharpCode.WpfDesign.Extensions;
using System.Collections.Generic;
using ICSharpCode.WpfDesign.Designer.UIExtensions;
using ICSharpCode.WpfDesign.UIExtensions;
namespace ICSharpCode.WpfDesign.Designer.Extensions
{
@ -119,14 +119,10 @@ namespace ICSharpCode.WpfDesign.Designer.Extensions @@ -119,14 +119,10 @@ namespace ICSharpCode.WpfDesign.Designer.Extensions
}
Size oldSize;
ZoomControl zoom;
// TODO : Remove all hide/show extensions from here.
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. */
foreach(var extension in this.ExtendedItem.Extensions){
if(extension is InPlaceEditorExtension){
@ -134,6 +130,8 @@ namespace ICSharpCode.WpfDesign.Designer.Extensions @@ -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));
if (resizeBehavior != null)
operation = PlacementOperation.Start(extendedItemArray, PlacementType.Resize);
@ -152,10 +150,6 @@ namespace ICSharpCode.WpfDesign.Designer.Extensions @@ -152,10 +150,6 @@ namespace ICSharpCode.WpfDesign.Designer.Extensions
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.Right) dx = delta.X;
if (alignment.Vertical == VerticalAlignment.Top) dy = -delta.Y;
@ -170,12 +164,6 @@ namespace ICSharpCode.WpfDesign.Designer.Extensions @@ -170,12 +164,6 @@ namespace ICSharpCode.WpfDesign.Designer.Extensions
else
dy = dx;
}
if (zoom != null)
{
dx = dx * (1 / zoom.CurrentZoom);
dy = dy * (1 / zoom.CurrentZoom);
}
var newWidth = Math.Max(0, oldSize.Width + dx);
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; @@ -27,7 +27,7 @@ using ICSharpCode.WpfDesign.Adorners;
using ICSharpCode.WpfDesign.Designer.Controls;
using ICSharpCode.WpfDesign.Extensions;
using System.Collections.Generic;
using ICSharpCode.WpfDesign.Designer.UIExtensions;
using ICSharpCode.WpfDesign.UIExtensions;
namespace ICSharpCode.WpfDesign.Designer.Extensions
{

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

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

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

@ -26,6 +26,7 @@ using System.Windows.Documents; @@ -26,6 +26,7 @@ using System.Windows.Documents;
using System.Windows.Markup;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
using System.Windows.Xps.Serialization;
using ICSharpCode.WpfDesign.Designer.Xaml;
@ -589,5 +590,24 @@ namespace ICSharpCode.WpfDesign.Designer @@ -589,5 +590,24 @@ namespace ICSharpCode.WpfDesign.Designer
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; @@ -20,7 +20,7 @@ using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using ICSharpCode.WpfDesign.Designer.UIExtensions;
using ICSharpCode.WpfDesign.UIExtensions;
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; @@ -24,7 +24,7 @@ using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Media;
using ICSharpCode.WpfDesign.Designer.Xaml;
using ICSharpCode.WpfDesign.Designer.UIExtensions;
using ICSharpCode.WpfDesign.UIExtensions;
using ICSharpCode.WpfDesign.Designer.themes;
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; @@ -27,7 +27,7 @@ using System.Windows.Controls.Primitives;
using System.Windows.Media;
using System.Diagnostics;
using ICSharpCode.WpfDesign.Designer.Controls;
using ICSharpCode.WpfDesign.Designer.UIExtensions;
using ICSharpCode.WpfDesign.UIExtensions;
namespace ICSharpCode.WpfDesign.Designer.ThumbnailView
{

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

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

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

@ -22,6 +22,8 @@ using System.ComponentModel; @@ -22,6 +22,8 @@ using System.ComponentModel;
using System.Diagnostics;
using System.Windows;
using System.Windows.Media;
using ICSharpCode.WpfDesign.UIExtensions;
using ICSharpCode.WpfDesign.Extensions;
using System.Linq;
@ -291,5 +293,21 @@ namespace ICSharpCode.WpfDesign @@ -291,5 +293,21 @@ namespace ICSharpCode.WpfDesign
/// Creates a copy of this design item.
/// </summary>
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; @@ -23,37 +23,39 @@ using System.Text;
using System.Windows;
using System.Windows.Media;
namespace ICSharpCode.WpfDesign.Designer.UIExtensions
namespace ICSharpCode.WpfDesign.UIExtensions
{
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;
var contentElement = child as ContentElement;
if (contentElement != null)
{
DependencyObject parent = ContentOperations.GetParent(contentElement);
if (parent != null) return parent;
var fce = contentElement as FrameworkContentElement;
return fce != null ? fce.Parent : null;
}
var frameworkElement = child as FrameworkElement;
if (frameworkElement != null)
{
DependencyObject parent = frameworkElement.Parent;
if (parent != null) return parent;
if (!searchCompleteVisualTree) {
var contentElement = child as ContentElement;
if (contentElement != null)
{
DependencyObject parent = ContentOperations.GetParent(contentElement);
if (parent != null) return parent;
var fce = contentElement as FrameworkContentElement;
return fce != null ? fce.Parent : null;
}
var frameworkElement = child as FrameworkElement;
if (frameworkElement != null)
{
DependencyObject parent = frameworkElement.Parent;
if (parent != null) return parent;
}
}
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;

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

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