diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Controls/ControlStyles.xaml b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Controls/ControlStyles.xaml index 000e7bba3b..d8657e78da 100644 --- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Controls/ControlStyles.xaml +++ b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Controls/ControlStyles.xaml @@ -81,23 +81,25 @@ - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Controls/QuickOperationMenu.cs b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Controls/QuickOperationMenu.cs index 9e942dab80..c3a11bff06 100644 --- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Controls/QuickOperationMenu.cs +++ b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Controls/QuickOperationMenu.cs @@ -39,12 +39,7 @@ namespace ICSharpCode.WpfDesign.Designer.Controls } public QuickOperationMenu() - { - scaleTransform = new ScaleTransform(1.0, 1.0); - this.LayoutTransform = scaleTransform; - } - - private ScaleTransform scaleTransform; + { } private MenuItem _mainHeader; @@ -96,16 +91,6 @@ namespace ICSharpCode.WpfDesign.Designer.Controls if (mainHeader != null) { _mainHeader = mainHeader; } - - var surface = this.TryFindParent(); - if (surface != null && surface.ZoomControl != null) - { - var bnd = new Binding("CurrentZoom") { Source = surface.ZoomControl }; - bnd.Converter = InvertedZoomConverter.Instance; - - BindingOperations.SetBinding(scaleTransform, ScaleTransform.ScaleXProperty, bnd); - BindingOperations.SetBinding(scaleTransform, ScaleTransform.ScaleYProperty, bnd); - } } /// diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Controls/Thumbs/PointThumb.cs b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Controls/Thumbs/PointThumb.cs index 2b9bfb07dd..a803df02c7 100644 --- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Controls/Thumbs/PointThumb.cs +++ b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Controls/Thumbs/PointThumb.cs @@ -17,6 +17,7 @@ // DEALINGS IN THE SOFTWARE. using System.Windows; +using System.Windows.Media; using ICSharpCode.WpfDesign.Adorners; using System.Windows.Data; @@ -27,6 +28,16 @@ namespace ICSharpCode.WpfDesign.Designer.Controls /// public class PointThumb : DesignerThumb { + public Transform InnerRenderTransform + { + get { return (Transform)GetValue(InnerRenderTransformProperty); } + set { SetValue(InnerRenderTransformProperty, value); } + } + + // Using a DependencyProperty as the backing store for InnerRenderTransform. This enables animation, styling, binding, etc... + public static readonly DependencyProperty InnerRenderTransformProperty = + DependencyProperty.Register("InnerRenderTransform", typeof(Transform), typeof(PointThumb), new PropertyMetadata(null)); + public bool IsEllipse { get { return (bool)GetValue(IsEllipseProperty); } @@ -97,8 +108,7 @@ namespace ICSharpCode.WpfDesign.Designer.Controls public override void Arrange(AdornerPanel panel, UIElement adorner, Size adornedElementSize) { - double thumbsize = 7; - adorner.Arrange(new Rect(p.X - thumbsize / 2, p.Y - thumbsize / 2, adornedElementSize.Width, adornedElementSize.Height)); + adorner.Arrange(new Rect(p.X, p.Y, adornedElementSize.Width, adornedElementSize.Height)); } } } diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Extensions/DefaultPlacementBehavior.cs b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Extensions/DefaultPlacementBehavior.cs index e0078914f3..31d54e2ebe 100644 --- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Extensions/DefaultPlacementBehavior.cs +++ b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Extensions/DefaultPlacementBehavior.cs @@ -175,5 +175,10 @@ namespace ICSharpCode.WpfDesign.Designer.Extensions } } } + + public virtual Point PlacePoint(Point point) + { + return point; + } } } diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Extensions/PathHandlerExtension.cs b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Extensions/PathHandlerExtension.cs index b1c69345f4..bf85c4fcd5 100644 --- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Extensions/PathHandlerExtension.cs +++ b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Extensions/PathHandlerExtension.cs @@ -86,7 +86,7 @@ namespace ICSharpCode.WpfDesign.Designer.Extensions public Point TranslatedPoint { - get { + get { return _shape.RenderedGeometry.Transform.Transform(Point); } set { @@ -129,17 +129,15 @@ namespace ICSharpCode.WpfDesign.Designer.Extensions protected class RelativeToPointConverter : IValueConverter { PathPoint pathPoint; - Shape shape; - public RelativeToPointConverter(PathPoint pathPoint/*, Shape shape*/) + public RelativeToPointConverter(PathPoint pathPoint) { this.pathPoint = pathPoint; - //this.shape = shape; } public object Convert(object value, Type targetType, object parameter, CultureInfo culture) { var pt = (Point)value; - return pt - new Vector(pathPoint.TranslatedPoint.X - 3.5, pathPoint.TranslatedPoint.Y - 3.5); + return pt - new Vector(pathPoint.TranslatedPoint.X, pathPoint.TranslatedPoint.Y); } public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) @@ -209,6 +207,8 @@ namespace ICSharpCode.WpfDesign.Designer.Extensions var designerThumb = new PathThumb(index, pathpoint) {Cursor = cursor}; designerThumb.OperationMenu = BuildMenu(pathpoint); + designerThumb.InnerRenderTransform = ((Transform)transform.Inverse); + if (pathpoint.TargetPathPoint != null) { designerThumb.IsEllipse = true; designerThumb.Foreground = Brushes.Blue; @@ -243,8 +243,7 @@ namespace ICSharpCode.WpfDesign.Designer.Extensions var point = senderThumb.PathPoint.Point; - if (pathSegment is PolyLineSegment) - { + if (pathSegment is PolyLineSegment) { var poly = pathSegment as PolyLineSegment; var lst = poly.Points.Take(senderThumb.PathPoint.PolyLineIndex); var lst2 = poly.Points.Skip(senderThumb.PathPoint.PolyLineIndex + 1); @@ -259,6 +258,10 @@ namespace ICSharpCode.WpfDesign.Designer.Extensions p2.Points.AddRange(lst2); pathFigure.Segments.Insert(idx+2, p2); idx++; + } else if (pathSegment is PolyBezierSegment) { + //TODO + } else if (pathSegment is PolyQuadraticBezierSegment) { + //TODO } pathFigure.Segments.RemoveAt(idx); @@ -566,6 +569,8 @@ namespace ICSharpCode.WpfDesign.Designer.Extensions List MovePoints(List pc, double displacementX, double displacementY) { + var relativeTo = new Vector(operation.PlacedItems[0].Bounds.TopLeft.X, operation.PlacedItems[0].Bounds.TopLeft.Y); + //iterate all selected points foreach (int i in _selectedThumbs.Keys) { Point p = pc[i].TranslatedPoint; @@ -576,6 +581,10 @@ namespace ICSharpCode.WpfDesign.Designer.Extensions p.X = x; p.Y = y; + + + p = operation.CurrentContainerBehavior.PlacePoint(p + relativeTo) - relativeTo; + pc[i].TranslatedPoint = p; } return pc; @@ -594,8 +603,8 @@ namespace ICSharpCode.WpfDesign.Designer.Extensions Debug.WriteLine("KeyDown"); if (IsArrowKey(e.Key)) { if (operation == null) { - SetOperation(); - _movingDistance = 0; + SetOperation(); + _movingDistance = 0; } } diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Extensions/PointTrackerPlacementSupport.cs b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Extensions/PointTrackerPlacementSupport.cs index 9807f3f533..6065dc2479 100644 --- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Extensions/PointTrackerPlacementSupport.cs +++ b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Extensions/PointTrackerPlacementSupport.cs @@ -47,7 +47,6 @@ namespace ICSharpCode.WpfDesign.Designer.Extensions public override void Arrange(AdornerPanel panel, UIElement adorner, Size adornedElementSize) { Point p = new Point(0, 0); - double thumbsize = 7; double distance = 0; if (shape is Line) { @@ -76,7 +75,7 @@ namespace ICSharpCode.WpfDesign.Designer.Extensions var transform = shape.RenderedGeometry.Transform; p = transform.Transform(p); - adorner.Arrange(new Rect(p.X - thumbsize / 2, p.Y - thumbsize / 2, thumbsize, thumbsize)); //thumbsize, thumbsize))); + adorner.Arrange(new Rect(p.X - 3.5, p.Y - 3.5, 7, 7)); } } } diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Extensions/QuickOperationMenuExtension.cs b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Extensions/QuickOperationMenuExtension.cs index 2ca8308f66..8b291fa37c 100644 --- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Extensions/QuickOperationMenuExtension.cs +++ b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Extensions/QuickOperationMenuExtension.cs @@ -20,6 +20,7 @@ using System; using System.Windows; using System.Windows.Controls; using System.Windows.Input; +using System.Windows.Media; using ICSharpCode.SharpDevelop.Widgets; using ICSharpCode.WpfDesign.Designer.Controls; using ICSharpCode.WpfDesign.Extensions; @@ -43,6 +44,7 @@ namespace ICSharpCode.WpfDesign.Designer.Extensions base.OnInitialized(); _menu = new QuickOperationMenu(); _menu.Loaded += OnMenuLoaded; + _menu.RenderTransform = ((Transform)this.ExtendedItem.GetCompleteAppliedTransformationToView().Inverse); var placement = new RelativePlacement(HorizontalAlignment.Right, VerticalAlignment.Top) {XOffset = 7, YOffset = 3.5}; this.AddAdorners(placement, _menu); diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Extensions/RasterPlacementBehavior.cs b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Extensions/RasterPlacementBehavior.cs index c5aa6e56ce..cbbfebcb76 100644 --- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Extensions/RasterPlacementBehavior.cs +++ b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Extensions/RasterPlacementBehavior.cs @@ -23,6 +23,7 @@ using System.Windows.Media; using System.Windows.Shapes; using ICSharpCode.WpfDesign.Adorners; using ICSharpCode.WpfDesign.Designer.Controls; +using System.Windows; namespace ICSharpCode.WpfDesign.Designer.Extensions { @@ -112,6 +113,30 @@ namespace ICSharpCode.WpfDesign.Designer.Extensions operation.PlacedItems[0].Bounds = bounds; } + public override Point PlacePoint(Point point) + { + if (surface == null) + return base.PlacePoint(point); + + DesignPanel designPanel = ExtendedItem.Services.DesignPanel as DesignPanel; + if (designPanel == null || !designPanel.UseRasterPlacement) + return base.PlacePoint(point); + + if (Keyboard.IsKeyDown(Key.LeftCtrl)) + { + surface.Children.Clear(); + rasterDrawn = false; + return base.PlacePoint(point); + } + + drawRaster(); + + point.Y = ((int)point.Y / raster) * raster; + point.X = ((int)point.X / raster) * raster; + + return point; + } + private void drawRaster() { if (!rasterDrawn) diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Extensions/SnaplinePlacementBehavior.cs b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Extensions/SnaplinePlacementBehavior.cs index 11c142a186..f7ff4d79cb 100644 --- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Extensions/SnaplinePlacementBehavior.cs +++ b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Extensions/SnaplinePlacementBehavior.cs @@ -77,7 +77,58 @@ namespace ICSharpCode.WpfDesign.Designer.Extensions base.LeaveContainer(operation); DeleteSurface(); } - + + public override Point PlacePoint(Point point) + { + if (surface == null) + return base.PlacePoint(point); + + DesignPanel designPanel = ExtendedItem.Services.DesignPanel as DesignPanel; + if (designPanel == null || !designPanel.UseSnaplinePlacement) + return base.PlacePoint(point); ; + + surface.Children.Clear(); + if (Keyboard.IsKeyDown(Key.LeftCtrl)) + return base.PlacePoint(point); ; + + Rect bounds = new Rect(point.X, point.Y, 0, 0); + + var horizontalInput = new List(); + var verticalInput = new List(); + + AddLines(bounds, 0, false, horizontalInput, verticalInput, null); + if (baseline.HasValue) + { + var textOffset = bounds.Top + baseline.Value; + horizontalInput.Add(new Snapline() { Group = 1, Offset = textOffset, Start = bounds.Left, End = bounds.Right }); + } + + List drawLines; + double delta; + + if (Snap(horizontalInput, horizontalMap, Accuracy, out drawLines, out delta)) + { + foreach (var d in drawLines) + { + DrawLine(d.Start, d.Offset + d.DrawOffset, d.End, d.Offset + d.DrawOffset); + } + + point.Y += delta; + } + + if (Snap(verticalInput, verticalMap, Accuracy, out drawLines, out delta)) + { + foreach (var d in drawLines) + { + DrawLine(d.Offset + d.DrawOffset, d.Start, d.Offset + d.DrawOffset, d.End); + } + + point.X += delta; + } + + return point; + } + public override void BeforeSetPosition(PlacementOperation operation) { base.BeforeSetPosition(operation); @@ -94,21 +145,25 @@ namespace ICSharpCode.WpfDesign.Designer.Extensions foreach (var item in operation.PlacedItems) { bounds.Union(item.Bounds); } - + var horizontalInput = new List(); var verticalInput = new List(); var info = operation.PlacedItems[0]; - - if (operation.Type == PlacementType.Resize) { + + if (operation.Type == PlacementType.Resize) + { AddLines(bounds, 0, false, horizontalInput, verticalInput, info.ResizeThumbAlignment); - } else { + } + else + { AddLines(bounds, 0, false, horizontalInput, verticalInput, null); - if (baseline.HasValue) { + if (baseline.HasValue) + { var textOffset = bounds.Top + baseline.Value; horizontalInput.Add(new Snapline() { Group = 1, Offset = textOffset, Start = bounds.Left, End = bounds.Right }); } } - + // debug //foreach (var t in horizontalMap.Concat(horizontalInput)) { // surface.Children.Add(new Line() { X1 = t.Start, X2 = t.End, Y1 = t.Offset, Y2 = t.Offset, Stroke = Brushes.Black }); @@ -117,57 +172,75 @@ namespace ICSharpCode.WpfDesign.Designer.Extensions // surface.Children.Add(new Line() { X1 = t.Offset, X2 = t.Offset, Y1 = t.Start , Y2 = t.End, Stroke = Brushes.Black }); //} //return; - + List drawLines; double delta; - - if (Snap(horizontalInput, horizontalMap, Accuracy, out drawLines, out delta)) { - - if (operation.Type == PlacementType.Resize) { - if (info.ResizeThumbAlignment != null && info.ResizeThumbAlignment.Value.Vertical == VerticalAlignment.Top) { + + if (Snap(horizontalInput, horizontalMap, Accuracy, out drawLines, out delta)) + { + + if (operation.Type == PlacementType.Resize) + { + if (info.ResizeThumbAlignment != null && info.ResizeThumbAlignment.Value.Vertical == VerticalAlignment.Top) + { bounds.Y += delta; bounds.Height = Math.Max(0, bounds.Height - delta); - } else { + } + else + { bounds.Height = Math.Max(0, bounds.Height + delta); } info.Bounds = bounds; - } else { - foreach (var item in operation.PlacedItems) { + } + else + { + foreach (var item in operation.PlacedItems) + { var r = item.Bounds; r.Y += delta; item.Bounds = r; } } - - foreach (var d in drawLines) { + + foreach (var d in drawLines) + { DrawLine(d.Start, d.Offset + d.DrawOffset, d.End, d.Offset + d.DrawOffset); } } - - if (Snap(verticalInput, verticalMap, Accuracy, out drawLines, out delta)) { - - if (operation.Type == PlacementType.Resize) { - if (info.ResizeThumbAlignment != null && info.ResizeThumbAlignment.Value.Horizontal == HorizontalAlignment.Left) { + + if (Snap(verticalInput, verticalMap, Accuracy, out drawLines, out delta)) + { + + if (operation.Type == PlacementType.Resize) + { + if (info.ResizeThumbAlignment != null && info.ResizeThumbAlignment.Value.Horizontal == HorizontalAlignment.Left) + { bounds.X += delta; bounds.Width = Math.Max(0, bounds.Width - delta); - } else { + } + else + { bounds.Width = Math.Max(0, bounds.Width + delta); } info.Bounds = bounds; - } else { - foreach (var item in operation.PlacedItems) { + } + else + { + foreach (var item in operation.PlacedItems) + { var r = item.Bounds; r.X += delta; item.Bounds = r; } } - - foreach (var d in drawLines) { + + foreach (var d in drawLines) + { DrawLine(d.Offset + d.DrawOffset, d.Start, d.Offset + d.DrawOffset, d.End); } } } - + void CreateSurface(PlacementOperation operation) { if (ExtendedItem.Services.GetService() != null) { diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/RootItemBehavior.cs b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/RootItemBehavior.cs index 4b436dba98..6e429e51f0 100644 --- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/RootItemBehavior.cs +++ b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/RootItemBehavior.cs @@ -94,5 +94,10 @@ namespace ICSharpCode.WpfDesign.Designer { throw new NotImplementedException(); } + + public Point PlacePoint(Point point) + { + return point; + } } } diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/DesignItem.cs b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/DesignItem.cs index b48d766137..da353b37c9 100644 --- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/DesignItem.cs +++ b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/DesignItem.cs @@ -298,23 +298,20 @@ namespace ICSharpCode.WpfDesign public Transform GetCompleteAppliedTransformationToView() { var retVal = new TransformGroup(); - var fe = this.View as FrameworkElement; - while (fe != null) { - if (fe.LayoutTransform != null) + var v = this.View as Visual; + while (v != null) { + var fe = v as FrameworkElement; + if (fe != null && fe.LayoutTransform != null) retVal.Children.Add(fe.LayoutTransform); - if (fe.RenderTransform != null) + if (fe != null && fe.RenderTransform != null) retVal.Children.Add(fe.RenderTransform); - if (fe is Viewbox) - { - var scaleX = fe.ActualWidth / ((FrameworkElement)((Viewbox)fe).Child).ActualWidth; - var scaleY = fe.ActualHeight / ((FrameworkElement)((Viewbox)fe).Child).ActualHeight; - retVal.Children.Add(new ScaleTransform(){ScaleX = scaleX, ScaleY = scaleY}); + if (v is ContainerVisual && ((ContainerVisual)v).Transform != null) { + retVal.Children.Add(((ContainerVisual)v).Transform); } - fe = fe.TryFindParent(true); + v = v.TryFindParent(true); } return retVal; - } } } diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/PlacementBehavior.cs b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/PlacementBehavior.cs index f34341e7bb..f75446dc5b 100644 --- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/PlacementBehavior.cs +++ b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/PlacementBehavior.cs @@ -78,6 +78,11 @@ namespace ICSharpCode.WpfDesign /// Let the placed children enter this container. /// void EnterContainer(PlacementOperation operation); + + /// + /// Place Point. + /// + Point PlacePoint(Point point); } ///