Browse Source

Fixes for Unit Tests and Whitespace

pull/584/head
jogibear9988 11 years ago
parent
commit
39e5da367e
  1. 44
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/BasicMetadata.cs
  2. 20
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Controls/AdornerLayer.cs
  3. 38
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Controls/ControlStyles.xaml
  4. 126
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/DesignPanel.cs
  5. 60
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Extensions/ArrangeItemsContextMenu.xaml
  6. 57
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Extensions/ArrangeItemsContextMenu.xaml.cs
  7. 29
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Extensions/ArrangeItemsContextMenuExtension.cs
  8. 34
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Extensions/RightClickContextMenu.xaml
  9. 10
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Extensions/RightClickContextMenu.xaml.cs
  10. 13
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Extensions/RightClickContextMenuExtension.cs
  11. 26
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Extensions/SkewThumbExtension.cs
  12. 12
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Extensions/TextBlockRightClickContextMenu.xaml
  13. 37
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Extensions/TextBlockRightClickContextMenu.xaml.cs
  14. 46
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Extensions/TextBlockRightClickContextMenuExtension.cs
  15. 10
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Extensions/WrapItemsContextMenu.xaml
  16. 14
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Extensions/WrapItemsContextMenu.xaml.cs
  17. 29
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Extensions/WrapItemsContextMenuExtension.cs
  18. 660
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/ModelTools.cs
  19. 1616
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/PropertyGrid/Editors/FormatedTextEditor/FormatedTextEditor.xaml
  20. 364
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/PropertyGrid/Editors/FormatedTextEditor/FormatedTextEditor.xaml.cs
  21. 112
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Translations.cs
  22. 2
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Tests/Designer/PlacementTests.cs
  23. 1
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Tests/XamlDom/MarkupExtensionTests.cs
  24. 53
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/PlacementOperation.cs

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

@ -145,10 +145,10 @@ namespace ICSharpCode.WpfDesign.Designer @@ -145,10 +145,10 @@ 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(Control.VerticalContentAlignmentProperty);
Metadata.AddPopularProperty(Control.HorizontalContentAlignmentProperty);
Metadata.AddPopularProperty(Grid.RowProperty);
Metadata.AddPopularProperty(Grid.RowProperty);
Metadata.AddPopularProperty(Grid.RowSpanProperty);
Metadata.AddPopularProperty(Grid.ColumnProperty);
Metadata.AddPopularProperty(Grid.ColumnSpanProperty);
@ -261,30 +261,30 @@ namespace ICSharpCode.WpfDesign.Designer @@ -261,30 +261,30 @@ namespace ICSharpCode.WpfDesign.Designer
Metadata.AddPopularControl(typeof(Viewport3D));
Metadata.AddPopularControl(typeof(WrapPanel));
//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));
//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));
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));
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(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), new Size(120, 20));
Metadata.AddDefaultSize(typeof(Menu), new Size(120, 20));
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(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));
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

@ -224,18 +224,18 @@ namespace ICSharpCode.WpfDesign.Designer.Controls @@ -224,18 +224,18 @@ namespace ICSharpCode.WpfDesign.Designer.Controls
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;
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));
adorner.Arrange(new Rect(new Point(0, 0), adorner.DesiredSize));
}
return finalSize;
}

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

@ -2,7 +2,7 @@ @@ -2,7 +2,7 @@
<!--
This file contains the default styles used by the Controls in ICSharpCode.WpfDesign.Designer.Controls
-->
<Converters:LevelConverter x:Key="FormatDoubleConverter" />
<Converters:LevelConverter x:Key="FormatDoubleConverter" />
<ControlConvertors:HandleLengthWithOffset x:Key="HandleLengthWithOffset" />
<SolidColorBrush Color="#FF474747" x:Key="HandleBrush" />
<Style TargetType="{x:Type Controls:PanelMoveAdorner}">
@ -335,15 +335,15 @@ @@ -335,15 +335,15 @@
<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 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>
<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>
</TextBlock>
@ -366,15 +366,15 @@ @@ -366,15 +366,15 @@
<Path Grid.Column="0" Stroke="#AC0000" StrokeThickness="1" Data="M0,0 L0,1 M0,0.75 L1,0.75" Stretch="Fill" SnapsToDevicePixels="True" />
<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>
<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>

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

@ -62,7 +62,7 @@ namespace ICSharpCode.WpfDesign.Designer @@ -62,7 +62,7 @@ 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)
@ -95,15 +95,15 @@ namespace ICSharpCode.WpfDesign.Designer @@ -95,15 +95,15 @@ 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>
/// <summary>
/// Performs a hit test on the design surface, raising <paramref name="callback"/> for each match.
/// Hit testing continues while the callback returns true.
/// </summary>
@ -156,8 +156,8 @@ namespace ICSharpCode.WpfDesign.Designer @@ -156,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)
@ -220,18 +220,18 @@ namespace ICSharpCode.WpfDesign.Designer @@ -220,18 +220,18 @@ 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>
public DesignContext Context {
public AdornerLayer AdornerLayer
{
get
{
return _adornerLayer;
}
}
/// <summary>
/// Gets/Sets the design context.
/// </summary>
public DesignContext Context {
get { return _context; }
set { _context = value; }
}
@ -416,9 +416,9 @@ namespace ICSharpCode.WpfDesign.Designer @@ -416,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,
@ -434,9 +434,9 @@ namespace ICSharpCode.WpfDesign.Designer @@ -434,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)
{
@ -457,53 +457,53 @@ namespace ICSharpCode.WpfDesign.Designer @@ -457,53 +457,53 @@ namespace ICSharpCode.WpfDesign.Designer
if (handler != null) handler(this, new PropertyChangedEventArgs(propertyName));
}
#region ContextMenu
#region ContextMenu
private Dictionary<ContextMenu, Tuple<int,List<object>>> contextMenusAndEntries = new Dictionary<ContextMenu, Tuple<int,List<object>>>();
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();
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();
}
UpdateContextMenu();
}
public void RemoveContextMenu(ContextMenu contextMenu)
{
contextMenusAndEntries.Remove(contextMenu);
public void RemoveContextMenu(ContextMenu contextMenu)
{
contextMenusAndEntries.Remove(contextMenu);
UpdateContextMenu();
}
UpdateContextMenu();
}
public void ClearContextMenu()
{
contextMenusAndEntries.Clear();
ContextMenu = null;
}
public void ClearContextMenu()
{
contextMenusAndEntries.Clear();
ContextMenu = null;
}
private void UpdateContextMenu()
{
if (contextMenusAndEntries.Count == 0)
this.ContextMenu = null;
private void UpdateContextMenu()
{
if (contextMenusAndEntries.Count == 0)
this.ContextMenu = null;
if (this.ContextMenu == null)
this.ContextMenu = new ContextMenu();
if (this.ContextMenu == null)
this.ContextMenu = new ContextMenu();
this.ContextMenu.Items.Clear();
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 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);
}
}
}
foreach (var entry in entries)
{
ContextMenu.Items.Add(entry);
}
}
}
#endregion
}
#endregion
}
}

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

@ -2,35 +2,35 @@ @@ -2,35 +2,35 @@
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>
<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>

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

@ -17,25 +17,12 @@ @@ -17,25 +17,12 @@
// 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 ArrangeItemsContextMenu
{
{
private DesignItem designItem;
public ArrangeItemsContextMenu(DesignItem designItem)
@ -50,29 +37,29 @@ namespace ICSharpCode.WpfDesign.Designer.Extensions @@ -50,29 +37,29 @@ namespace ICSharpCode.WpfDesign.Designer.Extensions
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_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_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_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_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);
}
}
void Click_ArrangeBottom(object sender, System.Windows.RoutedEventArgs e)
{
ModelTools.ArrangeItems(this.designItem.Services.Selection.SelectedItems, ArrangeDirection.Bottom);
}
}
}

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

@ -19,9 +19,6 @@ @@ -19,9 +19,6 @@
using System;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Media;
using System.Windows.Shapes;
using ICSharpCode.WpfDesign.Adorners;
using ICSharpCode.WpfDesign.Extensions;
using ICSharpCode.WpfDesign.Designer;
@ -33,26 +30,28 @@ namespace ICSharpCode.WpfDesign.Designer.Extensions @@ -33,26 +30,28 @@ namespace ICSharpCode.WpfDesign.Designer.Extensions
/// </summary>
[ExtensionServer(typeof(PrimarySelectionButOnlyWhenMultipleSelectedExtensionServer))]
[ExtensionFor(typeof(UIElement))]
[Extension(Order = 30)]
public class ArrangeItemsContextMenuExtension : SelectionAdornerProvider
{
DesignPanel panel;
ContextMenu contextMenu;
[Extension(Order = 30)]
public class ArrangeItemsContextMenuExtension : SelectionAdornerProvider
{
DesignPanel panel;
ContextMenu contextMenu;
protected override void OnInitialized()
protected override void OnInitialized()
{
base.OnInitialized();
contextMenu = new ArrangeItemsContextMenu(ExtendedItem);
panel = ExtendedItem.Context.Services.DesignPanel as DesignPanel;
panel.AddContextMenu(contextMenu);
}
contextMenu = new ArrangeItemsContextMenu(ExtendedItem);
panel = ExtendedItem.Context.Services.DesignPanel as DesignPanel;
if (panel != null)
panel.AddContextMenu(contextMenu);
}
protected override void OnRemove()
{
panel.RemoveContextMenu(contextMenu);
if (panel != null)
panel.RemoveContextMenu(contextMenu);
base.OnRemove();
base.OnRemove();
}
}
}

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

@ -2,25 +2,25 @@ @@ -2,25 +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.Icon>
<Image Source="/ICSharpCode.WpfDesign.Designer;component/Images/layers-stack-arrange.png" />
</MenuItem.Icon>
</MenuItem>
<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.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.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>
<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
{

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

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

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

@ -226,20 +226,22 @@ namespace ICSharpCode.WpfDesign.Designer.Extensions @@ -226,20 +226,22 @@ 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 * PlacementOperation.GetRealElementSize(ExtendedItem.View).Width / 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 * PlacementOperation.GetRealElementSize(ExtendedItem.View).Height / 4,
XOffset = 0
});
((DesignPanel)this.ExtendedItem.Services.DesignPanel).AdornerLayer.UpdateAdornersForElement(this.ExtendedItem.View, true);
}
}
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);
}
}
protected override void OnRemove()
{

12
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Extensions/TextBlockRightClickContextMenu.xaml

@ -2,10 +2,10 @@ @@ -2,10 +2,10 @@
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 FormatedTextEditor, Source={x:Static Translation:Translations.Instance}}" Click="Click_EditFormatedText">
<MenuItem.Icon>
<Image Source="/ICSharpCode.WpfDesign.Designer;component/Images/edit.png" />
</MenuItem.Icon>
</MenuItem>
>
<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>

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

@ -17,20 +17,9 @@ @@ -17,20 +17,9 @@
// 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.Designer.PropertyGrid.Editors.FormatedTextEditor;
using ICSharpCode.WpfDesign.PropertyGrid;
namespace ICSharpCode.WpfDesign.Designer.Extensions
{
@ -38,25 +27,25 @@ namespace ICSharpCode.WpfDesign.Designer.Extensions @@ -38,25 +27,25 @@ namespace ICSharpCode.WpfDesign.Designer.Extensions
{
private DesignItem designItem;
public TextBlockRightClickContextMenu(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>(),
};
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();
}
dlg.ShowDialog();
}
}
}

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

@ -17,39 +17,37 @@ @@ -17,39 +17,37 @@
// DEALINGS IN THE SOFTWARE.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
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;
[ExtensionServer(typeof (OnlyOneItemSelectedExtensionServer))]
[ExtensionFor(typeof (TextBlock))]
[Extension(Order = 10)]
public class TextBlockRightClickContextMenuExtension : PrimarySelectionAdornerProvider
{
DesignPanel panel;
ContextMenu contextMenu;
protected override void OnInitialized()
{
base.OnInitialized();
protected override void OnInitialized()
{
base.OnInitialized();
contextMenu = new TextBlockRightClickContextMenu(ExtendedItem);
panel = ExtendedItem.Context.Services.DesignPanel as DesignPanel;
panel.AddContextMenu(contextMenu);
}
contextMenu = new TextBlockRightClickContextMenu(ExtendedItem);
panel = ExtendedItem.Context.Services.DesignPanel as DesignPanel;
if (panel != null)
panel.AddContextMenu(contextMenu);
}
protected override void OnRemove()
{
panel.RemoveContextMenu(contextMenu);
protected override void OnRemove()
{
if (panel != null)
panel.RemoveContextMenu(contextMenu);
base.OnRemove();
}
}
base.OnRemove();
}
}
}

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

@ -2,11 +2,11 @@ @@ -2,11 +2,11 @@
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.Icon>
<Image Source="/ICSharpCode.WpfDesign.Designer;component/Images/grid.png" />
</MenuItem.Icon>
</MenuItem>
<MenuItem.Icon>
<Image Source="/ICSharpCode.WpfDesign.Designer;component/Images/grid.png" />
</MenuItem.Icon>
</MenuItem>
</ContextMenu>

14
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Extensions/WrapItemsContextMenu.xaml.cs

@ -17,25 +17,13 @@ @@ -17,25 +17,13 @@
// 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 WrapItemsContextMenu
{
{
private DesignItem designItem;
public WrapItemsContextMenu(DesignItem designItem)

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

@ -19,9 +19,6 @@ @@ -19,9 +19,6 @@
using System;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Media;
using System.Windows.Shapes;
using ICSharpCode.WpfDesign.Adorners;
using ICSharpCode.WpfDesign.Extensions;
using ICSharpCode.WpfDesign.Designer;
@ -33,26 +30,28 @@ namespace ICSharpCode.WpfDesign.Designer.Extensions @@ -33,26 +30,28 @@ namespace ICSharpCode.WpfDesign.Designer.Extensions
/// </summary>
[ExtensionServer(typeof(PrimarySelectionButOnlyWhenMultipleSelectedExtensionServer))]
[ExtensionFor(typeof(UIElement))]
[Extension(Order = 50)]
public class WrapItemsContextMenuExtension : SelectionAdornerProvider
{
DesignPanel panel;
ContextMenu contextMenu;
[Extension(Order = 50)]
public class WrapItemsContextMenuExtension : SelectionAdornerProvider
{
DesignPanel panel;
ContextMenu contextMenu;
protected override void OnInitialized()
protected override void OnInitialized()
{
base.OnInitialized();
contextMenu = new WrapItemsContextMenu(ExtendedItem);
panel = ExtendedItem.Context.Services.DesignPanel as DesignPanel;
panel.AddContextMenu(contextMenu);
}
contextMenu = new WrapItemsContextMenu(ExtendedItem);
panel = ExtendedItem.Context.Services.DesignPanel as DesignPanel;
if (panel != null)
panel.AddContextMenu(contextMenu);
}
protected override void OnRemove()
{
panel.RemoveContextMenu(contextMenu);
if (panel != null)
panel.RemoveContextMenu(contextMenu);
base.OnRemove();
base.OnRemove();
}
}
}

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

@ -123,45 +123,45 @@ namespace ICSharpCode.WpfDesign.Designer @@ -123,45 +123,45 @@ namespace ICSharpCode.WpfDesign.Designer
{
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);
fixedPage.Children.Remove(element);
}
catch (Exception)
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);
fixedPage.Children.Remove(element);
}
catch (Exception)
{ }
}
internal static Size GetDefaultSize(DesignItem createdItem)
{
var defS = Metadata.GetDefaultSize(createdItem.ComponentType, false);
if (defS != null)
return defS.Value;
if (defS != null)
return defS.Value;
CreateVisualTree(createdItem.View);
CreateVisualTree(createdItem.View);
var s = createdItem.View.DesiredSize;
var s = createdItem.View.DesiredSize;
var newS = Metadata.GetDefaultSize(createdItem.ComponentType, true);
var newS = Metadata.GetDefaultSize(createdItem.ComponentType, true);
if (newS.HasValue)
{
if (!(s.Width > 5) && newS.Value.Width > 0)
s.Width = newS.Value.Width;
if (newS.HasValue)
{
if (!(s.Width > 5) && newS.Value.Width > 0)
s.Width = newS.Value.Width;
if (!(s.Height > 5) && newS.Value.Height > 0)
s.Height = newS.Value.Height;
}
if (!(s.Height > 5) && newS.Value.Height > 0)
s.Height = newS.Value.Height;
}
if (double.IsNaN(s.Width) && GetWidth(createdItem.View) > 0) {
if (double.IsNaN(s.Width) && GetWidth(createdItem.View) > 0) {
s.Width = GetWidth(createdItem.View);
}
if (double.IsNaN(s.Height) && GetWidth(createdItem.View) > 0) {
@ -192,16 +192,16 @@ namespace ICSharpCode.WpfDesign.Designer @@ -192,16 +192,16 @@ namespace ICSharpCode.WpfDesign.Designer
public static void Resize(DesignItem item, double newWidth, double newHeight)
{
if (newWidth != GetWidth(item.View)) {
if(double.IsNaN(newWidth))
item.Properties.GetProperty(FrameworkElement.WidthProperty).Reset();
else
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)) {
if (double.IsNaN(newHeight))
item.Properties.GetProperty(FrameworkElement.HeightProperty).Reset();
else
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);
}
}
@ -223,120 +223,120 @@ namespace ICSharpCode.WpfDesign.Designer @@ -223,120 +223,120 @@ namespace ICSharpCode.WpfDesign.Designer
public DesignItem DesignItem { get; set; }
}
private static ItemPos GetItemPos(IPlacementBehavior placementBehavior, DesignItem designItem)
{
var itemPos = new ItemPos() {DesignItem = designItem};
var pos = placementBehavior.GetPosition(null, designItem);
itemPos.Xmin = pos.X;
itemPos.Xmax = pos.X + pos.Width;
itemPos.Ymin = pos.Y;
itemPos.Ymax = pos.Y + pos.Height;
return itemPos;
if (designItem.Parent.Component is Canvas)
{
var canvas = designItem.Parent.View as Canvas;
if (designItem.Properties.GetAttachedProperty(Canvas.RightProperty) != null &&
designItem.Properties.GetAttachedProperty(Canvas.RightProperty).IsSet)
{
itemPos.HorizontalAlignment = HorizontalAlignment.Right;
itemPos.Xmax = canvas.ActualWidth -
(double) designItem.Properties.GetAttachedProperty(Canvas.RightProperty).ValueOnInstance;
itemPos.Xmin = itemPos.Xmax - ((FrameworkElement) designItem.View).ActualWidth;
}
else if (designItem.Properties.GetAttachedProperty(Canvas.LeftProperty) != null &&
designItem.Properties.GetAttachedProperty(Canvas.LeftProperty).IsSet)
{
itemPos.HorizontalAlignment = HorizontalAlignment.Left;
itemPos.Xmin =
(double) designItem.Properties.GetAttachedProperty(Canvas.LeftProperty).ValueOnInstance;
itemPos.Xmax = itemPos.Xmin + ((FrameworkElement) designItem.View).ActualWidth;
}
else
{
itemPos.HorizontalAlignment = HorizontalAlignment.Left;
itemPos.Xmax = itemPos.Xmin + ((FrameworkElement) designItem.View).ActualWidth;
}
if (designItem.Properties.GetAttachedProperty(Canvas.BottomProperty) != null &&
designItem.Properties.GetAttachedProperty(Canvas.BottomProperty).IsSet)
{
itemPos.VerticalAlignment = VerticalAlignment.Bottom;
itemPos.Ymax = canvas.ActualHeight -
(double)
designItem.Properties.GetAttachedProperty(Canvas.BottomProperty).ValueOnInstance;
itemPos.Ymin = itemPos.Ymax - ((FrameworkElement) designItem.View).ActualHeight;
}
else if (designItem.Properties.GetAttachedProperty(Canvas.TopProperty) != null &&
designItem.Properties.GetAttachedProperty(Canvas.TopProperty).IsSet)
{
itemPos.VerticalAlignment = VerticalAlignment.Top;
itemPos.Ymin =
(double) designItem.Properties.GetAttachedProperty(Canvas.TopProperty).ValueOnInstance;
itemPos.Ymax = itemPos.Ymin + ((FrameworkElement) designItem.View).ActualHeight;
}
else
{
itemPos.VerticalAlignment = VerticalAlignment.Top;
itemPos.Ymax = itemPos.Ymin + ((FrameworkElement) designItem.View).ActualHeight;
}
}
else if (designItem.Parent.Component is Grid)
{
var grid = designItem.Parent.View as Grid;
if (
(HorizontalAlignment)
designItem.Properties.GetProperty(FrameworkElement.HorizontalAlignmentProperty).ValueOnInstance ==
HorizontalAlignment.Right)
{
itemPos.HorizontalAlignment = HorizontalAlignment.Right;
itemPos.Xmax = grid.ActualWidth -
((Thickness)
designItem.Properties.GetProperty(FrameworkElement.MarginProperty).ValueOnInstance)
.Right;
itemPos.Xmin = itemPos.Xmax - ((FrameworkElement) designItem.View).ActualWidth;
}
else
{
itemPos.HorizontalAlignment = HorizontalAlignment.Left;
itemPos.Xmin =
((Thickness) designItem.Properties.GetProperty(FrameworkElement.MarginProperty).ValueOnInstance)
.Left;
itemPos.Xmax = itemPos.Xmin + ((FrameworkElement) designItem.View).ActualWidth;
}
if (
(VerticalAlignment)
designItem.Properties.GetProperty(FrameworkElement.VerticalAlignmentProperty).ValueOnInstance ==
VerticalAlignment.Bottom)
{
itemPos.VerticalAlignment = VerticalAlignment.Bottom;
itemPos.Ymax = grid.ActualHeight -
((Thickness)
designItem.Properties.GetProperty(FrameworkElement.MarginProperty).ValueOnInstance)
.Bottom;
itemPos.Ymin = itemPos.Ymax - ((FrameworkElement) designItem.View).ActualHeight;
}
else
{
itemPos.VerticalAlignment = VerticalAlignment.Top;
itemPos.Ymin =
((Thickness) designItem.Properties.GetProperty(FrameworkElement.MarginProperty).ValueOnInstance)
.Top;
itemPos.Ymax = itemPos.Ymin + ((FrameworkElement) designItem.View).ActualHeight;
}
}
return itemPos;
}
public static void WrapItemsNewContainer(IEnumerable<DesignItem> items, Type containerType)
private static ItemPos GetItemPos(IPlacementBehavior placementBehavior, DesignItem designItem)
{
var itemPos = new ItemPos() {DesignItem = designItem};
var pos = placementBehavior.GetPosition(null, designItem);
itemPos.Xmin = pos.X;
itemPos.Xmax = pos.X + pos.Width;
itemPos.Ymin = pos.Y;
itemPos.Ymax = pos.Y + pos.Height;
return itemPos;
if (designItem.Parent.Component is Canvas)
{
var canvas = designItem.Parent.View as Canvas;
if (designItem.Properties.GetAttachedProperty(Canvas.RightProperty) != null &&
designItem.Properties.GetAttachedProperty(Canvas.RightProperty).IsSet)
{
itemPos.HorizontalAlignment = HorizontalAlignment.Right;
itemPos.Xmax = canvas.ActualWidth -
(double) designItem.Properties.GetAttachedProperty(Canvas.RightProperty).ValueOnInstance;
itemPos.Xmin = itemPos.Xmax - ((FrameworkElement) designItem.View).ActualWidth;
}
else if (designItem.Properties.GetAttachedProperty(Canvas.LeftProperty) != null &&
designItem.Properties.GetAttachedProperty(Canvas.LeftProperty).IsSet)
{
itemPos.HorizontalAlignment = HorizontalAlignment.Left;
itemPos.Xmin =
(double) designItem.Properties.GetAttachedProperty(Canvas.LeftProperty).ValueOnInstance;
itemPos.Xmax = itemPos.Xmin + ((FrameworkElement) designItem.View).ActualWidth;
}
else
{
itemPos.HorizontalAlignment = HorizontalAlignment.Left;
itemPos.Xmax = itemPos.Xmin + ((FrameworkElement) designItem.View).ActualWidth;
}
if (designItem.Properties.GetAttachedProperty(Canvas.BottomProperty) != null &&
designItem.Properties.GetAttachedProperty(Canvas.BottomProperty).IsSet)
{
itemPos.VerticalAlignment = VerticalAlignment.Bottom;
itemPos.Ymax = canvas.ActualHeight -
(double)
designItem.Properties.GetAttachedProperty(Canvas.BottomProperty).ValueOnInstance;
itemPos.Ymin = itemPos.Ymax - ((FrameworkElement) designItem.View).ActualHeight;
}
else if (designItem.Properties.GetAttachedProperty(Canvas.TopProperty) != null &&
designItem.Properties.GetAttachedProperty(Canvas.TopProperty).IsSet)
{
itemPos.VerticalAlignment = VerticalAlignment.Top;
itemPos.Ymin =
(double) designItem.Properties.GetAttachedProperty(Canvas.TopProperty).ValueOnInstance;
itemPos.Ymax = itemPos.Ymin + ((FrameworkElement) designItem.View).ActualHeight;
}
else
{
itemPos.VerticalAlignment = VerticalAlignment.Top;
itemPos.Ymax = itemPos.Ymin + ((FrameworkElement) designItem.View).ActualHeight;
}
}
else if (designItem.Parent.Component is Grid)
{
var grid = designItem.Parent.View as Grid;
if (
(HorizontalAlignment)
designItem.Properties.GetProperty(FrameworkElement.HorizontalAlignmentProperty).ValueOnInstance ==
HorizontalAlignment.Right)
{
itemPos.HorizontalAlignment = HorizontalAlignment.Right;
itemPos.Xmax = grid.ActualWidth -
((Thickness)
designItem.Properties.GetProperty(FrameworkElement.MarginProperty).ValueOnInstance)
.Right;
itemPos.Xmin = itemPos.Xmax - ((FrameworkElement) designItem.View).ActualWidth;
}
else
{
itemPos.HorizontalAlignment = HorizontalAlignment.Left;
itemPos.Xmin =
((Thickness) designItem.Properties.GetProperty(FrameworkElement.MarginProperty).ValueOnInstance)
.Left;
itemPos.Xmax = itemPos.Xmin + ((FrameworkElement) designItem.View).ActualWidth;
}
if (
(VerticalAlignment)
designItem.Properties.GetProperty(FrameworkElement.VerticalAlignmentProperty).ValueOnInstance ==
VerticalAlignment.Bottom)
{
itemPos.VerticalAlignment = VerticalAlignment.Bottom;
itemPos.Ymax = grid.ActualHeight -
((Thickness)
designItem.Properties.GetProperty(FrameworkElement.MarginProperty).ValueOnInstance)
.Bottom;
itemPos.Ymin = itemPos.Ymax - ((FrameworkElement) designItem.View).ActualHeight;
}
else
{
itemPos.VerticalAlignment = VerticalAlignment.Top;
itemPos.Ymin =
((Thickness) designItem.Properties.GetProperty(FrameworkElement.MarginProperty).ValueOnInstance)
.Top;
itemPos.Ymax = itemPos.Ymin + ((FrameworkElement) designItem.View).ActualHeight;
}
}
return itemPos;
}
public static void WrapItemsNewContainer(IEnumerable<DesignItem> items, Type containerType)
{
var collection = items;
@ -347,12 +347,12 @@ namespace ICSharpCode.WpfDesign.Designer @@ -347,12 +347,12 @@ namespace ICSharpCode.WpfDesign.Designer
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;
//Change Code to use the Placment Operation!
var placement = container.Extensions.OfType<IPlacementBehavior>().FirstOrDefault();
if (placement == null)
return;
var newInstance = Activator.CreateInstance(containerType);
var newInstance = Activator.CreateInstance(containerType);
DesignItem newPanel = _context.Services.Component.RegisterComponentForDesigner(newInstance);
var changeGroup = newPanel.OpenGroup("Wrap in Container");
@ -360,7 +360,7 @@ namespace ICSharpCode.WpfDesign.Designer @@ -360,7 +360,7 @@ namespace ICSharpCode.WpfDesign.Designer
foreach (var item in collection) {
itemList.Add(GetItemPos(placement, item));
//var pos = placement.GetPosition(null, item);
//var pos = placement.GetPosition(null, item);
if (container.Component is Canvas) {
item.Properties.GetAttachedProperty(Canvas.RightProperty).Reset();
item.Properties.GetAttachedProperty(Canvas.LeftProperty).Reset();
@ -381,7 +381,7 @@ namespace ICSharpCode.WpfDesign.Designer @@ -381,7 +381,7 @@ namespace ICSharpCode.WpfDesign.Designer
var ymin = itemList.Min(x => x.Ymin);
var ymax = itemList.Max(x => x.Ymax);
foreach (var item in itemList) {
foreach (var item in itemList) {
newPanel.ContentProperty.CollectionElements.Add(item.DesignItem);
if (newPanel.Component is Canvas) {
@ -418,184 +418,184 @@ namespace ICSharpCode.WpfDesign.Designer @@ -418,184 +418,184 @@ namespace ICSharpCode.WpfDesign.Designer
}
}
PlacementOperation operation = PlacementOperation.TryStartInsertNewComponents(
container,
new[] { newPanel },
new[] { new Rect(xmin, ymin, xmax - xmin, ymax - ymin).Round() },
PlacementType.AddItem
);
PlacementOperation operation = PlacementOperation.TryStartInsertNewComponents(
container,
new[] { newPanel },
new[] { new Rect(xmin, ymin, xmax - xmin, ymax - ymin).Round() },
PlacementType.AddItem
);
operation.Commit();
operation.Commit();
changeGroup.Commit();
changeGroup.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 changeGroup = container.OpenGroup("Arrange Elements");
List<ItemPos> itemList = new List<ItemPos>();
foreach (var item in collection)
{
itemList.Add(GetItemPos(placement, 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)
{
}
}
break;
case ArrangeDirection.HorizontalMiddle:
{
if (container.Component is Canvas)
{
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)
{
}
}
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)
{
}
}
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)
{
}
}
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)
{
}
}
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)
{
}
}
break;
}
}
changeGroup.Commit();
//_context.Services.Selection.SetSelectedComponents(null);
//_context.Services.Selection.SetSelectedComponents(items.ToList());
}
}
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 changeGroup = container.OpenGroup("Arrange Elements");
List<ItemPos> itemList = new List<ItemPos>();
foreach (var item in collection)
{
itemList.Add(GetItemPos(placement, 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)
{
}
}
break;
case ArrangeDirection.HorizontalMiddle:
{
if (container.Component is Canvas)
{
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)
{
}
}
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)
{
}
}
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)
{
}
}
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)
{
}
}
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)
{
}
}
break;
}
}
changeGroup.Commit();
//_context.Services.Selection.SetSelectedComponents(null);
//_context.Services.Selection.SetSelectedComponents(items.ToList());
}
}
}

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

File diff suppressed because it is too large Load Diff

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

@ -26,186 +26,186 @@ using ICSharpCode.WpfDesign.Designer.Xaml; @@ -26,186 +26,186 @@ 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);
}
}
/// <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);
}
}
}

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

@ -84,60 +84,60 @@ namespace ICSharpCode.WpfDesign.Designer @@ -84,60 +84,60 @@ namespace ICSharpCode.WpfDesign.Designer
}
}
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";
}
}
}
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";
}
}
}
}

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);

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}}\"");

53
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
@ -205,31 +202,31 @@ namespace ICSharpCode.WpfDesign @@ -205,31 +202,31 @@ 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>
/// 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.

Loading…
Cancel
Save