Browse Source

Merge pull request #584 from jogibear9988/master

WPF Designer multiple Fixes
pull/586/head
Siegfried Pammer 12 years ago
parent
commit
9f1d12bd37
  1. 18
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/ArrangeDirection.cs
  2. 54
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/BasicMetadata.cs
  3. 20
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Controls/AdornerLayer.cs
  4. 8
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Controls/CanvasPositionHandle.cs
  5. 23
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Controls/ControlStyles.xaml
  6. 4
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Controls/ResizeThumb.cs
  7. 34
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Converters.cs
  8. 100
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/DesignPanel.cs
  9. 3
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/DesignSurface.cs
  10. 36
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Extensions/ArrangeItemsContextMenu.xaml
  11. 65
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Extensions/ArrangeItemsContextMenu.xaml.cs
  12. 57
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Extensions/ArrangeItemsContextMenuExtension.cs
  13. 106
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Extensions/BorderForImageControl.cs
  14. 8
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Extensions/BorderForInvisibleControl.cs
  15. 10
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Extensions/CanvasPlacementSupport.cs
  16. 20
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Extensions/DefaultPlacementBehavior.cs
  17. 8
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Extensions/GridPlacementSupport.cs
  18. 2
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Extensions/InPlaceEditorExtension.cs
  19. 4
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Extensions/Initializers.cs
  20. 2
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Extensions/MarginHandleExtension.cs
  21. 26
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Extensions/PartialPanelSelectionHandler.cs
  22. 26
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Extensions/RightClickContextMenu.xaml
  23. 10
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Extensions/RightClickContextMenu.xaml.cs
  24. 14
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Extensions/RightClickContextMenuExtension.cs
  25. 5
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Extensions/RotateThumbExtension.cs
  26. 20
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Extensions/SkewThumbExtension.cs
  27. 37
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Extensions/SnaplinePlacementBehavior.cs
  28. 11
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Extensions/TextBlockRightClickContextMenu.xaml
  29. 51
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Extensions/TextBlockRightClickContextMenu.xaml.cs
  30. 53
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Extensions/TextBlockRightClickContextMenuExtension.cs
  31. 4
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Extensions/TopLeftContainerDragHandleMultipleItems.cs
  32. 11
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Extensions/WrapItemContextMenu.xaml
  33. 41
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Extensions/WrapItemContextMenu.xaml.cs
  34. 23
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Extensions/WrapItemContextMenuExtension.cs
  35. 16
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Extensions/WrapItemsContextMenu.xaml
  36. 16
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Extensions/WrapItemsContextMenu.xaml.cs
  37. 57
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Extensions/WrapItemsContextMenuExtension.cs
  38. BIN
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Images/canvas.png
  39. BIN
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Images/edit-bold.png
  40. BIN
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Images/edit-color.png
  41. BIN
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Images/edit-italic.png
  42. BIN
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Images/edit-strike.png
  43. BIN
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Images/edit-underline.png
  44. BIN
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Images/edit.png
  45. BIN
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Images/grid.png
  46. BIN
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Images/layers-alignment-bottom.png
  47. BIN
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Images/layers-alignment-center.png
  48. BIN
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Images/layers-alignment-left.png
  49. BIN
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Images/layers-alignment-middle.png
  50. BIN
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Images/layers-alignment-right.png
  51. BIN
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Images/layers-alignment.png
  52. BIN
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Images/layers-arrange-back.png
  53. BIN
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Images/layers-arrange.png
  54. BIN
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Images/layers-stack-arrange-back.png
  55. BIN
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Images/layers-stack-arrange.png
  56. BIN
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Images/paint-can-color.png
  57. BIN
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Images/wrap-option.png
  58. 421
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/ModelTools.cs
  59. 832
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/PropertyGrid/Editors/FormatedTextEditor/FormatedTextEditor.xaml
  60. 211
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/PropertyGrid/Editors/FormatedTextEditor/FormatedTextEditor.xaml.cs
  61. 68
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Translations.cs
  62. 73
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/WpfDesign.Designer.csproj
  63. 11
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Tests/Designer/OutlineView/InsertTests.cs
  64. 2
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Tests/Designer/PlacementTests.cs
  65. 5
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Tests/WpfDesign.Tests.csproj
  66. 24
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Tests/XamlDom/CollectionTests.cs
  67. 1
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Tests/XamlDom/MarkupExtensionTests.cs
  68. 227
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Tests/XamlDom/SamplesTests.cs
  69. 6
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.XamlDom/Project/CollectionSupport.cs
  70. 2
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.XamlDom/Project/XamlObject.cs
  71. 64
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.XamlDom/Project/XamlObjectServiceProvider.cs
  72. 78
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.XamlDom/Project/XamlParser.cs
  73. 50
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.XamlDom/Project/XamlProperty.cs
  74. 3
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/Adorners/AdornerPanel.cs
  75. 32
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/Extensions/ExtensionAttribute.cs
  76. 11
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/Extensions/ExtensionManager.cs
  77. 4
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/Metadata.cs
  78. 31
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/PlacementOperation.cs
  79. 1
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/PropertyGrid/TypeHelper.cs
  80. 2
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/Tools.cs
  81. 1
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/WpfDesign.csproj
  82. BIN
      src/Libraries/WPFExtendedToolkit/Xceed.Wpf.Toolkit.dll

18
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/ArrangeDirection.cs

@ -0,0 +1,18 @@ @@ -0,0 +1,18 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ICSharpCode.WpfDesign.Designer
{
public enum ArrangeDirection
{
Top,
VerticalMiddle,
Bottom,
Left,
HorizontalMiddle,
Right,
}
}

54
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/BasicMetadata.cs

@ -145,7 +145,9 @@ namespace ICSharpCode.WpfDesign.Designer @@ -145,7 +145,9 @@ namespace ICSharpCode.WpfDesign.Designer
Metadata.AddPopularProperty(TreeViewItem.IsSelectedProperty);
Metadata.AddPopularProperty(Border.PaddingProperty);
Metadata.AddPopularProperty(Shape.StretchProperty);
Metadata.AddPopularProperty(Control.VerticalContentAlignmentProperty);
Metadata.AddPopularProperty(Control.HorizontalContentAlignmentProperty);
Metadata.AddPopularProperty(Grid.RowProperty);
Metadata.AddPopularProperty(Grid.RowSpanProperty);
Metadata.AddPopularProperty(Grid.ColumnProperty);
@ -230,14 +232,14 @@ namespace ICSharpCode.WpfDesign.Designer @@ -230,14 +232,14 @@ namespace ICSharpCode.WpfDesign.Designer
Metadata.AddPopularControl(typeof(Border));
Metadata.AddPopularControl(typeof(Canvas));
Metadata.AddPopularControl(typeof(CheckBox));
Metadata.AddPopularControl(typeof(ComboBox));
Metadata.AddPopularControl(typeof(ComboBox));
Metadata.AddPopularControl(typeof(DataGrid));
Metadata.AddPopularControl(typeof(DockPanel));
Metadata.AddPopularControl(typeof(Expander));
Metadata.AddPopularControl(typeof(Grid));
Metadata.AddPopularControl(typeof(GroupBox));
Metadata.AddPopularControl(typeof(Image));
Metadata.AddPopularControl(typeof(InkCanvas));
Metadata.AddPopularControl(typeof(Image));
Metadata.AddPopularControl(typeof(InkCanvas));
Metadata.AddPopularControl(typeof(Label));
Metadata.AddPopularControl(typeof(ListBox));
Metadata.AddPopularControl(typeof(ListView));
@ -249,7 +251,7 @@ namespace ICSharpCode.WpfDesign.Designer @@ -249,7 +251,7 @@ namespace ICSharpCode.WpfDesign.Designer
Metadata.AddPopularControl(typeof(RichTextBox));
Metadata.AddPopularControl(typeof(StackPanel));
Metadata.AddPopularControl(typeof(ScrollViewer));
Metadata.AddPopularControl(typeof(Slider));
Metadata.AddPopularControl(typeof(Slider));
Metadata.AddPopularControl(typeof(TabControl));
Metadata.AddPopularControl(typeof(TextBlock));
Metadata.AddPopularControl(typeof(TextBox));
@ -259,28 +261,30 @@ namespace ICSharpCode.WpfDesign.Designer @@ -259,28 +261,30 @@ namespace ICSharpCode.WpfDesign.Designer
Metadata.AddPopularControl(typeof(Viewport3D));
Metadata.AddPopularControl(typeof(WrapPanel));
Metadata.AddDefaultSize(typeof(UIElement), new Size(120, 100));
Metadata.AddDefaultSize(typeof(ContentControl), new Size(120, 20));
Metadata.AddDefaultSize(typeof(Button), new Size(75, 23));
//Basic Metadata Size of double.NaN, means no Size should be set.
Metadata.AddDefaultSize(typeof(TextBlock), new Size(double.NaN, double.NaN));
Metadata.AddDefaultSize(typeof(CheckBox), new Size(double.NaN, double.NaN));
Metadata.AddDefaultSize(typeof(Image), new Size(double.NaN, double.NaN));
Metadata.AddDefaultSize(typeof(UIElement), new Size(120, 100));
Metadata.AddDefaultSize(typeof(ContentControl), new Size(120, 20));
Metadata.AddDefaultSize(typeof(Button), new Size(75, 23));
Metadata.AddDefaultSize(typeof(ToggleButton), new Size(75, 23));
var s1 = new Size(120, 20);
Metadata.AddDefaultSize(typeof(Slider), s1);
Metadata.AddDefaultSize(typeof(TextBox), s1);
Metadata.AddDefaultSize(typeof(PasswordBox), s1);
Metadata.AddDefaultSize(typeof(ComboBox), s1);
Metadata.AddDefaultSize(typeof(ProgressBar), s1);
Metadata.AddDefaultSize(typeof(Slider), new Size(120, 20));
Metadata.AddDefaultSize(typeof(TextBox), new Size(120, 20));
Metadata.AddDefaultSize(typeof(PasswordBox), new Size(120, 20));
Metadata.AddDefaultSize(typeof(ComboBox), new Size(120, 20));
Metadata.AddDefaultSize(typeof(ProgressBar), new Size(120, 20));
Metadata.AddDefaultSize(typeof(ToolBar), s1);
Metadata.AddDefaultSize(typeof(Menu), s1);
var s2=new Size(120,120);
Metadata.AddDefaultSize(typeof(InkCanvas),s2);
Metadata.AddDefaultSize(typeof(Image),s2);
Metadata.AddDefaultSize(typeof(TreeView),s2);
var s3=new Size(130,120);
Metadata.AddDefaultSize(typeof(Label),s3);
Metadata.AddDefaultSize(typeof(Expander),s3);
Metadata.AddDefaultSize(typeof(ToolBar), new Size(120, 20));
Metadata.AddDefaultSize(typeof(Menu), new Size(120, 20));
Metadata.AddDefaultSize(typeof(InkCanvas), new Size(120, 120));
Metadata.AddDefaultSize(typeof(TreeView), new Size(120, 120));
Metadata.AddDefaultSize(typeof(Label), new Size(130, 120));
Metadata.AddDefaultSize(typeof(Expander), new Size(130, 120));
}
}
}

20
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Controls/AdornerLayer.cs

@ -32,7 +32,7 @@ namespace ICSharpCode.WpfDesign.Designer.Controls @@ -32,7 +32,7 @@ namespace ICSharpCode.WpfDesign.Designer.Controls
/// <summary>
/// A control that displays adorner panels.
/// </summary>
sealed class AdornerLayer : Panel
public sealed class AdornerLayer : Panel
{
#region AdornerPanelCollection
internal sealed class AdornerPanelCollection : ICollection<AdornerPanel>, IReadOnlyCollection<AdornerPanel>
@ -218,13 +218,23 @@ namespace ICSharpCode.WpfDesign.Designer.Controls @@ -218,13 +218,23 @@ namespace ICSharpCode.WpfDesign.Designer.Controls
}
return new Size(0, 0);
}
protected override Size ArrangeOverride(Size finalSize)
{
foreach (AdornerPanel adorner in this.Children) {
if (adorner.AdornedElement.IsDescendantOf(_designPanel)) {
adorner.RenderTransform = (Transform)adorner.AdornedElement.TransformToAncestor(_designPanel);
foreach (AdornerPanel adorner in this.Children) {
if (adorner.AdornedElement.IsDescendantOf(_designPanel))
{
var rt = (MatrixTransform) adorner.AdornedElement.TransformToAncestor(_designPanel);
if (adorner.AdornedDesignItem != null && adorner.AdornedDesignItem.Parent != null && adorner.AdornedDesignItem.Parent.View is Canvas && adorner.AdornedElement.RenderSize.Height == 0 && adorner.AdornedElement.RenderSize.Width == 0)
{
var xOffset = rt.Matrix.OffsetX - (((FrameworkElement)adorner.AdornedElement).Width / 2);
var yOffset = rt.Matrix.OffsetY - (((FrameworkElement)adorner.AdornedElement).Height / 2);
rt = new MatrixTransform(new Matrix(rt.Matrix.M11, rt.Matrix.M12, rt.Matrix.M21, rt.Matrix.M22, xOffset, yOffset));
}
adorner.RenderTransform = rt;
}
adorner.Arrange(new Rect(new Point(0, 0), adorner.DesiredSize));
}
return finalSize;

8
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Controls/CanvasPositionHandle.cs

@ -146,7 +146,7 @@ namespace ICSharpCode.WpfDesign.Designer.Controls @@ -146,7 +146,7 @@ namespace ICSharpCode.WpfDesign.Designer.Controls
if (double.IsNaN(wr))
{
wr = (double) rightDescriptor.GetValue(adornedControl);
wr = canvas.ActualWidth - (adornedControl.ActualWidth + wr);
wr = canvas.ActualWidth - (PlacementOperation.GetRealElementSize(adornedControl).Width + wr);
}
else
{
@ -167,7 +167,7 @@ namespace ICSharpCode.WpfDesign.Designer.Controls @@ -167,7 +167,7 @@ namespace ICSharpCode.WpfDesign.Designer.Controls
if (double.IsNaN(wr))
{
wr = (double)bottomDescriptor.GetValue(adornedControl);
wr = canvas.ActualHeight - (adornedControl.ActualHeight + wr);
wr = canvas.ActualHeight - (PlacementOperation.GetRealElementSize(adornedControl).Height + wr);
}
else
{
@ -188,7 +188,7 @@ namespace ICSharpCode.WpfDesign.Designer.Controls @@ -188,7 +188,7 @@ namespace ICSharpCode.WpfDesign.Designer.Controls
if (double.IsNaN(wr))
{
wr = (double) leftDescriptor.GetValue(adornedControl);
wr = canvas.ActualWidth - (adornedControl.ActualWidth + wr);
wr = canvas.ActualWidth - (PlacementOperation.GetRealElementSize(adornedControl).Width + wr);
}
else
{
@ -209,7 +209,7 @@ namespace ICSharpCode.WpfDesign.Designer.Controls @@ -209,7 +209,7 @@ namespace ICSharpCode.WpfDesign.Designer.Controls
if (double.IsNaN(wr))
{
wr = (double)topDescriptor.GetValue(adornedControl);
wr = canvas.ActualHeight - (adornedControl.ActualHeight + wr);
wr = canvas.ActualHeight - (PlacementOperation.GetRealElementSize(adornedControl).Height + wr);
}
else
{

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

@ -333,7 +333,16 @@ @@ -333,7 +333,16 @@
<RowDefinition Height="5" />
</Grid.RowDefinitions>
<Path SnapsToDevicePixels="True" Grid.Row="0" Stroke="#AC0000" StrokeThickness="1.0" Data="M0,0 L1,0 M0.75,0 L0.75,1" Stretch="Fill" />
<TextBlock Text="{Binding Path=ActualHeight, Converter={x:Static Converters:FormatDoubleConverter.Instance}}" HorizontalAlignment="Center" Margin="8,0,0,1" Padding="1,1,1,1" FontSize="10" Grid.Row="1">
<TextBlock HorizontalAlignment="Center" Margin="8,0,0,1" Padding="1,1,1,1" FontSize="10" Grid.Row="1">
<TextBlock.Text>
<MultiBinding Converter="{x:Static Converters:ControlToRealHeightConverter.Instance}" StringFormat="0">
<MultiBinding.Bindings>
<Binding />
<Binding Path="ActualHeight" UpdateSourceTrigger="PropertyChanged" />
<Binding Path="Height" UpdateSourceTrigger="PropertyChanged" />
</MultiBinding.Bindings>
</MultiBinding>
</TextBlock.Text>
<TextBlock.LayoutTransform>
<RotateTransform Angle="270" CenterX="0.5" CenterY="0.5" />
</TextBlock.LayoutTransform>
@ -355,7 +364,17 @@ @@ -355,7 +364,17 @@
<ColumnDefinition Width="5" />
</Grid.ColumnDefinitions>
<Path Grid.Column="0" Stroke="#AC0000" StrokeThickness="1" Data="M0,0 L0,1 M0,0.75 L1,0.75" Stretch="Fill" SnapsToDevicePixels="True" />
<TextBlock Text="{Binding Path=ActualWidth, Converter={x:Static Converters:FormatDoubleConverter.Instance}}" HorizontalAlignment="Center" Margin="0,8,0,0" Padding="1,1,1,1" FontSize="10" Grid.Column="1" />
<TextBlock HorizontalAlignment="Center" Margin="0,8,0,0" Padding="1,1,1,1" FontSize="10" Grid.Column="1">
<TextBlock.Text>
<MultiBinding Converter="{x:Static Converters:ControlToRealWidthConverter.Instance}" StringFormat="0">
<MultiBinding.Bindings>
<Binding />
<Binding Path="ActualWidth" UpdateSourceTrigger="PropertyChanged" />
<Binding Path="Width" UpdateSourceTrigger="PropertyChanged" />
</MultiBinding.Bindings>
</MultiBinding>
</TextBlock.Text>
</TextBlock>
<Path Grid.Column="2" Stroke="#AC0000" StrokeThickness="1" Data="M0,0.75 L3,0.75 M3,0 L3,1 " Stretch="Fill" SnapsToDevicePixels="True" />
</Grid>
</ControlTemplate>

4
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Controls/ResizeThumb.cs

@ -90,9 +90,9 @@ namespace ICSharpCode.WpfDesign.Designer.Controls @@ -90,9 +90,9 @@ namespace ICSharpCode.WpfDesign.Designer.Controls
AdornerPanel parent = this.Parent as AdornerPanel;
if (parent != null && parent.AdornedElement != null) {
if (checkWidth)
this.ResizeThumbVisible = parent.AdornedElement.RenderSize.Width > 14;
this.ResizeThumbVisible = PlacementOperation.GetRealElementSize(parent.AdornedElement).Width > 14;
else if (checkHeight)
this.ResizeThumbVisible = parent.AdornedElement.RenderSize.Height > 14;
this.ResizeThumbVisible = PlacementOperation.GetRealElementSize(parent.AdornedElement).Height > 14;
}
return base.ArrangeOverride(arrangeBounds);
}

34
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Converters.cs

@ -159,8 +159,38 @@ namespace ICSharpCode.WpfDesign.Designer.Converters @@ -159,8 +159,38 @@ namespace ICSharpCode.WpfDesign.Designer.Converters
return value;
}
}
public class FormatDoubleConverter : IValueConverter
public class ControlToRealWidthConverter : IMultiValueConverter
{
public static readonly ControlToRealWidthConverter Instance = new ControlToRealWidthConverter();
public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture)
{
return PlacementOperation.GetRealElementSize((UIElement)values[0]).Width;
}
public object[] ConvertBack(object value, Type[] targetTypes, object parameter, CultureInfo culture)
{
throw new NotImplementedException();
}
}
public class ControlToRealHeightConverter : IMultiValueConverter
{
public static readonly ControlToRealHeightConverter Instance = new ControlToRealHeightConverter();
public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture)
{
return PlacementOperation.GetRealElementSize((UIElement)values[0]).Height;
}
public object[] ConvertBack(object value, Type[] targetTypes, object parameter, CultureInfo culture)
{
throw new NotImplementedException();
}
}
public class FormatDoubleConverter : IValueConverter
{
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Security", "CA2104:DoNotDeclareReadOnlyMutableReferenceTypes", Justification = "converter is immutable")]
public static readonly FormatDoubleConverter Instance=new FormatDoubleConverter();

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

@ -17,11 +17,15 @@ @@ -17,11 +17,15 @@
// DEALINGS IN THE SOFTWARE.
using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.ComponentModel;
using System.Diagnostics;
using System.Linq;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Threading;
@ -58,27 +62,27 @@ namespace ICSharpCode.WpfDesign.Designer @@ -58,27 +62,27 @@ namespace ICSharpCode.WpfDesign.Designer
void RunHitTest(Visual reference, Point point, HitTestFilterCallback filterCallback, HitTestResultCallback resultCallback)
{
VisualTreeHelper.HitTest(reference, filterCallback, resultCallback,
new PointHitTestParameters(point));
new PointHitTestParameters(point));
}
HitTestFilterBehavior FilterHitTestInvisibleElements(DependencyObject potentialHitTestTarget)
{
UIElement element = potentialHitTestTarget as UIElement;
if (element != null) {
if (!(element.IsHitTestVisible && element.Visibility == Visibility.Visible)) {
return HitTestFilterBehavior.ContinueSkipSelfAndChildren;
}
var designItem = Context.Services.Component.GetDesignItem(element) as XamlDesignItem;
if (designItem != null && designItem.IsDesignTimeLocked) {
return HitTestFilterBehavior.ContinueSkipSelfAndChildren;
}
}
}
hitTestElements.Add(element);
return HitTestFilterBehavior.Continue;
}
@ -91,14 +95,14 @@ namespace ICSharpCode.WpfDesign.Designer @@ -91,14 +95,14 @@ namespace ICSharpCode.WpfDesign.Designer
DesignPanelHitTestResult result = DesignPanelHitTestResult.NoHit;
HitTest(mousePosition, testAdorners, testDesignSurface,
delegate(DesignPanelHitTestResult r) {
result = r;
return false;
}, hitTestType);
delegate(DesignPanelHitTestResult r) {
result = r;
return false;
}, hitTestType);
return result;
}
/// <summary>
/// Performs a hit test on the design surface, raising <paramref name="callback"/> for each match.
/// Hit testing continues while the callback returns true.
@ -115,7 +119,7 @@ namespace ICSharpCode.WpfDesign.Designer @@ -115,7 +119,7 @@ namespace ICSharpCode.WpfDesign.Designer
HitTestFilterCallback filterBehavior = CustomHitTestFilterBehavior ?? FilterHitTestInvisibleElements;
CustomHitTestFilterBehavior = null;
hitTestElements.Clear();
if (testAdorners) {
RunHitTest(
@ -152,8 +156,8 @@ namespace ICSharpCode.WpfDesign.Designer @@ -152,8 +156,8 @@ namespace ICSharpCode.WpfDesign.Designer
if (hitTestType == HitTestType.ElementSelection)
{
if (Keyboard.IsKeyDown(Key.LeftAlt))
if (lastElement != null && lastElement != _context.RootItem.Component &&
hitTestElements.Contains(lastElement))
if (lastElement != null && lastElement != _context.RootItem.Component &&
hitTestElements.Contains(lastElement))
{
var idx = hitTestElements.IndexOf(lastElement) - 1;
if (idx >= 0)
@ -215,6 +219,15 @@ namespace ICSharpCode.WpfDesign.Designer @@ -215,6 +219,15 @@ namespace ICSharpCode.WpfDesign.Designer
//Set custom HitTestFilterCallbak
public HitTestFilterCallback CustomHitTestFilterBehavior { get; set; }
public AdornerLayer AdornerLayer
{
get
{
return _adornerLayer;
}
}
/// <summary>
/// Gets/Sets the design context.
/// </summary>
@ -403,9 +416,9 @@ namespace ICSharpCode.WpfDesign.Designer @@ -403,9 +416,9 @@ namespace ICSharpCode.WpfDesign.Designer
if (!Keyboard.IsKeyDown(Key.LeftCtrl)) {
info.Bounds = new Rect(bounds.Left + dx,
bounds.Top + dy,
bounds.Width,
bounds.Height);
bounds.Top + dy,
bounds.Width,
bounds.Height);
} else {
if (info.OriginalBounds.Width + dx >= 0 && info.OriginalBounds.Height + dy >= 0) {
info.Bounds = new Rect(info.OriginalBounds.Left,
@ -421,9 +434,9 @@ namespace ICSharpCode.WpfDesign.Designer @@ -421,9 +434,9 @@ namespace ICSharpCode.WpfDesign.Designer
}
static bool IsPropertySet(UIElement element, DependencyProperty d)
{
return element.ReadLocalValue(d) != DependencyProperty.UnsetValue;
}
{
return element.ReadLocalValue(d) != DependencyProperty.UnsetValue;
}
protected override void OnQueryCursor(QueryCursorEventArgs e)
{
@ -443,5 +456,54 @@ namespace ICSharpCode.WpfDesign.Designer @@ -443,5 +456,54 @@ namespace ICSharpCode.WpfDesign.Designer
PropertyChangedEventHandler handler = PropertyChanged;
if (handler != null) handler(this, new PropertyChangedEventArgs(propertyName));
}
#region ContextMenu
private Dictionary<ContextMenu, Tuple<int,List<object>>> contextMenusAndEntries = new Dictionary<ContextMenu, Tuple<int,List<object>>>();
public void AddContextMenu(ContextMenu contextMenu)
{
contextMenusAndEntries.Add(contextMenu, new Tuple<int, List<object>>(contextMenusAndEntries.Count, new List<object>(contextMenu.Items.Cast<object>())));
contextMenu.Items.Clear();
UpdateContextMenu();
}
public void RemoveContextMenu(ContextMenu contextMenu)
{
contextMenusAndEntries.Remove(contextMenu);
UpdateContextMenu();
}
public void ClearContextMenu()
{
contextMenusAndEntries.Clear();
ContextMenu = null;
}
private void UpdateContextMenu()
{
if (contextMenusAndEntries.Count == 0)
this.ContextMenu = null;
if (this.ContextMenu == null)
this.ContextMenu = new ContextMenu();
this.ContextMenu.Items.Clear();
foreach (var entries in contextMenusAndEntries.Values.OrderBy(x => x.Item1).Select(x => x.Item2))
{
if (this.ContextMenu.Items.Count > 0)
this.ContextMenu.Items.Add(new Separator());
foreach (var entry in entries)
{
ContextMenu.Items.Add(entry);
}
}
}
#endregion
}
}

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

@ -155,8 +155,9 @@ namespace ICSharpCode.WpfDesign.Designer @@ -155,8 +155,9 @@ namespace ICSharpCode.WpfDesign.Designer
{
_designContext = context;
_designPanel.Context = context;
_designPanel.ClearContextMenu();
if (context.RootItem != null) {
if (context.RootItem != null) {
_sceneContainer.Child = context.RootItem.View;
}

36
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Extensions/ArrangeItemsContextMenu.xaml

@ -0,0 +1,36 @@ @@ -0,0 +1,36 @@
<ContextMenu x:Class="ICSharpCode.WpfDesign.Designer.Extensions.ArrangeItemsContextMenu"
xmlns="http://schemas.microsoft.com/netfx/2007/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:Translation="clr-namespace:ICSharpCode.WpfDesign.Designer"
>
<MenuItem Header="{Binding ArrangeLeft, Source={x:Static Translation:Translations.Instance}}" Click="Click_ArrangeLeft">
<MenuItem.Icon>
<Image Source="/ICSharpCode.WpfDesign.Designer;component/Images/layers-alignment-left.png" />
</MenuItem.Icon>
</MenuItem>
<MenuItem Header="{Binding ArrangeHorizontalMiddle, Source={x:Static Translation:Translations.Instance}}" Click="Click_ArrangeHorizontalCentered">
<MenuItem.Icon>
<Image Source="/ICSharpCode.WpfDesign.Designer;component/Images/layers-alignment-center.png" />
</MenuItem.Icon>
</MenuItem>
<MenuItem Header="{Binding ArrangeRight, Source={x:Static Translation:Translations.Instance}}" Click="Click_ArrangeRight">
<MenuItem.Icon>
<Image Source="/ICSharpCode.WpfDesign.Designer;component/Images/layers-alignment-right.png" />
</MenuItem.Icon>
</MenuItem>
<MenuItem Header="{Binding ArrangeTop, Source={x:Static Translation:Translations.Instance}}" Click="Click_ArrangeTop">
<MenuItem.Icon>
<Image Source="/ICSharpCode.WpfDesign.Designer;component/Images/layers-alignment.png" />
</MenuItem.Icon>
</MenuItem>
<MenuItem Header="{Binding ArrangeVerticalMiddle, Source={x:Static Translation:Translations.Instance}}" Click="Click_ArrangeVerticalCentered">
<MenuItem.Icon>
<Image Source="/ICSharpCode.WpfDesign.Designer;component/Images/layers-alignment-middle.png" />
</MenuItem.Icon>
</MenuItem>
<MenuItem Header="{Binding ArrangeBottom, Source={x:Static Translation:Translations.Instance}}" Click="Click_ArrangeBottom">
<MenuItem.Icon>
<Image Source="/ICSharpCode.WpfDesign.Designer;component/Images/layers-alignment-bottom.png" />
</MenuItem.Icon>
</MenuItem>
</ContextMenu>

65
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Extensions/ArrangeItemsContextMenu.xaml.cs

@ -0,0 +1,65 @@ @@ -0,0 +1,65 @@
// 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.Linq;
namespace ICSharpCode.WpfDesign.Designer.Extensions
{
public partial class ArrangeItemsContextMenu
{
private DesignItem designItem;
public ArrangeItemsContextMenu(DesignItem designItem)
{
this.designItem = designItem;
InitializeComponent();
}
void Click_ArrangeLeft(object sender, System.Windows.RoutedEventArgs e)
{
ModelTools.ArrangeItems(this.designItem.Services.Selection.SelectedItems, ArrangeDirection.Left);
}
void Click_ArrangeHorizontalCentered(object sender, System.Windows.RoutedEventArgs e)
{
ModelTools.ArrangeItems(this.designItem.Services.Selection.SelectedItems, ArrangeDirection.HorizontalMiddle);
}
void Click_ArrangeRight(object sender, System.Windows.RoutedEventArgs e)
{
ModelTools.ArrangeItems(this.designItem.Services.Selection.SelectedItems, ArrangeDirection.Right);
}
void Click_ArrangeTop(object sender, System.Windows.RoutedEventArgs e)
{
ModelTools.ArrangeItems(this.designItem.Services.Selection.SelectedItems, ArrangeDirection.Top);
}
void Click_ArrangeVerticalCentered(object sender, System.Windows.RoutedEventArgs e)
{
ModelTools.ArrangeItems(this.designItem.Services.Selection.SelectedItems, ArrangeDirection.VerticalMiddle);
}
void Click_ArrangeBottom(object sender, System.Windows.RoutedEventArgs e)
{
ModelTools.ArrangeItems(this.designItem.Services.Selection.SelectedItems, ArrangeDirection.Bottom);
}
}
}

57
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Extensions/ArrangeItemsContextMenuExtension.cs

@ -0,0 +1,57 @@ @@ -0,0 +1,57 @@
// 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;
using System.Windows.Controls;
using ICSharpCode.WpfDesign.Adorners;
using ICSharpCode.WpfDesign.Extensions;
using ICSharpCode.WpfDesign.Designer;
namespace ICSharpCode.WpfDesign.Designer.Extensions
{
/// <summary>
///
/// </summary>
[ExtensionServer(typeof(PrimarySelectionButOnlyWhenMultipleSelectedExtensionServer))]
[ExtensionFor(typeof(UIElement))]
[Extension(Order = 30)]
public class ArrangeItemsContextMenuExtension : SelectionAdornerProvider
{
DesignPanel panel;
ContextMenu contextMenu;
protected override void OnInitialized()
{
base.OnInitialized();
contextMenu = new ArrangeItemsContextMenu(ExtendedItem);
panel = ExtendedItem.Context.Services.DesignPanel as DesignPanel;
if (panel != null)
panel.AddContextMenu(contextMenu);
}
protected override void OnRemove()
{
if (panel != null)
panel.RemoveContextMenu(contextMenu);
base.OnRemove();
}
}
}

106
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Extensions/BorderForImageControl.cs

@ -0,0 +1,106 @@ @@ -0,0 +1,106 @@
// 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.ComponentModel;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Input;
using System.Windows.Media;
using ICSharpCode.WpfDesign.Adorners;
using ICSharpCode.WpfDesign.Designer.Controls;
using ICSharpCode.WpfDesign.Extensions;
namespace ICSharpCode.WpfDesign.Designer.Extensions
{
[ExtensionFor(typeof(Image))]
public class BorderForImageControl : PermanentAdornerProvider
{
AdornerPanel adornerPanel;
AdornerPanel cachedAdornerPanel;
Border border;
protected override void OnInitialized()
{
base.OnInitialized();
this.ExtendedItem.PropertyChanged += OnPropertyChanged;
UpdateAdorner();
}
protected override void OnRemove()
{
this.ExtendedItem.PropertyChanged -= OnPropertyChanged;
base.OnRemove();
}
void OnPropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)
{
if (sender == null || e.PropertyName == "Width" || e.PropertyName == "Height")
{
((DesignPanel) this.ExtendedItem.Services.DesignPanel).AdornerLayer.UpdateAdornersForElement(this.ExtendedItem.View, true);
}
}
void UpdateAdorner()
{
var element = ExtendedItem.Component as UIElement;
if (element != null) {
CreateAdorner();
}
}
private void CreateAdorner()
{
if (adornerPanel == null) {
if (cachedAdornerPanel == null) {
cachedAdornerPanel = new AdornerPanel();
cachedAdornerPanel.Order = AdornerOrder.Background;
border = new Border();
border.BorderThickness = new Thickness(1);
border.BorderBrush = new SolidColorBrush(Color.FromRgb(0xCC, 0xCC, 0xCC));
border.Background = Brushes.Transparent;
border.IsHitTestVisible = true;
border.MouseDown += border_MouseDown;
AdornerPanel.SetPlacement(border, AdornerPlacement.FillContent);
cachedAdornerPanel.Children.Add(border);
}
adornerPanel = cachedAdornerPanel;
Adorners.Add(adornerPanel);
}
}
void border_MouseDown(object sender, System.Windows.Input.MouseButtonEventArgs e)
{
if (!Keyboard.IsKeyDown(Key.LeftAlt) && ((Image) this.ExtendedItem.View).Source == null)
{
e.Handled = true;
this.ExtendedItem.Services.Selection.SetSelectedComponents(new DesignItem[] {this.ExtendedItem},
SelectionTypes.Auto);
((DesignPanel) this.ExtendedItem.Services.DesignPanel).Focus();
}
}
}
}

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

@ -39,8 +39,8 @@ namespace ICSharpCode.WpfDesign.Designer.Extensions @@ -39,8 +39,8 @@ namespace ICSharpCode.WpfDesign.Designer.Extensions
{
AdornerPanel adornerPanel;
AdornerPanel cachedAdornerPanel;
protected override void OnInitialized()
protected override void OnInitialized()
{
base.OnInitialized();
@ -58,9 +58,9 @@ namespace ICSharpCode.WpfDesign.Designer.Extensions @@ -58,9 +58,9 @@ namespace ICSharpCode.WpfDesign.Designer.Extensions
element.IsVisibleChanged += (s, e) => UpdateAdorner();
}
}
}
}
void UpdateAdorner()
void UpdateAdorner()
{
var element = ExtendedItem.Component as UIElement;
if (element != null) {

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

@ -70,19 +70,21 @@ namespace ICSharpCode.WpfDesign.Designer.Extensions @@ -70,19 +70,21 @@ namespace ICSharpCode.WpfDesign.Designer.Extensions
if (IsPropertySet(child, Canvas.LeftProperty) || !IsPropertySet(child, Canvas.RightProperty)) {
x = GetCanvasProperty(child, Canvas.LeftProperty);
} else {
x = extendedComponent.ActualWidth - GetCanvasProperty(child, Canvas.RightProperty) - child.RenderSize.Width;
x = extendedComponent.ActualWidth - GetCanvasProperty(child, Canvas.RightProperty) - PlacementOperation.GetRealElementSize(child).Width;
}
if (IsPropertySet(child, Canvas.TopProperty) || !IsPropertySet(child, Canvas.BottomProperty)) {
y = GetCanvasProperty(child, Canvas.TopProperty);
} else {
y = extendedComponent.ActualHeight - GetCanvasProperty(child, Canvas.BottomProperty) - child.RenderSize.Height;
y = extendedComponent.ActualHeight - GetCanvasProperty(child, Canvas.BottomProperty) - PlacementOperation.GetRealElementSize(child).Height;
}
var p = new Point(x, y);
return new Rect(p, child.RenderSize);
}
//Fixes, Empty Image Resized to 0
//return new Rect(p, child.RenderSize);
return new Rect(p, PlacementOperation.GetRealElementSize(item.View));
}
public override void SetPosition(PlacementInformation info)
{

20
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Extensions/DefaultPlacementBehavior.cs

@ -79,15 +79,19 @@ namespace ICSharpCode.WpfDesign.Designer.Extensions @@ -79,15 +79,19 @@ namespace ICSharpCode.WpfDesign.Designer.Extensions
public virtual void EndPlacement(PlacementOperation operation)
{
InfoTextEnterArea.Stop(ref infoTextEnterArea);
}
InfoTextEnterArea.Stop(ref infoTextEnterArea);
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)
{
if (item.View == null)
return Rect.Empty;
var p = item.View.TranslatePoint(new Point(), operation.CurrentContainer.View);
return new Rect(p, item.View.RenderSize);
return new Rect(p, PlacementOperation.GetRealElementSize(item.View));
}
public virtual void BeforeSetPosition(PlacementOperation operation)
@ -96,7 +100,8 @@ namespace ICSharpCode.WpfDesign.Designer.Extensions @@ -96,7 +100,8 @@ namespace ICSharpCode.WpfDesign.Designer.Extensions
public virtual void SetPosition(PlacementInformation info)
{
ModelTools.Resize(info.Item, info.Bounds.Width, info.Bounds.Height);
if (info.Operation.Type != PlacementType.Move)
ModelTools.Resize(info.Item, info.Bounds.Width, info.Bounds.Height);
}
public virtual bool CanLeaveContainer(PlacementOperation operation)
@ -158,7 +163,10 @@ namespace ICSharpCode.WpfDesign.Designer.Extensions @@ -158,7 +163,10 @@ namespace ICSharpCode.WpfDesign.Designer.Extensions
return false;
}
}
if (ExtendedItem.ContentProperty.ReturnType == typeof(string))
return false;
if (!ExtendedItem.ContentProperty.IsSet)
return true;
@ -180,7 +188,7 @@ namespace ICSharpCode.WpfDesign.Designer.Extensions @@ -180,7 +188,7 @@ namespace ICSharpCode.WpfDesign.Designer.Extensions
foreach (var info in operation.PlacedItems) {
SetPosition(info);
}
}
}
}
}
}

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

@ -220,13 +220,13 @@ namespace ICSharpCode.WpfDesign.Designer.Extensions @@ -220,13 +220,13 @@ namespace ICSharpCode.WpfDesign.Designer.Extensions
if (ha == HorizontalAlignment.Stretch)
info.Item.Properties[FrameworkElement.WidthProperty].Reset();
else
info.Item.Properties[FrameworkElement.WidthProperty].SetValue(info.Bounds.Width);
//else
// info.Item.Properties[FrameworkElement.WidthProperty].SetValue(info.Bounds.Width);
if (va == VerticalAlignment.Stretch)
info.Item.Properties[FrameworkElement.HeightProperty].Reset();
else
info.Item.Properties[FrameworkElement.HeightProperty].SetValue(info.Bounds.Height);
//else
// info.Item.Properties[FrameworkElement.HeightProperty].SetValue(info.Bounds.Height);
}
public override void LeaveContainer(PlacementOperation operation)

2
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Extensions/InPlaceEditorExtension.cs

@ -34,7 +34,7 @@ namespace ICSharpCode.WpfDesign.Designer.Extensions @@ -34,7 +34,7 @@ namespace ICSharpCode.WpfDesign.Designer.Extensions
/// <summary>
/// Extends In-Place editor to edit any text in the designer which is wrapped in the Visual tree under TexBlock
/// </summary>
[ExtensionFor(typeof(FrameworkElement))]
[ExtensionFor(typeof(TextBlock))]
public class InPlaceEditorExtension : PrimarySelectionAdornerProvider
{
AdornerPanel adornerPanel;

4
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Extensions/Initializers.cs

@ -63,7 +63,9 @@ namespace ICSharpCode.WpfDesign.Designer.Extensions.Initializers @@ -63,7 +63,9 @@ namespace ICSharpCode.WpfDesign.Designer.Extensions.Initializers
if (textProperty.ValueOnInstance == null || textProperty.ValueOnInstance.ToString() == "")
{
textProperty.SetValue(item.ComponentType.Name);
}
item.Properties[FrameworkElement.WidthProperty].Reset();
item.Properties[FrameworkElement.HeightProperty].Reset();
}
DesignItemProperty verticalAlignmentProperty = item.Properties["VerticalAlignment"];
if (verticalAlignmentProperty.ValueOnInstance == null)

2
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Extensions/MarginHandleExtension.cs

@ -82,7 +82,7 @@ namespace ICSharpCode.WpfDesign.Designer.Extensions @@ -82,7 +82,7 @@ namespace ICSharpCode.WpfDesign.Designer.Extensions
var margin = (Thickness) this.ExtendedItem.Properties[FrameworkElement.MarginProperty].ValueOnInstance;
var point = this.ExtendedItem.View.TranslatePoint(new Point(), _grid);
var position = new Rect(point, this.ExtendedItem.View.RenderSize);
var position = new Rect(point, PlacementOperation.GetRealElementSize(this.ExtendedItem.View));
MarginHandle handle = null;
if (sender is MarginHandle)
handle = sender as MarginHandle;

26
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Extensions/PartialPanelSelectionHandler.cs

@ -1,11 +1,21 @@ @@ -1,11 +1,21 @@
/*
* Created by SharpDevelop.
* User: trubra
* Date: 2014-08-06
* Time: 14:13
*
* To change this template use Tools | Options | Coding | Edit Standard Headers.
*/
// 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.Diagnostics;

26
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Extensions/RightClickContextMenu.xaml

@ -2,9 +2,25 @@ @@ -2,9 +2,25 @@
xmlns="http://schemas.microsoft.com/netfx/2007/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:Translation="clr-namespace:ICSharpCode.WpfDesign.Designer"
>
<MenuItem Header="{Binding SendToFrontText, Source={x:Static Translation:Translations.Instance}}" Click="Click_BringToFront" />
<MenuItem Header="{Binding SendForward, Source={x:Static Translation:Translations.Instance}}" Click="Click_Forward" />
<MenuItem Header="{Binding SendBackward, Source={x:Static Translation:Translations.Instance}}" Click="Click_Backward" />
<MenuItem Header="{Binding SendToBack, Source={x:Static Translation:Translations.Instance}}" Click="Click_SendToBack" />
>
<MenuItem Header="{Binding SendToFrontText, Source={x:Static Translation:Translations.Instance}}" Click="Click_BringToFront">
<MenuItem.Icon>
<Image Source="/ICSharpCode.WpfDesign.Designer;component/Images/layers-stack-arrange.png" />
</MenuItem.Icon>
</MenuItem>
<MenuItem Header="{Binding SendForward, Source={x:Static Translation:Translations.Instance}}" Click="Click_Forward">
<MenuItem.Icon>
<Image Source="/ICSharpCode.WpfDesign.Designer;component/Images/layers-arrange.png" />
</MenuItem.Icon>
</MenuItem>
<MenuItem Header="{Binding SendBackward, Source={x:Static Translation:Translations.Instance}}" Click="Click_Backward">
<MenuItem.Icon>
<Image Source="/ICSharpCode.WpfDesign.Designer;component/Images/layers-arrange-back.png" />
</MenuItem.Icon>
</MenuItem>
<MenuItem Header="{Binding SendToBack, Source={x:Static Translation:Translations.Instance}}" Click="Click_SendToBack">
<MenuItem.Icon>
<Image Source="/ICSharpCode.WpfDesign.Designer;component/Images/layers-stack-arrange-back.png" />
</MenuItem.Icon>
</MenuItem>
</ContextMenu>

10
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Extensions/RightClickContextMenu.xaml.cs

@ -19,17 +19,7 @@ @@ -19,17 +19,7 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using ICSharpCode.WpfDesign.PropertyGrid;
namespace ICSharpCode.WpfDesign.Designer.Extensions
{

14
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Extensions/RightClickContextMenuExtension.cs

@ -18,9 +18,7 @@ @@ -18,9 +18,7 @@
using System;
using System.Windows;
using System.Windows.Media;
using System.Windows.Shapes;
using System.Windows.Controls;
using ICSharpCode.WpfDesign.Adorners;
using ICSharpCode.WpfDesign.Extensions;
using ICSharpCode.WpfDesign.Designer;
@ -35,18 +33,22 @@ namespace ICSharpCode.WpfDesign.Designer.Extensions @@ -35,18 +33,22 @@ namespace ICSharpCode.WpfDesign.Designer.Extensions
public sealed class RightClickContextMenuExtension : PrimarySelectionAdornerProvider
{
DesignPanel panel;
ContextMenu contextMenu;
protected override void OnInitialized()
{
base.OnInitialized();
contextMenu = new RightClickContextMenu(ExtendedItem);
panel = ExtendedItem.Context.Services.DesignPanel as DesignPanel;
panel.ContextMenu = new RightClickContextMenu(ExtendedItem);
if (panel != null)
panel.AddContextMenu(contextMenu);
}
protected override void OnRemove()
{
panel.ContextMenu = null;
if (panel != null)
panel.RemoveContextMenu(contextMenu);
base.OnRemove();
}

5
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Extensions/RotateThumbExtension.cs

@ -42,7 +42,6 @@ namespace ICSharpCode.WpfDesign.Designer.Extensions @@ -42,7 +42,6 @@ namespace ICSharpCode.WpfDesign.Designer.Extensions
readonly DesignItem[] extendedItemArray = new DesignItem[1];
IPlacementBehavior resizeBehavior;
PlacementOperation operation;
private AdornerLayer _adornerLayer;
public RotateThumbExtension()
{
@ -81,8 +80,6 @@ namespace ICSharpCode.WpfDesign.Designer.Extensions @@ -81,8 +80,6 @@ namespace ICSharpCode.WpfDesign.Designer.Extensions
private void drag_Rotate_Started(DragListener drag)
{
_adornerLayer = this.adornerPanel.TryFindParent<AdornerLayer>();
var designerItem = this.ExtendedItem.Component as FrameworkElement;
this.parent = VisualTreeHelper.GetParent(designerItem) as UIElement;
this.centerPoint = designerItem.TranslatePoint(
@ -140,7 +137,7 @@ namespace ICSharpCode.WpfDesign.Designer.Extensions @@ -140,7 +137,7 @@ namespace ICSharpCode.WpfDesign.Designer.Extensions
}
rtTransform.Properties["Angle"].SetValue(destAngle);
_adornerLayer.UpdateAdornersForElement(this.ExtendedItem.View, true);
((DesignPanel) this.ExtendedItem.Services.DesignPanel).AdornerLayer.UpdateAdornersForElement(this.ExtendedItem.View, true);
}
}

20
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Extensions/SkewThumbExtension.cs

@ -226,16 +226,20 @@ namespace ICSharpCode.WpfDesign.Designer.Extensions @@ -226,16 +226,20 @@ namespace ICSharpCode.WpfDesign.Designer.Extensions
{
if (sender == null || e.PropertyName == "Width" || e.PropertyName == "Height") {
AdornerPanel.SetPlacement(thumb1,
new RelativePlacement(HorizontalAlignment.Center, VerticalAlignment.Top) {
YOffset = 0,
XOffset = -1 * ((FrameworkElement)ExtendedItem.View).ActualWidth / 4
});
new RelativePlacement(HorizontalAlignment.Center, VerticalAlignment.Top) {
YOffset = 0,
XOffset = -1 * PlacementOperation.GetRealElementSize(ExtendedItem.View).Width / 4
});
AdornerPanel.SetPlacement(thumb2,
new RelativePlacement(HorizontalAlignment.Left, VerticalAlignment.Center) {
YOffset = -1 * ((FrameworkElement)ExtendedItem.View).ActualHeight / 4,
XOffset = 0
});
new RelativePlacement(HorizontalAlignment.Left, VerticalAlignment.Center) {
YOffset = -1 * PlacementOperation.GetRealElementSize(ExtendedItem.View).Height / 4,
XOffset = 0
});
var designPanel = this.ExtendedItem.Services.DesignPanel as DesignPanel;
if (designPanel != null)
designPanel.AdornerLayer.UpdateAdornersForElement(this.ExtendedItem.View, true);
}
}

37
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Extensions/SnaplinePlacementBehavior.cs

@ -235,23 +235,26 @@ namespace ICSharpCode.WpfDesign.Designer.Extensions @@ -235,23 +235,26 @@ namespace ICSharpCode.WpfDesign.Designer.Extensions
void AddLines(Rect r, double inflate, bool requireOverlap, List<Snapline> h, List<Snapline> v, PlacementAlignment? filter)
{
Rect r2 = r;
r2.Inflate(inflate, inflate);
if (r != Rect.Empty)
{
Rect r2 = r;
r2.Inflate(inflate, inflate);
if (filter == null || filter.Value.Vertical == VerticalAlignment.Top)
h.Add(new Snapline() { RequireOverlap = requireOverlap, Offset = r2.Top - 1, Start = r.Left, End = r.Right });
if (filter == null || filter.Value.Vertical == VerticalAlignment.Bottom)
h.Add(new Snapline() { RequireOverlap = requireOverlap, Offset = r2.Bottom - 1, Start = r.Left, End = r.Right });
if (filter == null || filter.Value.Horizontal == HorizontalAlignment.Left)
v.Add(new Snapline() { RequireOverlap = requireOverlap, Offset = r2.Left - 1, Start = r.Top, End = r.Bottom });
if (filter == null || filter.Value.Horizontal == HorizontalAlignment.Right)
v.Add(new Snapline() { RequireOverlap = requireOverlap, Offset = r2.Right - 1, Start = r.Top, End = r.Bottom });
if (filter == null || filter.Value.Vertical == VerticalAlignment.Top)
h.Add(new Snapline() { RequireOverlap = requireOverlap, Offset = r2.Top - 1, Start = r.Left, End = r.Right });
if (filter == null || filter.Value.Vertical == VerticalAlignment.Bottom)
h.Add(new Snapline() { RequireOverlap = requireOverlap, Offset = r2.Bottom - 1, Start = r.Left, End = r.Right });
if (filter == null || filter.Value.Horizontal == HorizontalAlignment.Left)
v.Add(new Snapline() { RequireOverlap = requireOverlap, Offset = r2.Left - 1, Start = r.Top, End = r.Bottom });
if (filter == null || filter.Value.Horizontal == HorizontalAlignment.Right)
v.Add(new Snapline() { RequireOverlap = requireOverlap, Offset = r2.Right - 1, Start = r.Top, End = r.Bottom });
if (filter == null)
{
h.Add(new Snapline() { RequireOverlap = requireOverlap, Offset = r2.Top + Math.Abs((r2.Top - r2.Bottom) / 2), Start = r.Left, End = r.Right });
v.Add(new Snapline() { RequireOverlap = requireOverlap, Offset = r2.Left + Math.Abs((r2.Left - r2.Right) / 2), Start = r.Top, End = r.Bottom });
}
if (filter == null)
{
h.Add(new Snapline() { RequireOverlap = requireOverlap, Offset = r2.Top + Math.Abs((r2.Top - r2.Bottom) / 2), Start = r.Left, End = r.Right });
v.Add(new Snapline() { RequireOverlap = requireOverlap, Offset = r2.Left + Math.Abs((r2.Left - r2.Right) / 2), Start = r.Top, End = r.Bottom });
}
}
}
void AddBaseline(DesignItem item, Rect bounds, List<Snapline> list)
@ -276,6 +279,10 @@ namespace ICSharpCode.WpfDesign.Designer.Extensions @@ -276,6 +279,10 @@ namespace ICSharpCode.WpfDesign.Designer.Extensions
void DrawLine(double x1, double y1, double x2, double y2)
{
if (double.IsInfinity(x1) || double.IsNaN(x1) || double.IsInfinity(y1) || double.IsNaN(y1) ||
double.IsInfinity(x2) || double.IsNaN(x2) || double.IsInfinity(y2) || double.IsNaN(y2))
return;
var line1 = new Line() {
X1 = x1,
Y1 = y1,

11
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Extensions/RightClickMultipleItemsContextMenu.xaml → src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Extensions/TextBlockRightClickContextMenu.xaml

@ -1,8 +1,11 @@ @@ -1,8 +1,11 @@
<ContextMenu x:Class="ICSharpCode.WpfDesign.Designer.Extensions.RightClickMultipleItemsContextMenu"
<ContextMenu x:Class="ICSharpCode.WpfDesign.Designer.Extensions.TextBlockRightClickContextMenu"
xmlns="http://schemas.microsoft.com/netfx/2007/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:Translation="clr-namespace:ICSharpCode.WpfDesign.Designer"
>
<MenuItem Header="{Binding WrapInCanvas, Source={x:Static Translation:Translations.Instance}}" Click="Click_WrapInCanvas" />
<MenuItem Header="{Binding WrapInGrid, Source={x:Static Translation:Translations.Instance}}" Click="Click_WrapInGrid" />
>
<MenuItem Header="{Binding FormatedTextEditor, Source={x:Static Translation:Translations.Instance}}" Click="Click_EditFormatedText">
<MenuItem.Icon>
<Image Source="/ICSharpCode.WpfDesign.Designer;component/Images/edit.png" />
</MenuItem.Icon>
</MenuItem>
</ContextMenu>

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

@ -0,0 +1,51 @@ @@ -0,0 +1,51 @@
// 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.Linq;
using System.Windows;
using ICSharpCode.WpfDesign.Designer.PropertyGrid.Editors.FormatedTextEditor;
namespace ICSharpCode.WpfDesign.Designer.Extensions
{
public partial class TextBlockRightClickContextMenu
{
private DesignItem designItem;
public TextBlockRightClickContextMenu(DesignItem designItem)
{
this.designItem = designItem;
InitializeComponent();
}
void Click_EditFormatedText(object sender, RoutedEventArgs e)
{
var dlg = new Window()
{
Content = new FormatedTextEditor(designItem),
Width = 440,
Height = 200,
WindowStyle = WindowStyle.ToolWindow,
Owner = ((DesignPanel) designItem.Context.Services.DesignPanel).TryFindParent<Window>(),
};
dlg.ShowDialog();
}
}
}

53
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Extensions/TextBlockRightClickContextMenuExtension.cs

@ -0,0 +1,53 @@ @@ -0,0 +1,53 @@
// 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.Linq;
using System.Windows.Controls;
using ICSharpCode.WpfDesign.Adorners;
using ICSharpCode.WpfDesign.Extensions;
namespace ICSharpCode.WpfDesign.Designer.Extensions
{
[ExtensionServer(typeof (OnlyOneItemSelectedExtensionServer))]
[ExtensionFor(typeof (TextBlock))]
[Extension(Order = 10)]
public class TextBlockRightClickContextMenuExtension : PrimarySelectionAdornerProvider
{
DesignPanel panel;
ContextMenu contextMenu;
protected override void OnInitialized()
{
base.OnInitialized();
contextMenu = new TextBlockRightClickContextMenu(ExtendedItem);
panel = ExtendedItem.Context.Services.DesignPanel as DesignPanel;
if (panel != null)
panel.AddContextMenu(contextMenu);
}
protected override void OnRemove()
{
if (panel != null)
panel.RemoveContextMenu(contextMenu);
base.OnRemove();
}
}
}

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

@ -66,8 +66,8 @@ namespace ICSharpCode.WpfDesign.Designer.Extensions @@ -66,8 +66,8 @@ namespace ICSharpCode.WpfDesign.Designer.Extensions
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;
maxX = maxX > relativeLocation.X + ((FrameworkElement)di.View).ActualWidth ? maxX : relativeLocation.X + ((FrameworkElement)di.View).ActualWidth;
maxY = maxY > relativeLocation.Y + ((FrameworkElement)di.View).ActualHeight ? maxY : relativeLocation.Y + ((FrameworkElement)di.View).ActualHeight;
}
Rectangle rect2 = new Rectangle() {

11
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Extensions/WrapItemContextMenu.xaml

@ -0,0 +1,11 @@ @@ -0,0 +1,11 @@
<ContextMenu x:Class="ICSharpCode.WpfDesign.Designer.Extensions.WrapItemContextMenu"
xmlns="http://schemas.microsoft.com/netfx/2007/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:Translation="clr-namespace:ICSharpCode.WpfDesign.Designer"
>
<MenuItem Header="{Binding WrapInViewbox, Source={x:Static Translation:Translations.Instance}}" Click="Click_WrapInViewbox">
<MenuItem.Icon>
<Image Source="/ICSharpCode.WpfDesign.Designer;component/Images/wrap-option.png" />
</MenuItem.Icon>
</MenuItem>
</ContextMenu>

41
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Extensions/WrapItemContextMenu.xaml.cs

@ -0,0 +1,41 @@ @@ -0,0 +1,41 @@
// 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.Linq;
using System.Windows.Controls;
namespace ICSharpCode.WpfDesign.Designer.Extensions
{
public partial class WrapItemContextMenu
{
private DesignItem designItem;
public WrapItemContextMenu(DesignItem designItem)
{
this.designItem = designItem;
InitializeComponent();
}
void Click_WrapInViewbox(object sender, System.Windows.RoutedEventArgs e)
{
ModelTools.WrapItemsNewContainer(this.designItem.Services.Selection.SelectedItems, typeof(Viewbox));
}
}
}

23
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Extensions/RightClickMultipleItemsContextMenuExtension.cs → src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Extensions/WrapItemContextMenuExtension.cs

@ -18,9 +18,7 @@ @@ -18,9 +18,7 @@
using System;
using System.Windows;
using System.Windows.Media;
using System.Windows.Shapes;
using System.Windows.Controls;
using ICSharpCode.WpfDesign.Adorners;
using ICSharpCode.WpfDesign.Extensions;
using ICSharpCode.WpfDesign.Designer;
@ -30,24 +28,29 @@ namespace ICSharpCode.WpfDesign.Designer.Extensions @@ -30,24 +28,29 @@ namespace ICSharpCode.WpfDesign.Designer.Extensions
/// <summary>
///
/// </summary>
[ExtensionServer(typeof(MultipleSelectedExtensionServer))]
[ExtensionServer(typeof(OnlyOneItemSelectedExtensionServer))]
[ExtensionFor(typeof(UIElement))]
public class RightClickMultipleItemsContextMenuExtension : SelectionAdornerProvider
[Extension(Order = 50)]
public class WrapItemContextMenuExtension : SelectionAdornerProvider
{
DesignPanel panel;
ContextMenu contextMenu;
protected override void OnInitialized()
{
base.OnInitialized();
contextMenu = new WrapItemContextMenu(ExtendedItem);
panel = ExtendedItem.Context.Services.DesignPanel as DesignPanel;
panel.ContextMenu = new RightClickMultipleItemsContextMenu(ExtendedItem);
if (panel != null)
panel.AddContextMenu(contextMenu);
}
protected override void OnRemove()
{
panel.ContextMenu = null;
if (panel != null)
panel.RemoveContextMenu(contextMenu);
base.OnRemove();
}
}

16
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Extensions/WrapItemsContextMenu.xaml

@ -0,0 +1,16 @@ @@ -0,0 +1,16 @@
<ContextMenu x:Class="ICSharpCode.WpfDesign.Designer.Extensions.WrapItemsContextMenu"
xmlns="http://schemas.microsoft.com/netfx/2007/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:Translation="clr-namespace:ICSharpCode.WpfDesign.Designer"
>
<MenuItem Header="{Binding WrapInCanvas, Source={x:Static Translation:Translations.Instance}}" Click="Click_WrapInCanvas">
<MenuItem.Icon>
<Image Width="16" Source="/ICSharpCode.WpfDesign.Designer;component/Images/canvas.png" />
</MenuItem.Icon>
</MenuItem>
<MenuItem Header="{Binding WrapInGrid, Source={x:Static Translation:Translations.Instance}}" Click="Click_WrapInGrid">
<MenuItem.Icon>
<Image Source="/ICSharpCode.WpfDesign.Designer;component/Images/grid.png" />
</MenuItem.Icon>
</MenuItem>
</ContextMenu>

16
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Extensions/RightClickMultipleItemsContextMenu.xaml.cs → src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Extensions/WrapItemsContextMenu.xaml.cs

@ -17,28 +17,16 @@ @@ -17,28 +17,16 @@
// DEALINGS IN THE SOFTWARE.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using ICSharpCode.WpfDesign.PropertyGrid;
using ICSharpCode.WpfDesign.Designer.Xaml;
namespace ICSharpCode.WpfDesign.Designer.Extensions
{
public partial class RightClickMultipleItemsContextMenu
public partial class WrapItemsContextMenu
{
private DesignItem designItem;
public RightClickMultipleItemsContextMenu(DesignItem designItem)
public WrapItemsContextMenu(DesignItem designItem)
{
this.designItem = designItem;

57
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Extensions/WrapItemsContextMenuExtension.cs

@ -0,0 +1,57 @@ @@ -0,0 +1,57 @@
// 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;
using System.Windows.Controls;
using ICSharpCode.WpfDesign.Adorners;
using ICSharpCode.WpfDesign.Extensions;
using ICSharpCode.WpfDesign.Designer;
namespace ICSharpCode.WpfDesign.Designer.Extensions
{
/// <summary>
///
/// </summary>
[ExtensionServer(typeof(PrimarySelectionButOnlyWhenMultipleSelectedExtensionServer))]
[ExtensionFor(typeof(UIElement))]
[Extension(Order = 50)]
public class WrapItemsContextMenuExtension : SelectionAdornerProvider
{
DesignPanel panel;
ContextMenu contextMenu;
protected override void OnInitialized()
{
base.OnInitialized();
contextMenu = new WrapItemsContextMenu(ExtendedItem);
panel = ExtendedItem.Context.Services.DesignPanel as DesignPanel;
if (panel != null)
panel.AddContextMenu(contextMenu);
}
protected override void OnRemove()
{
if (panel != null)
panel.RemoveContextMenu(contextMenu);
base.OnRemove();
}
}
}

BIN
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Images/canvas.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

BIN
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Images/edit-bold.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 282 B

BIN
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Images/edit-color.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 326 B

BIN
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Images/edit-italic.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 247 B

BIN
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Images/edit-strike.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 312 B

BIN
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Images/edit-underline.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 260 B

BIN
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Images/edit.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 445 B

BIN
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Images/grid.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 270 B

BIN
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Images/layers-alignment-bottom.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 581 B

BIN
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Images/layers-alignment-center.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 624 B

BIN
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Images/layers-alignment-left.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 551 B

BIN
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Images/layers-alignment-middle.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 657 B

BIN
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Images/layers-alignment-right.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 559 B

BIN
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Images/layers-alignment.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 645 B

BIN
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Images/layers-arrange-back.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 646 B

BIN
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Images/layers-arrange.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 639 B

BIN
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Images/layers-stack-arrange-back.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 750 B

BIN
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Images/layers-stack-arrange.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 739 B

BIN
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Images/paint-can-color.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 697 B

BIN
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Images/wrap-option.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

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

@ -121,14 +121,15 @@ namespace ICSharpCode.WpfDesign.Designer @@ -121,14 +121,15 @@ namespace ICSharpCode.WpfDesign.Designer
internal static void CreateVisualTree(this UIElement element)
{
try {
try
{
var fixedDoc = new FixedDocument();
var pageContent = new PageContent();
var fixedPage = new FixedPage();
fixedPage.Children.Add(element);
(pageContent as IAddChild).AddChild(fixedPage);
fixedDoc.Pages.Add(pageContent);
var f = new XpsSerializerFactory();
var w = f.CreateSerializerWriter(new MemoryStream());
w.Write(fixedDoc);
@ -141,31 +142,29 @@ namespace ICSharpCode.WpfDesign.Designer @@ -141,31 +142,29 @@ namespace ICSharpCode.WpfDesign.Designer
internal static Size GetDefaultSize(DesignItem createdItem)
{
CreateVisualTree(createdItem.View);
var s = Metadata.GetDefaultSize(createdItem.ComponentType, false);
var defS = Metadata.GetDefaultSize(createdItem.ComponentType, false);
if (defS != null)
return defS.Value;
if (double.IsNaN(s.Width) && createdItem.View.DesiredSize.Width > 0)
{
s.Width = createdItem.View.DesiredSize.Width;
}
if (double.IsNaN(s.Height) && createdItem.View.DesiredSize.Height > 0)
{
s.Height = createdItem.View.DesiredSize.Height;
}
CreateVisualTree(createdItem.View);
var s = createdItem.View.DesiredSize;
var newS = Metadata.GetDefaultSize(createdItem.ComponentType, true);
if (!(s.Width > 0))
s.Width = newS.Width;
if (newS.HasValue)
{
if (!(s.Width > 5) && newS.Value.Width > 0)
s.Width = newS.Value.Width;
if (!(s.Height > 0))
s.Height = newS.Height;
if (!(s.Height > 5) && newS.Value.Height > 0)
s.Height = newS.Value.Height;
}
if (double.IsNaN(s.Width)) {
if (double.IsNaN(s.Width) && GetWidth(createdItem.View) > 0) {
s.Width = GetWidth(createdItem.View);
}
if (double.IsNaN(s.Height)) {
if (double.IsNaN(s.Height) && GetWidth(createdItem.View) > 0) {
s.Height = GetHeight(createdItem.View);
}
@ -193,10 +192,16 @@ namespace ICSharpCode.WpfDesign.Designer @@ -193,10 +192,16 @@ namespace ICSharpCode.WpfDesign.Designer
public static void Resize(DesignItem item, double newWidth, double newHeight)
{
if (newWidth != GetWidth(item.View)) {
item.Properties.GetProperty(FrameworkElement.WidthProperty).SetValue(newWidth);
if(double.IsNaN(newWidth))
item.Properties.GetProperty(FrameworkElement.WidthProperty).Reset();
else
item.Properties.GetProperty(FrameworkElement.WidthProperty).SetValue(newWidth);
}
if (newHeight != GetHeight(item.View)) {
item.Properties.GetProperty(FrameworkElement.HeightProperty).SetValue(newHeight);
if (double.IsNaN(newHeight))
item.Properties.GetProperty(FrameworkElement.HeightProperty).Reset();
else
item.Properties.GetProperty(FrameworkElement.HeightProperty).SetValue(newHeight);
}
}
@ -217,87 +222,53 @@ namespace ICSharpCode.WpfDesign.Designer @@ -217,87 +222,53 @@ namespace ICSharpCode.WpfDesign.Designer
public DesignItem DesignItem { get; set; }
}
private static ItemPos GetItemPos(PlacementOperation operation, DesignItem designItem)
{
var itemPos = new ItemPos() {DesignItem = designItem};
var pos = operation.CurrentContainerBehavior.GetPosition(operation, designItem);
itemPos.Xmin = pos.X;
itemPos.Xmax = pos.X + pos.Width;
itemPos.Ymin = pos.Y;
itemPos.Ymax = pos.Y + pos.Height;
return itemPos;
}
public static void WrapItemsNewContainer(IEnumerable<DesignItem> items, Type containerType)
{
var collection = items;
var _context = collection.First().Context as XamlDesignContext;
var oldContainer = collection.First().Parent;
var container = collection.First().Parent;
if (collection.Any(x => x.Parent != oldContainer))
if (collection.Any(x => x.Parent != container))
return;
//Change Code to use the Placment Operation!
var placement = container.Extensions.OfType<IPlacementBehavior>().FirstOrDefault();
if (placement == null)
return;
var operation = PlacementOperation.Start(items.ToList(), PlacementType.Move);
var newInstance = Activator.CreateInstance(containerType);
DesignItem newPanel = _context.Services.Component.RegisterComponentForDesigner(newInstance);
var changeGroup = newPanel.OpenGroup("Wrap in Container");
//var changeGroup = newPanel.OpenGroup("Wrap in Container");
List<ItemPos> itemList = new List<ItemPos>();
foreach (var item in collection) {
var itemPos = new ItemPos(){ DesignItem = item };
itemList.Add(itemPos);
if (oldContainer.Component is Canvas) {
var canvas = oldContainer.View as Canvas;
if (item.Properties.GetAttachedProperty(Canvas.RightProperty) != null && item.Properties.GetAttachedProperty(Canvas.RightProperty).IsSet) {
itemPos.HorizontalAlignment = HorizontalAlignment.Right;
itemPos.Xmax = canvas.ActualWidth - (double)item.Properties.GetAttachedProperty(Canvas.RightProperty).ValueOnInstance;
itemPos.Xmin = itemPos.Xmax - ((FrameworkElement)item.View).ActualWidth;
}
else if (item.Properties.GetAttachedProperty(Canvas.LeftProperty) != null && item.Properties.GetAttachedProperty(Canvas.LeftProperty).IsSet) {
itemPos.HorizontalAlignment = HorizontalAlignment.Left;
itemPos.Xmin = (double)item.Properties.GetAttachedProperty(Canvas.LeftProperty).ValueOnInstance;
itemPos.Xmax = itemPos.Xmin + ((FrameworkElement)item.View).ActualWidth;
} else {
itemPos.HorizontalAlignment = HorizontalAlignment.Left;
itemPos.Xmax = itemPos.Xmin + ((FrameworkElement)item.View).ActualWidth;
}
if (item.Properties.GetAttachedProperty(Canvas.BottomProperty) != null && item.Properties.GetAttachedProperty(Canvas.BottomProperty).IsSet) {
itemPos.VerticalAlignment = VerticalAlignment.Bottom;
itemPos.Ymax = canvas.ActualHeight - (double)item.Properties.GetAttachedProperty(Canvas.BottomProperty).ValueOnInstance;
itemPos.Ymin = itemPos.Ymax - ((FrameworkElement)item.View).ActualHeight;
}
else if (item.Properties.GetAttachedProperty(Canvas.TopProperty) != null && item.Properties.GetAttachedProperty(Canvas.TopProperty).IsSet) {
itemPos.VerticalAlignment = VerticalAlignment.Top;
itemPos.Ymin = (double)item.Properties.GetAttachedProperty(Canvas.TopProperty).ValueOnInstance;
itemPos.Ymax = itemPos.Ymin + ((FrameworkElement)item.View).ActualHeight;
} else {
itemPos.VerticalAlignment = VerticalAlignment.Top;
itemPos.Ymax = itemPos.Ymin + ((FrameworkElement)item.View).ActualHeight;
}
itemList.Add(GetItemPos(operation, item));
//var pos = placement.GetPosition(null, item);
if (container.Component is Canvas) {
item.Properties.GetAttachedProperty(Canvas.RightProperty).Reset();
item.Properties.GetAttachedProperty(Canvas.LeftProperty).Reset();
item.Properties.GetAttachedProperty(Canvas.TopProperty).Reset();
item.Properties.GetAttachedProperty(Canvas.BottomProperty).Reset();
} else if (oldContainer.Component is Grid) {
var grid = oldContainer.View as Grid;
if ((HorizontalAlignment)item.Properties.GetProperty(FrameworkElement.HorizontalAlignmentProperty).ValueOnInstance == HorizontalAlignment.Right) {
itemPos.HorizontalAlignment = HorizontalAlignment.Right;
itemPos.Xmax = grid.ActualWidth - ((Thickness)item.Properties.GetProperty(FrameworkElement.MarginProperty).ValueOnInstance).Right;
itemPos.Xmin = itemPos.Xmax - ((FrameworkElement)item.View).ActualWidth;
} else {
itemPos.HorizontalAlignment = HorizontalAlignment.Left;
itemPos.Xmin = ((Thickness)item.Properties.GetProperty(FrameworkElement.MarginProperty).ValueOnInstance).Left;
itemPos.Xmax = itemPos.Xmin + ((FrameworkElement)item.View).ActualWidth;
}
if ((VerticalAlignment)item.Properties.GetProperty(FrameworkElement.VerticalAlignmentProperty).ValueOnInstance == VerticalAlignment.Bottom) {
itemPos.VerticalAlignment = VerticalAlignment.Bottom;
itemPos.Ymax = grid.ActualHeight - ((Thickness)item.Properties.GetProperty(FrameworkElement.MarginProperty).ValueOnInstance).Bottom;
itemPos.Ymin = itemPos.Ymax - ((FrameworkElement)item.View).ActualHeight;
} else {
itemPos.VerticalAlignment = VerticalAlignment.Top;
itemPos.Ymin = ((Thickness)item.Properties.GetProperty(FrameworkElement.MarginProperty).ValueOnInstance).Top;
itemPos.Ymax = itemPos.Ymin + ((FrameworkElement)item.View).ActualHeight;
}
} else if (container.Component is Grid) {
item.Properties.GetProperty(FrameworkElement.HorizontalAlignmentProperty).Reset();
item.Properties.GetProperty(FrameworkElement.VerticalAlignmentProperty).Reset();
item.Properties.GetProperty(FrameworkElement.MarginProperty).Reset();
@ -311,23 +282,8 @@ namespace ICSharpCode.WpfDesign.Designer @@ -311,23 +282,8 @@ namespace ICSharpCode.WpfDesign.Designer
var xmax = itemList.Max(x => x.Xmax);
var ymin = itemList.Min(x => x.Ymin);
var ymax = itemList.Max(x => x.Ymax);
if (oldContainer.Component is Canvas) {
newPanel.Properties.GetProperty(FrameworkElement.WidthProperty).SetValue(xmax - xmin);
newPanel.Properties.GetProperty(FrameworkElement.HeightProperty).SetValue(ymax - ymin);
newPanel.Properties.GetAttachedProperty(Canvas.LeftProperty).SetValue(xmin);
newPanel.Properties.GetAttachedProperty(Canvas.TopProperty).SetValue(ymin);
} else if (oldContainer.Component is Grid) {
newPanel.Properties.GetProperty(FrameworkElement.HorizontalAlignmentProperty).SetValue(HorizontalAlignment.Left);
newPanel.Properties.GetProperty(FrameworkElement.VerticalAlignmentProperty).SetValue(VerticalAlignment.Top);
newPanel.Properties.GetProperty(FrameworkElement.MarginProperty).SetValue(new Thickness(xmin, ymin, 0, 0));
newPanel.Properties.GetProperty(FrameworkElement.WidthProperty).SetValue(xmax - xmin);
newPanel.Properties.GetProperty(FrameworkElement.HeightProperty).SetValue(ymax - ymin);
}
foreach (var item in itemList) {
newPanel.ContentProperty.CollectionElements.Add(item.DesignItem);
if (newPanel.Component is Canvas) {
if (item.HorizontalAlignment == HorizontalAlignment.Right) {
item.DesignItem.Properties.GetAttachedProperty(Canvas.RightProperty).SetValue(xmax - item.Xmax);
@ -340,6 +296,9 @@ namespace ICSharpCode.WpfDesign.Designer @@ -340,6 +296,9 @@ namespace ICSharpCode.WpfDesign.Designer
} else {
item.DesignItem.Properties.GetAttachedProperty(Canvas.TopProperty).SetValue(item.Ymin - ymin);
}
newPanel.ContentProperty.CollectionElements.Add(item.DesignItem);
} else if (newPanel.Component is Grid) {
Thickness thickness = new Thickness(0);
if (item.HorizontalAlignment == HorizontalAlignment.Right) {
@ -359,14 +318,272 @@ namespace ICSharpCode.WpfDesign.Designer @@ -359,14 +318,272 @@ namespace ICSharpCode.WpfDesign.Designer
}
item.DesignItem.Properties.GetProperty(FrameworkElement.MarginProperty).SetValue(thickness);
newPanel.ContentProperty.CollectionElements.Add(item.DesignItem);
} else if (newPanel.Component is Viewbox) {
newPanel.ContentProperty.SetValue(item.DesignItem);
}
}
oldContainer.ContentProperty.CollectionElements.Add(newPanel);
PlacementOperation operation2 = PlacementOperation.TryStartInsertNewComponents(
container,
new[] { newPanel },
new[] { new Rect(xmin, ymin, xmax - xmin, ymax - ymin).Round() },
PlacementType.AddItem
);
changeGroup.Commit();
operation2.Commit();
operation.Commit();
_context.Services.Selection.SetSelectedComponents(new []{ newPanel });
}
public static void ArrangeItems(IEnumerable<DesignItem> items, ArrangeDirection arrangeDirection)
{
var collection = items;
var _context = collection.First().Context as XamlDesignContext;
var container = collection.First().Parent;
if (collection.Any(x => x.Parent != container))
return;
var placement = container.Extensions.OfType<IPlacementBehavior>().FirstOrDefault();
if (placement == null)
return;
var operation = PlacementOperation.Start(items.ToList(), PlacementType.Move);
//var changeGroup = container.OpenGroup("Arrange Elements");
List<ItemPos> itemList = new List<ItemPos>();
foreach (var item in collection)
{
itemList.Add(GetItemPos(operation, item));
}
var xmin = itemList.Min(x => x.Xmin);
var xmax = itemList.Max(x => x.Xmax);
var mpos = (xmax - xmin) / 2 + xmin;
var ymin = itemList.Min(x => x.Ymin);
var ymax = itemList.Max(x => x.Ymax);
var ympos = (ymax - ymin) / 2 + ymin;
foreach (var item in collection)
{
switch (arrangeDirection)
{
case ArrangeDirection.Left:
{
if (container.Component is Canvas)
{
if (!item.Properties.GetAttachedProperty(Canvas.RightProperty).IsSet)
{
item.Properties.GetAttachedProperty(Canvas.LeftProperty).SetValue(xmin);
}
else
{
var pos = (double)((Panel)item.Parent.Component).ActualWidth - (xmin + (double) ((FrameworkElement) item.Component).ActualWidth);
item.Properties.GetAttachedProperty(Canvas.RightProperty).SetValue(pos);
}
}
else if (container.Component is Grid)
{
if ((HorizontalAlignment)item.Properties.GetProperty(FrameworkElement.HorizontalAlignmentProperty).ValueOnInstance != HorizontalAlignment.Right)
{
var margin = (Thickness)item.Properties.GetProperty(FrameworkElement.MarginProperty).ValueOnInstance;
margin.Left = xmin;
item.Properties.GetProperty(FrameworkElement.MarginProperty).SetValue(margin);
}
else
{
var pos = (double)((Panel)item.Parent.Component).ActualWidth - (xmin + (double)((FrameworkElement)item.Component).ActualWidth);
var margin = (Thickness)item.Properties.GetProperty(FrameworkElement.MarginProperty).ValueOnInstance;
margin.Right = pos;
item.Properties.GetProperty(FrameworkElement.MarginProperty).SetValue(margin);
}
}
}
break;
case ArrangeDirection.HorizontalMiddle:
{
if (container.Component is Canvas)
{
if (!item.Properties.GetAttachedProperty(Canvas.RightProperty).IsSet)
{
if (!item.Properties.GetAttachedProperty(Canvas.RightProperty).IsSet)
{
item.Properties.GetAttachedProperty(Canvas.LeftProperty).SetValue(mpos - (((FrameworkElement)item.Component).ActualWidth) / 2);
}
else
{
var pp = mpos - (((FrameworkElement)item.Component).ActualWidth) / 2;
var pos = (double)((Panel)item.Parent.Component).ActualWidth - pp - (((FrameworkElement)item.Component).ActualWidth);
item.Properties.GetAttachedProperty(Canvas.RightProperty).SetValue(pos);
}
}
}
else if (container.Component is Grid)
{
if ((HorizontalAlignment)item.Properties.GetProperty(FrameworkElement.HorizontalAlignmentProperty).ValueOnInstance != HorizontalAlignment.Right)
{
var margin = (Thickness)item.Properties.GetProperty(FrameworkElement.MarginProperty).ValueOnInstance;
margin.Left = mpos - (((FrameworkElement)item.Component).ActualWidth) / 2;
item.Properties.GetProperty(FrameworkElement.MarginProperty).SetValue(margin);
}
else
{
var pp = mpos - (((FrameworkElement)item.Component).ActualWidth) / 2;
var pos = (double)((Panel)item.Parent.Component).ActualWidth - pp - (((FrameworkElement)item.Component).ActualWidth);
var margin = (Thickness)item.Properties.GetProperty(FrameworkElement.MarginProperty).ValueOnInstance;
margin.Right = pos;
item.Properties.GetProperty(FrameworkElement.MarginProperty).SetValue(margin);
}
}
}
break;
case ArrangeDirection.Right:
{
if (container.Component is Canvas)
{
if (!item.Properties.GetAttachedProperty(Canvas.RightProperty).IsSet)
{
var pos = xmax - (double)((FrameworkElement)item.Component).ActualWidth;
item.Properties.GetAttachedProperty(Canvas.LeftProperty).SetValue(pos);
}
else
{
var pos = (double)((Panel)item.Parent.Component).ActualWidth - xmax;
item.Properties.GetAttachedProperty(Canvas.RightProperty).SetValue(pos);
}
}
else if (container.Component is Grid)
{
if ((HorizontalAlignment)item.Properties.GetProperty(FrameworkElement.HorizontalAlignmentProperty).ValueOnInstance != HorizontalAlignment.Right)
{
var pos = xmax - (double)((FrameworkElement)item.Component).ActualWidth;
var margin = (Thickness)item.Properties.GetProperty(FrameworkElement.MarginProperty).ValueOnInstance;
margin.Left = pos;
item.Properties.GetProperty(FrameworkElement.MarginProperty).SetValue(margin);
}
else
{
var pos = (double)((Panel)item.Parent.Component).ActualWidth - xmax;
var margin = (Thickness)item.Properties.GetProperty(FrameworkElement.MarginProperty).ValueOnInstance;
margin.Right = pos;
item.Properties.GetProperty(FrameworkElement.MarginProperty).SetValue(margin);
}
}
}
break;
case ArrangeDirection.Top:
{
if (container.Component is Canvas)
{
if (!item.Properties.GetAttachedProperty(Canvas.BottomProperty).IsSet)
{
item.Properties.GetAttachedProperty(Canvas.TopProperty).SetValue(ymin);
}
else
{
var pos = (double)((Panel)item.Parent.Component).ActualHeight - (ymin + (double)((FrameworkElement)item.Component).ActualHeight);
item.Properties.GetAttachedProperty(Canvas.BottomProperty).SetValue(pos);
}
}
else if (container.Component is Grid)
{
if ((VerticalAlignment)item.Properties.GetProperty(FrameworkElement.VerticalAlignmentProperty).ValueOnInstance != VerticalAlignment.Bottom)
{
item.Properties.GetAttachedProperty(Canvas.TopProperty).SetValue(ymin);
var margin = (Thickness)item.Properties.GetProperty(FrameworkElement.MarginProperty).ValueOnInstance;
margin.Top = ymin;
item.Properties.GetProperty(FrameworkElement.MarginProperty).SetValue(margin);
}
else
{
var pos = (double)((Panel)item.Parent.Component).ActualHeight - (ymin + (double)((FrameworkElement)item.Component).ActualHeight);
var margin = (Thickness)item.Properties.GetProperty(FrameworkElement.MarginProperty).ValueOnInstance;
margin.Bottom = pos;
item.Properties.GetProperty(FrameworkElement.MarginProperty).SetValue(margin);
}
}
}
break;
case ArrangeDirection.VerticalMiddle:
{
if (container.Component is Canvas)
{
if (!item.Properties.GetAttachedProperty(Canvas.BottomProperty).IsSet)
{
item.Properties.GetAttachedProperty(Canvas.TopProperty).SetValue(ympos - (((FrameworkElement)item.Component).ActualHeight) / 2);
}
else
{
var pp = mpos - (((FrameworkElement)item.Component).ActualHeight) / 2;
var pos = (double)((Panel)item.Parent.Component).ActualHeight - pp - (((FrameworkElement)item.Component).ActualHeight);
item.Properties.GetAttachedProperty(Canvas.BottomProperty).SetValue(pos);
}
}
else if (container.Component is Grid)
{
if ((VerticalAlignment)item.Properties.GetProperty(FrameworkElement.VerticalAlignmentProperty).ValueOnInstance != VerticalAlignment.Bottom)
{
var margin = (Thickness)item.Properties.GetProperty(FrameworkElement.MarginProperty).ValueOnInstance;
margin.Top = ympos - (((FrameworkElement)item.Component).ActualHeight) / 2;
item.Properties.GetProperty(FrameworkElement.MarginProperty).SetValue(margin);
}
else
{
var pp = mpos - (((FrameworkElement)item.Component).ActualHeight) / 2;
var pos = (double)((Panel)item.Parent.Component).ActualHeight - pp - (((FrameworkElement)item.Component).ActualHeight);
var margin = (Thickness)item.Properties.GetProperty(FrameworkElement.MarginProperty).ValueOnInstance;
margin.Bottom = pos;
item.Properties.GetProperty(FrameworkElement.MarginProperty).SetValue(margin);
}
}
}
break;
case ArrangeDirection.Bottom:
{
if (container.Component is Canvas)
{
if (!item.Properties.GetAttachedProperty(Canvas.BottomProperty).IsSet)
{
var pos = ymax - (double)((FrameworkElement)item.Component).ActualHeight;
item.Properties.GetAttachedProperty(Canvas.TopProperty).SetValue(pos);
}
else
{
var pos = (double)((Panel)item.Parent.Component).ActualHeight - ymax;
item.Properties.GetAttachedProperty(Canvas.BottomProperty).SetValue(pos);
}
}
else if (container.Component is Grid)
{
if ((VerticalAlignment)item.Properties.GetProperty(FrameworkElement.VerticalAlignmentProperty).ValueOnInstance != VerticalAlignment.Bottom)
{
var pos = ymax - (double)((FrameworkElement)item.Component).ActualHeight;
var margin = (Thickness)item.Properties.GetProperty(FrameworkElement.MarginProperty).ValueOnInstance;
margin.Top = pos;
item.Properties.GetProperty(FrameworkElement.MarginProperty).SetValue(margin);
}
else
{
var pos = (double)((Panel)item.Parent.Component).ActualHeight - ymax;
var margin = (Thickness)item.Properties.GetProperty(FrameworkElement.MarginProperty).ValueOnInstance;
margin.Bottom = pos;
item.Properties.GetProperty(FrameworkElement.MarginProperty).SetValue(margin);
}
}
}
break;
}
}
operation.Commit();
}
}
}

832
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/PropertyGrid/Editors/FormatedTextEditor/FormatedTextEditor.xaml

@ -0,0 +1,832 @@ @@ -0,0 +1,832 @@
<UserControl x:Class="ICSharpCode.WpfDesign.Designer.PropertyGrid.Editors.FormatedTextEditor.FormatedTextEditor"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:xctk="http://schemas.xceed.com/wpf/xaml/toolkit"
xmlns:sys="clr-namespace:System;assembly=mscorlib"
xmlns:componentModel="clr-namespace:System.ComponentModel;assembly=WindowsBase"
mc:Ignorable="d" d:DesignWidth="410" d:DesignHeight="259" >
<UserControl.Resources>
<CollectionViewSource x:Key="Fonts" Source="{Binding Source={x:Static Fonts.SystemFontFamilies}}">
<CollectionViewSource.SortDescriptions>
<componentModel:SortDescription PropertyName="Source" />
</CollectionViewSource.SortDescriptions>
</CollectionViewSource>
<Style x:Key="RichTextBoxFormatBarStyle" TargetType="{x:Type xctk:RichTextBoxFormatBar}">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type xctk:RichTextBoxFormatBar}">
<ControlTemplate.Resources>
<Style x:Key="{x:Type Separator}" TargetType="{x:Type Separator}">
<Style.BasedOn>
<Style TargetType="{x:Type Separator}">
<Setter Property="Background" Value="#FFC6C7C6"/>
<Setter Property="MinWidth" Value="1"/>
<Setter Property="MinHeight" Value="1"/>
<Setter Property="Margin" Value="2"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type Separator}">
<Border BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Background="{TemplateBinding Background}" SnapsToDevicePixels="True"/>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</Style.BasedOn>
</Style>
</ControlTemplate.Resources>
<Border BorderBrush="Gray" BorderThickness="1" Background="WhiteSmoke" CornerRadius="3">
<Grid Margin="5,0,5,5">
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<Thumb x:Name="_dragWidget" Visibility="Collapsed" Height="10">
<Thumb.Template>
<ControlTemplate TargetType="{x:Type Thumb}">
<Border Background="Transparent" Cursor="Hand" ToolTip="Click to Drag">
<StackPanel VerticalAlignment="Center" Width="75">
<Line Margin="0.5" Stretch="Fill" SnapsToDevicePixels="True" Stroke="Gray" StrokeThickness="1" StrokeDashArray="1 2" X1="0" X2="1"/>
<Line Margin="0.5" Stretch="Fill" SnapsToDevicePixels="True" Stroke="Gray" StrokeThickness="1" StrokeDashArray="1 2" X1="0" X2="1"/>
<Line Margin="0.5" Stretch="Fill" SnapsToDevicePixels="True" Stroke="Gray" StrokeThickness="1" StrokeDashArray="1 2" X1="0" X2="1"/>
</StackPanel>
</Border>
</ControlTemplate>
</Thumb.Template>
</Thumb>
<StackPanel Grid.Row="1">
<StackPanel Orientation="Horizontal">
<ComboBox x:Name="_cmbFontFamilies" IsEditable="True" ToolTip="Font Family" Width="100">
<ComboBox.ItemTemplate>
<DataTemplate>
<TextBlock FontFamily="{Binding}" Text="{Binding}" ToolTip="{Binding}" />
</DataTemplate>
</ComboBox.ItemTemplate>
<ComboBox.ItemsPanel>
<ItemsPanelTemplate>
<VirtualizingStackPanel />
</ItemsPanelTemplate>
</ComboBox.ItemsPanel>
</ComboBox>
<ComboBox x:Name="_cmbFontSizes" IsEditable="True" ToolTip="Font Size" Margin="3,0,0,0" Width="43"/>
<ToggleButton x:Name="_btnBullets" Visibility="Collapsed" CommandTarget="{Binding Target, RelativeSource={RelativeSource TemplatedParent}}" Command="EditingCommands.ToggleBullets" ToolTip="Bullets">
</ToggleButton>
<ToggleButton x:Name="_btnNumbers" Visibility="Collapsed" CommandTarget="{Binding Target, RelativeSource={RelativeSource TemplatedParent}}" Command="EditingCommands.ToggleNumbering" ToolTip="Numbering">
</ToggleButton>
</StackPanel>
<StackPanel Margin="0,3,0,0" Orientation="Horizontal">
<ToggleButton x:Name="_btnBold" CommandTarget="{Binding Target, RelativeSource={RelativeSource TemplatedParent}}" Command="EditingCommands.ToggleBold" ToolTip="Bold">
<ToggleButton.Style>
<Style TargetType="{x:Type ToggleButton}">
<Setter Property="Background" Value="Transparent"/>
<Setter Property="BorderBrush" Value="Transparent"/>
<Setter Property="BorderThickness" Value="1"/>
<Setter Property="FocusVisualStyle" Value="{x:Null}"/>
<Setter Property="Height" Value="22"/>
<Setter Property="HorizontalContentAlignment" Value="Center"/>
<Setter Property="ToolTipService.InitialShowDelay" Value="900"/>
<Setter Property="ToolTipService.ShowDuration" Value="20000"/>
<Setter Property="ToolTipService.BetweenShowDelay" Value="0"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type ToggleButton}">
<Grid SnapsToDevicePixels="True">
<Border x:Name="OuterBorder" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Background="{TemplateBinding Background}" CornerRadius="2"/>
<Border x:Name="MiddleBorder" BorderBrush="Transparent" BorderThickness="{TemplateBinding BorderThickness}" Background="Transparent" CornerRadius="2">
<Border x:Name="InnerBorder" BorderBrush="Transparent" BorderThickness="{TemplateBinding BorderThickness}" Background="Transparent" CornerRadius="2" Padding="{TemplateBinding Padding}">
<StackPanel x:Name="StackPanel" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}">
<ContentPresenter x:Name="Content" RenderOptions.BitmapScalingMode="NearestNeighbor" Content="{TemplateBinding Content}" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" Margin="1" VerticalAlignment="Center"/>
</StackPanel>
</Border>
</Border>
</Grid>
<ControlTemplate.Triggers>
<Trigger Property="IsMouseOver" Value="True">
<Setter Property="Background" TargetName="OuterBorder">
<Setter.Value>
<LinearGradientBrush EndPoint="0,1" StartPoint="0,0">
<GradientStop Color="#FFFEFBF4" Offset="0"/>
<GradientStop Color="#FFFDE7CE" Offset="0.19"/>
<GradientStop Color="#FFFDDEB8" Offset="0.39"/>
<GradientStop Color="#FFFFCE6B" Offset="0.39"/>
<GradientStop Color="#FFFFDE9A" Offset="0.79"/>
<GradientStop Color="#FFFFEBAA" Offset="1"/>
</LinearGradientBrush>
</Setter.Value>
</Setter>
<Setter Property="BorderBrush" TargetName="OuterBorder" Value="#FFFFB700"/>
<Setter Property="BorderBrush" TargetName="InnerBorder" Value="#80FFFFFF"/>
</Trigger>
<Trigger Property="IsEnabled" Value="False">
<Setter Property="Opacity" TargetName="Content" Value="0.5"/>
<Setter Property="TextElement.Foreground" TargetName="OuterBorder" Value="#FF9E9E9E"/>
</Trigger>
<Trigger Property="IsChecked" Value="True">
<Setter Property="Background" TargetName="OuterBorder">
<Setter.Value>
<LinearGradientBrush EndPoint="0,1" StartPoint="0,0">
<GradientStop Color="#FFFFDCA0" Offset="0"/>
<GradientStop Color="#FFFFD692" Offset="0.18"/>
<GradientStop Color="#FFFFC45D" Offset="0.39"/>
<GradientStop Color="#FFFFD178" Offset="1"/>
</LinearGradientBrush>
</Setter.Value>
</Setter>
<Setter Property="BorderBrush" TargetName="OuterBorder" Value="#FFC29B29"/>
<Setter Property="BorderBrush" TargetName="InnerBorder">
<Setter.Value>
<LinearGradientBrush EndPoint="0,1" StartPoint="0,0">
<GradientStop Color="#FFE7CBAD" Offset="0"/>
<GradientStop Color="#FFF7D7B5" Offset="0.1"/>
<GradientStop Color="#FFFFD38C" Offset="0.36"/>
<GradientStop Color="#FFFFC75A" Offset="0.36"/>
<GradientStop Color="#FFFFEFA5" Offset="1"/>
</LinearGradientBrush>
</Setter.Value>
</Setter>
</Trigger>
<Trigger Property="IsPressed" Value="True">
<Setter Property="Background" TargetName="OuterBorder">
<Setter.Value>
<LinearGradientBrush EndPoint="0,1" StartPoint="0,0">
<GradientStop Color="#FFE3C085" Offset="0"/>
<GradientStop Color="#FFF4CC89" Offset="0.19"/>
<GradientStop Color="#FFF5C777" Offset="0.36"/>
<GradientStop Color="#FFF5BB56" Offset="0.36"/>
<GradientStop Color="#FFF4CE9A" Offset="0.79"/>
<GradientStop Color="#FFF3E28D" Offset="1"/>
</LinearGradientBrush>
</Setter.Value>
</Setter>
<Setter Property="BorderBrush" TargetName="OuterBorder" Value="#FFC29B29"/>
<Setter Property="BorderBrush" TargetName="InnerBorder" Value="Transparent"/>
</Trigger>
<MultiTrigger>
<MultiTrigger.Conditions>
<Condition Property="IsChecked" Value="True"/>
<Condition Property="IsMouseOver" Value="True"/>
</MultiTrigger.Conditions>
<Setter Property="Background" TargetName="MiddleBorder">
<Setter.Value>
<LinearGradientBrush EndPoint="0,1" StartPoint="0,0">
<GradientStop Color="#40FFFEFE" Offset="0"/>
<GradientStop Color="#40FFFEFE" Offset="0.39"/>
<GradientStop Color="#20FFCE68" Offset="0.39"/>
<GradientStop Color="#20FFCE68" Offset="0.69"/>
<GradientStop Color="#10FFFFFF" Offset="1"/>
</LinearGradientBrush>
</Setter.Value>
</Setter>
</MultiTrigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</ToggleButton.Style>
<Image>
<Image.Source>
<BitmapImage UriSource="pack://application:,,,/Xceed.Wpf.Toolkit;v2.2.0.0;component/RichTextBoxFormatBar/Images/Bold16.png"/>
</Image.Source>
</Image>
</ToggleButton>
<ToggleButton x:Name="_btnItalic" CommandTarget="{Binding Target, RelativeSource={RelativeSource TemplatedParent}}" Command="EditingCommands.ToggleItalic" ToolTip="Italic">
<ToggleButton.Style>
<Style TargetType="{x:Type ToggleButton}">
<Setter Property="Background" Value="Transparent"/>
<Setter Property="BorderBrush" Value="Transparent"/>
<Setter Property="BorderThickness" Value="1"/>
<Setter Property="FocusVisualStyle" Value="{x:Null}"/>
<Setter Property="Height" Value="22"/>
<Setter Property="HorizontalContentAlignment" Value="Center"/>
<Setter Property="ToolTipService.InitialShowDelay" Value="900"/>
<Setter Property="ToolTipService.ShowDuration" Value="20000"/>
<Setter Property="ToolTipService.BetweenShowDelay" Value="0"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type ToggleButton}">
<Grid SnapsToDevicePixels="True">
<Border x:Name="OuterBorder" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Background="{TemplateBinding Background}" CornerRadius="2"/>
<Border x:Name="MiddleBorder" BorderBrush="Transparent" BorderThickness="{TemplateBinding BorderThickness}" Background="Transparent" CornerRadius="2">
<Border x:Name="InnerBorder" BorderBrush="Transparent" BorderThickness="{TemplateBinding BorderThickness}" Background="Transparent" CornerRadius="2" Padding="{TemplateBinding Padding}">
<StackPanel x:Name="StackPanel" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}">
<ContentPresenter x:Name="Content" RenderOptions.BitmapScalingMode="NearestNeighbor" Content="{TemplateBinding Content}" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" Margin="1" VerticalAlignment="Center"/>
</StackPanel>
</Border>
</Border>
</Grid>
<ControlTemplate.Triggers>
<Trigger Property="IsMouseOver" Value="True">
<Setter Property="Background" TargetName="OuterBorder">
<Setter.Value>
<LinearGradientBrush EndPoint="0,1" StartPoint="0,0">
<GradientStop Color="#FFFEFBF4" Offset="0"/>
<GradientStop Color="#FFFDE7CE" Offset="0.19"/>
<GradientStop Color="#FFFDDEB8" Offset="0.39"/>
<GradientStop Color="#FFFFCE6B" Offset="0.39"/>
<GradientStop Color="#FFFFDE9A" Offset="0.79"/>
<GradientStop Color="#FFFFEBAA" Offset="1"/>
</LinearGradientBrush>
</Setter.Value>
</Setter>
<Setter Property="BorderBrush" TargetName="OuterBorder" Value="#FFFFB700"/>
<Setter Property="BorderBrush" TargetName="InnerBorder" Value="#80FFFFFF"/>
</Trigger>
<Trigger Property="IsEnabled" Value="False">
<Setter Property="Opacity" TargetName="Content" Value="0.5"/>
<Setter Property="TextElement.Foreground" TargetName="OuterBorder" Value="#FF9E9E9E"/>
</Trigger>
<Trigger Property="IsChecked" Value="True">
<Setter Property="Background" TargetName="OuterBorder">
<Setter.Value>
<LinearGradientBrush EndPoint="0,1" StartPoint="0,0">
<GradientStop Color="#FFFFDCA0" Offset="0"/>
<GradientStop Color="#FFFFD692" Offset="0.18"/>
<GradientStop Color="#FFFFC45D" Offset="0.39"/>
<GradientStop Color="#FFFFD178" Offset="1"/>
</LinearGradientBrush>
</Setter.Value>
</Setter>
<Setter Property="BorderBrush" TargetName="OuterBorder" Value="#FFC29B29"/>
<Setter Property="BorderBrush" TargetName="InnerBorder">
<Setter.Value>
<LinearGradientBrush EndPoint="0,1" StartPoint="0,0">
<GradientStop Color="#FFE7CBAD" Offset="0"/>
<GradientStop Color="#FFF7D7B5" Offset="0.1"/>
<GradientStop Color="#FFFFD38C" Offset="0.36"/>
<GradientStop Color="#FFFFC75A" Offset="0.36"/>
<GradientStop Color="#FFFFEFA5" Offset="1"/>
</LinearGradientBrush>
</Setter.Value>
</Setter>
</Trigger>
<Trigger Property="IsPressed" Value="True">
<Setter Property="Background" TargetName="OuterBorder">
<Setter.Value>
<LinearGradientBrush EndPoint="0,1" StartPoint="0,0">
<GradientStop Color="#FFE3C085" Offset="0"/>
<GradientStop Color="#FFF4CC89" Offset="0.19"/>
<GradientStop Color="#FFF5C777" Offset="0.36"/>
<GradientStop Color="#FFF5BB56" Offset="0.36"/>
<GradientStop Color="#FFF4CE9A" Offset="0.79"/>
<GradientStop Color="#FFF3E28D" Offset="1"/>
</LinearGradientBrush>
</Setter.Value>
</Setter>
<Setter Property="BorderBrush" TargetName="OuterBorder" Value="#FFC29B29"/>
<Setter Property="BorderBrush" TargetName="InnerBorder" Value="Transparent"/>
</Trigger>
<MultiTrigger>
<MultiTrigger.Conditions>
<Condition Property="IsChecked" Value="True"/>
<Condition Property="IsMouseOver" Value="True"/>
</MultiTrigger.Conditions>
<Setter Property="Background" TargetName="MiddleBorder">
<Setter.Value>
<LinearGradientBrush EndPoint="0,1" StartPoint="0,0">
<GradientStop Color="#40FFFEFE" Offset="0"/>
<GradientStop Color="#40FFFEFE" Offset="0.39"/>
<GradientStop Color="#20FFCE68" Offset="0.39"/>
<GradientStop Color="#20FFCE68" Offset="0.69"/>
<GradientStop Color="#10FFFFFF" Offset="1"/>
</LinearGradientBrush>
</Setter.Value>
</Setter>
</MultiTrigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</ToggleButton.Style>
<Image>
<Image.Source>
<BitmapImage UriSource="pack://application:,,,/Xceed.Wpf.Toolkit;v2.2.0.0;component/RichTextBoxFormatBar/Images/Italic16.png"/>
</Image.Source>
</Image>
</ToggleButton>
<ToggleButton x:Name="_btnUnderline" CommandTarget="{Binding Target, RelativeSource={RelativeSource TemplatedParent}}" Command="EditingCommands.ToggleUnderline" ToolTip="Underline">
<ToggleButton.Style>
<Style TargetType="{x:Type ToggleButton}">
<Setter Property="Background" Value="Transparent"/>
<Setter Property="BorderBrush" Value="Transparent"/>
<Setter Property="BorderThickness" Value="1"/>
<Setter Property="FocusVisualStyle" Value="{x:Null}"/>
<Setter Property="Height" Value="22"/>
<Setter Property="HorizontalContentAlignment" Value="Center"/>
<Setter Property="ToolTipService.InitialShowDelay" Value="900"/>
<Setter Property="ToolTipService.ShowDuration" Value="20000"/>
<Setter Property="ToolTipService.BetweenShowDelay" Value="0"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type ToggleButton}">
<Grid SnapsToDevicePixels="True">
<Border x:Name="OuterBorder" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Background="{TemplateBinding Background}" CornerRadius="2"/>
<Border x:Name="MiddleBorder" BorderBrush="Transparent" BorderThickness="{TemplateBinding BorderThickness}" Background="Transparent" CornerRadius="2">
<Border x:Name="InnerBorder" BorderBrush="Transparent" BorderThickness="{TemplateBinding BorderThickness}" Background="Transparent" CornerRadius="2" Padding="{TemplateBinding Padding}">
<StackPanel x:Name="StackPanel" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}">
<ContentPresenter x:Name="Content" RenderOptions.BitmapScalingMode="NearestNeighbor" Content="{TemplateBinding Content}" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" Margin="1" VerticalAlignment="Center"/>
</StackPanel>
</Border>
</Border>
</Grid>
<ControlTemplate.Triggers>
<Trigger Property="IsMouseOver" Value="True">
<Setter Property="Background" TargetName="OuterBorder">
<Setter.Value>
<LinearGradientBrush EndPoint="0,1" StartPoint="0,0">
<GradientStop Color="#FFFEFBF4" Offset="0"/>
<GradientStop Color="#FFFDE7CE" Offset="0.19"/>
<GradientStop Color="#FFFDDEB8" Offset="0.39"/>
<GradientStop Color="#FFFFCE6B" Offset="0.39"/>
<GradientStop Color="#FFFFDE9A" Offset="0.79"/>
<GradientStop Color="#FFFFEBAA" Offset="1"/>
</LinearGradientBrush>
</Setter.Value>
</Setter>
<Setter Property="BorderBrush" TargetName="OuterBorder" Value="#FFFFB700"/>
<Setter Property="BorderBrush" TargetName="InnerBorder" Value="#80FFFFFF"/>
</Trigger>
<Trigger Property="IsEnabled" Value="False">
<Setter Property="Opacity" TargetName="Content" Value="0.5"/>
<Setter Property="TextElement.Foreground" TargetName="OuterBorder" Value="#FF9E9E9E"/>
</Trigger>
<Trigger Property="IsChecked" Value="True">
<Setter Property="Background" TargetName="OuterBorder">
<Setter.Value>
<LinearGradientBrush EndPoint="0,1" StartPoint="0,0">
<GradientStop Color="#FFFFDCA0" Offset="0"/>
<GradientStop Color="#FFFFD692" Offset="0.18"/>
<GradientStop Color="#FFFFC45D" Offset="0.39"/>
<GradientStop Color="#FFFFD178" Offset="1"/>
</LinearGradientBrush>
</Setter.Value>
</Setter>
<Setter Property="BorderBrush" TargetName="OuterBorder" Value="#FFC29B29"/>
<Setter Property="BorderBrush" TargetName="InnerBorder">
<Setter.Value>
<LinearGradientBrush EndPoint="0,1" StartPoint="0,0">
<GradientStop Color="#FFE7CBAD" Offset="0"/>
<GradientStop Color="#FFF7D7B5" Offset="0.1"/>
<GradientStop Color="#FFFFD38C" Offset="0.36"/>
<GradientStop Color="#FFFFC75A" Offset="0.36"/>
<GradientStop Color="#FFFFEFA5" Offset="1"/>
</LinearGradientBrush>
</Setter.Value>
</Setter>
</Trigger>
<Trigger Property="IsPressed" Value="True">
<Setter Property="Background" TargetName="OuterBorder">
<Setter.Value>
<LinearGradientBrush EndPoint="0,1" StartPoint="0,0">
<GradientStop Color="#FFE3C085" Offset="0"/>
<GradientStop Color="#FFF4CC89" Offset="0.19"/>
<GradientStop Color="#FFF5C777" Offset="0.36"/>
<GradientStop Color="#FFF5BB56" Offset="0.36"/>
<GradientStop Color="#FFF4CE9A" Offset="0.79"/>
<GradientStop Color="#FFF3E28D" Offset="1"/>
</LinearGradientBrush>
</Setter.Value>
</Setter>
<Setter Property="BorderBrush" TargetName="OuterBorder" Value="#FFC29B29"/>
<Setter Property="BorderBrush" TargetName="InnerBorder" Value="Transparent"/>
</Trigger>
<MultiTrigger>
<MultiTrigger.Conditions>
<Condition Property="IsChecked" Value="True"/>
<Condition Property="IsMouseOver" Value="True"/>
</MultiTrigger.Conditions>
<Setter Property="Background" TargetName="MiddleBorder">
<Setter.Value>
<LinearGradientBrush EndPoint="0,1" StartPoint="0,0">
<GradientStop Color="#40FFFEFE" Offset="0"/>
<GradientStop Color="#40FFFEFE" Offset="0.39"/>
<GradientStop Color="#20FFCE68" Offset="0.39"/>
<GradientStop Color="#20FFCE68" Offset="0.69"/>
<GradientStop Color="#10FFFFFF" Offset="1"/>
</LinearGradientBrush>
</Setter.Value>
</Setter>
</MultiTrigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</ToggleButton.Style>
<Image>
<Image.Source>
<BitmapImage UriSource="pack://application:,,,/Xceed.Wpf.Toolkit;v2.2.0.0;component/RichTextBoxFormatBar/Images/Underline16.png"/>
</Image.Source>
</Image>
</ToggleButton>
<ToggleButton ToolTip="ToggleStrikethrough" Click="StrikeThroughButton_Click">
<ToggleButton.Style>
<Style TargetType="{x:Type ToggleButton}">
<Setter Property="Background" Value="Transparent"/>
<Setter Property="BorderBrush" Value="Transparent"/>
<Setter Property="BorderThickness" Value="1"/>
<Setter Property="FocusVisualStyle" Value="{x:Null}"/>
<Setter Property="Height" Value="22"/>
<Setter Property="HorizontalContentAlignment" Value="Center"/>
<Setter Property="ToolTipService.InitialShowDelay" Value="900"/>
<Setter Property="ToolTipService.ShowDuration" Value="20000"/>
<Setter Property="ToolTipService.BetweenShowDelay" Value="0"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type ToggleButton}">
<Grid SnapsToDevicePixels="True">
<Border x:Name="OuterBorder" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Background="{TemplateBinding Background}" CornerRadius="2"/>
<Border x:Name="MiddleBorder" BorderBrush="Transparent" BorderThickness="{TemplateBinding BorderThickness}" Background="Transparent" CornerRadius="2">
<Border x:Name="InnerBorder" BorderBrush="Transparent" BorderThickness="{TemplateBinding BorderThickness}" Background="Transparent" CornerRadius="2" Padding="{TemplateBinding Padding}">
<StackPanel x:Name="StackPanel" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}">
<ContentPresenter x:Name="Content" RenderOptions.BitmapScalingMode="NearestNeighbor" Content="{TemplateBinding Content}" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" Margin="1" VerticalAlignment="Center"/>
</StackPanel>
</Border>
</Border>
</Grid>
<ControlTemplate.Triggers>
<Trigger Property="IsMouseOver" Value="True">
<Setter Property="Background" TargetName="OuterBorder">
<Setter.Value>
<LinearGradientBrush EndPoint="0,1" StartPoint="0,0">
<GradientStop Color="#FFFEFBF4" Offset="0"/>
<GradientStop Color="#FFFDE7CE" Offset="0.19"/>
<GradientStop Color="#FFFDDEB8" Offset="0.39"/>
<GradientStop Color="#FFFFCE6B" Offset="0.39"/>
<GradientStop Color="#FFFFDE9A" Offset="0.79"/>
<GradientStop Color="#FFFFEBAA" Offset="1"/>
</LinearGradientBrush>
</Setter.Value>
</Setter>
<Setter Property="BorderBrush" TargetName="OuterBorder" Value="#FFFFB700"/>
<Setter Property="BorderBrush" TargetName="InnerBorder" Value="#80FFFFFF"/>
</Trigger>
<Trigger Property="IsEnabled" Value="False">
<Setter Property="Opacity" TargetName="Content" Value="0.5"/>
<Setter Property="TextElement.Foreground" TargetName="OuterBorder" Value="#FF9E9E9E"/>
</Trigger>
<Trigger Property="IsChecked" Value="True">
<Setter Property="Background" TargetName="OuterBorder">
<Setter.Value>
<LinearGradientBrush EndPoint="0,1" StartPoint="0,0">
<GradientStop Color="#FFFFDCA0" Offset="0"/>
<GradientStop Color="#FFFFD692" Offset="0.18"/>
<GradientStop Color="#FFFFC45D" Offset="0.39"/>
<GradientStop Color="#FFFFD178" Offset="1"/>
</LinearGradientBrush>
</Setter.Value>
</Setter>
<Setter Property="BorderBrush" TargetName="OuterBorder" Value="#FFC29B29"/>
<Setter Property="BorderBrush" TargetName="InnerBorder">
<Setter.Value>
<LinearGradientBrush EndPoint="0,1" StartPoint="0,0">
<GradientStop Color="#FFE7CBAD" Offset="0"/>
<GradientStop Color="#FFF7D7B5" Offset="0.1"/>
<GradientStop Color="#FFFFD38C" Offset="0.36"/>
<GradientStop Color="#FFFFC75A" Offset="0.36"/>
<GradientStop Color="#FFFFEFA5" Offset="1"/>
</LinearGradientBrush>
</Setter.Value>
</Setter>
</Trigger>
<Trigger Property="IsPressed" Value="True">
<Setter Property="Background" TargetName="OuterBorder">
<Setter.Value>
<LinearGradientBrush EndPoint="0,1" StartPoint="0,0">
<GradientStop Color="#FFE3C085" Offset="0"/>
<GradientStop Color="#FFF4CC89" Offset="0.19"/>
<GradientStop Color="#FFF5C777" Offset="0.36"/>
<GradientStop Color="#FFF5BB56" Offset="0.36"/>
<GradientStop Color="#FFF4CE9A" Offset="0.79"/>
<GradientStop Color="#FFF3E28D" Offset="1"/>
</LinearGradientBrush>
</Setter.Value>
</Setter>
<Setter Property="BorderBrush" TargetName="OuterBorder" Value="#FFC29B29"/>
<Setter Property="BorderBrush" TargetName="InnerBorder" Value="Transparent"/>
</Trigger>
<MultiTrigger>
<MultiTrigger.Conditions>
<Condition Property="IsChecked" Value="True"/>
<Condition Property="IsMouseOver" Value="True"/>
</MultiTrigger.Conditions>
<Setter Property="Background" TargetName="MiddleBorder">
<Setter.Value>
<LinearGradientBrush EndPoint="0,1" StartPoint="0,0">
<GradientStop Color="#40FFFEFE" Offset="0"/>
<GradientStop Color="#40FFFEFE" Offset="0.39"/>
<GradientStop Color="#20FFCE68" Offset="0.39"/>
<GradientStop Color="#20FFCE68" Offset="0.69"/>
<GradientStop Color="#10FFFFFF" Offset="1"/>
</LinearGradientBrush>
</Setter.Value>
</Setter>
</MultiTrigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</ToggleButton.Style>
<Image Source="/ICSharpCode.WpfDesign.Designer;component/Images/edit-strike.png" />
</ToggleButton>
<Separator/>
<RadioButton x:Name="_btnAlignLeft" Visibility="Collapsed" CommandTarget="{Binding Target, RelativeSource={RelativeSource TemplatedParent}}" Command="EditingCommands.AlignLeft" ToolTip="Align Left">
</RadioButton>
<RadioButton x:Name="_btnAlignCenter" Visibility="Collapsed" CommandTarget="{Binding Target, RelativeSource={RelativeSource TemplatedParent}}" Command="EditingCommands.AlignCenter" ToolTip="Align Center">
</RadioButton>
<RadioButton x:Name="_btnAlignRight" Visibility="Collapsed" CommandTarget="{Binding Target, RelativeSource={RelativeSource TemplatedParent}}" Command="EditingCommands.AlignRight" ToolTip="Align Right">
</RadioButton>
<xctk:ColorPicker x:Name="_cmbFontBackgroundColor" BorderThickness="0" ToolTip="Text Highlight Color">
<xctk:ColorPicker.ButtonStyle>
<Style TargetType="{x:Type ToggleButton}">
<Setter Property="Background" Value="White"/>
<Setter Property="BorderBrush" Value="Transparent"/>
<Setter Property="BorderThickness" Value="1"/>
<Setter Property="FocusVisualStyle" Value="{x:Null}"/>
<Setter Property="Height" Value="22"/>
<Setter Property="HorizontalContentAlignment" Value="Center"/>
<Setter Property="ToolTipService.InitialShowDelay" Value="900"/>
<Setter Property="ToolTipService.ShowDuration" Value="20000"/>
<Setter Property="ToolTipService.BetweenShowDelay" Value="0"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type ToggleButton}">
<Grid SnapsToDevicePixels="True">
<Border x:Name="OuterBorder" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" CornerRadius="2"/>
<Border x:Name="MiddleBorder" BorderBrush="Transparent" BorderThickness="{TemplateBinding BorderThickness}" Background="Transparent" CornerRadius="2">
<Border x:Name="InnerBorder" BorderBrush="Transparent" BorderThickness="{TemplateBinding BorderThickness}" Background="Transparent" CornerRadius="2" Padding="{TemplateBinding Padding}">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
<ColumnDefinition/>
</Grid.ColumnDefinitions>
<Grid>
<Image Height="16" Width="16">
<Image.Source>
<BitmapImage UriSource="pack://application:,,,/Xceed.Wpf.Toolkit;v2.2.0.0;component/RichTextBoxFormatBar/Images/TextHighlightColorPicker16.png"/>
</Image.Source>
</Image>
<Rectangle Height="4" Margin="0,12,0,0" Grid.Row="1">
<Rectangle.Fill>
<Binding Path="SelectedColor" RelativeSource="{RelativeSource FindAncestor, AncestorLevel=1, AncestorType={x:Type xctk:ColorPicker}}">
<Binding.Converter>
<xctk:ColorToSolidColorBrushConverter/>
</Binding.Converter>
</Binding>
</Rectangle.Fill>
</Rectangle>
</Grid>
<Path Grid.Column="1" Data="M0,1C0,1 0,0 0,0 0,0 3,0 3,0 3,0 3,1 3,1 3,1 4,1 4,1 4,1 4,0 4,0 4,0 7,0 7,0 7,0 7,1 7,1 7,1 6,1 6,1 6,1 6,2 6,2 6,2 5,2 5,2 5,2 5,3 5,3 5,3 4,3 4,3 4,3 4,4 4,4 4,4 3,4 3,4 3,4 3,3 3,3 3,3 2,3 2,3 2,3 2,2 2,2 2,2 1,2 1,2 1,2 1,1 1,1 1,1 0,1 0,1z" Fill="Black" Height="4" Width="7"/>
</Grid>
</Border>
</Border>
</Grid>
<ControlTemplate.Triggers>
<Trigger Property="IsMouseOver" Value="True">
<Setter Property="Background" TargetName="OuterBorder">
<Setter.Value>
<LinearGradientBrush EndPoint="0,1" StartPoint="0,0">
<GradientStop Color="#FFFEFBF4" Offset="0"/>
<GradientStop Color="#FFFDE7CE" Offset="0.19"/>
<GradientStop Color="#FFFDDEB8" Offset="0.39"/>
<GradientStop Color="#FFFFCE6B" Offset="0.39"/>
<GradientStop Color="#FFFFDE9A" Offset="0.79"/>
<GradientStop Color="#FFFFEBAA" Offset="1"/>
</LinearGradientBrush>
</Setter.Value>
</Setter>
<Setter Property="BorderBrush" TargetName="OuterBorder" Value="#FFFFB700"/>
<Setter Property="BorderBrush" TargetName="InnerBorder" Value="#80FFFFFF"/>
</Trigger>
<Trigger Property="IsEnabled" Value="False">
<Setter Property="TextElement.Foreground" TargetName="OuterBorder" Value="#FF9E9E9E"/>
</Trigger>
<Trigger Property="IsChecked" Value="True">
<Setter Property="Background" TargetName="OuterBorder">
<Setter.Value>
<LinearGradientBrush EndPoint="0,1" StartPoint="0,0">
<GradientStop Color="#FFFFDCA0" Offset="0"/>
<GradientStop Color="#FFFFD692" Offset="0.18"/>
<GradientStop Color="#FFFFC45D" Offset="0.39"/>
<GradientStop Color="#FFFFD178" Offset="1"/>
</LinearGradientBrush>
</Setter.Value>
</Setter>
<Setter Property="BorderBrush" TargetName="OuterBorder" Value="#FFC29B29"/>
<Setter Property="BorderBrush" TargetName="InnerBorder">
<Setter.Value>
<LinearGradientBrush EndPoint="0,1" StartPoint="0,0">
<GradientStop Color="#FFE7CBAD" Offset="0"/>
<GradientStop Color="#FFF7D7B5" Offset="0.1"/>
<GradientStop Color="#FFFFD38C" Offset="0.36"/>
<GradientStop Color="#FFFFC75A" Offset="0.36"/>
<GradientStop Color="#FFFFEFA5" Offset="1"/>
</LinearGradientBrush>
</Setter.Value>
</Setter>
</Trigger>
<Trigger Property="IsPressed" Value="True">
<Setter Property="Background" TargetName="OuterBorder">
<Setter.Value>
<LinearGradientBrush EndPoint="0,1" StartPoint="0,0">
<GradientStop Color="#FFE3C085" Offset="0"/>
<GradientStop Color="#FFF4CC89" Offset="0.19"/>
<GradientStop Color="#FFF5C777" Offset="0.36"/>
<GradientStop Color="#FFF5BB56" Offset="0.36"/>
<GradientStop Color="#FFF4CE9A" Offset="0.79"/>
<GradientStop Color="#FFF3E28D" Offset="1"/>
</LinearGradientBrush>
</Setter.Value>
</Setter>
<Setter Property="BorderBrush" TargetName="OuterBorder" Value="#FFC29B29"/>
<Setter Property="BorderBrush" TargetName="InnerBorder" Value="Transparent"/>
</Trigger>
<MultiTrigger>
<MultiTrigger.Conditions>
<Condition Property="IsChecked" Value="True"/>
<Condition Property="IsMouseOver" Value="True"/>
</MultiTrigger.Conditions>
<Setter Property="Background" TargetName="MiddleBorder">
<Setter.Value>
<LinearGradientBrush EndPoint="0,1" StartPoint="0,0">
<GradientStop Color="#40FFFEFE" Offset="0"/>
<GradientStop Color="#40FFFEFE" Offset="0.39"/>
<GradientStop Color="#20FFCE68" Offset="0.39"/>
<GradientStop Color="#20FFCE68" Offset="0.69"/>
<GradientStop Color="#10FFFFFF" Offset="1"/>
</LinearGradientBrush>
</Setter.Value>
</Setter>
</MultiTrigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</xctk:ColorPicker.ButtonStyle>
</xctk:ColorPicker>
<xctk:ColorPicker x:Name="_cmbFontColor" BorderThickness="0" ToolTip="Font Color">
<xctk:ColorPicker.ButtonStyle>
<Style TargetType="{x:Type ToggleButton}">
<Setter Property="Background" Value="Transparent"/>
<Setter Property="BorderBrush" Value="Transparent"/>
<Setter Property="BorderThickness" Value="1"/>
<Setter Property="FocusVisualStyle" Value="{x:Null}"/>
<Setter Property="Height" Value="22"/>
<Setter Property="HorizontalContentAlignment" Value="Center"/>
<Setter Property="ToolTipService.InitialShowDelay" Value="900"/>
<Setter Property="ToolTipService.ShowDuration" Value="20000"/>
<Setter Property="ToolTipService.BetweenShowDelay" Value="0"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type ToggleButton}">
<Grid SnapsToDevicePixels="True">
<Border x:Name="OuterBorder" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" CornerRadius="2"/>
<Border x:Name="MiddleBorder" BorderBrush="Transparent" BorderThickness="{TemplateBinding BorderThickness}" Background="Transparent" CornerRadius="2">
<Border x:Name="InnerBorder" BorderBrush="Transparent" BorderThickness="{TemplateBinding BorderThickness}" Background="Transparent" CornerRadius="2" Padding="{TemplateBinding Padding}">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
<ColumnDefinition/>
</Grid.ColumnDefinitions>
<Grid>
<Image Height="16" Width="16">
<Image.Source>
<BitmapImage UriSource="pack://application:,,,/Xceed.Wpf.Toolkit;v2.2.0.0;component/RichTextBoxFormatBar/Images/FontColorPicker16.png"/>
</Image.Source>
</Image>
<Rectangle Height="4" Margin="0,12,0,0" Grid.Row="1">
<Rectangle.Fill>
<Binding Path="SelectedColor" RelativeSource="{RelativeSource FindAncestor, AncestorLevel=1, AncestorType={x:Type xctk:ColorPicker}}">
<Binding.Converter>
<xctk:ColorToSolidColorBrushConverter/>
</Binding.Converter>
</Binding>
</Rectangle.Fill>
</Rectangle>
</Grid>
<Path Grid.Column="1" Data="M0,1C0,1 0,0 0,0 0,0 3,0 3,0 3,0 3,1 3,1 3,1 4,1 4,1 4,1 4,0 4,0 4,0 7,0 7,0 7,0 7,1 7,1 7,1 6,1 6,1 6,1 6,2 6,2 6,2 5,2 5,2 5,2 5,3 5,3 5,3 4,3 4,3 4,3 4,4 4,4 4,4 3,4 3,4 3,4 3,3 3,3 3,3 2,3 2,3 2,3 2,2 2,2 2,2 1,2 1,2 1,2 1,1 1,1 1,1 0,1 0,1z" Fill="Black" Height="4" Width="7"/>
</Grid>
</Border>
</Border>
</Grid>
<ControlTemplate.Triggers>
<Trigger Property="IsMouseOver" Value="True">
<Setter Property="Background" TargetName="OuterBorder">
<Setter.Value>
<LinearGradientBrush EndPoint="0,1" StartPoint="0,0">
<GradientStop Color="#FFFEFBF4" Offset="0"/>
<GradientStop Color="#FFFDE7CE" Offset="0.19"/>
<GradientStop Color="#FFFDDEB8" Offset="0.39"/>
<GradientStop Color="#FFFFCE6B" Offset="0.39"/>
<GradientStop Color="#FFFFDE9A" Offset="0.79"/>
<GradientStop Color="#FFFFEBAA" Offset="1"/>
</LinearGradientBrush>
</Setter.Value>
</Setter>
<Setter Property="BorderBrush" TargetName="OuterBorder" Value="#FFFFB700"/>
<Setter Property="BorderBrush" TargetName="InnerBorder" Value="#80FFFFFF"/>
</Trigger>
<Trigger Property="IsEnabled" Value="False">
<Setter Property="TextElement.Foreground" TargetName="OuterBorder" Value="#FF9E9E9E"/>
</Trigger>
<Trigger Property="IsChecked" Value="True">
<Setter Property="Background" TargetName="OuterBorder">
<Setter.Value>
<LinearGradientBrush EndPoint="0,1" StartPoint="0,0">
<GradientStop Color="#FFFFDCA0" Offset="0"/>
<GradientStop Color="#FFFFD692" Offset="0.18"/>
<GradientStop Color="#FFFFC45D" Offset="0.39"/>
<GradientStop Color="#FFFFD178" Offset="1"/>
</LinearGradientBrush>
</Setter.Value>
</Setter>
<Setter Property="BorderBrush" TargetName="OuterBorder" Value="#FFC29B29"/>
<Setter Property="BorderBrush" TargetName="InnerBorder">
<Setter.Value>
<LinearGradientBrush EndPoint="0,1" StartPoint="0,0">
<GradientStop Color="#FFE7CBAD" Offset="0"/>
<GradientStop Color="#FFF7D7B5" Offset="0.1"/>
<GradientStop Color="#FFFFD38C" Offset="0.36"/>
<GradientStop Color="#FFFFC75A" Offset="0.36"/>
<GradientStop Color="#FFFFEFA5" Offset="1"/>
</LinearGradientBrush>
</Setter.Value>
</Setter>
</Trigger>
<Trigger Property="IsPressed" Value="True">
<Setter Property="Background" TargetName="OuterBorder">
<Setter.Value>
<LinearGradientBrush EndPoint="0,1" StartPoint="0,0">
<GradientStop Color="#FFE3C085" Offset="0"/>
<GradientStop Color="#FFF4CC89" Offset="0.19"/>
<GradientStop Color="#FFF5C777" Offset="0.36"/>
<GradientStop Color="#FFF5BB56" Offset="0.36"/>
<GradientStop Color="#FFF4CE9A" Offset="0.79"/>
<GradientStop Color="#FFF3E28D" Offset="1"/>
</LinearGradientBrush>
</Setter.Value>
</Setter>
<Setter Property="BorderBrush" TargetName="OuterBorder" Value="#FFC29B29"/>
<Setter Property="BorderBrush" TargetName="InnerBorder" Value="Transparent"/>
</Trigger>
<MultiTrigger>
<MultiTrigger.Conditions>
<Condition Property="IsChecked" Value="True"/>
<Condition Property="IsMouseOver" Value="True"/>
</MultiTrigger.Conditions>
<Setter Property="Background" TargetName="MiddleBorder">
<Setter.Value>
<LinearGradientBrush EndPoint="0,1" StartPoint="0,0">
<GradientStop Color="#40FFFEFE" Offset="0"/>
<GradientStop Color="#40FFFEFE" Offset="0.39"/>
<GradientStop Color="#20FFCE68" Offset="0.39"/>
<GradientStop Color="#20FFCE68" Offset="0.69"/>
<GradientStop Color="#10FFFFFF" Offset="1"/>
</LinearGradientBrush>
</Setter.Value>
</Setter>
</MultiTrigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</xctk:ColorPicker.ButtonStyle>
</xctk:ColorPicker>
</StackPanel>
</StackPanel>
</Grid>
</Border>
</ControlTemplate>
</Setter.Value>
</Setter>
<Setter Property="Background" Value="Transparent"/>
<Setter Property="IsTabStop" Value="False"/>
</Style>
</UserControl.Resources>
<Grid>
<xctk:RichTextBox Margin="10,74,10,10" x:Name="richTextBox">
</xctk:RichTextBox>
<xctk:RichTextBoxFormatBar x:Name="formatBar" Target="{Binding ElementName=richTextBox}" Margin="10,10,0,0" Style="{DynamicResource RichTextBoxFormatBarStyle}" HorizontalAlignment="Left" Width="295" Height="59" VerticalAlignment="Top" />
<Button Content="Ok" Margin="0,10,10,0" HorizontalAlignment="Right" Width="90" Height="20" VerticalAlignment="Top" Click="Ok_Click" />
<Button Content="Cancel" Margin="0,34,10,0" HorizontalAlignment="Right" Width="90" Height="20" VerticalAlignment="Top" Click="Cancel_Click" />
</Grid>
</UserControl>

211
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/PropertyGrid/Editors/FormatedTextEditor/FormatedTextEditor.xaml.cs

@ -0,0 +1,211 @@ @@ -0,0 +1,211 @@
// 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.Collections.Generic;
using System.Linq;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Media;
using ICSharpCode.WpfDesign.Designer.Xaml;
namespace ICSharpCode.WpfDesign.Designer.PropertyGrid.Editors.FormatedTextEditor
{
/// <summary>
/// Interaktionslogik für FormatedTextEditor.xaml
/// </summary>
public partial class FormatedTextEditor
{
private DesignItem designItem;
public FormatedTextEditor(DesignItem designItem)
{
InitializeComponent();
this.designItem = designItem;
IEnumerable<Inline> inlines = null;
var tb = ((TextBlock) designItem.Component);
inlines = tb.Inlines.Select(x => CloneInline(x)).ToList();
var paragraph = richTextBox.Document.Blocks.First() as Paragraph;
paragraph.Inlines.AddRange(inlines);
richTextBox.Document.Blocks.Add(paragraph);
richTextBox.Foreground = tb.Foreground;
richTextBox.Background = tb.Background;
}
private void GetDesignItems(TextElementCollection<Block> blocks, List<DesignItem> list)
{
bool first = true;
foreach (var block in blocks)
{
if (block is Paragraph)
{
if (!first)
{
list.Add(designItem.Services.Component.RegisterComponentForDesigner(new LineBreak()));
list.Add(designItem.Services.Component.RegisterComponentForDesigner(new LineBreak()));
}
foreach (var inline in ((Paragraph) block).Inlines)
{
list.Add(InlineToDesignItem(inline));
}
}
else if (block is Section)
{
GetDesignItems(((Section)block).Blocks, list);
}
first = false;
}
}
private Inline CloneInline(Inline inline)
{
Inline retVal = null;
if (inline is LineBreak)
retVal = new LineBreak();
else if (inline is Span)
retVal = new Span();
else if (inline is Run)
{
retVal = new Run(((Run) inline).Text);
}
retVal.Background = inline.Background;
retVal.Foreground = inline.Foreground;
retVal.FontFamily = inline.FontFamily;
retVal.FontSize = inline.FontSize;
retVal.FontStretch = inline.FontStretch;
retVal.FontStyle = inline.FontStyle;
retVal.FontWeight = inline.FontWeight;
retVal.TextEffects = inline.TextEffects;
retVal.TextDecorations = inline.TextDecorations;
return retVal;
}
private DesignItem InlineToDesignItem(Inline inline)
{
DesignItem d = d = designItem.Services.Component.RegisterComponentForDesigner(CloneInline(inline));
if (inline is Run)
{
var run = inline as Run;
if (run.ReadLocalValue(Run.TextProperty) != DependencyProperty.UnsetValue)
{
d.Properties.GetProperty(Run.TextProperty).SetValue(run.Text);
}
}
else if (inline is Span)
{ }
else if (inline is LineBreak)
{ }
else
{
return null;
}
if (inline.ReadLocalValue(TextElement.BackgroundProperty) != DependencyProperty.UnsetValue)
d.Properties.GetProperty(TextElement.BackgroundProperty).SetValue(inline.Background);
if (inline.ReadLocalValue(TextElement.ForegroundProperty) != DependencyProperty.UnsetValue)
d.Properties.GetProperty(TextElement.ForegroundProperty).SetValue(inline.Foreground);
if (inline.ReadLocalValue(TextElement.FontFamilyProperty) != DependencyProperty.UnsetValue)
d.Properties.GetProperty(TextElement.FontFamilyProperty).SetValue(inline.FontFamily);
if (inline.ReadLocalValue(TextElement.FontSizeProperty) != DependencyProperty.UnsetValue)
d.Properties.GetProperty(TextElement.FontSizeProperty).SetValue(inline.FontSize);
if (inline.ReadLocalValue(TextElement.FontStretchProperty) != DependencyProperty.UnsetValue)
d.Properties.GetProperty(TextElement.FontStretchProperty).SetValue(inline.FontStretch);
if (inline.ReadLocalValue(TextElement.FontStyleProperty) != DependencyProperty.UnsetValue)
d.Properties.GetProperty(TextElement.FontStyleProperty).SetValue(inline.FontStyle);
if (inline.ReadLocalValue(TextElement.FontWeightProperty) != DependencyProperty.UnsetValue)
d.Properties.GetProperty(TextElement.FontWeightProperty).SetValue(inline.FontWeight);
if (inline.TextDecorations.Count > 0)
{
d.Properties.GetProperty("TextDecorations").SetValue(new TextDecorationCollection());
var tdColl = d.Properties.GetProperty("TextDecorations");
foreach (var td in inline.TextDecorations)
{
var newTd = designItem.Services.Component.RegisterComponentForDesigner(new TextDecoration());
if (inline.ReadLocalValue(TextDecoration.LocationProperty) != DependencyProperty.UnsetValue)
newTd.Properties.GetProperty(TextDecoration.LocationProperty).SetValue(td.Location);
if (inline.ReadLocalValue(TextDecoration.PenProperty) != DependencyProperty.UnsetValue)
newTd.Properties.GetProperty(TextDecoration.PenProperty).SetValue(td.Pen);
tdColl.CollectionElements.Add(newTd);
}
}
return d;
}
private void Ok_Click(object sender, RoutedEventArgs e)
{
var changeGroup = designItem.OpenGroup("Formated Text");
designItem.Properties.GetProperty(TextBlock.TextProperty).Reset();
var inlinesProperty = designItem.Properties.GetProperty("Inlines");
inlinesProperty.CollectionElements.Clear();
var doc = richTextBox.Document;
richTextBox.Document = new FlowDocument();
var inlines = new List<DesignItem>();
GetDesignItems(doc.Blocks, inlines);
foreach (var inline in inlines)
{
inlinesProperty.CollectionElements.Add(inline);
}
changeGroup.Commit();
this.TryFindParent<Window>().Close();
}
private void Cancel_Click(object sender, RoutedEventArgs e)
{
this.TryFindParent<Window>().Close();
}
private void StrikeThroughButton_Click(object sender, RoutedEventArgs e)
{
TextRange range = new TextRange(richTextBox.Selection.Start, richTextBox.Selection.End);
TextDecorationCollection tdc = (TextDecorationCollection) richTextBox.Selection.GetPropertyValue(Inline.TextDecorationsProperty);
if (tdc == null || !tdc.Equals(TextDecorations.Strikethrough))
{
tdc = TextDecorations.Strikethrough;
}
else
{
tdc = null;
}
range.ApplyPropertyValue(Inline.TextDecorationsProperty, tdc);
}
}
}

68
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Translations.cs

@ -26,11 +26,11 @@ namespace ICSharpCode.WpfDesign.Designer @@ -26,11 +26,11 @@ namespace ICSharpCode.WpfDesign.Designer
public class Translations
{
private static Translations _instance;
public static Translations Instance {
public static Translations Instance {
get {
if (_instance == null)
_instance = new Translations();
return _instance;
return _instance;
} protected set {
_instance = value;
}
@ -77,11 +77,73 @@ namespace ICSharpCode.WpfDesign.Designer @@ -77,11 +77,73 @@ namespace ICSharpCode.WpfDesign.Designer
return "Wrap in Grid";
}
}
public virtual string WrapInBorder {
get {
return "Wrap in Border";
}
}
public virtual string WrapInViewbox {
get {
return "Wrap in Viewbox";
}
}
public virtual string FormatedTextEditor
{
get
{
return "Formated Text Editor";
}
}
public virtual string ArrangeLeft
{
get
{
return "Arrange Left";
}
}
public virtual string ArrangeHorizontalMiddle
{
get
{
return "Horizontal centered";
}
}
public virtual string ArrangeRight
{
get
{
return "Arrange Right";
}
}
public virtual string ArrangeTop
{
get
{
return "Arrange Top";
}
}
public virtual string ArrangeVerticalMiddle
{
get
{
return "Vertical centered";
}
}
public virtual string ArrangeBottom
{
get
{
return "Arrange Bottom";
}
}
}
}

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

@ -83,18 +83,32 @@ @@ -83,18 +83,32 @@
<Compile Include="..\..\..\..\..\Main\GlobalAssemblyInfo.cs">
<Link>Configuration\GlobalAssemblyInfo.cs</Link>
</Compile>
<Compile Include="ArrangeDirection.cs" />
<Compile Include="Controls\RenderTransformOriginThumb.cs" />
<Compile Include="Extensions\BorderForImageControl.cs" />
<Compile Include="Extensions\PartialPanelSelectionHandler.cs" />
<Compile Include="Extensions\TextBlockRightClickContextMenu.xaml.cs">
<DependentUpon>TextBlockRightClickContextMenu.xaml</DependentUpon>
</Compile>
<Compile Include="Extensions\RightClickContextMenu.xaml.cs">
<DependentUpon>RightClickContextMenu.xaml</DependentUpon>
<SubType>Code</SubType>
</Compile>
<Compile Include="Extensions\RenderTransformOriginExtension.cs" />
<Compile Include="Extensions\RightClickContextMenuExtension.cs" />
<Compile Include="Extensions\TextBlockRightClickContextMenuExtension.cs" />
<Compile Include="Extensions\ArrangeItemsContextMenuExtension.cs" />
<Compile Include="Extensions\ArrangeItemsContextMenu.xaml.cs">
<DependentUpon>ArrangeItemsContextMenu.xaml</DependentUpon>
</Compile>
<Compile Include="Extensions\WrapItemContextMenu.xaml.cs">
<DependentUpon>WrapItemContextMenu.xaml</DependentUpon>
</Compile>
<Compile Include="Extensions\WrapItemsContextMenuExtension.cs" />
<Compile Include="OutlineView\OutlineNodeBase.cs" />
<Compile Include="Extensions\RightClickMultipleItemsContextMenuExtension.cs" />
<Compile Include="Extensions\RightClickMultipleItemsContextMenu.xaml.cs">
<DependentUpon>RightClickMultipleItemsContextMenu.xaml</DependentUpon>
<Compile Include="Extensions\WrapItemContextMenuExtension.cs" />
<Compile Include="Extensions\WrapItemsContextMenu.xaml.cs">
<DependentUpon>WrapItemsContextMenu.xaml</DependentUpon>
</Compile>
<Compile Include="Extensions\SkewThumbExtension.cs" />
<Compile Include="Extensions\TopLeftContainerDragHandleMultipleItems.cs" />
@ -105,6 +119,9 @@ @@ -105,6 +119,9 @@
<DependentUpon>FlatCollectionEditor.xaml</DependentUpon>
<SubType>Code</SubType>
</Compile>
<Compile Include="PropertyGrid\Editors\FormatedTextEditor\FormatedTextEditor.xaml.cs">
<DependentUpon>FormatedTextEditor.xaml</DependentUpon>
</Compile>
<Compile Include="PropertyGrid\Editors\OpenCollectionEditor.xaml.cs">
<DependentUpon>OpenCollectionEditor.xaml</DependentUpon>
</Compile>
@ -268,10 +285,25 @@ @@ -268,10 +285,25 @@
<Resource Include="Images\Tag.png" />
</ItemGroup>
<ItemGroup>
<Page Include="Extensions\TextBlockRightClickContextMenu.xaml">
<SubType>Designer</SubType>
</Page>
<Page Include="Extensions\RightClickContextMenu.xaml" />
<Page Include="Extensions\RightClickMultipleItemsContextMenu.xaml" />
<Page Include="Extensions\ArrangeItemsContextMenu.xaml">
<SubType>Designer</SubType>
</Page>
<Page Include="Extensions\WrapItemContextMenu.xaml">
<SubType>Designer</SubType>
</Page>
<Page Include="Extensions\WrapItemsContextMenu.xaml">
<SubType>Designer</SubType>
</Page>
<Page Include="PropertyGrid\Editors\ColorEditor.xaml" />
<Page Include="PropertyGrid\Editors\FlatCollectionEditor.xaml" />
<Page Include="PropertyGrid\Editors\FormatedTextEditor\FormatedTextEditor.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="PropertyGrid\Editors\OpenCollectionEditor.xaml" />
<Page Include="PropertyGrid\Editors\TimeSpanEditor.xaml" />
<Page Include="ThumbnailView\ThumbnailView.xaml" />
@ -380,7 +412,20 @@ @@ -380,7 +412,20 @@
<Resource Include="Images\group2.png" />
</ItemGroup>
<ItemGroup>
<Folder Include="ThumbnailView" />
<Resource Include="Images\edit-bold.png" />
<Resource Include="Images\edit-color.png" />
<Resource Include="Images\edit-italic.png" />
<Resource Include="Images\edit-strike.png" />
<Resource Include="Images\layers-alignment-bottom.png" />
<Resource Include="Images\layers-alignment-center.png" />
<Resource Include="Images\layers-alignment-left.png" />
<Resource Include="Images\layers-alignment-middle.png" />
<Resource Include="Images\layers-alignment-right.png" />
<Resource Include="Images\layers-alignment.png" />
<Resource Include="Images\layers-arrange-back.png" />
<Resource Include="Images\layers-arrange.png" />
<Resource Include="Images\layers-stack-arrange-back.png" />
<Resource Include="Images\layers-stack-arrange.png" />
</ItemGroup>
<ItemGroup>
<Resource Include="Images\Icons.16x16.Properties.Events.png" />
@ -395,4 +440,22 @@ @@ -395,4 +440,22 @@
<ItemGroup>
<Resource Include="Images\lock.png" />
</ItemGroup>
<ItemGroup>
<Resource Include="Images\edit.png" />
</ItemGroup>
<ItemGroup>
<Resource Include="Images\grid.png" />
</ItemGroup>
<ItemGroup>
<Resource Include="Images\edit-underline.png" />
</ItemGroup>
<ItemGroup>
<Resource Include="Images\paint-can-color.png" />
</ItemGroup>
<ItemGroup>
<Resource Include="Images\wrap-option.png" />
</ItemGroup>
<ItemGroup>
<Resource Include="Images\canvas.png" />
</ItemGroup>
</Project>

11
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Tests/Designer/OutlineView/InsertTests.cs

@ -241,7 +241,6 @@ namespace ICSharpCode.WpfDesign.Tests.Designer.OutlineView @@ -241,7 +241,6 @@ namespace ICSharpCode.WpfDesign.Tests.Designer.OutlineView
}
[Test]
[Ignore]
public void CheckStackPanelChildrenCountWhenCopy()
{
InsertIntoButtonByCopy();
@ -250,25 +249,23 @@ namespace ICSharpCode.WpfDesign.Tests.Designer.OutlineView @@ -250,25 +249,23 @@ namespace ICSharpCode.WpfDesign.Tests.Designer.OutlineView
}
[Test]
[Ignore]
public void CheckElementInOutlineWhenCopy()
{
InsertIntoButtonByCopy();
Assert.AreEqual(_gridButtonNode, _outline.Children[0]);
Assert.AreEqual(_stackPanelImageNode, _outline.Children[0].Children[0]);
Assert.AreEqual(_stackPanelImageNode.DesignItem.ComponentType, _outline.Children[0].Children[0].DesignItem.ComponentType);
Assert.AreEqual(_stackPanelNode, _outline.Children[1]);
Assert.AreEqual(_stackPanelImageNode, _outline.Children[1].Children[0]);
}
[Test]
[Ignore]
public void CheckElementInDesignerWhenCopy()
{
InsertIntoButtonByCopy();
Assert.AreEqual(_gridButton, _grid.ContentProperty.CollectionElements[0]);
Assert.AreEqual(_stackPanelImage, _grid.ContentProperty.CollectionElements[0].ContentProperty.ValueOnInstance);
Assert.AreEqual(_stackPanel, _grid.ContentProperty.CollectionElements[1]);
Assert.AreEqual(_stackPanel, _grid.ContentProperty.CollectionElements[1].ContentProperty.CollectionElements[0]);
Assert.AreEqual(_stackPanelImage.ComponentType, _grid.ContentProperty.CollectionElements[0].ContentProperty.Value.ComponentType);
Assert.AreEqual(_stackPanel.ComponentType, _grid.ContentProperty.CollectionElements[1].ComponentType);
Assert.AreEqual(_stackPanelImage, _grid.ContentProperty.CollectionElements[1].ContentProperty.CollectionElements[0]);
}
#endregion

2
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Tests/Designer/PlacementTests.cs

@ -53,7 +53,6 @@ namespace ICSharpCode.WpfDesign.Tests.Designer @@ -53,7 +53,6 @@ namespace ICSharpCode.WpfDesign.Tests.Designer
}
[Test]
[Ignore("Currently bounds calculated using visuals")]
public void MoveFixedWidthButton()
{
DesignItem button = CreateCanvasContext("<Button Width='100' Height='200'/>");
@ -135,7 +134,6 @@ namespace ICSharpCode.WpfDesign.Tests.Designer @@ -135,7 +134,6 @@ namespace ICSharpCode.WpfDesign.Tests.Designer
}
[Test]
[Ignore("Bounds calculated using Visuals")]
public void AssertSizeForFixedSize()
{
Assert.AreEqual(50,_buttonIsGridWithFixedSize.Properties[FrameworkElement.HeightProperty].ValueOnInstance);

5
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Tests/WpfDesign.Tests.csproj

@ -72,6 +72,7 @@ @@ -72,6 +72,7 @@
<Compile Include="Designer\OutlineView\SelectionTests.cs" />
<Compile Include="Designer\PlacementTests.cs" />
<Compile Include="Designer\SetPropertyTests.cs" />
<Compile Include="XamlDom\CollectionTests.cs" />
<Compile Include="XamlDom\ExampleClass.cs" />
<Compile Include="XamlDom\ExampleClassContainer.cs" />
<Compile Include="XamlDom\ExampleService.cs" />
@ -101,7 +102,5 @@ @@ -101,7 +102,5 @@
<Name>WpfDesign.Designer</Name>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<Folder Include="Designer\OutlineView" />
</ItemGroup>
<ItemGroup />
</Project>

24
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Tests/XamlDom/CollectionTests.cs

@ -0,0 +1,24 @@ @@ -0,0 +1,24 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Documents;
using System.Windows.Media.Animation;
using ICSharpCode.WpfDesign.XamlDom;
using NUnit.Framework;
namespace ICSharpCode.WpfDesign.Tests.XamlDom
{
[TestFixture]
public class CollectionTests
{
[Test]
public void LineBreakNoCollection()
{
var isCollection = CollectionSupport.IsCollectionType(typeof(LineBreak));
Assert.IsFalse(isCollection);
}
}
}

1
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Tests/XamlDom/MarkupExtensionTests.cs

@ -71,7 +71,6 @@ namespace ICSharpCode.WpfDesign.Tests.XamlDom @@ -71,7 +71,6 @@ namespace ICSharpCode.WpfDesign.Tests.XamlDom
}
[Test]
[Ignore]
public void Test7()
{
TestMarkupExtension("Background=\"{DynamicResource {x:Static SystemColors.ControlBrushKey}}\"");

227
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Tests/XamlDom/SamplesTests.cs

@ -140,5 +140,230 @@ namespace ICSharpCode.WpfDesign.Tests.XamlDom @@ -140,5 +140,230 @@ namespace ICSharpCode.WpfDesign.Tests.XamlDom
</StackPanel>
</Page>");
}
}
[Test]
public void Resources2()
{
TestLoading(@"<UserControl
xmlns=""http://schemas.microsoft.com/winfx/2006/xaml/presentation""
xmlns:x=""http://schemas.microsoft.com/winfx/2006/xaml"">
<UserControl.Resources>
<ResourceDictionary />
</UserControl.Resources>
</UserControl>");
}
[Test]
public void Resources3()
{
TestLoading(@"<UserControl
xmlns=""http://schemas.microsoft.com/winfx/2006/xaml/presentation""
xmlns:x=""http://schemas.microsoft.com/winfx/2006/xaml"">
<FrameworkElement.Resources>
<ResourceDictionary />
</FrameworkElement.Resources>
</UserControl>");
}
[Test]
public void Resources4()
{
TestLoading(@"<UserControl
xmlns=""http://schemas.microsoft.com/winfx/2006/xaml/presentation""
xmlns:x=""http://schemas.microsoft.com/winfx/2006/xaml"">
<UserControl.Resources>
<ResourceDictionary>
<SolidColorBrush x:Key=""MyBrush"" Color=""Gold""/>
</ResourceDictionary>
</UserControl.Resources>
</UserControl>");
}
[Test]
public void Animation1()
{
TestLoading(@"<Window
xmlns=""http://schemas.microsoft.com/winfx/2006/xaml/presentation""
xmlns:x=""http://schemas.microsoft.com/winfx/2006/xaml"">
<Canvas>
<Button Width=""100"" Height=""100"" Canvas.Left=""8"" Canvas.Top=""8"">
<Button.Triggers>
<EventTrigger RoutedEvent=""Button.Loaded"">
<BeginStoryboard>
<Storyboard>
<DoubleAnimation Duration=""0:0:10""
From=""1""
To=""0""
Storyboard.TargetProperty=""Opacity"" />
</Storyboard>
</BeginStoryboard>
</EventTrigger>
</Button.Triggers>
</Button>
</Canvas>
</Window>");
}
[Test]
public void Animation2()
{
//Loaded Property has to be found, because this so also works in WPF
TestLoading(@"<Window
xmlns=""http://schemas.microsoft.com/winfx/2006/xaml/presentation""
xmlns:x=""http://schemas.microsoft.com/winfx/2006/xaml"">
<Canvas>
<Button Width=""100"" Height=""100"" Canvas.Left=""8"" Canvas.Top=""8"">
<Button.Triggers>
<EventTrigger RoutedEvent=""Loaded"">
<BeginStoryboard>
<Storyboard>
<DoubleAnimation Duration=""0:0:10""
From=""1""
To=""0""
Storyboard.TargetProperty=""Opacity"" />
</Storyboard>
</BeginStoryboard>
</EventTrigger>
</Button.Triggers>
</Button>
</Canvas>
</Window>");
}
[Test]
public void Animation3()
{
TestLoading(@"<Window
xmlns=""http://schemas.microsoft.com/winfx/2006/xaml/presentation""
xmlns:x=""http://schemas.microsoft.com/winfx/2006/xaml"">
<Canvas>
<Button Width=""100"" Height=""100"" Canvas.Left=""8"" Canvas.Top=""8"">
<Button.Triggers>
<EventTrigger RoutedEvent=""Button.Loaded"">
<BeginStoryboard>
<BeginStoryboard.Storyboard>
<Storyboard>
<DoubleAnimation Duration=""0:0:10""
From=""1""
To=""0""
Storyboard.TargetProperty=""Opacity"" />
</Storyboard>
</BeginStoryboard.Storyboard>
</BeginStoryboard>
</EventTrigger>
</Button.Triggers>
</Button>
</Canvas>
</Window>");
}
[Test]
public void ContentControl1()
{
TestLoading(@"<Window
xmlns=""http://schemas.microsoft.com/winfx/2006/xaml/presentation""
xmlns:x=""http://schemas.microsoft.com/winfx/2006/xaml"">
<Canvas>
<ContentControl>
<Grid />
</ContentControl>
</Canvas>
</Window>");
}
[Test]
public void ContentControl2()
{
TestLoading(@"<Window
xmlns=""http://schemas.microsoft.com/winfx/2006/xaml/presentation""
xmlns:x=""http://schemas.microsoft.com/winfx/2006/xaml"">
<Canvas>
<ContentControl>
<ContentControl.Content>
<Grid />
</ContentControl.Content>
</ContentControl>
</Canvas>
</Window>");
}
[Test]
public void Children1()
{
TestLoading(@"<Window
xmlns=""http://schemas.microsoft.com/winfx/2006/xaml/presentation""
xmlns:x=""http://schemas.microsoft.com/winfx/2006/xaml"">
<Canvas>
<Button />
</Canvas>
</Window>");
}
[Test]
public void Children2()
{
TestLoading(@"<Window
xmlns=""http://schemas.microsoft.com/winfx/2006/xaml/presentation""
xmlns:x=""http://schemas.microsoft.com/winfx/2006/xaml"">
<Canvas>
<Canvas.Children>
<Button />
</Canvas.Children>
</Canvas>
</Window>");
}
[Test]
public void Children3()
{
TestLoading(@"<Window
xmlns=""http://schemas.microsoft.com/winfx/2006/xaml/presentation""
xmlns:x=""http://schemas.microsoft.com/winfx/2006/xaml"">
<Canvas>
<Canvas.Children>
<Button />
</Canvas.Children>
</Canvas>
</Window>");
}
[Test]
public void ListBox1()
{
TestLoading(@"<Window
xmlns=""http://schemas.microsoft.com/winfx/2006/xaml/presentation""
xmlns:x=""http://schemas.microsoft.com/winfx/2006/xaml"">
<Canvas>
<ListBox>
aa
bb
</ListBox>
</Canvas>
</Window>");
}
[Test]
public void CData1()
{
TestLoading(@"<Window
xmlns=""http://schemas.microsoft.com/winfx/2006/xaml/presentation""
xmlns:x=""http://schemas.microsoft.com/winfx/2006/xaml"">
<Canvas>
<Button>Press</Button>
<x:Code>
<![CDATA[
public void ButtonOnClick(object sender, RoutedEventArgs args)
{
Button btn = sender as Button;
MessageBox.Show(""Button clicked"", ""Hello"");
}
]]>
</x:Code>
</Canvas>
</Window>");
}
}
}

6
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.XamlDom/Project/CollectionSupport.cs

@ -23,6 +23,7 @@ using System.ComponentModel; @@ -23,6 +23,7 @@ using System.ComponentModel;
using System.Globalization;
using System.Reflection;
using System.Windows;
using System.Windows.Documents;
using System.Windows.Markup;
namespace ICSharpCode.WpfDesign.XamlDom
@ -37,10 +38,11 @@ namespace ICSharpCode.WpfDesign.XamlDom @@ -37,10 +38,11 @@ namespace ICSharpCode.WpfDesign.XamlDom
/// </summary>
public static bool IsCollectionType(Type type)
{
return typeof(IList).IsAssignableFrom(type)
return type != typeof(LineBreak) && (
typeof(IList).IsAssignableFrom(type)
|| type.IsArray
|| typeof(IAddChild).IsAssignableFrom(type)
|| typeof(IDictionary).IsAssignableFrom(type);
|| typeof(IDictionary).IsAssignableFrom(type));
}
/// <summary>

2
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.XamlDom/Project/XamlObject.cs

@ -70,7 +70,7 @@ namespace ICSharpCode.WpfDesign.XamlDom @@ -70,7 +70,7 @@ namespace ICSharpCode.WpfDesign.XamlDom
if (property.IsAttached == false) {
foreach (XamlProperty p in properties) {
if (p.IsAttached == false && p.PropertyName == property.PropertyName)
Debug.Fail("duplicate property");
throw new XamlLoadException("duplicate property");
}
}
#endif

64
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.XamlDom/Project/XamlObjectServiceProvider.cs

@ -21,6 +21,7 @@ using System.Collections.Generic; @@ -21,6 +21,7 @@ using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Markup;
using System.Xaml;
namespace ICSharpCode.WpfDesign.XamlDom
{
@ -28,7 +29,7 @@ namespace ICSharpCode.WpfDesign.XamlDom @@ -28,7 +29,7 @@ namespace ICSharpCode.WpfDesign.XamlDom
/// A service provider that provides the IProvideValueTarget and IXamlTypeResolver services.
/// No other services (e.g. from the document's service provider) are offered.
/// </summary>
public class XamlObjectServiceProvider : IServiceProvider, IProvideValueTarget
public class XamlObjectServiceProvider : IServiceProvider, IProvideValueTarget, IXamlSchemaContextProvider, IAmbientProvider
{
/// <summary>
/// Creates a new XamlObjectServiceProvider instance.
@ -60,6 +61,12 @@ namespace ICSharpCode.WpfDesign.XamlDom @@ -60,6 +61,12 @@ namespace ICSharpCode.WpfDesign.XamlDom
if (serviceType == typeof(IXamlTypeResolver)) {
return Resolver;
}
if (serviceType == typeof(IXamlSchemaContextProvider)) {
return this;
}
if (serviceType == typeof(IAmbientProvider)) {
return this;
}
return null;
}
@ -102,5 +109,58 @@ namespace ICSharpCode.WpfDesign.XamlDom @@ -102,5 +109,58 @@ namespace ICSharpCode.WpfDesign.XamlDom
}
#endregion
}
#region IXamlSchemaContextProvider Members
private XamlSchemaContext iCsharpXamlSchemaContext;
//Maybe we new our own XamlSchemaContext?
//private class ICsharpXamlSchemaContext : XamlSchemaContext
//{
// public override XamlType GetXamlType(Type type)
// {
// return base.GetXamlType(type);
// }
//}
public XamlSchemaContext SchemaContext
{
get
{
return iCsharpXamlSchemaContext = iCsharpXamlSchemaContext ?? new XamlSchemaContext();
}
}
#endregion
#region IAmbientProvider Members
public AmbientPropertyValue GetFirstAmbientValue(IEnumerable<XamlType> ceilingTypes, params XamlMember[] properties)
{
return null;
}
public object GetFirstAmbientValue(params XamlType[] types)
{
return null;
}
public IEnumerable<AmbientPropertyValue> GetAllAmbientValues(IEnumerable<XamlType> ceilingTypes, params XamlMember[] properties)
{
return new List<AmbientPropertyValue>();
}
public IEnumerable<object> GetAllAmbientValues(params XamlType[] types)
{
return new List<object>();
}
public IEnumerable<AmbientPropertyValue> GetAllAmbientValues(IEnumerable<XamlType> ceilingTypes, bool searchLiveStackOnly, IEnumerable<XamlType> types,
params XamlMember[] properties)
{
return new List<AmbientPropertyValue>();
}
#endregion
}
}

78
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.XamlDom/Project/XamlParser.cs

@ -22,6 +22,7 @@ using System.ComponentModel; @@ -22,6 +22,7 @@ using System.ComponentModel;
using System.Globalization;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Windows;
using System.Windows.Interop;
@ -279,7 +280,7 @@ namespace ICSharpCode.WpfDesign.XamlDom @@ -279,7 +280,7 @@ namespace ICSharpCode.WpfDesign.XamlDom
}
continue;
}
ParseObjectAttribute(obj, attribute);
}
@ -326,34 +327,50 @@ namespace ICSharpCode.WpfDesign.XamlDom @@ -326,34 +327,50 @@ namespace ICSharpCode.WpfDesign.XamlDom
}
}
}
foreach (XmlNode childNode in elementChildNodes) {
XmlElement childElement = childNode as XmlElement;
if (childElement != null) {
if (childElement.NamespaceURI == XamlConstants.XamlNamespace)
continue;
if (ObjectChildElementIsPropertyElement(childElement)) {
ParseObjectChildElementAsPropertyElement(obj, childElement, defaultProperty);
continue;
}
if (collectionType != null && collectionInstance == null && elementChildNodes.Count() == 1)
{
var firstChild = elementChildNodes.First() as XmlElement;
if (ObjectChildElementIsCollectionInstance(firstChild, collectionType))
{
collectionInstance = ParseObject(firstChild);
collectionProperty.PropertyValue = (XamlPropertyValue) collectionInstance;
}
if (initializeFromTextValueInsteadOfConstructor != null)
continue;
XamlPropertyValue childValue = ParseValue(childNode);
if (childValue != null) {
if (collectionProperty != null) {
collectionProperty.ParserAddCollectionElement(collectionPropertyElement, childValue);
CollectionSupport.AddToCollection(collectionType, collectionInstance, childValue);
} else {
if (defaultProperty == null)
throw new XamlLoadException("This element does not have a default value, cannot assign to it");
if (isDefaultValueSet)
throw new XamlLoadException("default property may have only one value assigned");
else
{
throw new XamlLoadException("Collection Instance is null");
}
}
else
{
foreach (XmlNode childNode in elementChildNodes) {
XmlElement childElement = childNode as XmlElement;
if (childElement != null) {
if (childElement.NamespaceURI == XamlConstants.XamlNamespace)
continue;
obj.AddProperty(new XamlProperty(obj, defaultProperty, childValue));
isDefaultValueSet = true;
if (ObjectChildElementIsPropertyElement(childElement)) {
ParseObjectChildElementAsPropertyElement(obj, childElement, defaultProperty);
continue;
}
}
if (initializeFromTextValueInsteadOfConstructor != null)
continue;
XamlPropertyValue childValue = ParseValue(childNode);
if (childValue != null) {
if (collectionProperty != null) {
collectionProperty.ParserAddCollectionElement(collectionPropertyElement, childValue);
CollectionSupport.AddToCollection(collectionType, collectionInstance, childValue);
} else {
if (defaultProperty == null)
throw new XamlLoadException("This element does not have a default value, cannot assign to it");
if (isDefaultValueSet)
throw new XamlLoadException("default property may have only one value assigned");
obj.AddProperty(new XamlProperty(obj, defaultProperty, childValue));
isDefaultValueSet = true;
}
}
}
}
@ -581,7 +598,12 @@ namespace ICSharpCode.WpfDesign.XamlDom @@ -581,7 +598,12 @@ namespace ICSharpCode.WpfDesign.XamlDom
{
return element.LocalName.Contains(".");
}
static bool ObjectChildElementIsCollectionInstance(XmlElement element, Type collectionType)
{
return element.Name == collectionType.Name;
}
static bool IsElementChildACollectionForProperty(XamlTypeFinder typeFinder, XmlElement element, XamlPropertyInfo propertyInfo)
{
return element.ChildNodes.Count == 1 && propertyInfo.ReturnType.IsAssignableFrom(FindType(typeFinder, element.FirstChild.NamespaceURI, element.FirstChild.LocalName));

50
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.XamlDom/Project/XamlProperty.cs

@ -21,10 +21,8 @@ using System.Collections.Generic; @@ -21,10 +21,8 @@ using System.Collections.Generic;
using System.ComponentModel;
using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Xml;
using System.Windows;
using System.Windows.Markup;
namespace ICSharpCode.WpfDesign.XamlDom
{
@ -139,7 +137,7 @@ namespace ICSharpCode.WpfDesign.XamlDom @@ -139,7 +137,7 @@ namespace ICSharpCode.WpfDesign.XamlDom
}
/// <summary>
/// Gets if the property represents the FrameworkElement.Resources property that holds a locally-defined resource dictionary.
/// Gets if the property represents the FrameworkElement.Resources property that holds a locally-defined resource dictionary.
/// </summary>
public bool IsResources {
get { return isResources; }
@ -264,7 +262,7 @@ namespace ICSharpCode.WpfDesign.XamlDom @@ -264,7 +262,7 @@ namespace ICSharpCode.WpfDesign.XamlDom
propertyValue = null;
}
if (_propertyElement != null) {
Debug.Assert(!isExplicitCollection || _propertyElement.ParentNode == null);
Debug.Assert(!isExplicitCollection || _propertyElement.ParentNode == null);
if (!isExplicitCollection) {
_propertyElement.ParentNode.RemoveChild(_propertyElement);
@ -315,19 +313,47 @@ namespace ICSharpCode.WpfDesign.XamlDom @@ -315,19 +313,47 @@ namespace ICSharpCode.WpfDesign.XamlDom
return this.IsAttached ? this.PropertyTargetType : parentObject.ElementType;
}
static XmlNode FindChildNode(XmlNode node, string localName, string namespaceURI)
static XmlNode FindChildNode(XmlNode node, Type elementType, string propertyName, XamlDocument xamlDocument)
{
foreach (XmlNode childNode in node.ChildNodes) {
var localName = elementType.Name + "." + propertyName;
var namespaceURI = xamlDocument.GetNamespaceFor(elementType);
foreach (XmlNode childNode in node.ChildNodes)
{
if (childNode.LocalName == localName && childNode.NamespaceURI == namespaceURI)
{
return childNode;
}
}
var type = elementType.BaseType;
namespaceURI = xamlDocument.GetNamespaceFor(type);
while (type != typeof(object))
{
if (type.GetProperty(propertyName) == null)
break;
localName = type.Name + "." + propertyName;
foreach (XmlNode childNode in node.ChildNodes)
{
if (childNode.LocalName == localName && childNode.NamespaceURI == namespaceURI)
{
return childNode;
}
}
type = type.BaseType;
}
return null;
}
bool IsNodeCollectionForThisProperty(XmlNode node)
{
return _propertyElement == null && this.PropertyName != this.ParentObject.ContentPropertyName && this.ReturnType.IsAssignableFrom(this.ParentObject.OwnerDocument.TypeFinder.GetType(node.NamespaceURI, node.LocalName));
//Remove the commented check! This is Possible: BeginStoryboard=>The COntent Property is Storyboard, and the Content Element is also Storyboard!
return _propertyElement == null /* && this.PropertyName != this.ParentObject.ContentPropertyName */ && this.ReturnType.IsAssignableFrom(this.ParentObject.OwnerDocument.TypeFinder.GetType(node.NamespaceURI, node.LocalName));
}
internal void AddChildNodeToProperty(XmlNode newChildNode)
@ -335,7 +361,7 @@ namespace ICSharpCode.WpfDesign.XamlDom @@ -335,7 +361,7 @@ namespace ICSharpCode.WpfDesign.XamlDom
if (this.IsCollection) {
if (IsNodeCollectionForThisProperty(newChildNode)) {
Type propertyElementType = GetPropertyElementType();
XmlNode parentNode = FindChildNode(parentObject.XmlElement, propertyElementType.Name + "." + this.PropertyName, parentObject.OwnerDocument.GetNamespaceFor(propertyElementType));
XmlNode parentNode = FindChildNode(parentObject.XmlElement, propertyElementType, this.PropertyName, parentObject.OwnerDocument);
if (parentNode == null) {
parentNode = CreatePropertyElement();
@ -384,7 +410,7 @@ namespace ICSharpCode.WpfDesign.XamlDom @@ -384,7 +410,7 @@ namespace ICSharpCode.WpfDesign.XamlDom
if (collection == null) {
if (collectionElements.Count == 0 && this.PropertyName != this.ParentObject.ContentPropertyName) {
// we have to create the collection element
_propertyElement = CreatePropertyElement();
_propertyElement = CreatePropertyElement();
if (this.IsResources) {
parentObject.XmlElement.PrependChild(_propertyElement);
@ -423,11 +449,11 @@ namespace ICSharpCode.WpfDesign.XamlDom @@ -423,11 +449,11 @@ namespace ICSharpCode.WpfDesign.XamlDom
name = PropertyTargetType.Name + "." + PropertyName;
string ns = ParentObject.OwnerDocument.GetNamespaceFor(PropertyTargetType);
string prefix = element.GetPrefixOfNamespace(ns);
string prefix = element.GetPrefixOfNamespace(ns);
if (String.IsNullOrEmpty(prefix)) {
prefix = ParentObject.OwnerDocument.GetPrefixForNamespace(ns);
}
prefix = ParentObject.OwnerDocument.GetPrefixForNamespace(ns);
}
if (!string.IsNullOrEmpty(prefix)) {
element.SetAttribute(name, ns, value);

3
src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/Adorners/AdornerPanel.cs

@ -137,7 +137,8 @@ namespace ICSharpCode.WpfDesign.Adorners @@ -137,7 +137,8 @@ namespace ICSharpCode.WpfDesign.Adorners
e.Measure(new Size(double.PositiveInfinity, double.PositiveInfinity));
}
}
return this.AdornedElement.RenderSize;
return PlacementOperation.GetRealElementSize(this.AdornedElement);
} else {
return base.MeasureOverride(availableSize);
}

32
src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/Extensions/ExtensionAttribute.cs

@ -0,0 +1,32 @@ @@ -0,0 +1,32 @@
// 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;
namespace ICSharpCode.WpfDesign.Extensions
{
/// <summary>
/// Attribute to specify Properties of the Extension.
/// </summary>
[AttributeUsage(AttributeTargets.Class, AllowMultiple=false, Inherited=false)]
public sealed class ExtensionAttribute : Attribute
{
//The Order in wich the Extensions are used
public int Order { get; set; }
}
}

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

@ -65,12 +65,14 @@ namespace ICSharpCode.WpfDesign.Extensions @@ -65,12 +65,14 @@ namespace ICSharpCode.WpfDesign.Extensions
internal readonly Type ExtensionType;
internal readonly ExtensionServer Server;
internal readonly Type OverriddenExtensionType;
public ExtensionEntry(Type extensionType, ExtensionServer server, Type overriddenExtensionType)
internal readonly int Order;
public ExtensionEntry(Type extensionType, ExtensionServer server, Type overriddenExtensionType, int Order)
{
this.ExtensionType = extensionType;
this.Server = server;
this.OverriddenExtensionType = overriddenExtensionType;
this.Order = Order;
}
}
@ -104,7 +106,7 @@ namespace ICSharpCode.WpfDesign.Extensions @@ -104,7 +106,7 @@ namespace ICSharpCode.WpfDesign.Extensions
result.Add(entry);
}
}
return result;
return result.OrderBy(x => x.Order).ToList();
}
/// <summary>
@ -184,7 +186,8 @@ namespace ICSharpCode.WpfDesign.Extensions @@ -184,7 +186,8 @@ namespace ICSharpCode.WpfDesign.Extensions
foreach (ExtensionForAttribute designerFor in extensionForAttributes) {
ExtensionServer server = GetServerForExtension(type);
AddExtensionEntry(designerFor.DesignedItemType, new ExtensionEntry(type, server, designerFor.OverrideExtension));
ExtensionAttribute extensionAttribute = type.GetCustomAttributes(typeof(ExtensionAttribute), false).FirstOrDefault() as ExtensionAttribute;
AddExtensionEntry(designerFor.DesignedItemType, new ExtensionEntry(type, server, designerFor.OverrideExtension, extensionAttribute != null ? extensionAttribute.Order : 0));
}
}
}

4
src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/Metadata.cs

@ -313,7 +313,7 @@ namespace ICSharpCode.WpfDesign @@ -313,7 +313,7 @@ namespace ICSharpCode.WpfDesign
/// Gets the default size for new controls of the specified type,
/// or new Size(double.NaN, double.NaN) if no default size was registered.
/// </summary>
public static Size GetDefaultSize(Type t, bool checkBasetype = true)
public static Size? GetDefaultSize(Type t, bool checkBasetype = true)
{
Size s;
lock (defaultSizes) {
@ -324,7 +324,7 @@ namespace ICSharpCode.WpfDesign @@ -324,7 +324,7 @@ namespace ICSharpCode.WpfDesign
t = checkBasetype ? t.BaseType : null;
}
}
return new Size(double.NaN, double.NaN);
return null;
}
}

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

@ -22,9 +22,6 @@ using System.Collections.ObjectModel; @@ -22,9 +22,6 @@ using System.Collections.ObjectModel;
using System.Diagnostics;
using System.Linq;
using System.Windows;
using System.Windows.Input;
using ICSharpCode.WpfDesign.Adorners;
using System.Windows.Media;
namespace ICSharpCode.WpfDesign
@ -204,7 +201,33 @@ namespace ICSharpCode.WpfDesign @@ -204,7 +201,33 @@ namespace ICSharpCode.WpfDesign
this.changeGroup = items[0].Context.OpenGroup(type.ToString(), items);
}
/// <summary>
/// The Size wich the Element really should have (even if its smaller Rendered (like emtpy Image!))
/// </summary>
/// <param name="element"></param>
/// <returns></returns>
public static Size GetRealElementSize(UIElement element)
{
var size = element.RenderSize;
if (element is FrameworkElement && !double.IsNaN(((FrameworkElement)element).Width))
size.Width = ((FrameworkElement)element).Width;
if (element is FrameworkElement && !double.IsNaN(((FrameworkElement)element).Height))
size.Height = ((FrameworkElement)element).Height;
if (element is FrameworkElement && size.Width < ((FrameworkElement)element).MinWidth)
size.Width = ((FrameworkElement)element).MinWidth;
if (element is FrameworkElement && size.Height < ((FrameworkElement)element).MinHeight)
size.Height = ((FrameworkElement)element).Height;
if (element is FrameworkElement && size.Width == 0)
size.Width = element.DesiredSize.Width;
if (element is FrameworkElement && size.Height == 0)
size.Height = element.DesiredSize.Height;
return size;
}
/// <summary>
/// Gets the placement behavior associated with the specified items.
/// </summary>

1
src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/PropertyGrid/TypeHelper.cs

@ -102,6 +102,7 @@ namespace ICSharpCode.WpfDesign.PropertyGrid @@ -102,6 +102,7 @@ namespace ICSharpCode.WpfDesign.PropertyGrid
}
else
{
var l=TypeDescriptor.GetProperties(element);
foreach(PropertyDescriptor p in TypeDescriptor.GetProperties(element)){
if (!p.IsBrowsable) continue;
if (p.IsReadOnly && !typeof(ICollection).IsAssignableFrom(p.PropertyType)) continue;

2
src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/Tools.cs

@ -147,6 +147,6 @@ namespace ICSharpCode.WpfDesign @@ -147,6 +147,6 @@ namespace ICSharpCode.WpfDesign
/// <summary>
/// Occurs when an element is dropped on the design panel.
/// </summary>
event DragEventHandler Drop;
event DragEventHandler Drop;
}
}

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

@ -74,6 +74,7 @@ @@ -74,6 +74,7 @@
<Compile Include="Adorners\AdornerProviderClasses.cs" />
<Compile Include="Adorners\RelativePlacement.cs" />
<Compile Include="ExtensionMethods.cs" />
<Compile Include="Extensions\ExtensionAttribute.cs" />
<Compile Include="HitTestType.cs" />
<Compile Include="Metadata.cs" />
<Compile Include="PlacementInformation.cs" />

BIN
src/Libraries/WPFExtendedToolkit/Xceed.Wpf.Toolkit.dll

Binary file not shown.
Loading…
Cancel
Save