Browse Source

Show a Border around multiple Selected Items and a TopLeftContainerDragHandle (multipleItems)

pull/446/head
jkuehner 12 years ago
parent
commit
78fe8ec698
  1. 2
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Controls/PanelMoveAdorner.cs
  2. 6
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Extensions/TopLeftContainerDragHandle.cs
  3. 93
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Extensions/TopLeftContainerDragHandleMultipleItems.cs
  4. 1
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/WpfDesign.Designer.csproj

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

@ -54,7 +54,7 @@ namespace ICSharpCode.WpfDesign.Designer.Controls
protected override void OnMouseLeftButtonDown(MouseButtonEventArgs e) protected override void OnMouseLeftButtonDown(MouseButtonEventArgs e)
{ {
e.Handled = true; e.Handled = true;
item.Services.Selection.SetSelectedComponents(new DesignItem [] { item }, SelectionTypes.Auto); //item.Services.Selection.SetSelectedComponents(new DesignItem [] { item }, SelectionTypes.Auto);
new DragMoveMouseGesture(item, false).Start(item.Services.DesignPanel, e); new DragMoveMouseGesture(item, false).Start(item.Services.DesignPanel, e);
} }

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

@ -32,9 +32,9 @@ namespace ICSharpCode.WpfDesign.Designer.Extensions
{ {
/// <summary> /// <summary>
/// The drag handle displayed for panels. /// The drag handle displayed for Framework Elements
/// </summary> /// </summary>
[ExtensionServer(typeof(PrimarySelectionExtensionServer))] [ExtensionServer(typeof(OnlyOneItemSelectedExtensionServer))]
[ExtensionFor(typeof(FrameworkElement))] [ExtensionFor(typeof(FrameworkElement))]
public class TopLeftContainerDragHandle : AdornerProvider public class TopLeftContainerDragHandle : AdornerProvider
{ {
@ -44,7 +44,7 @@ namespace ICSharpCode.WpfDesign.Designer.Extensions
ContainerDragHandle rect = new ContainerDragHandle(); ContainerDragHandle rect = new ContainerDragHandle();
rect.PreviewMouseDown += delegate(object sender, MouseButtonEventArgs e) { rect.PreviewMouseDown += delegate(object sender, MouseButtonEventArgs e) {
Services.Selection.SetSelectedComponents(new DesignItem[] { this.ExtendedItem }, SelectionTypes.Auto); //Services.Selection.SetSelectedComponents(new DesignItem[] { this.ExtendedItem }, SelectionTypes.Auto);
new DragMoveMouseGesture(this.ExtendedItem, false).Start(this.ExtendedItem.Services.DesignPanel,e); new DragMoveMouseGesture(this.ExtendedItem, false).Start(this.ExtendedItem.Services.DesignPanel,e);
e.Handled=true; e.Handled=true;
}; };

93
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Extensions/TopLeftContainerDragHandleMultipleItems.cs

@ -0,0 +1,93 @@
// 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.Windows.Controls;
using System.Windows;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Shapes;
using ICSharpCode.WpfDesign.Adorners;
using ICSharpCode.WpfDesign.Extensions;
using ICSharpCode.WpfDesign.Designer.Services;
using ICSharpCode.WpfDesign.Designer.Controls;
namespace ICSharpCode.WpfDesign.Designer.Extensions
{
/// <summary>
/// The drag handle displayed for Framework Elements
/// </summary>
[ExtensionServer(typeof(PrimarySelectionButOnlyWhenMultipleSelectedExtensionServer))]
[ExtensionFor(typeof(FrameworkElement))]
public class TopLeftContainerDragHandleMultipleItems : AdornerProvider
{
/// <summary/>
public TopLeftContainerDragHandleMultipleItems()
{ }
protected override void OnInitialized()
{
base.OnInitialized();
ContainerDragHandle rect = new ContainerDragHandle();
rect.PreviewMouseDown += delegate(object sender, MouseButtonEventArgs e) {
//Services.Selection.SetSelectedComponents(new DesignItem[] { this.ExtendedItem }, SelectionTypes.Auto);
new DragMoveMouseGesture(this.ExtendedItem, false).Start(this.ExtendedItem.Services.DesignPanel,e);
e.Handled=true;
};
var items = this.ExtendedItem.Services.Selection.SelectedItems;
double minX = 0;
double minY = 0;
double maxX = 0;
double maxY = 0;
foreach (DesignItem di in items) {
Point relativeLocation = di.View.TranslatePoint(new Point(0, 0), this.ExtendedItem.View);
minX = minX < relativeLocation.X ? minX : relativeLocation.X;
minY = minY < relativeLocation.Y ? minY : relativeLocation.Y;
maxX = maxX > relativeLocation.X + ((FrameworkElement)this.ExtendedItem.View).ActualWidth ? maxX : relativeLocation.X + ((FrameworkElement)this.ExtendedItem.View).ActualWidth;
maxY = maxY > relativeLocation.Y + ((FrameworkElement)this.ExtendedItem.View).ActualHeight ? maxY : relativeLocation.Y + ((FrameworkElement)this.ExtendedItem.View).ActualHeight;
}
Rectangle rect2 = new Rectangle() {
Width = (maxX - minX) + 4,
Height = (maxY - minY) + 4,
Stroke = Brushes.Black,
StrokeThickness = 2,
StrokeDashArray = new DoubleCollection(){ 2, 2 },
};
RelativePlacement p = new RelativePlacement(HorizontalAlignment.Left, VerticalAlignment.Top);
p.XOffset = minX - 3;
p.YOffset = minY - 3;
RelativePlacement p2 = new RelativePlacement(HorizontalAlignment.Left, VerticalAlignment.Top);
p2.XOffset = (minX + rect2.Width) - 2;
p2.YOffset = (minY + rect2.Height) - 2;
AddAdorner(p, AdornerOrder.Background, rect);
AddAdorner(p2, AdornerOrder.Background, rect2);
}
}
}

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

@ -88,6 +88,7 @@
<Compile Include="Extensions\RenderTransformOriginExtension.cs" /> <Compile Include="Extensions\RenderTransformOriginExtension.cs" />
<Compile Include="Extensions\RightClickContextMenuExtension.cs" /> <Compile Include="Extensions\RightClickContextMenuExtension.cs" />
<Compile Include="Extensions\SkewThumbExtension.cs" /> <Compile Include="Extensions\SkewThumbExtension.cs" />
<Compile Include="Extensions\TopLeftContainerDragHandleMultipleItems.cs" />
<Compile Include="PropertyGrid\Editors\FlatCollectionEditor.xaml.cs"> <Compile Include="PropertyGrid\Editors\FlatCollectionEditor.xaml.cs">
<DependentUpon>FlatCollectionEditor.xaml</DependentUpon> <DependentUpon>FlatCollectionEditor.xaml</DependentUpon>
<SubType>Code</SubType> <SubType>Code</SubType>

Loading…
Cancel
Save