Browse Source

Implemented deleting components from the design surface.

git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/trunk@2440 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61
shortcuts
Daniel Grunwald 19 years ago
parent
commit
8f3490bb87
  1. 15
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/DesignPanel.cs
  2. 10
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/DesignSurface.cs
  3. 8
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Extensions/CanvasPlacementSupport.cs
  4. 16
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Extensions/ResizeThumbExtension.cs
  5. 6
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Extensions/WindowResizeBehavior.cs
  6. 27
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/ModelTools.cs
  7. 7
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Services/CreateComponentTool.cs
  8. 2
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Services/DragMoveMouseGesture.cs
  9. 2
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Services/MouseGestureBase.cs
  10. 13
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Xaml/XamlDesignContext.cs
  11. 27
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/Extensions/ExtensionManager.cs
  12. 9
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/PlacementAlignment.cs
  13. 21
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/PlacementOperation.cs
  14. 11
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/PlacementType.cs
  15. 2
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/PropertyEditor/DesignItemDataSource.cs
  16. 1
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/PropertyEditor/FallbackEditor.cs
  17. 3
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/PropertyEditor/IPropertyEditorDataSource.cs
  18. 6
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/PropertyEditor/MultipleSelectionDataProperty.cs
  19. 8
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/PropertyEditor/MultipleSelectionDataSource.cs
  20. 2
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/PropertyEditor/TextBoxEditor.cs
  21. 4
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/WpfDesign.csproj

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

@ -137,7 +137,6 @@ namespace ICSharpCode.WpfDesign.Designer
DesignContext _context; DesignContext _context;
readonly EatAllHitTestRequests _eatAllHitTestRequests; readonly EatAllHitTestRequests _eatAllHitTestRequests;
readonly AdornerLayer _adornerLayer; readonly AdornerLayer _adornerLayer;
readonly Canvas _markerCanvas;
public DesignPanel() public DesignPanel()
{ {
@ -148,10 +147,12 @@ namespace ICSharpCode.WpfDesign.Designer
DesignerProperties.SetIsInDesignMode(this, true); DesignerProperties.SetIsInDesignMode(this, true);
_eatAllHitTestRequests = new EatAllHitTestRequests(); _eatAllHitTestRequests = new EatAllHitTestRequests();
_eatAllHitTestRequests.MouseDown += delegate {
// ensure the design panel has focus while the user is interacting with it
this.Focus();
};
_eatAllHitTestRequests.AllowDrop = true; _eatAllHitTestRequests.AllowDrop = true;
_adornerLayer = new AdornerLayer(this); _adornerLayer = new AdornerLayer(this);
_markerCanvas = new Canvas();
_markerCanvas.IsHitTestVisible = false;
} }
#endregion #endregion
@ -201,12 +202,10 @@ namespace ICSharpCode.WpfDesign.Designer
// remove _adornerLayer and _eatAllHitTestRequests // remove _adornerLayer and _eatAllHitTestRequests
RemoveVisualChild(_adornerLayer); RemoveVisualChild(_adornerLayer);
RemoveVisualChild(_eatAllHitTestRequests); RemoveVisualChild(_eatAllHitTestRequests);
RemoveVisualChild(_markerCanvas);
} else if (base.Child == null) { } else if (base.Child == null) {
// Child is being set from null to some value // Child is being set from null to some value
AddVisualChild(_adornerLayer); AddVisualChild(_adornerLayer);
AddVisualChild(_eatAllHitTestRequests); AddVisualChild(_eatAllHitTestRequests);
AddVisualChild(_markerCanvas);
} }
base.Child = value; base.Child = value;
} }
@ -221,8 +220,6 @@ namespace ICSharpCode.WpfDesign.Designer
return _eatAllHitTestRequests; return _eatAllHitTestRequests;
else if (index == 2) else if (index == 2)
return _adornerLayer; return _adornerLayer;
else if (index == 3)
return _markerCanvas;
} }
return base.GetVisualChild(index); return base.GetVisualChild(index);
} }
@ -230,7 +227,7 @@ namespace ICSharpCode.WpfDesign.Designer
protected override int VisualChildrenCount { protected override int VisualChildrenCount {
get { get {
if (base.Child != null) if (base.Child != null)
return 4; return 3;
else else
return base.VisualChildrenCount; return base.VisualChildrenCount;
} }
@ -242,7 +239,6 @@ namespace ICSharpCode.WpfDesign.Designer
if (this.Child != null) { if (this.Child != null) {
_adornerLayer.Measure(constraint); _adornerLayer.Measure(constraint);
_eatAllHitTestRequests.Measure(constraint); _eatAllHitTestRequests.Measure(constraint);
_markerCanvas.Measure(constraint);
} }
return result; return result;
} }
@ -254,7 +250,6 @@ namespace ICSharpCode.WpfDesign.Designer
Rect r = new Rect(new Point(0, 0), arrangeSize); Rect r = new Rect(new Point(0, 0), arrangeSize);
_adornerLayer.Arrange(r); _adornerLayer.Arrange(r);
_eatAllHitTestRequests.Arrange(r); _eatAllHitTestRequests.Arrange(r);
_markerCanvas.Arrange(r);
} }
return result; return result;
} }

10
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/DesignSurface.cs

@ -86,12 +86,18 @@ namespace ICSharpCode.WpfDesign.Designer
#region Command: Delete #region Command: Delete
void OnDeleteExecuted(object sender, ExecutedRoutedEventArgs e) void OnDeleteExecuted(object sender, ExecutedRoutedEventArgs e)
{ {
if (_designContext != null) {
ModelTools.DeleteComponents(_designContext.Services.Selection.SelectedItems);
}
} }
void OnDeleteCanExecute(object sender, CanExecuteRoutedEventArgs e) void OnDeleteCanExecute(object sender, CanExecuteRoutedEventArgs e)
{ {
if (_designContext != null) {
e.CanExecute = ModelTools.CanDeleteComponents(_designContext.Services.Selection.SelectedItems);
} else {
e.CanExecute = false;
}
} }
#endregion #endregion

8
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Extensions/CanvasPlacementSupport.cs

@ -34,7 +34,9 @@ namespace ICSharpCode.WpfDesign.Designer.Extensions
/// <inherits/> /// <inherits/>
public bool CanPlace(ICollection<DesignItem> child, PlacementType type, PlacementAlignment position) public bool CanPlace(ICollection<DesignItem> child, PlacementType type, PlacementAlignment position)
{ {
return type == PlacementType.Resize || type == PlacementType.Move || type == PlacementType.Delete; return type == PlacementType.Resize || type == PlacementType.Move
|| type == PlacementType.Delete
|| type == PlacementType.AddItem;
} }
/// <inherits/> /// <inherits/>
@ -84,7 +86,9 @@ namespace ICSharpCode.WpfDesign.Designer.Extensions
/// <inherits/> /// <inherits/>
public void BeginPlacement(PlacementOperation op) public void BeginPlacement(PlacementOperation op)
{ {
GrayOutDesignerExceptActiveArea.Start(ref grayOut, this.Services, this.ExtendedItem.View); if (op.Type == PlacementType.Move || op.Type == PlacementType.Resize) {
GrayOutDesignerExceptActiveArea.Start(ref grayOut, this.Services, this.ExtendedItem.View);
}
} }
/// <inherits/> /// <inherits/>

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

@ -39,14 +39,14 @@ namespace ICSharpCode.WpfDesign.Designer.Extensions
this.Adorners.Add(adornerPanel); this.Adorners.Add(adornerPanel);
resizeThumbs = new ResizeThumb[] { resizeThumbs = new ResizeThumb[] {
CreateThumb(PlacementAlignments.TopLeft, Cursors.SizeNWSE), CreateThumb(PlacementAlignment.TopLeft, Cursors.SizeNWSE),
CreateThumb(PlacementAlignments.Top, Cursors.SizeNS), CreateThumb(PlacementAlignment.Top, Cursors.SizeNS),
CreateThumb(PlacementAlignments.TopRight, Cursors.SizeNESW), CreateThumb(PlacementAlignment.TopRight, Cursors.SizeNESW),
CreateThumb(PlacementAlignments.Left, Cursors.SizeWE), CreateThumb(PlacementAlignment.Left, Cursors.SizeWE),
CreateThumb(PlacementAlignments.Right, Cursors.SizeWE), CreateThumb(PlacementAlignment.Right, Cursors.SizeWE),
CreateThumb(PlacementAlignments.BottomLeft, Cursors.SizeNESW), CreateThumb(PlacementAlignment.BottomLeft, Cursors.SizeNESW),
CreateThumb(PlacementAlignments.Bottom, Cursors.SizeNS), CreateThumb(PlacementAlignment.Bottom, Cursors.SizeNS),
CreateThumb(PlacementAlignments.BottomRight, Cursors.SizeNWSE) CreateThumb(PlacementAlignment.BottomRight, Cursors.SizeNWSE)
}; };
} }

6
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Extensions/WindowResizeBehavior.cs

@ -29,9 +29,9 @@ namespace ICSharpCode.WpfDesign.Designer.Extensions
public bool CanPlace(ICollection<DesignItem> children, PlacementType type, PlacementAlignment position) public bool CanPlace(ICollection<DesignItem> children, PlacementType type, PlacementAlignment position)
{ {
return type == PlacementType.Resize && return type == PlacementType.Resize &&
(position == PlacementAlignments.Right (position == PlacementAlignment.Right
|| position == PlacementAlignments.BottomRight || position == PlacementAlignment.BottomRight
|| position == PlacementAlignments.Bottom); || position == PlacementAlignment.Bottom);
} }

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

@ -6,6 +6,7 @@
// </file> // </file>
using System; using System;
using System.Collections.Generic;
using System.Windows; using System.Windows;
namespace ICSharpCode.WpfDesign.Designer namespace ICSharpCode.WpfDesign.Designer
@ -43,6 +44,32 @@ namespace ICSharpCode.WpfDesign.Designer
return 0; return 0;
} }
/// <summary>
/// Gets if the specified components can be deleted.
/// </summary>
public static bool CanDeleteComponents(ICollection<DesignItem> items)
{
IPlacementBehavior b = PlacementOperation.GetPlacementBehavior(items);
return b != null
&& b.CanPlace(items, PlacementType.Delete, PlacementAlignment.Center);
}
/// <summary>
/// Deletes the specified components from their parent containers.
/// If the deleted components are currently selected, they are deselected before they are deleted.
/// </summary>
public static void DeleteComponents(ICollection<DesignItem> items)
{
PlacementOperation operation = PlacementOperation.Start(items, PlacementType.Delete);
try {
Func.First(items).Services.Selection.SetSelectedComponents(items, SelectionTypes.Remove);
operation.DeleteItemsAndCommit();
} catch {
operation.Abort();
throw;
}
}
internal static Size GetDefaultSize(DesignItem createdItem) internal static Size GetDefaultSize(DesignItem createdItem)
{ {
return new Size(GetWidth(createdItem.View), GetHeight(createdItem.View)); return new Size(GetWidth(createdItem.View), GetHeight(createdItem.View));

7
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Services/CreateComponentTool.cs

@ -64,7 +64,7 @@ namespace ICSharpCode.WpfDesign.Designer.Services
/// </summary> /// </summary>
protected virtual DesignItem CreateItem(DesignContext context) protected virtual DesignItem CreateItem(DesignContext context)
{ {
object newInstance = Activator.CreateInstance(componentType); object newInstance = context.Services.ExtensionManager.CreateInstanceWithCustomInstanceFactory(componentType, null);
return context.Services.Component.RegisterComponentForDesigner(newInstance); return context.Services.Component.RegisterComponentForDesigner(newInstance);
} }
@ -104,7 +104,7 @@ namespace ICSharpCode.WpfDesign.Designer.Services
container, container,
new DesignItem[] { createdItem }, new DesignItem[] { createdItem },
new Rect[] { new Rect(position, ModelTools.GetDefaultSize(createdItem)) }, new Rect[] { new Rect(position, ModelTools.GetDefaultSize(createdItem)) },
PlacementType.Move PlacementType.AddItem
); );
if (operation != null) { if (operation != null) {
container.Services.Selection.SetSelectedComponents(new DesignItem[] { createdItem }); container.Services.Selection.SetSelectedComponents(new DesignItem[] { createdItem });
@ -124,9 +124,6 @@ namespace ICSharpCode.WpfDesign.Designer.Services
if (result.ModelHit != null) { if (result.ModelHit != null) {
IPlacementBehavior behavior = result.ModelHit.GetBehavior<IPlacementBehavior>(); IPlacementBehavior behavior = result.ModelHit.GetBehavior<IPlacementBehavior>();
if (behavior != null) { if (behavior != null) {
// ensure the design panel has the focus - otherwise pressing Escape to abort creating doesn't work
designPanel.Focus();
DesignItem createdItem = CreateItem(designPanel.Context); DesignItem createdItem = CreateItem(designPanel.Context);
new CreateComponentMouseGesture(result.ModelHit, createdItem).Start(designPanel, e); new CreateComponentMouseGesture(result.ModelHit, createdItem).Start(designPanel, e);

2
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Services/DragMoveMouseGesture.cs

@ -42,7 +42,7 @@ namespace ICSharpCode.WpfDesign.Designer.Services
protected override void OnDragStarted(MouseEventArgs e) protected override void OnDragStarted(MouseEventArgs e)
{ {
IPlacementBehavior b = PlacementOperation.GetPlacementBehavior(selectedItems); IPlacementBehavior b = PlacementOperation.GetPlacementBehavior(selectedItems);
if (b != null && b.CanPlace(selectedItems, PlacementType.Move, PlacementAlignments.TopLeft)) { if (b != null && b.CanPlace(selectedItems, PlacementType.Move, PlacementAlignment.TopLeft)) {
List<DesignItem> sortedSelectedItems = new List<DesignItem>(selectedItems); List<DesignItem> sortedSelectedItems = new List<DesignItem>(selectedItems);
sortedSelectedItems.Sort(ModelTools.ComparePositionInModelFile); sortedSelectedItems.Sort(ModelTools.ComparePositionInModelFile);
selectedItems = sortedSelectedItems; selectedItems = sortedSelectedItems;

2
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Services/MouseGestureBase.cs

@ -45,7 +45,6 @@ namespace ICSharpCode.WpfDesign.Designer.Services
isStarted = true; isStarted = true;
this.designPanel = designPanel; this.designPanel = designPanel;
this.services = designPanel.Context.Services; this.services = designPanel.Context.Services;
designPanel.IsAdornerLayerHitTestVisible = false;
if (designPanel.CaptureMouse()) { if (designPanel.CaptureMouse()) {
RegisterEvents(); RegisterEvents();
OnStarted(e); OnStarted(e);
@ -104,7 +103,6 @@ namespace ICSharpCode.WpfDesign.Designer.Services
isStarted = false; isStarted = false;
designPanel.ReleaseMouseCapture(); designPanel.ReleaseMouseCapture();
UnRegisterEvents(); UnRegisterEvents();
designPanel.IsAdornerLayerHitTestVisible = true;
OnStopped(); OnStopped();
} }

13
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Xaml/XamlDesignContext.cs

@ -55,22 +55,11 @@ namespace ICSharpCode.WpfDesign.Designer.Xaml
propertyGridEditorManager.RegisterAssembly(typeof(XamlDesignContext).Assembly); propertyGridEditorManager.RegisterAssembly(typeof(XamlDesignContext).Assembly);
XamlParserSettings xamlParseSettings = new XamlParserSettings(); XamlParserSettings xamlParseSettings = new XamlParserSettings();
xamlParseSettings.CreateInstanceCallback = OnXamlParserCreateInstance; xamlParseSettings.CreateInstanceCallback = this.Services.ExtensionManager.CreateInstanceWithCustomInstanceFactory;
_doc = XamlParser.Parse(xamlReader, xamlParseSettings); _doc = XamlParser.Parse(xamlReader, xamlParseSettings);
_rootItem = _componentService.RegisterXamlComponentRecursive(_doc.RootElement); _rootItem = _componentService.RegisterXamlComponentRecursive(_doc.RootElement);
} }
object OnXamlParserCreateInstance(Type instanceType, object[] arguments)
{
foreach (Type extensionType in this.Services.ExtensionManager.GetExtensionTypes(instanceType)) {
if (typeof(CustomInstanceFactory).IsAssignableFrom(extensionType)) {
CustomInstanceFactory factory = (CustomInstanceFactory)Activator.CreateInstance(extensionType);
return factory.CreateInstance(instanceType, arguments);
}
}
return CustomInstanceFactory.DefaultInstanceFactory.CreateInstance(instanceType, arguments);
}
/// <summary> /// <summary>
/// Saves the XAML DOM into the XML writer. /// Saves the XAML DOM into the XML writer.
/// </summary> /// </summary>

27
src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/Extensions/ExtensionManager.cs

@ -98,6 +98,8 @@ namespace ICSharpCode.WpfDesign.Extensions
/// </summary> /// </summary>
public IEnumerable<Type> GetExtensionTypes(Type extendedItemType) public IEnumerable<Type> GetExtensionTypes(Type extendedItemType)
{ {
if (extendedItemType == null)
throw new ArgumentNullException("extendedItemType");
foreach (ExtensionEntry entry in GetExtensionEntries(extendedItemType)) { foreach (ExtensionEntry entry in GetExtensionEntries(extendedItemType)) {
yield return entry.ExtensionType; yield return entry.ExtensionType;
} }
@ -194,6 +196,9 @@ namespace ICSharpCode.WpfDesign.Extensions
/// </summary> /// </summary>
public ExtensionServer GetExtensionServer(ExtensionServerAttribute attribute) public ExtensionServer GetExtensionServer(ExtensionServerAttribute attribute)
{ {
if (attribute == null)
throw new ArgumentNullException("attribute");
Type extensionServerType = attribute.ExtensionServerType; Type extensionServerType = attribute.ExtensionServerType;
ExtensionServer server; ExtensionServer server;
@ -209,5 +214,27 @@ namespace ICSharpCode.WpfDesign.Extensions
return server; return server;
} }
#endregion #endregion
#region Special extensions (Instance Factory)
/// <summary>
/// Create an instance of the specified type using the specified arguments.
/// The instance is created using a CustomInstanceFactory registered for the type,
/// or using reflection if no instance factory is found.
/// </summary>
public object CreateInstanceWithCustomInstanceFactory(Type instanceType, object[] arguments)
{
if (instanceType == null)
throw new ArgumentNullException("instanceType");
if (arguments == null)
arguments = new object[0];
foreach (Type extensionType in GetExtensionTypes(instanceType)) {
if (typeof(CustomInstanceFactory).IsAssignableFrom(extensionType)) {
CustomInstanceFactory factory = (CustomInstanceFactory)Activator.CreateInstance(extensionType);
return factory.CreateInstance(instanceType, arguments);
}
}
return CustomInstanceFactory.DefaultInstanceFactory.CreateInstance(instanceType, arguments);
}
#endregion
} }
} }

9
src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/PlacementAlignment.cs

@ -81,13 +81,8 @@ namespace ICSharpCode.WpfDesign
return !(lhs.Equals(rhs)); return !(lhs.Equals(rhs));
} }
#endregion #endregion
}
/// <summary>
/// Contains known PlacementAlignment values like an enumeration.
/// </summary>
public static class PlacementAlignments
{
/// <summary>Top left</summary> /// <summary>Top left</summary>
public static readonly PlacementAlignment TopLeft = new PlacementAlignment(HorizontalAlignment.Left, VerticalAlignment.Top); public static readonly PlacementAlignment TopLeft = new PlacementAlignment(HorizontalAlignment.Left, VerticalAlignment.Top);
/// <summary>Top center</summary> /// <summary>Top center</summary>

21
src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/PlacementOperation.cs

@ -82,9 +82,14 @@ namespace ICSharpCode.WpfDesign
{ {
if (newContainer == null) if (newContainer == null)
throw new ArgumentNullException("newContainer"); throw new ArgumentNullException("newContainer");
if (isAborted || isCommitted)
throw new InvalidOperationException("The operation is not running anymore.");
if (currentContainer == newContainer) if (currentContainer == newContainer)
return; return;
if (!currentContainerBehavior.CanLeaveContainer(this))
throw new NotSupportedException("The items cannot be removed from their parent container.");
try { try {
currentContainerBehavior.LeaveContainer(this); currentContainerBehavior.LeaveContainer(this);
@ -107,6 +112,22 @@ namespace ICSharpCode.WpfDesign
} }
#endregion #endregion
#region Delete Items
/// <summary>
/// Deletes the items being placed, and commits the placement operation.
/// </summary>
public void DeleteItemsAndCommit()
{
if (isAborted || isCommitted)
throw new InvalidOperationException("The operation is not running anymore.");
if (!currentContainerBehavior.CanLeaveContainer(this))
throw new NotSupportedException("The items cannot be removed from their parent container.");
currentContainerBehavior.LeaveContainer(this);
Commit();
}
#endregion
#region Start #region Start
/// <summary> /// <summary>
/// Starts a new placement operation that changes the placement of <paramref name="placedItem"/>. /// Starts a new placement operation that changes the placement of <paramref name="placedItem"/>.

11
src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/PlacementType.cs

@ -15,17 +15,24 @@ namespace ICSharpCode.WpfDesign
public sealed class PlacementType public sealed class PlacementType
{ {
/// <summary> /// <summary>
/// Placement is done by resizing an element. /// Placement is done by resizing an element in a drag'n'drop operation.
/// </summary> /// </summary>
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Security", "CA2104:DoNotDeclareReadOnlyMutableReferenceTypes")] [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Security", "CA2104:DoNotDeclareReadOnlyMutableReferenceTypes")]
public static readonly PlacementType Resize = Register("Resize"); public static readonly PlacementType Resize = Register("Resize");
/// <summary> /// <summary>
/// Placement is done by moving an element. /// Placement is done by moving an element in a drag'n'drop operation.
/// </summary> /// </summary>
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Security", "CA2104:DoNotDeclareReadOnlyMutableReferenceTypes")] [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Security", "CA2104:DoNotDeclareReadOnlyMutableReferenceTypes")]
public static readonly PlacementType Move = Register("Move"); public static readonly PlacementType Move = Register("Move");
/// <summary>
/// Adding an element to a specified position in the container.
/// T
/// </summary>
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Security", "CA2104:DoNotDeclareReadOnlyMutableReferenceTypes")]
public static readonly PlacementType AddItem = Register("AddItem");
/// <summary> /// <summary>
/// Not a "real" placement, but deleting the element. /// Not a "real" placement, but deleting the element.
/// </summary> /// </summary>

2
src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/PropertyEditor/DesignItemDataSource.cs

@ -98,7 +98,7 @@ namespace ICSharpCode.WpfDesign.PropertyEditor
sources[i++] = GetDataSourceForDesignItem(item); sources[i++] = GetDataSourceForDesignItem(item);
} }
return MultiSelectionDataSource.CreateDataSource(context != null ? context.Services : null, sources); return MultipleSelectionDataSource.CreateDataSource(context != null ? context.Services : null, sources);
} }
/// <summary> /// <summary>

1
src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/PropertyEditor/FallbackEditor.cs

@ -36,6 +36,7 @@ namespace ICSharpCode.WpfDesign.PropertyEditor
OnValueChanged(null, null); OnValueChanged(null, null);
} }
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1031:DoNotCatchGeneralExceptionTypes")]
void OnValueChanged(object sender, EventArgs e) void OnValueChanged(object sender, EventArgs e)
{ {
if (property.IsSet) { if (property.IsSet) {

3
src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/PropertyEditor/IPropertyEditorDataSource.cs

@ -93,7 +93,8 @@ namespace ICSharpCode.WpfDesign.PropertyEditor
/// Gets the description of the property. The returned object should be something that /// Gets the description of the property. The returned object should be something that
/// can be used as Content for a WPF tooltip. /// can be used as Content for a WPF tooltip.
/// </summary> /// </summary>
object GetDescription(); [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1024:UsePropertiesWhereAppropriate")]
object GetDescription(); // is not a property because it can create a new instance on every call
/// <summary> /// <summary>
/// Gets/Sets if the property has been assigned a local value. /// Gets/Sets if the property has been assigned a local value.

6
src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/PropertyEditor/MultiSelectionDataProperty.cs → src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/PropertyEditor/MultipleSelectionDataProperty.cs

@ -10,12 +10,12 @@ using System.Diagnostics;
namespace ICSharpCode.WpfDesign.PropertyEditor namespace ICSharpCode.WpfDesign.PropertyEditor
{ {
sealed class MultiSelectionDataProperty : IPropertyEditorDataProperty sealed class MultipleSelectionDataProperty : IPropertyEditorDataProperty
{ {
readonly MultiSelectionDataSource ownerDataSource; readonly MultipleSelectionDataSource ownerDataSource;
readonly IPropertyEditorDataProperty[] data; readonly IPropertyEditorDataProperty[] data;
public MultiSelectionDataProperty(MultiSelectionDataSource ownerDataSource, IPropertyEditorDataProperty[] data) public MultipleSelectionDataProperty(MultipleSelectionDataSource ownerDataSource, IPropertyEditorDataProperty[] data)
{ {
Debug.Assert(ownerDataSource != null); Debug.Assert(ownerDataSource != null);
Debug.Assert(data != null); Debug.Assert(data != null);

8
src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/PropertyEditor/MultiSelectionDataSource.cs → src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/PropertyEditor/MultipleSelectionDataSource.cs

@ -13,7 +13,7 @@ namespace ICSharpCode.WpfDesign.PropertyEditor
/// <summary> /// <summary>
/// Implements IPropertyEditorDataSource by combining the information from multiple data sources. /// Implements IPropertyEditorDataSource by combining the information from multiple data sources.
/// </summary> /// </summary>
public sealed class MultiSelectionDataSource : IPropertyEditorDataSource public sealed class MultipleSelectionDataSource : IPropertyEditorDataSource
{ {
/// <summary> /// <summary>
/// Creates a data source for a collection of data sources. /// Creates a data source for a collection of data sources.
@ -35,7 +35,7 @@ namespace ICSharpCode.WpfDesign.PropertyEditor
} }
throw new InvalidOperationException(); throw new InvalidOperationException();
} else { } else {
return new MultiSelectionDataSource(services, sources); return new MultipleSelectionDataSource(services, sources);
} }
} }
@ -47,7 +47,7 @@ namespace ICSharpCode.WpfDesign.PropertyEditor
/// <summary> /// <summary>
/// Creates a new MultiSelectionDataSource instance. /// Creates a new MultiSelectionDataSource instance.
/// </summary> /// </summary>
public MultiSelectionDataSource(ServiceContainer services, ICollection<IPropertyEditorDataSource> sources) public MultipleSelectionDataSource(ServiceContainer services, ICollection<IPropertyEditorDataSource> sources)
{ {
this.services = services; this.services = services;
if (sources == null) if (sources == null)
@ -73,7 +73,7 @@ namespace ICSharpCode.WpfDesign.PropertyEditor
} }
if (properties != null) { if (properties != null) {
this.properties.Add(new MultiSelectionDataProperty(this, properties)); this.properties.Add(new MultipleSelectionDataProperty(this, properties));
} }
} }
} }

2
src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/PropertyEditor/TextBoxEditor.cs

@ -93,6 +93,7 @@ namespace ICSharpCode.WpfDesign.PropertyEditor
base.OnTextChanged(e); base.OnTextChanged(e);
} }
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1031:DoNotCatchGeneralExceptionTypes")]
protected override void OnLostFocus(RoutedEventArgs e) protected override void OnLostFocus(RoutedEventArgs e)
{ {
if (isDirty) { if (isDirty) {
@ -113,6 +114,7 @@ namespace ICSharpCode.WpfDesign.PropertyEditor
base.OnLostFocus(e); base.OnLostFocus(e);
} }
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1031:DoNotCatchGeneralExceptionTypes")]
protected override void OnKeyDown(KeyEventArgs e) protected override void OnKeyDown(KeyEventArgs e)
{ {
base.OnKeyDown(e); base.OnKeyDown(e);

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

@ -89,14 +89,14 @@
<Compile Include="PlacementOperation.cs" /> <Compile Include="PlacementOperation.cs" />
<Compile Include="PlacementType.cs" /> <Compile Include="PlacementType.cs" />
<Compile Include="PropertyEditor\BooleanEditor.cs" /> <Compile Include="PropertyEditor\BooleanEditor.cs" />
<Compile Include="PropertyEditor\MultiSelectionDataProperty.cs" /> <Compile Include="PropertyEditor\MultipleSelectionDataProperty.cs" />
<Compile Include="PropertyEditor\StandardValuesComboBoxEditor.cs" /> <Compile Include="PropertyEditor\StandardValuesComboBoxEditor.cs" />
<Compile Include="PropertyEditor\DesignItemDataProperty.cs" /> <Compile Include="PropertyEditor\DesignItemDataProperty.cs" />
<Compile Include="PropertyEditor\DesignItemDataSource.cs" /> <Compile Include="PropertyEditor\DesignItemDataSource.cs" />
<Compile Include="PropertyEditor\EditorManager.cs" /> <Compile Include="PropertyEditor\EditorManager.cs" />
<Compile Include="PropertyEditor\FallbackEditor.cs" /> <Compile Include="PropertyEditor\FallbackEditor.cs" />
<Compile Include="PropertyEditor\IPropertyEditorDataSource.cs" /> <Compile Include="PropertyEditor\IPropertyEditorDataSource.cs" />
<Compile Include="PropertyEditor\MultiSelectionDataSource.cs" /> <Compile Include="PropertyEditor\MultipleSelectionDataSource.cs" />
<Compile Include="PropertyEditor\TextBoxEditor.cs" /> <Compile Include="PropertyEditor\TextBoxEditor.cs" />
<Compile Include="PropertyEditor\PropertyEditorAttribute.cs" /> <Compile Include="PropertyEditor\PropertyEditorAttribute.cs" />
<Compile Include="PropertyEditor\PropertyEditorBindingHelper.cs" /> <Compile Include="PropertyEditor\PropertyEditorBindingHelper.cs" />

Loading…
Cancel
Save