Browse Source

Merge branch 'DrawLineOnCanvas' of https://github.com/jogibear9988/SharpDevelop into DrawLineOnCanvas

Conflicts:
	src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Controls/ControlStyles.xaml
pull/633/head
jogibear9988 11 years ago
parent
commit
75477250aa
  1. 2
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Controls/ControlStyles.xaml
  2. 3
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Xaml/XamlComponentService.cs
  3. 41
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.XamlDom/Project/CollectionSupport.cs

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

@ -100,7 +100,7 @@
</Grid.Resources> </Grid.Resources>
<Rectangle HorizontalAlignment="Left" VerticalAlignment="Top" Width="7" Height="7" Name="thumbRectangle" SnapsToDevicePixels="True" Stroke="{TemplateBinding Foreground}" Fill="White" RadiusX="1.414" RadiusY="1.414" /> <Rectangle HorizontalAlignment="Left" VerticalAlignment="Top" Width="7" Height="7" Name="thumbRectangle" SnapsToDevicePixels="True" Stroke="{TemplateBinding Foreground}" Fill="White" RadiusX="1.414" RadiusY="1.414" />
<Ellipse HorizontalAlignment="Left" VerticalAlignment="Top" Width="7" Height="7" Name="thumbElipse" Stroke="{TemplateBinding Foreground}" SnapsToDevicePixels="True" Fill="White" Visibility="Collapsed" /> <Ellipse HorizontalAlignment="Left" VerticalAlignment="Top" Width="7" Height="7" Name="thumbElipse" Stroke="{TemplateBinding Foreground}" SnapsToDevicePixels="True" Fill="White" Visibility="Collapsed" />
<Menu Height="15" HorizontalAlignment="Left" Margin="0,-19,-19,0" VerticalAlignment="Top" Width="15" BorderThickness="0" Background="Transparent" Visibility="{Binding Path=OperationMenu, RelativeSource={RelativeSource TemplatedParent}, Converter={x:Static Converters:CollapsedWhenNull.Instance}}" > <Menu Foreground="Black" Height="15" HorizontalAlignment="Left" Margin="0,-19,-19,0" VerticalAlignment="Top" Width="15" BorderThickness="0" Background="Transparent" Visibility="{Binding Path=OperationMenu, RelativeSource={RelativeSource TemplatedParent}, Converter={x:Static Converters:CollapsedWhenNull.Instance}}" >
<MenuItem RenderTransform="{TemplateBinding InnerRenderTransform}" Height="15" Width="15" Padding="0" Background="Transparent" BorderThickness="1" ItemsSource="{TemplateBinding OperationMenu}"> <MenuItem RenderTransform="{TemplateBinding InnerRenderTransform}" Height="15" Width="15" Padding="0" Background="Transparent" BorderThickness="1" ItemsSource="{TemplateBinding OperationMenu}">
<MenuItem.Header> <MenuItem.Header>
<Path Data="M3.5,5.5 L11.5,5.5 L7.5,11 z" Fill="Black" Stroke="Gray" StrokeThickness="1" /> <Path Data="M3.5,5.5 L11.5,5.5 L7.5,11 z" Fill="Black" Stroke="Gray" StrokeThickness="1" />

3
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Xaml/XamlComponentService.cs

@ -89,7 +89,8 @@ namespace ICSharpCode.WpfDesign.Designer.Xaml
} }
XamlDesignItem item = new XamlDesignItem(_context.Document.CreateObject(component), _context); XamlDesignItem item = new XamlDesignItem(_context.Document.CreateObject(component), _context);
_sites.Add(component, item); if (!(component is string))
_sites.Add(component, item);
if (ComponentRegistered != null) { if (ComponentRegistered != null) {
ComponentRegistered(this, new DesignItemEventArgs(item)); ComponentRegistered(this, new DesignItemEventArgs(item));
} }

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

@ -21,6 +21,7 @@ using System.Diagnostics;
using System.Collections; using System.Collections;
using System.ComponentModel; using System.ComponentModel;
using System.Globalization; using System.Globalization;
using System.Linq;
using System.Reflection; using System.Reflection;
using System.Windows; using System.Windows;
using System.Windows.Documents; using System.Windows.Documents;
@ -39,11 +40,11 @@ namespace ICSharpCode.WpfDesign.XamlDom
public static bool IsCollectionType(Type type) public static bool IsCollectionType(Type type)
{ {
return type != typeof(LineBreak) && ( return type != typeof(LineBreak) && (
typeof(IList).IsAssignableFrom(type) typeof(IList).IsAssignableFrom(type)
|| type.IsArray || type.IsArray
|| typeof(IAddChild).IsAssignableFrom(type) || typeof(IAddChild).IsAssignableFrom(type)
|| typeof(IDictionary).IsAssignableFrom(type)); || typeof(IDictionary).IsAssignableFrom(type));
} }
/// <summary> /// <summary>
/// Gets if the collection type <paramref name="col"/> can accepts items of type /// Gets if the collection type <paramref name="col"/> can accepts items of type
@ -85,12 +86,12 @@ namespace ICSharpCode.WpfDesign.XamlDom
} else if (collectionInstance is IDictionary) { } else if (collectionInstance is IDictionary) {
object val = newElement.GetValueFor(null); object val = newElement.GetValueFor(null);
object key = newElement is XamlObject ? ((XamlObject)newElement).GetXamlAttribute("Key") : null; object key = newElement is XamlObject ? ((XamlObject)newElement).GetXamlAttribute("Key") : null;
if (key == null || key == "") if (key == null || key == "")
{ {
if (val is Style) if (val is Style)
key = ((Style)val).TargetType; key = ((Style)val).TargetType;
} }
if (key == null || (key as string) == "") if (key == null || (key as string) == "")
key = val; key = val;
((IDictionary)collectionInstance).Add(key, val); ((IDictionary)collectionInstance).Add(key, val);
} else { } else {
@ -102,16 +103,24 @@ namespace ICSharpCode.WpfDesign.XamlDom
} }
} }
/// <summary> /// <summary>
/// Adds a value at the specified index in the collection. /// Adds a value at the specified index in the collection.
/// </summary> /// </summary>
public static void Insert(Type collectionType, object collectionInstance, XamlPropertyValue newElement, int index) public static bool Insert(Type collectionType, object collectionInstance, XamlPropertyValue newElement, int index)
{ {
collectionType.InvokeMember( var hasInsert = collectionType.GetMethods().Any(x => x.Name == "Insert");
"Insert", BindingFlags.Public | BindingFlags.InvokeMethod | BindingFlags.Instance,
null, collectionInstance, if (hasInsert) {
new object[] { index, newElement.GetValueFor(null) }, collectionType.InvokeMember(
CultureInfo.InvariantCulture); "Insert", BindingFlags.Public | BindingFlags.InvokeMethod | BindingFlags.Instance,
null, collectionInstance,
new object[] { index, newElement.GetValueFor(null) },
CultureInfo.InvariantCulture);
return true;
}
return false;
} }
/// <summary> /// <summary>
@ -121,7 +130,7 @@ namespace ICSharpCode.WpfDesign.XamlDom
internal static bool TryInsert(Type collectionType, object collectionInstance, XamlPropertyValue newElement, int index) internal static bool TryInsert(Type collectionType, object collectionInstance, XamlPropertyValue newElement, int index)
{ {
try { try {
Insert(collectionType, collectionInstance, newElement, index); return Insert(collectionType, collectionInstance, newElement, index);
} catch (MissingMethodException) { } catch (MissingMethodException) {
return false; return false;
} }

Loading…
Cancel
Save