diff --git a/samples/XamlDesigner/App.xaml.cs b/samples/XamlDesigner/App.xaml.cs index 5ec88cffc2..6a9be5c98c 100644 --- a/samples/XamlDesigner/App.xaml.cs +++ b/samples/XamlDesigner/App.xaml.cs @@ -2,11 +2,16 @@ using System; using System.Collections.Generic; using System.Configuration; using System.Data; +using System.Diagnostics; +using System.IO; using System.Linq; +using System.Reflection; +using System.Threading; using System.Windows; -using ICSharpCode.XamlDesigner.Configuration; using System.Windows.Threading; -using System.Diagnostics; + +using ICSharpCode.WpfDesign.Designer; +using ICSharpCode.XamlDesigner.Configuration; namespace ICSharpCode.XamlDesigner { @@ -14,12 +19,70 @@ namespace ICSharpCode.XamlDesigner { public static string[] Args; - protected override void OnStartup(StartupEventArgs e) - { + protected override void OnStartup(StartupEventArgs e) + { + AppDomain.CurrentDomain.AssemblyResolve += new ResolveEventHandler(AppDomain_CurrentDomain_AssemblyResolve); + AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(AppDomain_CurrentDomain_UnhandledException); + DragDropExceptionHandler.UnhandledException += new ThreadExceptionEventHandler(DragDropExceptionHandler_UnhandledException); DispatcherUnhandledException += App_DispatcherUnhandledException; Args = e.Args; - base.OnStartup(e); - } + base.OnStartup(e); + } + + private static bool internalLoad = false; + private static string lastRequesting = null; + + Assembly AppDomain_CurrentDomain_AssemblyResolve(object sender, ResolveEventArgs args) + { + if (internalLoad) + return null; + + if (args.Name.Split(new [] { ',' })[0].Trim().EndsWith(".resources")) + return null; + + internalLoad = true; + + Assembly ass = null; + try { + + ass = Assembly.Load(args.Name); + } + catch (Exception) { } + + if (ass == null && args.RequestingAssembly != null) { + lastRequesting = args.RequestingAssembly.Location; + var dir = Path.GetDirectoryName(args.RequestingAssembly.Location); + var file = args.Name.Split(new [] { ',' })[0].Trim() + ".dll"; + try { + ass = Assembly.LoadFrom(Path.Combine(dir, file)); + } + catch (Exception) { } + } + else if (lastRequesting != null) { + var dir = Path.GetDirectoryName(lastRequesting); + var file = args.Name.Split(new [] { ',' })[0].Trim() + ".dll"; + try { + ass = Assembly.LoadFrom(Path.Combine(dir, file)); + } + catch (Exception) { } + } + + internalLoad = false; + + return ass; + } + + void DragDropExceptionHandler_UnhandledException(object sender, ThreadExceptionEventArgs e) + { + Shell.ReportException(e.Exception); + + } + + void AppDomain_CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e) + { + Shell.ReportException(e.ExceptionObject as Exception); + } + void App_DispatcherUnhandledException(object sender, DispatcherUnhandledExceptionEventArgs e) { @@ -27,10 +90,10 @@ namespace ICSharpCode.XamlDesigner e.Handled = true; } - protected override void OnExit(ExitEventArgs e) - { - Settings.Default.Save(); - base.OnExit(e); - } + protected override void OnExit(ExitEventArgs e) + { + Settings.Default.Save(); + base.OnExit(e); + } } } diff --git a/samples/XamlDesigner/Configuration/Settings.Designer.cs b/samples/XamlDesigner/Configuration/Settings.Designer.cs index 9a835b8cf5..856ed1ff13 100644 --- a/samples/XamlDesigner/Configuration/Settings.Designer.cs +++ b/samples/XamlDesigner/Configuration/Settings.Designer.cs @@ -37,25 +37,34 @@ namespace ICSharpCode.XamlDesigner.Configuration { [global::System.Configuration.UserScopedSettingAttribute()] [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - [global::System.Configuration.DefaultSettingValueAttribute(@" - - - - - - - - + [global::System.Configuration.DefaultSettingValueAttribute(@" + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - diff --git a/samples/XamlDesigner/Configuration/Settings.settings b/samples/XamlDesigner/Configuration/Settings.settings index 65e359e302..33f62b33b9 100644 --- a/samples/XamlDesigner/Configuration/Settings.settings +++ b/samples/XamlDesigner/Configuration/Settings.settings @@ -6,25 +6,34 @@ 0,0,0,0 - <DockingManager> - <ResizingPanel Orientation="Horizontal"> - <ResizingPanel ResizeWidth="200" Orientation="Vertical"> - <DockablePane ResizeHeight="441.36166666666668" Anchor="Left"> - <DockableContent Name="content1" AutoHide="false" /> - </DockablePane> - <DockablePane ResizeWidth="200" Anchor="Left"> - <DockableContent Name="content2" AutoHide="false" /> - </DockablePane> + <DockingManager version="1.3.0"> + <ResizingPanel ResizeWidth="*" ResizeHeight="*" EffectiveSize="0,0" Orientation="Vertical"> + <ResizingPanel ResizeWidth="*" ResizeHeight="*" EffectiveSize="1920,1153.04" Orientation="Horizontal"> + <ResizingPanel ResizeWidth="250" ResizeHeight="*" EffectiveSize="250,1153.04" Orientation="Vertical"> + <DockablePane ResizeWidth="0.742440632565806*" ResizeHeight="0.742440632565806*" EffectiveSize="250,851.609103178282" ID="bb7a5fd3-be24-4636-8fd6-a50a09e65e69" Anchor="Left" IsAutoHidden="false"> + <DockableContent Name="content1" FloatingWindowSize="250,400" ChildIndex="0" Width="315" Height="1153.04" Anchor="Right" State="Docked" /> + </DockablePane> + <DockablePane ResizeWidth="0.257559367434194*" ResizeHeight="0.257559367434194*" EffectiveSize="250,295.430896821718" ID="17cd1941-1004-4ed9-8cda-03c254681289" Anchor="Left" IsAutoHidden="false"> + <DockableContent Name="content2" FloatingWindowSize="250,400" ChildIndex="0" Width="328" Height="1153.04" Anchor="Right" State="Docked" /> + </DockablePane> + </ResizingPanel> + <ResizingPanel ResizeWidth="*" ResizeHeight="*" EffectiveSize="1408,1153.04" Orientation="Vertical"> + <DocumentPaneResizingPanel ResizeWidth="*" ResizeHeight="*" EffectiveSize="1408,965.04" Orientation="Vertical"> + <DocumentPane IsMain="true" ResizeWidth="*" ResizeHeight="*" EffectiveSize="1408,965.04" /> + </DocumentPaneResizingPanel> + <DockablePane ResizeWidth="*" ResizeHeight="182" EffectiveSize="1408,182" ID="ebd34b7e-6a89-42c6-b172-0e666b0d8a0a" Anchor="Bottom" IsAutoHidden="false"> + <DockableContent Name="content3" FloatingWindowSize="250,400" ChildIndex="0" Width="1920" Height="400" Anchor="Bottom" State="Docked" /> + </DockablePane> + </ResizingPanel> + <ResizingPanel ResizeWidth="250" ResizeHeight="*" EffectiveSize="250,1153.04" Orientation="Vertical"> + <DockablePane ResizeWidth="0.145251345356991*" ResizeHeight="0.145251345356991*" EffectiveSize="250,166.609103178283" ID="aa545474-48b3-49a6-b76c-b0c625e79e4c" Anchor="Right" IsAutoHidden="false"> + <DockableContent Name="content5" FloatingWindowSize="250,400" ChildIndex="0" Width="550.666666666667" Height="1153.04" Anchor="Right" State="Docked" /> + </DockablePane> + <DockablePane ResizeWidth="0.854748654643009*" ResizeHeight="0.854748654643009*" EffectiveSize="250,980.430896821717" ID="64e5518b-2c83-4e22-908d-a510a6995c27" Anchor="Right" IsAutoHidden="false"> + <DockableContent Name="content4" FloatingWindowSize="250,400" ChildIndex="0" Width="399.967430639324" Height="1153.04" Anchor="Right" State="Docked" /> + </DockablePane> + </ResizingPanel> </ResizingPanel> - <ResizingPanel Orientation="Vertical"> - <DocumentPanePlaceHolder /> - <DockablePane ResizeHeight="138" Anchor="Bottom"> - <DockableContent Name="content3" AutoHide="false" /> - </DockablePane> - </ResizingPanel> - <DockablePane ResizeWidth="271" Anchor="Right"> - <DockableContent Name="content4" AutoHide="false" /> - </DockablePane> </ResizingPanel> <Hidden /> <Windows /> diff --git a/samples/XamlDesigner/MainWindow.xaml b/samples/XamlDesigner/MainWindow.xaml index b3cd9e3b43..881a18b050 100644 --- a/samples/XamlDesigner/MainWindow.xaml +++ b/samples/XamlDesigner/MainWindow.xaml @@ -42,6 +42,12 @@ + + + + @@ -78,8 +84,12 @@ + + + + - + diff --git a/samples/XamlDesigner/MainWindow_Commands.cs b/samples/XamlDesigner/MainWindow_Commands.cs index 040f15a27c..bb6c0c7b5b 100644 --- a/samples/XamlDesigner/MainWindow_Commands.cs +++ b/samples/XamlDesigner/MainWindow_Commands.cs @@ -1,9 +1,18 @@ using System; using System.Collections.Generic; +using System.IO; using System.Linq; using System.Text; -using System.Windows.Input; using System.Windows; +using System.Windows.Controls; +using System.Windows.Documents; +using System.Windows.Input; +using System.Windows.Markup; +using System.Windows.Media; +using System.Windows.Media.Imaging; +using System.Xml; + +using Microsoft.Win32; namespace ICSharpCode.XamlDesigner { @@ -13,6 +22,8 @@ namespace ICSharpCode.XamlDesigner public static SimpleCommand SaveAllCommand = new SimpleCommand("Save All", ModifierKeys.Control | ModifierKeys.Shift, Key.S); public static SimpleCommand ExitCommand = new SimpleCommand("Exit"); public static SimpleCommand RefreshCommand = new SimpleCommand("Refresh", Key.F5); + public static SimpleCommand RunCommand = new SimpleCommand("Run", ModifierKeys.Shift, Key.F5); + public static SimpleCommand RenderToBitmapCommand = new SimpleCommand("Render to Bitmap"); static void RenameCommands() { @@ -59,6 +70,72 @@ namespace ICSharpCode.XamlDesigner { Shell.Instance.SaveAll(); } + + void RunCommand_Executed(object sender, ExecutedRoutedEventArgs e) + { + StringBuilder sb = new StringBuilder(); + var xmlWriter = XmlWriter.Create(new StringWriter(sb)); + Shell.Instance.CurrentDocument.DesignSurface.SaveDesigner(xmlWriter); + + var txt = sb.ToString(); + var xmlReader = XmlReader.Create(new StringReader(txt)); + + var ctl = XamlReader.Load(xmlReader); + + Window wnd = ctl as Window; + if (wnd == null) { + wnd = new Window(); + wnd.Content = ctl; + } + wnd.Show(); + } + + void RenderToBitmapCommand_Executed(object sender, ExecutedRoutedEventArgs e) + { + int desiredWidth = 300; + int desiredHeight = 300; + + StringBuilder sb = new StringBuilder(); + var xmlWriter = XmlWriter.Create(new StringWriter(sb)); + Shell.Instance.CurrentDocument.DesignSurface.SaveDesigner(xmlWriter); + + var txt = sb.ToString(); + var xmlReader = XmlReader.Create(new StringReader(txt)); + + var ctl = XamlReader.Load(xmlReader) as Control; + if (ctl is Window) { + var wnd = ctl as Window; + wnd.Width = desiredWidth; + wnd.Height = desiredHeight; + wnd.Top = -10000; + wnd.Left = -10000; + wnd.Show(); + } else { + ctl.Measure(new Size(desiredWidth, desiredHeight)); + ctl.Arrange(new Rect(new Size(desiredWidth, desiredHeight))); + } + + RenderTargetBitmap bmp = new RenderTargetBitmap(300, 300, 96, 96, PixelFormats.Default); + bmp.Render(ctl); + + var encoder = new PngBitmapEncoder(); + + encoder.Frames.Add(BitmapFrame.Create(bmp)); + + var dlg = new SaveFileDialog(); + dlg.Filter = "*.png|*.png"; + if (dlg.ShowDialog() == true) { + using (Stream stm = File.OpenWrite(dlg.FileName)) { + encoder.Save(stm); + stm.Flush(); + } + } + + if (ctl is Window) { + var wnd = ctl as Window; + wnd.Close(); + } + } void ExitCommand_Executed(object sender, ExecutedRoutedEventArgs e) { diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/BasicMetadata.cs b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/BasicMetadata.cs index d3d6ffcd18..91dbe48dd1 100644 --- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/BasicMetadata.cs +++ b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/BasicMetadata.cs @@ -163,6 +163,8 @@ namespace ICSharpCode.WpfDesign.Designer Metadata.AddPopularProperty(typeof(Binding), "ElementName"); Metadata.AddPopularProperty(typeof(Binding), "Converter"); Metadata.AddPopularProperty(typeof(Binding), "XPath"); + + Metadata.AddPopularProperty(typeof(ItemsControl), "Items"); Metadata.AddValueRange(Block.LineHeightProperty, double.Epsilon, double.MaxValue); Metadata.AddValueRange(Canvas.BottomProperty, double.MinValue, double.MaxValue); @@ -219,7 +221,7 @@ namespace ICSharpCode.WpfDesign.Designer Metadata.HideProperty(typeof(UIElement), "RenderSize"); Metadata.HideProperty(FrameworkElement.NameProperty); - Metadata.HideProperty(typeof(FrameworkElement), "Resources"); + //Metadata.HideProperty(typeof(FrameworkElement), "Resources"); Metadata.HideProperty(typeof(Window), "Owner"); //Metadata.DisablePlacement(typeof(Button)); diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/DesignPanel.cs b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/DesignPanel.cs index aa8f55a245..0a5ba978a3 100644 --- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/DesignPanel.cs +++ b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/DesignPanel.cs @@ -35,6 +35,10 @@ namespace ICSharpCode.WpfDesign.Designer public sealed class DesignPanel : Decorator, IDesignPanel, INotifyPropertyChanged { #region Hit Testing + + private List hitTestElements = new List(); + private DependencyObject lastElement; + /// /// this element is always hit (unless HitTestVisible is set to false) /// @@ -54,7 +58,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) @@ -70,9 +74,10 @@ namespace ICSharpCode.WpfDesign.Designer if (designItem != null && designItem.IsDesignTimeLocked) { return HitTestFilterBehavior.ContinueSkipSelfAndChildren; + } } - } + hitTestElements.Add(element); return HitTestFilterBehavior.Continue; } @@ -80,14 +85,17 @@ namespace ICSharpCode.WpfDesign.Designer /// /// Performs a custom hit testing lookup for the specified mouse event args. /// - public DesignPanelHitTestResult HitTest(Point mousePosition, bool testAdorners, bool testDesignSurface) + public DesignPanelHitTestResult HitTest(Point mousePosition, bool testAdorners, bool testDesignSurface, HitTestType hitTestType) { + hitTestElements.Clear(); + DesignPanelHitTestResult result = DesignPanelHitTestResult.NoHit; HitTest(mousePosition, testAdorners, testDesignSurface, - delegate(DesignPanelHitTestResult r) { - result = r; - return false; - }); + delegate(DesignPanelHitTestResult r) { + result = r; + return false; + }, hitTestType); + return result; } @@ -95,7 +103,7 @@ namespace ICSharpCode.WpfDesign.Designer /// Performs a hit test on the design surface, raising for each match. /// Hit testing continues while the callback returns true. /// - public void HitTest(Point mousePosition, bool testAdorners, bool testDesignSurface, Predicate callback) + public void HitTest(Point mousePosition, bool testAdorners, bool testDesignSurface, Predicate callback, HitTestType hitTestType) { if (mousePosition.X < 0 || mousePosition.Y < 0 || mousePosition.X > this.RenderSize.Width || mousePosition.Y > this.RenderSize.Height) { return; @@ -104,6 +112,8 @@ namespace ICSharpCode.WpfDesign.Designer bool continueHitTest = true; + hitTestElements.Clear(); + if (testAdorners) { RunHitTest( _adornerLayer, mousePosition, FilterHitTestInvisibleElements, @@ -135,6 +145,19 @@ namespace ICSharpCode.WpfDesign.Designer ViewService viewService = _context.Services.View; DependencyObject obj = result.VisualHit; + + if (hitTestType == HitTestType.ElementSelection) + { + if (Keyboard.IsKeyDown(Key.LeftAlt)) + if (lastElement != null && lastElement != _context.RootItem.Component && + hitTestElements.Contains(lastElement)) + { + var idx = hitTestElements.IndexOf(lastElement) - 1; + if (idx >= 0) + obj = hitTestElements[idx]; + } + } + while (obj != null) { if ((customResult.ModelHit = viewService.GetModel(obj)) != null) break; @@ -143,6 +166,13 @@ namespace ICSharpCode.WpfDesign.Designer if (customResult.ModelHit == null) { customResult.ModelHit = _context.RootItem; } + + if (hitTestType == HitTestType.ElementSelection) + { + lastElement = obj; + } + + continueHitTest = callback(customResult); return continueHitTest ? HitTestResultBehavior.Continue : HitTestResultBehavior.Stop; } else { @@ -223,7 +253,7 @@ namespace ICSharpCode.WpfDesign.Designer } } } - + /// /// Enables / Disables the Raster Placement /// @@ -341,14 +371,14 @@ namespace ICSharpCode.WpfDesign.Designer if (e.Key == Key.Left || e.Key == Key.Right || e.Key == Key.Up || e.Key == Key.Down) { e.Handled = true; - + if (placementOp == null) { dx = 0; dy = 0; placementOp = PlacementOperation.Start(Context.Services.Selection.SelectedItems, PlacementType.Move); } - - + + dx += (e.Key == Key.Left) ? Keyboard.IsKeyDown(Key.LeftShift) ? -10 : -1 : 0; dy += (e.Key == Key.Up) ? Keyboard.IsKeyDown(Key.LeftShift) ? -10 : -1 : 0; dx += (e.Key == Key.Right) ? Keyboard.IsKeyDown(Key.LeftShift) ? 10 : 1 : 0; @@ -358,18 +388,18 @@ namespace ICSharpCode.WpfDesign.Designer if (!Keyboard.IsKeyDown(Key.LeftCtrl)) { info.Bounds = new Rect(info.OriginalBounds.Left + dx, - info.OriginalBounds.Top + dy, - info.OriginalBounds.Width, - info.OriginalBounds.Height); + info.OriginalBounds.Top + dy, + info.OriginalBounds.Width, + info.OriginalBounds.Height); } else { info.Bounds = new Rect(info.OriginalBounds.Left, - info.OriginalBounds.Top, - info.OriginalBounds.Width + dx, - info.OriginalBounds.Height + dy); + info.OriginalBounds.Top, + info.OriginalBounds.Width + dx, + info.OriginalBounds.Height + dy); } - + placementOp.CurrentContainerBehavior.SetPosition(info); } } diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Extensions/InPlaceEditorExtension.cs b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Extensions/InPlaceEditorExtension.cs index 744f34e9b3..81a24d77c4 100644 --- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Extensions/InPlaceEditorExtension.cs +++ b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Extensions/InPlaceEditorExtension.cs @@ -159,7 +159,7 @@ namespace ICSharpCode.WpfDesign.Designer.Extensions void MouseDown(object sender,MouseEventArgs e) { - result = designPanel.HitTest(e.GetPosition(designPanel), false, true); + result = designPanel.HitTest(e.GetPosition(designPanel), false, true, HitTestType.Default); if(result.ModelHit==ExtendedItem && result.VisualHit is TextBlock) { Start = Mouse.GetPosition(null); Current = Start; @@ -171,7 +171,7 @@ namespace ICSharpCode.WpfDesign.Designer.Extensions void MouseMove(object sender, MouseEventArgs e) { Current += e.GetPosition(null) - Start; - result = designPanel.HitTest(e.GetPosition(designPanel), false, true); + result = designPanel.HitTest(e.GetPosition(designPanel), false, true, HitTestType.Default); if (result.ModelHit == ExtendedItem && result.VisualHit is TextBlock) { if (numClicks > 0) { if (isMouseDown && @@ -190,7 +190,7 @@ namespace ICSharpCode.WpfDesign.Designer.Extensions void MouseUp(object sender,MouseEventArgs e) { - result = designPanel.HitTest(e.GetPosition(designPanel), false, true); + result = designPanel.HitTest(e.GetPosition(designPanel), false, true, HitTestType.Default); if (result.ModelHit == ExtendedItem && result.VisualHit is TextBlock && numClicks>0){ if (!isGettingDragged) { PlaceEditor(result.VisualHit, e); diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/PropertyGrid/Editors/BoolEditor.xaml b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/PropertyGrid/Editors/BoolEditor.xaml index f088519992..5c05391fb0 100644 --- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/PropertyGrid/Editors/BoolEditor.xaml +++ b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/PropertyGrid/Editors/BoolEditor.xaml @@ -3,5 +3,6 @@ xmlns="http://schemas.microsoft.com/netfx/2007/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" IsChecked="{Binding Value}" + Focusable="False" > diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/PropertyGrid/Editors/ColorEditor.xaml b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/PropertyGrid/Editors/ColorEditor.xaml new file mode 100644 index 0000000000..559d1520ca --- /dev/null +++ b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/PropertyGrid/Editors/ColorEditor.xaml @@ -0,0 +1,7 @@ + + \ No newline at end of file diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/PropertyGrid/Editors/ColorEditor.xaml.cs b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/PropertyGrid/Editors/ColorEditor.xaml.cs new file mode 100644 index 0000000000..033175be75 --- /dev/null +++ b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/PropertyGrid/Editors/ColorEditor.xaml.cs @@ -0,0 +1,29 @@ +// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) +// This code is distributed under the GNU LGPL (for details please see \doc\license.txt) + +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.PropertyGrid.Editors +{ + [TypeEditor(typeof(Color))] + public partial class ColorEditor + { + public ColorEditor() + { + InitializeComponent(); + } + } +} \ No newline at end of file diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/PropertyGrid/Editors/FlatCollectionEditor.xaml.cs b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/PropertyGrid/Editors/FlatCollectionEditor.xaml.cs index 07f33783f9..bffd2a8f4e 100644 --- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/PropertyGrid/Editors/FlatCollectionEditor.xaml.cs +++ b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/PropertyGrid/Editors/FlatCollectionEditor.xaml.cs @@ -57,18 +57,28 @@ namespace ICSharpCode.WpfDesign.Designer.PropertyGrid.Editors this.Owner = Application.Current.MainWindow; } + public Type GetItemsSourceType(Type t) + { + Type tp = t.GetInterfaces().FirstOrDefault(x => x.IsGenericType && x.GetGenericTypeDefinition() == typeof(ICollection<>)); + + return (tp != null ) ? tp.GetGenericArguments()[0] : null; + } + public void LoadItemsCollection(DesignItemProperty itemProperty) { _itemProperty = itemProperty; _componentService=_itemProperty.DesignItem.Services.Component; TypeMappings.TryGetValue(_itemProperty.ReturnType, out _type); + + _type = _type ?? GetItemsSourceType(_itemProperty.ReturnType); + if (_type == null) { - PropertyGridView.IsEnabled=false; - ListBox.IsEnabled=false; + //PropertyGridView.IsEnabled=false; + //ListBox.IsEnabled=false; AddItem.IsEnabled=false; - RemoveItem.IsEnabled=false; - MoveUpItem.IsEnabled=false; - MoveDownItem.IsEnabled=false; + //RemoveItem.IsEnabled=false; + //MoveUpItem.IsEnabled=false; + //MoveDownItem.IsEnabled=false; } ListBox.ItemsSource = _itemProperty.CollectionElements; diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/PropertyGrid/Editors/OpenCollectionEditor.xaml b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/PropertyGrid/Editors/OpenCollectionEditor.xaml new file mode 100644 index 0000000000..346915708c --- /dev/null +++ b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/PropertyGrid/Editors/OpenCollectionEditor.xaml @@ -0,0 +1,17 @@ + + + + +