diff --git a/data/resources/StringResources.it.resx b/data/resources/StringResources.it.resx
index cfd311c3e3..7743977f62 100644
--- a/data/resources/StringResources.it.resx
+++ b/data/resources/StringResources.it.resx
@@ -409,6 +409,9 @@ Smetteranno di funzionare dopo la rimozione di questo Componente! Sei sicuro di
Mostra Diagramma delle Classi
+
+ Pulisci console
+
Cancella cronologia
diff --git a/data/resources/StringResources.ru.resx b/data/resources/StringResources.ru.resx
index 65951d1889..d2ff9e4dae 100644
--- a/data/resources/StringResources.ru.resx
+++ b/data/resources/StringResources.ru.resx
@@ -3247,7 +3247,7 @@
Строка
- Перерисовать
+ Обновить
Предупреждение
diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Controls/Thumbs/UserControlPointsObjectThumb.cs b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Controls/Thumbs/UserControlPointsObjectThumb.cs
new file mode 100644
index 0000000000..18cb5735c0
--- /dev/null
+++ b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Controls/Thumbs/UserControlPointsObjectThumb.cs
@@ -0,0 +1,30 @@
+// Copyright (c) 2014 AlphaSierraPapa for the SharpDevelop Team
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy of this
+// software and associated documentation files (the "Software"), to deal in the Software
+// without restriction, including without limitation the rights to use, copy, modify, merge,
+// publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
+// to whom the Software is furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in all copies or
+// substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
+// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
+// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
+// FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
+// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+// DEALINGS IN THE SOFTWARE.
+
+using ICSharpCode.WpfDesign.UIExtensions;
+using System.Windows;
+using System.Windows.Controls;
+using System.Windows.Controls.Primitives;
+
+namespace ICSharpCode.WpfDesign.Designer.Controls
+{
+ public class UserControlPointsObjectThumb : DesignerThumb
+ {
+ public DependencyProperty DependencyProperty { get; set; }
+ }
+}
diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/DesignPanel.cs b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/DesignPanel.cs
index d038b14dfb..5e932ffd44 100644
--- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/DesignPanel.cs
+++ b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/DesignPanel.cs
@@ -219,6 +219,8 @@ namespace ICSharpCode.WpfDesign.Designer
#region Properties
+ public DesignSurface DesignSurface { get; internal set; }
+
//Set custom HitTestFilterCallbak
public HitTestFilterCallback CustomHitTestFilterBehavior { get; set; }
diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/DesignSurface.cs b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/DesignSurface.cs
index b5e88ce221..382d0a1245 100644
--- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/DesignSurface.cs
+++ b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/DesignSurface.cs
@@ -76,14 +76,13 @@ namespace ICSharpCode.WpfDesign.Designer
this.AddCommandHandler(Commands.AlignCenterCommand, () => ModelTools.ArrangeItems(this.DesignContext.Services.Selection.SelectedItems, ArrangeDirection.HorizontalMiddle), () => this.DesignContext.Services.Selection.SelectedItems.Count() > 1);
this.AddCommandHandler(Commands.AlignRightCommand, () => ModelTools.ArrangeItems(this.DesignContext.Services.Selection.SelectedItems, ArrangeDirection.Right), () => this.DesignContext.Services.Selection.SelectedItems.Count() > 1);
- //Todo
- //this.AddCommandHandler(Commands.RotateLeftCommand, () => , () => this.DesignContext.Services.Selection.SelectedItems.Count() > 1);
- //this.AddCommandHandler(Commands.RotateRightCommand, () => , () => this.DesignContext.Services.Selection.SelectedItems.Count() > 1);
+ this.AddCommandHandler(Commands.RotateLeftCommand, () => ModelTools.ApplyTransform(this.DesignContext.Services.Selection.PrimarySelection, new RotateTransform(-90)), () => this.DesignContext.Services.Selection.PrimarySelection != null);
+ this.AddCommandHandler(Commands.RotateRightCommand, () => ModelTools.ApplyTransform(this.DesignContext.Services.Selection.PrimarySelection, new RotateTransform(90)), () => this.DesignContext.Services.Selection.PrimarySelection != null);
_sceneContainer = new Border() { AllowDrop = false, UseLayoutRounding = true };
_sceneContainer.SetValue(TextOptions.TextFormattingModeProperty, TextFormattingMode.Ideal);
- _designPanel = new DesignPanel() {Child = _sceneContainer};
+ _designPanel = new DesignPanel() {Child = _sceneContainer, DesignSurface = this};
}
internal DesignPanel _designPanel;
diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Extensions/CanvasPlacementSupport.cs b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Extensions/CanvasPlacementSupport.cs
index 0f45fd9f4c..c8f4ce5760 100644
--- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Extensions/CanvasPlacementSupport.cs
+++ b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Extensions/CanvasPlacementSupport.cs
@@ -147,6 +147,11 @@ namespace ICSharpCode.WpfDesign.Designer.Extensions
info.Item.Properties[FrameworkElement.HorizontalAlignmentProperty].Reset();
info.Item.Properties[FrameworkElement.VerticalAlignmentProperty].Reset();
info.Item.Properties[FrameworkElement.MarginProperty].Reset();
+
+ if (operation.Type == PlacementType.PasteItem) {
+ info.Item.Properties.GetAttachedProperty(Canvas.LeftProperty).SetValue(((double)info.Item.Properties.GetAttachedProperty(Canvas.LeftProperty).ValueOnInstance) + PlacementOperation.PasteOffset);
+ info.Item.Properties.GetAttachedProperty(Canvas.TopProperty).SetValue(((double)info.Item.Properties.GetAttachedProperty(Canvas.TopProperty).ValueOnInstance) + PlacementOperation.PasteOffset);
+ }
}
}
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 67f8743067..54cd207b2a 100644
--- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Extensions/DefaultPlacementBehavior.cs
+++ b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Extensions/DefaultPlacementBehavior.cs
@@ -63,8 +63,11 @@ namespace ICSharpCode.WpfDesign.Designer.Extensions
{
InfoTextEnterArea.Stop(ref infoTextEnterArea);
- this.ExtendedItem.Services.Selection.SetSelectedComponents(null);
- this.ExtendedItem.Services.Selection.SetSelectedComponents(operation.PlacedItems.Select(x => x.Item).ToList());
+ if (operation.Type != PlacementType.Delete)
+ {
+ this.ExtendedItem.Services.Selection.SetSelectedComponents(null);
+ this.ExtendedItem.Services.Selection.SetSelectedComponents(operation.PlacedItems.Select(x => x.Item).ToList());
+ }
}
public virtual Rect GetPosition(PlacementOperation operation, DesignItem item)
diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Extensions/GridPlacementSupport.cs b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Extensions/GridPlacementSupport.cs
index cbd2ad1baa..e5a78cf63e 100644
--- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Extensions/GridPlacementSupport.cs
+++ b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Extensions/GridPlacementSupport.cs
@@ -162,6 +162,26 @@ namespace ICSharpCode.WpfDesign.Designer.Extensions
enteredIntoNewContainer=true;
grid.UpdateLayout();
base.EnterContainer(operation);
+
+ if (operation.Type == PlacementType.PasteItem) {
+ foreach (PlacementInformation info in operation.PlacedItems) {
+ var margin = (Thickness)info.Item.Properties.GetProperty(FrameworkElement.MarginProperty).ValueOnInstance;
+ var horizontalAlignment = (HorizontalAlignment)info.Item.Properties.GetProperty(FrameworkElement.HorizontalAlignmentProperty).ValueOnInstance;
+ var verticalAlignment = (VerticalAlignment)info.Item.Properties.GetProperty(FrameworkElement.VerticalAlignmentProperty).ValueOnInstance;
+
+ if (horizontalAlignment == HorizontalAlignment.Left)
+ margin.Left += PlacementOperation.PasteOffset;
+ else if (horizontalAlignment == HorizontalAlignment.Right)
+ margin.Right -= PlacementOperation.PasteOffset;
+
+ if (verticalAlignment == VerticalAlignment.Top)
+ margin.Top += PlacementOperation.PasteOffset;
+ else if (verticalAlignment == VerticalAlignment.Bottom)
+ margin.Bottom -= PlacementOperation.PasteOffset;
+
+ info.Item.Properties.GetProperty(FrameworkElement.MarginProperty).SetValue(margin);
+ }
+ }
}
GrayOutDesignerExceptActiveArea grayOut;
diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Extensions/LineExtensionBase.cs b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Extensions/LineExtensionBase.cs
index 623bf53f2b..5d2b3214ea 100644
--- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Extensions/LineExtensionBase.cs
+++ b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Extensions/LineExtensionBase.cs
@@ -107,7 +107,7 @@ namespace ICSharpCode.WpfDesign.Designer.Extensions
///
/// if using a polygon or multipoint adorner this is the index of the point in the Points array
///
- protected PointTrackerPlacementSupport Place(ref DesignerThumb designerThumb, PlacementAlignment alignment, int index = -1)
+ protected PointTrackerPlacementSupport Place(DesignerThumb designerThumb, PlacementAlignment alignment, int index = -1)
{
PointTrackerPlacementSupport placement = new PointTrackerPlacementSupport(ExtendedItem.View as Shape, alignment, index);
return placement;
diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Extensions/LineHandlerExtension.cs b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Extensions/LineHandlerExtension.cs
index 161b9a3236..30fdd856fd 100644
--- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Extensions/LineHandlerExtension.cs
+++ b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Extensions/LineHandlerExtension.cs
@@ -56,7 +56,7 @@ namespace ICSharpCode.WpfDesign.Designer.Extensions
protected DesignerThumb CreateThumb(PlacementAlignment alignment, Cursor cursor)
{
DesignerThumb designerThumb = new DesignerThumb { Alignment = alignment, Cursor = cursor, IsPrimarySelection = true};
- AdornerPanel.SetPlacement(designerThumb, Place(ref designerThumb, alignment));
+ AdornerPanel.SetPlacement(designerThumb, Place(designerThumb, alignment));
adornerPanel.Children.Add(designerThumb);
diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Extensions/PolyLineHandlerExtension.cs b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Extensions/PolyLineHandlerExtension.cs
index 0a8bd1ccdd..4817174750 100644
--- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Extensions/PolyLineHandlerExtension.cs
+++ b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Extensions/PolyLineHandlerExtension.cs
@@ -49,7 +49,7 @@ namespace ICSharpCode.WpfDesign.Designer.Extensions
protected DesignerThumb CreateThumb(PlacementAlignment alignment, Cursor cursor, int index)
{
DesignerThumb designerThumb = new MultiPointThumb { Index = index, Alignment = alignment, Cursor = cursor, IsPrimarySelection = true };
- AdornerPlacement ap = Place(ref designerThumb, alignment, index);
+ AdornerPlacement ap = Place(designerThumb, alignment, index);
(designerThumb as MultiPointThumb).AdornerPlacement = ap;
AdornerPanel.SetPlacement(designerThumb, ap);
diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Extensions/RotateThumbExtension.cs b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Extensions/RotateThumbExtension.cs
index 89b39c9aaa..f7e06b31be 100644
--- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Extensions/RotateThumbExtension.cs
+++ b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Extensions/RotateThumbExtension.cs
@@ -18,6 +18,7 @@
using System;
using System.Diagnostics;
+using System.Linq;
using System.Windows;
using System.Windows.Controls.Primitives;
using System.Windows.Input;
@@ -116,29 +117,7 @@ namespace ICSharpCode.WpfDesign.Designer.Extensions
if (!Keyboard.IsKeyDown(Key.LeftCtrl))
destAngle = ((int)destAngle / 15) * 15;
- if (destAngle == 0)
- {
- this.ExtendedItem.Properties.GetProperty(FrameworkElement.RenderTransformProperty).Reset();
- rtTransform = null;
- rotateTransform = null;
- }
- else
- {
- if ((rtTransform == null) || !(rtTransform.Component is RotateTransform))
- {
- if (!this.ExtendedItem.Properties.GetProperty(FrameworkElement.RenderTransformOriginProperty).IsSet) {
- this.ExtendedItem.Properties.GetProperty(FrameworkElement.RenderTransformOriginProperty).SetValue(new Point(0.5,0.5));
- }
-
- if (this.rotateTransform == null)
- this.rotateTransform = new RotateTransform(0);
- this.ExtendedItem.Properties.GetProperty(FrameworkElement.RenderTransformProperty).SetValue(rotateTransform);
- rtTransform = this.ExtendedItem.Properties[FrameworkElement.RenderTransformProperty].Value;
- }
- rtTransform.Properties["Angle"].SetValue(destAngle);
-
- ((DesignPanel) this.ExtendedItem.Services.DesignPanel).AdornerLayer.UpdateAdornersForElement(this.ExtendedItem.View, true);
- }
+ ModelTools.ApplyTransform(this.ExtendedItem, new RotateTransform() { Angle = destAngle });
}
void drag_Rotate_Completed(ICSharpCode.WpfDesign.Designer.Controls.DragListener drag)
@@ -161,6 +140,13 @@ namespace ICSharpCode.WpfDesign.Designer.Extensions
var designerItem = this.ExtendedItem.Component as FrameworkElement;
this.rotateTransform = designerItem.RenderTransform as RotateTransform;
+ if (this.rotateTransform == null) {
+ var tg = designerItem.RenderTransform as TransformGroup;
+ if (tg != null) {
+ this.rotateTransform = tg.Children.FirstOrDefault(x => x is RotateTransform) as RotateTransform;
+ }
+ }
+
}
void OnPropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)
diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Extensions/UserControlPointsObjectExtension.cs b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Extensions/UserControlPointsObjectExtension.cs
new file mode 100644
index 0000000000..dbf2388dfb
--- /dev/null
+++ b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Extensions/UserControlPointsObjectExtension.cs
@@ -0,0 +1,245 @@
+// Copyright (c) 2014 AlphaSierraPapa for the SharpDevelop Team
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy of this
+// software and associated documentation files (the "Software"), to deal in the Software
+// without restriction, including without limitation the rights to use, copy, modify, merge,
+// publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
+// to whom the Software is furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in all copies or
+// substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
+// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
+// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
+// FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
+// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+// DEALINGS IN THE SOFTWARE.
+
+using System;
+using System.Collections.Generic;
+using System.Windows;
+using ICSharpCode.WpfDesign.Extensions;
+using ICSharpCode.WpfDesign.Adorners;
+using ICSharpCode.WpfDesign.Designer.Controls;
+using System.Windows.Input;
+using System.Windows.Media;
+using System.Windows.Shapes;
+using System.Windows.Controls;
+using ICSharpCode.WpfDesign.UIExtensions;
+namespace ICSharpCode.WpfDesign.Designer.Extensions
+{
+ ///
+ /// Description of UserControlPointsObjectExtension.
+ ///
+ //[ExtensionFor(typeof(Line), OverrideExtensions = new Type[] { typeof(ResizeThumbExtension), typeof(SelectedElementRectangleExtension), typeof(CanvasPositionExtension), typeof(QuickOperationMenuExtension), typeof(RotateThumbExtension), typeof(RenderTransformOriginExtension), typeof(InPlaceEditorExtension), typeof(SkewThumbExtension) })]
+ public abstract class UserControlPointsObjectExtension : LineExtensionBase
+ {
+ ///
+ /// Used instead of Rect to allow negative values on "Width" and "Height" (here called X and Y).
+ ///
+ class Bounds
+ {
+ public double X, Y, Left, Top;
+ }
+
+ //
+ private double CurrentX2;
+ private double CurrentY2;
+ private double CurrentLeft;
+ private double CurrentTop;
+
+ private IEnumerable _thumbProperties;
+
+ //Size oldSize;
+ ZoomControl zoom;
+
+ public DragListener DragListener {get; private set;}
+
+ protected UserControlPointsObjectThumb CreateThumb(PlacementAlignment alignment, Cursor cursor, DependencyProperty property)
+ {
+ var designerThumb = new UserControlPointsObjectThumb { Alignment = alignment, Cursor = cursor, IsPrimarySelection = true, DependencyProperty = property};
+ AdornerPanel.SetPlacement(designerThumb, Place(designerThumb, alignment));
+
+ adornerPanel.Children.Add(designerThumb);
+
+ DragListener = new DragListener(designerThumb);
+ DragListener.Started += drag_Started;
+ DragListener.Changed += drag_Changed;
+ DragListener.Completed += drag_Completed;
+
+ return designerThumb;
+ }
+
+ Bounds CalculateDrawing(double x, double y, double left, double top, double xleft, double xtop)
+ {
+
+ Double theta = (180 / Math.PI) * Math.Atan2(y, x);
+ double verticaloffset = Math.Abs(90 - Math.Abs(theta));
+ if (Keyboard.IsKeyDown(Key.LeftAlt) || Keyboard.IsKeyDown(Key.RightAlt))
+ {
+ if (Math.Abs(theta) < 45 || Math.Abs(theta) > 135)
+ {
+ y = 0;
+ top = xtop;
+ }
+ else if (verticaloffset < 45)
+ {
+ x = 0;
+ left = xleft;
+ }
+ }
+ else if (Keyboard.IsKeyDown(Key.LeftShift) || Keyboard.IsKeyDown(Key.RightShift))
+ {
+ if (verticaloffset < 10)
+ {
+ x = 0;
+ left = xleft;
+ }
+ else if (Math.Abs(theta) < 10 || Math.Abs(theta) > 170)
+ {
+ y = 0;
+ top = xtop;
+ }
+ }
+
+ SetSurfaceInfo(0, 3, Math.Round((180 / Math.PI) * Math.Atan2(y, x), 0).ToString());
+ return new Bounds { X = Math.Round(x, 1), Y = Math.Round(y, 1), Left = Math.Round(left, 1), Top = Math.Round(top, 1) };
+ }
+
+ #region eventhandlers
+
+ protected virtual void drag_Started(DragListener drag)
+ {
+ Line al = ExtendedItem.View as Line;
+ CurrentX2 = al.X2;
+ CurrentY2 = al.Y2;
+ CurrentLeft = (double)al.GetValue(Canvas.LeftProperty);
+ CurrentTop = (double)al.GetValue(Canvas.TopProperty);
+
+ var designPanel = ExtendedItem.Services.DesignPanel as DesignPanel;
+ zoom = designPanel.TryFindParent();
+
+ if (resizeBehavior != null)
+ operation = PlacementOperation.Start(extendedItemArray, PlacementType.Resize);
+ else
+ {
+ changeGroup = this.ExtendedItem.Context.OpenGroup("Resize", extendedItemArray);
+ }
+ _isResizing = true;
+
+ (drag.Target as UserControlPointsObjectThumb).IsPrimarySelection = false;
+ }
+
+ protected virtual void drag_Changed(DragListener drag)
+ {
+ Line al = ExtendedItem.View as Line;
+
+ var alignment = (drag.Target as UserControlPointsObjectThumb).Alignment;
+ var info = operation.PlacedItems[0];
+ double dx = 0;
+ double dy = 0;
+
+ if (zoom != null) {
+ dx = drag.Delta.X * (1 / zoom.CurrentZoom);
+ dy = drag.Delta.Y * (1 / zoom.CurrentZoom);
+ }
+
+ double top, left, x, y, xtop, xleft;
+
+ if (alignment == PlacementAlignment.TopLeft) {
+
+ //normal values
+ x = CurrentX2 - dx;
+ y = CurrentY2 - dy;
+ top = CurrentTop + dy;
+ left = CurrentLeft + dx;
+
+ //values to use when keys are pressed
+ xtop = CurrentTop + CurrentY2;
+ xleft = CurrentLeft + CurrentX2;
+
+ } else {
+ x = CurrentX2 + dx;
+ y = CurrentY2 + dy;
+ top = xtop = CurrentTop;
+ left = xleft = CurrentLeft;
+ }
+
+ Bounds position = CalculateDrawing(x, y, left, top, xleft, xtop);
+
+ ExtendedItem.Properties.GetProperty(Line.X1Property).SetValue(0);
+ ExtendedItem.Properties.GetProperty(Line.Y1Property).SetValue(0);
+ ExtendedItem.Properties.GetProperty(Line.X2Property).SetValue(position.X);
+ ExtendedItem.Properties.GetProperty(Line.Y2Property).SetValue(position.Y);
+
+ if (operation != null) {
+ var result = info.OriginalBounds;
+ result.X = position.Left;
+ result.Y = position.Top;
+ result.Width = Math.Abs(position.X);
+ result.Height = Math.Abs(position.Y);
+
+ info.Bounds = result.Round();
+ operation.CurrentContainerBehavior.BeforeSetPosition(operation);
+ operation.CurrentContainerBehavior.SetPosition(info);
+ }
+
+ (drag.Target as UserControlPointsObjectThumb).InvalidateArrange();
+ ResetWidthHeightProperties();
+ }
+
+ protected virtual void drag_Completed(DragListener drag)
+ {
+ if (operation != null)
+ {
+ if (drag.IsCanceled) operation.Abort();
+ else
+ {
+ ResetWidthHeightProperties();
+
+ operation.Commit();
+ }
+ operation = null;
+ }
+ else
+ {
+ if (drag.IsCanceled)
+ changeGroup.Abort();
+ else
+ changeGroup.Commit();
+ changeGroup = null;
+ }
+
+ _isResizing = false;
+ (drag.Target as UserControlPointsObjectThumb).IsPrimarySelection = true;
+ HideSizeAndShowHandles();
+ }
+
+ #endregion
+
+ ///
+ /// is invoked whenever a line is selected on the canvas, remember that the adorners are created for each line object and never destroyed
+ ///
+ protected override void OnInitialized()
+ {
+ base.OnInitialized();
+
+ FillThumbProperties();
+
+ foreach (var prp in _thumbProperties) {
+ CreateThumb(PlacementAlignment.Center, Cursors.Cross, prp);
+ }
+
+ extendedItemArray[0] = this.ExtendedItem;
+
+ Invalidate();
+
+ this.ExtendedItem.PropertyChanged += OnPropertyChanged;
+ resizeBehavior = PlacementOperation.GetPlacementBehavior(extendedItemArray);
+ UpdateAdornerVisibility();
+ }
+
+ protected abstract IEnumerable FillThumbProperties();
+ }
+}
diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/MarkupExtensions/DesignItemBinding.cs b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/MarkupExtensions/DesignItemBinding.cs
index b0340d7379..10279b816b 100644
--- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/MarkupExtensions/DesignItemBinding.cs
+++ b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/MarkupExtensions/DesignItemBinding.cs
@@ -43,6 +43,12 @@ namespace ICSharpCode.WpfDesign.Designer.MarkupExtensions
public bool SingleItemProperty { get; set; }
+ public bool AskWhenMultipleItemsSelected { get; set; }
+
+ public IValueConverter Converter { get; set; }
+
+ public object ConverterParameter { get; set; }
+
public UpdateSourceTrigger UpdateSourceTrigger { get; set; }
public DesignItemBinding(string path)
@@ -50,6 +56,7 @@ namespace ICSharpCode.WpfDesign.Designer.MarkupExtensions
this._propertyName = path;
UpdateSourceTrigger = UpdateSourceTrigger.Default;
+ AskWhenMultipleItemsSelected = true;
}
public override object ProvideValue(IServiceProvider serviceProvider)
@@ -63,22 +70,44 @@ namespace ICSharpCode.WpfDesign.Designer.MarkupExtensions
return null;
}
+ public void CreateBindingOnProperty(DependencyProperty targetProperty, FrameworkElement targetObject)
+ {
+ _targetProperty = targetProperty;
+ _targetObject = targetObject;
+ _targetObject.DataContextChanged += targetObject_DataContextChanged;
+ targetObject_DataContextChanged(_targetObject, new DependencyPropertyChangedEventArgs());
+ }
+
void targetObject_DataContextChanged(object sender, DependencyPropertyChangedEventArgs e)
{
- var ctx = ((FrameworkElement) sender).DataContext as FrameworkElement;
-
- var surface = ctx.TryFindParent();
+ var dcontext = ((FrameworkElement) sender).DataContext;
+
+ DesignContext context = null;
+ FrameworkElement fe = null;
+ DesignItem designItem = null;
+
+ if (dcontext is DesignItem) {
+ designItem = (DesignItem)dcontext;
+ context = designItem.Context;
+ fe = designItem.View as FrameworkElement;
+ } else if (dcontext is FrameworkElement) {
+ fe = ((FrameworkElement)dcontext);
+ var srv = fe.TryFindParent();
+ if (srv != null) {
+ context = srv.DesignContext;
+ designItem = context.Services.Component.GetDesignItem(fe);
+ }
+ }
- if (surface != null)
+ if (context != null)
{
_binding = new Binding(_propertyName);
- _binding.Source = ctx;
+ _binding.Source = fe;
_binding.UpdateSourceTrigger = UpdateSourceTrigger;
_binding.Mode = BindingMode.TwoWay;
+ _binding.ConverterParameter = ConverterParameter;
- var designItem = surface.DesignContext.Services.Component.GetDesignItem(ctx);
-
- _converter = new DesignItemSetConverter(designItem, _propertyName, SingleItemProperty);
+ _converter = new DesignItemSetConverter(designItem, _propertyName, SingleItemProperty, AskWhenMultipleItemsSelected, Converter);
_binding.Converter = _converter;
_targetObject.SetBinding(_targetProperty, _binding);
@@ -94,33 +123,47 @@ namespace ICSharpCode.WpfDesign.Designer.MarkupExtensions
private DesignItem _designItem;
private string _property;
private bool _singleItemProperty;
+ private bool _askWhenMultipleItemsSelected;
+ private IValueConverter _converter;
- public DesignItemSetConverter(DesignItem desigItem, string property, bool singleItemProperty)
+ public DesignItemSetConverter(DesignItem desigItem, string property, bool singleItemProperty, bool askWhenMultipleItemsSelected, IValueConverter converter)
{
this._designItem = desigItem;
this._property = property;
this._singleItemProperty = singleItemProperty;
+ this._converter = converter;
+ this._askWhenMultipleItemsSelected = askWhenMultipleItemsSelected;
}
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
+ if (_converter != null)
+ return _converter.Convert(value, targetType, parameter, culture);
+
return value;
}
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
+ var val = value;
+ if (_converter != null)
+ val = _converter.ConvertBack(value, targetType, parameter, culture);
+
var changeGroup = _designItem.OpenGroup("Property: " + _property);
try
{
var property = _designItem.Properties.GetProperty(_property);
- property.SetValue(value);
+ property.SetValue(val);
if (!_singleItemProperty && _designItem.Services.Selection.SelectedItems.Count > 1)
{
- var msg = MessageBox.Show("Apply changes to all selected Items","", MessageBoxButton.YesNo);
+ var msg = MessageBoxResult.Yes;
+ if (_askWhenMultipleItemsSelected) {
+ msg = MessageBox.Show("Apply changes to all selected Items","", MessageBoxButton.YesNo);
+ }
if (msg == MessageBoxResult.Yes)
{
foreach (var item in _designItem.Services.Selection.SelectedItems)
@@ -132,7 +175,7 @@ namespace ICSharpCode.WpfDesign.Designer.MarkupExtensions
catch(Exception)
{ }
if (property != null)
- property.SetValue(value);
+ property.SetValue(val);
}
}
}
@@ -144,7 +187,7 @@ namespace ICSharpCode.WpfDesign.Designer.MarkupExtensions
changeGroup.Abort();
}
- return value;
+ return val;
}
}
}
diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/ModelTools.cs b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/ModelTools.cs
index 88bfe0a00b..0175a7c2cd 100644
--- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/ModelTools.cs
+++ b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/ModelTools.cs
@@ -113,6 +113,12 @@ namespace ICSharpCode.WpfDesign.Designer
foreach (var designItem in items) {
designItem.Name = null;
}
+
+ var service = parent.Services.Component as XamlComponentService;
+ foreach (var item in items) {
+ service.RaiseComponentRemoved(item);
+ }
+
operation.DeleteItemsAndCommit();
} catch {
operation.Abort();
@@ -344,6 +350,89 @@ namespace ICSharpCode.WpfDesign.Designer
return new Tuple(newPanel, new Rect(xmin, ymin, xmax - xmin, ymax - ymin).Round());
}
+
+ public static void ApplyTransform(DesignItem designItem, Transform transform, bool relative = true)
+ {
+ var changeGroup = designItem.OpenGroup("Apply Transform");
+
+ Transform oldTransform = null;
+ if (designItem.Properties.GetProperty(FrameworkElement.RenderTransformProperty).IsSet) {
+ oldTransform = designItem.Properties.GetProperty(FrameworkElement.RenderTransformProperty).ValueOnInstance as Transform;
+ }
+
+ if (oldTransform is MatrixTransform) {
+ var mt = oldTransform as MatrixTransform;
+ var tg = new TransformGroup();
+ if (mt.Matrix.OffsetX != 0 && mt.Matrix.OffsetY != 0)
+ tg.Children.Add(new TranslateTransform(){ X = mt.Matrix.OffsetX, Y = mt.Matrix.OffsetY });
+ if (mt.Matrix.M11 != 0 && mt.Matrix.M22 != 0)
+ tg.Children.Add(new ScaleTransform(){ ScaleX = mt.Matrix.M11, ScaleY = mt.Matrix.M22 });
+
+ var angle = Math.Atan2(mt.Matrix.M21, mt.Matrix.M11) * 180 / Math.PI;
+ if (angle != 0)
+ tg.Children.Add(new RotateTransform(){ Angle = angle });
+ //if (mt.Matrix.M11 != 0 && mt.Matrix.M22 != 0)
+ // tg.Children.Add(new SkewTransform(){ ScaleX = mt.Matrix.M11, ScaleY = mt.Matrix.M22 });
+ } else if (oldTransform != null && oldTransform.GetType() != transform.GetType()) {
+ var tg = new TransformGroup();
+ var tgDes = designItem.Services.Component.RegisterComponentForDesigner(tg);
+ tgDes.ContentProperty.CollectionElements.Add(designItem.Services.Component.GetDesignItem(oldTransform));
+ designItem.Properties.GetProperty(FrameworkElement.RenderTransformProperty).SetValue(tg);
+ oldTransform = tg;
+ }
+
+
+
+ if (transform is RotateTransform) {
+ var rotateTransform = transform as RotateTransform;
+
+ if (oldTransform is RotateTransform || oldTransform == null) {
+ if (rotateTransform.Angle != 0) {
+ designItem.Properties.GetProperty(FrameworkElement.RenderTransformProperty).SetValue(transform);
+ var angle = rotateTransform.Angle;
+ if (relative && oldTransform != null) {
+ angle = rotateTransform.Angle + ((RotateTransform)oldTransform).Angle;
+ }
+ designItem.Properties.GetProperty(FrameworkElement.RenderTransformProperty).Value.Properties.GetProperty(RotateTransform.AngleProperty).SetValue(angle);
+ if (rotateTransform.CenterX != 0.0)
+ designItem.Properties.GetProperty(FrameworkElement.RenderTransformProperty).Value.Properties.GetProperty(RotateTransform.CenterXProperty).SetValue(rotateTransform.CenterX);
+ if (rotateTransform.CenterY != 0.0)
+ designItem.Properties.GetProperty(FrameworkElement.RenderTransformProperty).Value.Properties.GetProperty(RotateTransform.CenterYProperty).SetValue(rotateTransform.CenterY);
+
+ if (oldTransform == null)
+ designItem.Properties.GetProperty(FrameworkElement.RenderTransformOriginProperty).SetValue(new Point(0.5, 0.5));
+ }
+ else {
+ designItem.Properties.GetProperty(FrameworkElement.RenderTransformProperty).Reset();
+ designItem.Properties.GetProperty(FrameworkElement.RenderTransformOriginProperty).Reset();
+ }
+ } else if (oldTransform is TransformGroup) {
+ var tg = oldTransform as TransformGroup;
+ var rot = tg.Children.FirstOrDefault(x=> x is RotateTransform);
+ if (rot != null) {
+ designItem.Services.Component.GetDesignItem(tg).ContentProperty.CollectionElements.Remove(designItem.Services.Component.GetDesignItem(rot));
+ }
+ if (rotateTransform.Angle != 0) {
+ var des = designItem.Services.Component.GetDesignItem(transform);
+ if (des == null)
+ des = designItem.Services.Component.RegisterComponentForDesigner(transform);
+ designItem.Services.Component.GetDesignItem(tg).ContentProperty.CollectionElements.Add(des);
+ if (oldTransform == null)
+ designItem.Properties.GetProperty(FrameworkElement.RenderTransformOriginProperty).SetValue(new Point(0.5, 0.5));
+ }
+ } else {
+ if (rotateTransform.Angle != 0) {
+ designItem.Properties.GetProperty(FrameworkElement.RenderTransformProperty).SetValue(transform);
+ if (oldTransform == null)
+ designItem.Properties.GetProperty(FrameworkElement.RenderTransformOriginProperty).SetValue(new Point(0.5, 0.5));
+ }
+ }
+ }
+
+ ((DesignPanel) designItem.Services.DesignPanel).AdornerLayer.UpdateAdornersForElement(designItem.View, true);
+
+ changeGroup.Commit();
+ }
public static void ArrangeItems(IEnumerable items, ArrangeDirection arrangeDirection)
{
diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/WpfDesign.Designer.csproj b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/WpfDesign.Designer.csproj
index 73df4f6809..444bb3b156 100644
--- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/WpfDesign.Designer.csproj
+++ b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/WpfDesign.Designer.csproj
@@ -88,6 +88,7 @@
+
@@ -131,6 +132,7 @@
ArrangeItemsContextMenu.xaml
+
WrapItemContextMenu.xaml
diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Xaml/XamlComponentService.cs b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Xaml/XamlComponentService.cs
index 9998929502..53a6608478 100644
--- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Xaml/XamlComponentService.cs
+++ b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Xaml/XamlComponentService.cs
@@ -56,6 +56,8 @@ namespace ICSharpCode.WpfDesign.Designer.Xaml
public event EventHandler ComponentRegistered;
+ public event EventHandler ComponentRemoved;
+
// TODO: this must not be a dictionary because there's no way to unregister components
// however, this isn't critical because our design items will stay alive for the lifetime of the
// designer anyway if we don't limit the Undo stack.
@@ -164,5 +166,16 @@ namespace ICSharpCode.WpfDesign.Designer.Xaml
ev(this, new DesignItemPropertyChangedEventArgs(property.DesignItem, property));
}
}
+
+ ///
+ /// raises the RaiseComponentRemoved Event
+ ///
+ internal void RaiseComponentRemoved(DesignItem item)
+ {
+ var ev = this.ComponentRemoved;
+ if (ev != null) {
+ ev(this, new DesignItemEventArgs(item));
+ }
+ }
}
}
diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Xaml/XamlDesignItem.cs b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Xaml/XamlDesignItem.cs
index f877a734a9..74f0160e3a 100644
--- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Xaml/XamlDesignItem.cs
+++ b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Xaml/XamlDesignItem.cs
@@ -260,6 +260,10 @@ namespace ICSharpCode.WpfDesign.Designer.Xaml
get { return _properties; }
}
+ public override IEnumerable AllSetProperties {
+ get { return _xamlObject.Properties.Select(x => new XamlModelProperty(this, x)); }
+ }
+
internal void NotifyPropertyChanged(XamlModelProperty property)
{
Debug.Assert(property != null);
diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Xaml/XamlEditOperations.cs b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Xaml/XamlEditOperations.cs
index be2964d11a..96af34fa59 100644
--- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Xaml/XamlEditOperations.cs
+++ b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Xaml/XamlEditOperations.cs
@@ -179,7 +179,7 @@ namespace ICSharpCode.WpfDesign.Designer.Xaml
var operation = PlacementOperation.TryStartInsertNewComponents(parent, pastedItems, rects.ToList(), PlacementType.PasteItem);
ISelectionService selection = _context.Services.Selection;
selection.SetSelectedComponents(pastedItems);
- if(operation!=null)
+ if(operation != null)
operation.Commit();
}
}
diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Xaml/XamlModelCollectionElementsCollection.cs b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Xaml/XamlModelCollectionElementsCollection.cs
index 3a5766f11a..0824fe99ae 100644
--- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Xaml/XamlModelCollectionElementsCollection.cs
+++ b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Xaml/XamlModelCollectionElementsCollection.cs
@@ -180,7 +180,7 @@ namespace ICSharpCode.WpfDesign.Designer.Xaml
void RemoveInternal(int index, XamlDesignItem item)
{
- NameScopeHelper.NameChanged(item.XamlObject, item.Name, null);
+ RemoveFromNamescopeRecursive(item);
Debug.Assert(property.CollectionElements[index] == item.XamlObject);
property.CollectionElements.RemoveAt(index);
@@ -196,7 +196,41 @@ namespace ICSharpCode.WpfDesign.Designer.Xaml
if (CollectionChanged != null)
CollectionChanged(this, new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Add, item, index));
- NameScopeHelper.NameChanged(item.XamlObject, null, item.Name);
+ AddToNamescopeRecursive(item);
+ }
+
+ private static void RemoveFromNamescopeRecursive(XamlDesignItem designItem)
+ {
+ NameScopeHelper.NameChanged(designItem.XamlObject, designItem.Name, null);
+
+ foreach (var p in designItem.Properties)
+ {
+ if (p.Value != null) {
+ RemoveFromNamescopeRecursive((XamlDesignItem)p.Value);
+ }
+ else if (p.IsCollection && p.CollectionElements != null) {
+ foreach (var c in p.CollectionElements) {
+ RemoveFromNamescopeRecursive((XamlDesignItem)c);
+ }
+ }
+ }
+ }
+
+ private static void AddToNamescopeRecursive(XamlDesignItem designItem)
+ {
+ NameScopeHelper.NameChanged(designItem.XamlObject, null, designItem.Name);
+
+ foreach (var p in designItem.Properties)
+ {
+ if (p.Value != null) {
+ AddToNamescopeRecursive((XamlDesignItem)p.Value);
+ }
+ else if (p.IsCollection && p.CollectionElements != null) {
+ foreach (var c in p.CollectionElements) {
+ AddToNamescopeRecursive((XamlDesignItem)c);
+ }
+ }
+ }
}
sealed class InsertAction : ITransactionItem
diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Xaml/XamlModelPropertyCollection.cs b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Xaml/XamlModelPropertyCollection.cs
index 8c708bf69c..6264665627 100644
--- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Xaml/XamlModelPropertyCollection.cs
+++ b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Xaml/XamlModelPropertyCollection.cs
@@ -24,6 +24,8 @@ using System.Collections.Generic;
namespace ICSharpCode.WpfDesign.Designer.Xaml
{
+ using System.Linq;
+
sealed class XamlModelPropertyCollection : DesignItemPropertyCollection
{
XamlDesignItem _item;
@@ -51,7 +53,10 @@ namespace ICSharpCode.WpfDesign.Designer.Xaml
public override System.Collections.Generic.IEnumerator GetEnumerator()
{
- yield break;
+ foreach (var value in propertiesDictionary.Values)
+ {
+ yield return value;
+ }
}
}
}
diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Tests/Designer/EditOperationTests.cs b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Tests/Designer/EditOperationTests.cs
index 827ccd037c..5c816fe895 100644
--- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Tests/Designer/EditOperationTests.cs
+++ b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Tests/Designer/EditOperationTests.cs
@@ -254,7 +254,7 @@ namespace ICSharpCode.WpfDesign.Tests.Designer
xamlContext.XamlEditAction.Paste();
string expectedXaml = "\n" +
- "\n" +
+ "\n" +
" \n" +
" \n" +
" \n" +
@@ -315,6 +315,13 @@ namespace ICSharpCode.WpfDesign.Tests.Designer
selection.SetSelectedComponents(new[] {grid});
xamlContext.XamlEditAction.Paste();
+ // Verify xaml document to be copied
+ expectedXaml = "\n" +
+ " \n" +
+ "\n" +
+ "\n" +
+ "\n";
+
AssertGridDesignerOutput(expectedXaml, grid.Context,
"xmlns:Controls0=\"clr-namespace:ICSharpCode.WpfDesign.Tests.Designer;assembly=ICSharpCode.WpfDesign.Tests\"",
"xmlns:sdtcontrols=\"http://sharpdevelop.net/WpfDesign/Tests/Controls\"");
diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Tests/Designer/ModelTests.cs b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Tests/Designer/ModelTests.cs
index 82fd578baf..05a74a12da 100644
--- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Tests/Designer/ModelTests.cs
+++ b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Tests/Designer/ModelTests.cs
@@ -895,6 +895,52 @@ namespace ICSharpCode.WpfDesign.Tests.Designer
AssertLog("");
}
+ [Test]
+ public void AddBindingWithStaticResourceToMultiBinding()
+ {
+ DesignItem textBox = CreateCanvasContext("");
+
+ DesignItem canvasItem = textBox.Parent;
+ DesignItemProperty canvasResources = canvasItem.Properties.GetProperty("Resources");
+
+ DesignItem exampleClassItem = textBox.Services.Component.RegisterComponentForDesigner(new ICSharpCode.WpfDesign.Tests.XamlDom.ExampleClass());
+ exampleClassItem.Key = "testKey";
+ exampleClassItem.Properties["StringProp"].SetValue("String value");
+ canvasResources.CollectionElements.Add(exampleClassItem);
+
+ DesignItem multiBindingItem = textBox.Context.Services.Component.RegisterComponentForDesigner(new MultiBinding());
+ multiBindingItem.Properties["Converter"].SetValue(new ReturnFirstValueMultiConverter());
+ DesignItemProperty bindingsProp = multiBindingItem.ContentProperty;
+
+ DesignItem myBindingExtension = textBox.Context.Services.Component.RegisterComponentForDesigner(new Binding());
+ myBindingExtension.Properties["Path"].SetValue("StringProp");
+ myBindingExtension.Properties["Source"].SetValue(new StaticResourceExtension());
+ myBindingExtension.Properties["Source"].Value.Properties["ResourceKey"].SetValue("testKey");
+
+ // Adding it to MultiBinding "Bindings" collection.
+ bindingsProp.CollectionElements.Add(myBindingExtension);
+
+ textBox.ContentProperty.SetValue(multiBindingItem);
+
+ // Verify that the text have the expected value, proving that the StaticResource have been resolved.
+ Assert.AreEqual("String value", ((TextBox)textBox.Component).Text);
+
+ const string expectedXaml = "\n" +
+ " \n" +
+ "\n" +
+ "\n" +
+ " \n" +
+ " \n" +
+ " \n" +
+ " \n" +
+ " \n" +
+ " \n" +
+ "";
+
+ AssertCanvasDesignerOutput(expectedXaml, textBox.Context, "xmlns:Controls0=\"" + ICSharpCode.WpfDesign.Tests.XamlDom.XamlTypeFinderTests.XamlDomTestsNamespace + "\"");
+ AssertLog("");
+ }
+
[Test]
public void AddBrushAsResource()
{
@@ -1024,6 +1070,22 @@ namespace ICSharpCode.WpfDesign.Tests.Designer
}
}
+ public class ReturnFirstValueMultiConverter : IMultiValueConverter
+ {
+ public object Convert(object[] values, Type targetType, object parameter, System.Globalization.CultureInfo culture)
+ {
+ if(values != null && values.Length > 0) {
+ return values[0];
+ } else {
+ return System.Windows.DependencyProperty.UnsetValue;
+ }
+ }
+ public object[] ConvertBack(object value, Type[] targetTypes, object parameter, System.Globalization.CultureInfo culture)
+ {
+ throw new NotImplementedException();
+ }
+ }
+
public class ExampleClass
{
string stringProp;
diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.XamlDom/Project/XamlObject.cs b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.XamlDom/Project/XamlObject.cs
index 72e8f8b7be..5400bafaf3 100644
--- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.XamlDom/Project/XamlObject.cs
+++ b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.XamlDom/Project/XamlObject.cs
@@ -283,8 +283,17 @@ namespace ICSharpCode.WpfDesign.XamlDom
void UpdateChildMarkupExtensions(XamlObject obj)
{
- foreach (XamlObject propXamlObject in obj.Properties.Where((prop) => prop.IsSet).Select((prop) => prop.PropertyValue).OfType()) {
- UpdateChildMarkupExtensions(propXamlObject);
+ foreach (var prop in obj.Properties) {
+ if (prop.IsSet) {
+ var propXamlObject = prop.PropertyValue as XamlObject;
+ if (propXamlObject != null) {
+ UpdateChildMarkupExtensions(propXamlObject);
+ }
+ } else if (prop.IsCollection) {
+ foreach (var propXamlObject in prop.CollectionElements.OfType()) {
+ UpdateChildMarkupExtensions(propXamlObject);
+ }
+ }
}
if (obj.IsMarkupExtension && obj.ParentProperty != null) {
diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.XamlDom/Project/XamlProperty.cs b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.XamlDom/Project/XamlProperty.cs
index 093c418abb..2bee6dda09 100644
--- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.XamlDom/Project/XamlProperty.cs
+++ b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.XamlDom/Project/XamlProperty.cs
@@ -248,8 +248,9 @@ namespace ICSharpCode.WpfDesign.XamlDom
try {
ValueOnInstance = PropertyValue.GetValueFor(propertyInfo);
- if (this.parentObject.XamlSetTypeConverter != null)
+ if (this.parentObject.XamlSetTypeConverter != null && propertyValue is XamlTextValue) {
this.ParentObject.XamlSetTypeConverter(this.parentObject.Instance, new XamlSetTypeConverterEventArgs(this.SystemXamlMemberForProperty, null, ((XamlTextValue) propertyValue).Text, this.parentObject.OwnerDocument.GetTypeDescriptorContext(this.parentObject), null));
+ }
if (propertyInfo.DependencyProperty == DesignTimeProperties.DesignWidthProperty) {
var widthProperty = this.ParentObject.Properties.FirstOrDefault(x => x.DependencyProperty == FrameworkElement.WidthProperty);
@@ -266,6 +267,15 @@ namespace ICSharpCode.WpfDesign.XamlDom
catch (Exception ex) {
Debug.WriteLine("UpdateValueOnInstance() failed - Exception:" + ex.Message);
}
+ } else if (IsCollection) {
+ var list = ValueOnInstance as System.Collections.IList;
+ if (list != null) {
+ list.Clear();
+ foreach (var item in CollectionElements) {
+ var newValue = item.GetValueFor(propertyInfo);
+ list.Add(newValue);
+ }
+ }
}
}
diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/DesignItem.cs b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/DesignItem.cs
index 19b0426528..73e9f2bae9 100644
--- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/DesignItem.cs
+++ b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/DesignItem.cs
@@ -78,6 +78,11 @@ namespace ICSharpCode.WpfDesign
///
public abstract DesignItemPropertyCollection Properties { get; }
+ ///
+ /// Gets properties set on the design item.
+ ///
+ public abstract IEnumerable AllSetProperties { get; }
+
///
/// Gets/Sets the name of the design item.
///
diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/PlacementOperation.cs b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/PlacementOperation.cs
index dcd1080fbf..4d9b70fa5e 100644
--- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/PlacementOperation.cs
+++ b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/PlacementOperation.cs
@@ -38,6 +38,8 @@ namespace ICSharpCode.WpfDesign
IPlacementBehavior currentContainerBehavior;
bool isAborted, isCommitted;
+ public const double PasteOffset = 10;
+
#region Properties
///
/// The items being placed.
@@ -294,6 +296,7 @@ namespace ICSharpCode.WpfDesign
#endregion
#region ChangeGroup handling
+
///
/// Gets/Sets the description of the underlying change group.
///
@@ -301,7 +304,7 @@ namespace ICSharpCode.WpfDesign
get { return changeGroup.Title; }
set { changeGroup.Title = value; }
}
-
+
///
/// Aborts the operation.
/// This aborts the underlying change group, reverting all changes done while the operation was running.
diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/Services.cs b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/Services.cs
index 61ed242246..dfd90f1b47 100644
--- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/Services.cs
+++ b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/Services.cs
@@ -127,6 +127,9 @@ namespace ICSharpCode.WpfDesign
/// Event raised whenever a component is registered
event EventHandler ComponentRegistered;
+ /// Event raised whenever a component is removed
+ event EventHandler ComponentRemoved;
+
/// Property Changed
event EventHandler PropertyChanged;