diff --git a/data/resources/StringResources.de.resx b/data/resources/StringResources.de.resx index 0447753912..66570b2945 100644 --- a/data/resources/StringResources.de.resx +++ b/data/resources/StringResources.de.resx @@ -415,11 +415,14 @@ Sie werden nicht mehr funktionieren, nachdem dieses AddIn entfernt wurde! Sind S Hilfebibliothek - Hilfetyp + Hilfetyp wählen Help Library Manager kann nicht gestartet werden, weil kein Hilfekatalog installiert oder ausgewählt wurde. Bitte überprüfen Sie die Hilfeeinstellungen (siehe Extras > Optionen... > Tools > Microsoft Help Viewer). + + Der Help Library Manager wurde nicht gefunden. Um die Hilfe von SharpDevelop nutzen zu können, laden Sie bitte das Windows SDK 7.1 von Microsoft herunter und installieren Sie es. + Help Library Manager wurde nicht gefunden. Bitte stellen Sie sicher, dass es korrekt installiert wurde. @@ -448,7 +451,7 @@ Sie werden nicht mehr funktionieren, nachdem dieses AddIn entfernt wurde! Sind S Hilfe anzeigen - Externe Hilfe verwenden + Externen Hilfebetrachter verwenden Ich möchte die lokale Hilfe verwenden diff --git a/data/resources/StringResources.resx b/data/resources/StringResources.resx index c7892e9e74..fcea373641 100644 --- a/data/resources/StringResources.resx +++ b/data/resources/StringResources.resx @@ -426,12 +426,15 @@ They will stop working after removing this AddIn! Are you sure you want to conti Help Library - Help Mode + Set Help Preference Cannot launch Help Library Manager, because there is no help catalog installed/selected. Please check your help settings (see Tools > Options > Tools > Microsoft Help Viewer). Error message when there is no help catalog active + + The Help Library Manager was not found. In order to use SharpDevelop's help feature please download and install Microsoft's Windows SDK 7.1. + Help Library Manager was not found. Please check if it was installed correctly. @@ -460,7 +463,7 @@ They will stop working after removing this AddIn! Are you sure you want to conti Show Help - Use external help + Use external help viewer I want to use local help diff --git a/doc/Dependencies.html b/doc/Dependencies.html new file mode 100644 index 0000000000..ed8bdf4c9a --- /dev/null +++ b/doc/Dependencies.html @@ -0,0 +1,38 @@ + + + SharpDevelop Dependencies + + + +

+ SharpDevelop can take advantage of the following software if you install it: +

+ + + + \ No newline at end of file diff --git a/src/AddIns/BackendBindings/Python/RequiredLibraries/Chiron.exe b/src/AddIns/BackendBindings/Python/RequiredLibraries/Chiron.exe index 94a5ca6f2b..c879fd9bf2 100644 Binary files a/src/AddIns/BackendBindings/Python/RequiredLibraries/Chiron.exe and b/src/AddIns/BackendBindings/Python/RequiredLibraries/Chiron.exe differ diff --git a/src/AddIns/BackendBindings/Python/RequiredLibraries/DLLs/IronPython.Wpf.dll b/src/AddIns/BackendBindings/Python/RequiredLibraries/DLLs/IronPython.Wpf.dll index 96a3038946..0d2fd5b432 100644 Binary files a/src/AddIns/BackendBindings/Python/RequiredLibraries/DLLs/IronPython.Wpf.dll and b/src/AddIns/BackendBindings/Python/RequiredLibraries/DLLs/IronPython.Wpf.dll differ diff --git a/src/AddIns/BackendBindings/Python/RequiredLibraries/IronPython.Modules.dll b/src/AddIns/BackendBindings/Python/RequiredLibraries/IronPython.Modules.dll index 91d96fbe86..109d59f433 100755 Binary files a/src/AddIns/BackendBindings/Python/RequiredLibraries/IronPython.Modules.dll and b/src/AddIns/BackendBindings/Python/RequiredLibraries/IronPython.Modules.dll differ diff --git a/src/AddIns/BackendBindings/Python/RequiredLibraries/IronPython.dll b/src/AddIns/BackendBindings/Python/RequiredLibraries/IronPython.dll index 364120c581..592155a683 100755 Binary files a/src/AddIns/BackendBindings/Python/RequiredLibraries/IronPython.dll and b/src/AddIns/BackendBindings/Python/RequiredLibraries/IronPython.dll differ diff --git a/src/AddIns/BackendBindings/Python/RequiredLibraries/Microsoft.Dynamic.dll b/src/AddIns/BackendBindings/Python/RequiredLibraries/Microsoft.Dynamic.dll index e621051170..14b7ff99e0 100644 Binary files a/src/AddIns/BackendBindings/Python/RequiredLibraries/Microsoft.Dynamic.dll and b/src/AddIns/BackendBindings/Python/RequiredLibraries/Microsoft.Dynamic.dll differ diff --git a/src/AddIns/BackendBindings/Python/RequiredLibraries/Microsoft.Scripting.Metadata.dll b/src/AddIns/BackendBindings/Python/RequiredLibraries/Microsoft.Scripting.Metadata.dll index 4c093b1530..7d94df195f 100644 Binary files a/src/AddIns/BackendBindings/Python/RequiredLibraries/Microsoft.Scripting.Metadata.dll and b/src/AddIns/BackendBindings/Python/RequiredLibraries/Microsoft.Scripting.Metadata.dll differ diff --git a/src/AddIns/BackendBindings/Python/RequiredLibraries/Microsoft.Scripting.dll b/src/AddIns/BackendBindings/Python/RequiredLibraries/Microsoft.Scripting.dll index f37c4c4473..61556abb80 100755 Binary files a/src/AddIns/BackendBindings/Python/RequiredLibraries/Microsoft.Scripting.dll and b/src/AddIns/BackendBindings/Python/RequiredLibraries/Microsoft.Scripting.dll differ diff --git a/src/AddIns/BackendBindings/Python/RequiredLibraries/ipy.exe b/src/AddIns/BackendBindings/Python/RequiredLibraries/ipy.exe index e1041bfded..51b875418b 100755 Binary files a/src/AddIns/BackendBindings/Python/RequiredLibraries/ipy.exe and b/src/AddIns/BackendBindings/Python/RequiredLibraries/ipy.exe differ diff --git a/src/AddIns/BackendBindings/Python/RequiredLibraries/ipyw.exe b/src/AddIns/BackendBindings/Python/RequiredLibraries/ipyw.exe index 6cc71e8087..97d1660474 100644 Binary files a/src/AddIns/BackendBindings/Python/RequiredLibraries/ipyw.exe and b/src/AddIns/BackendBindings/Python/RequiredLibraries/ipyw.exe differ diff --git a/src/AddIns/BackendBindings/Ruby/IronRuby/bin/Chiron.exe b/src/AddIns/BackendBindings/Ruby/IronRuby/bin/Chiron.exe index 94a5ca6f2b..c879fd9bf2 100644 Binary files a/src/AddIns/BackendBindings/Ruby/IronRuby/bin/Chiron.exe and b/src/AddIns/BackendBindings/Ruby/IronRuby/bin/Chiron.exe differ diff --git a/src/AddIns/BackendBindings/Ruby/IronRuby/bin/IronRuby.Libraries.Yaml.dll b/src/AddIns/BackendBindings/Ruby/IronRuby/bin/IronRuby.Libraries.Yaml.dll index 901b79fcaa..265a0e553f 100644 Binary files a/src/AddIns/BackendBindings/Ruby/IronRuby/bin/IronRuby.Libraries.Yaml.dll and b/src/AddIns/BackendBindings/Ruby/IronRuby/bin/IronRuby.Libraries.Yaml.dll differ diff --git a/src/AddIns/BackendBindings/Ruby/IronRuby/bin/IronRuby.Libraries.dll b/src/AddIns/BackendBindings/Ruby/IronRuby/bin/IronRuby.Libraries.dll index 271712e8e4..477a87d187 100644 Binary files a/src/AddIns/BackendBindings/Ruby/IronRuby/bin/IronRuby.Libraries.dll and b/src/AddIns/BackendBindings/Ruby/IronRuby/bin/IronRuby.Libraries.dll differ diff --git a/src/AddIns/BackendBindings/Ruby/IronRuby/bin/IronRuby.dll b/src/AddIns/BackendBindings/Ruby/IronRuby/bin/IronRuby.dll index 9b8bf98a9d..79b634a2ec 100644 Binary files a/src/AddIns/BackendBindings/Ruby/IronRuby/bin/IronRuby.dll and b/src/AddIns/BackendBindings/Ruby/IronRuby/bin/IronRuby.dll differ diff --git a/src/AddIns/BackendBindings/Ruby/IronRuby/bin/Microsoft.Dynamic.dll b/src/AddIns/BackendBindings/Ruby/IronRuby/bin/Microsoft.Dynamic.dll index e621051170..14b7ff99e0 100644 Binary files a/src/AddIns/BackendBindings/Ruby/IronRuby/bin/Microsoft.Dynamic.dll and b/src/AddIns/BackendBindings/Ruby/IronRuby/bin/Microsoft.Dynamic.dll differ diff --git a/src/AddIns/BackendBindings/Ruby/IronRuby/bin/Microsoft.Scripting.Metadata.dll b/src/AddIns/BackendBindings/Ruby/IronRuby/bin/Microsoft.Scripting.Metadata.dll index 4c093b1530..7d94df195f 100644 Binary files a/src/AddIns/BackendBindings/Ruby/IronRuby/bin/Microsoft.Scripting.Metadata.dll and b/src/AddIns/BackendBindings/Ruby/IronRuby/bin/Microsoft.Scripting.Metadata.dll differ diff --git a/src/AddIns/BackendBindings/Ruby/IronRuby/bin/Microsoft.Scripting.dll b/src/AddIns/BackendBindings/Ruby/IronRuby/bin/Microsoft.Scripting.dll index f37c4c4473..61556abb80 100644 Binary files a/src/AddIns/BackendBindings/Ruby/IronRuby/bin/Microsoft.Scripting.dll and b/src/AddIns/BackendBindings/Ruby/IronRuby/bin/Microsoft.Scripting.dll differ diff --git a/src/AddIns/BackendBindings/Ruby/IronRuby/bin/ir.exe b/src/AddIns/BackendBindings/Ruby/IronRuby/bin/ir.exe index 6ecfda77ac..728b191245 100644 Binary files a/src/AddIns/BackendBindings/Ruby/IronRuby/bin/ir.exe and b/src/AddIns/BackendBindings/Ruby/IronRuby/bin/ir.exe differ diff --git a/src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/CodeEditorView.cs b/src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/CodeEditorView.cs index b42a62e93b..a49d7eab11 100755 --- a/src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/CodeEditorView.cs +++ b/src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/CodeEditorView.cs @@ -27,6 +27,7 @@ using ICSharpCode.AvalonEdit.Highlighting; using ICSharpCode.AvalonEdit.Rendering; using ICSharpCode.NRefactory.Editor; using ICSharpCode.NRefactory.Semantics; +using ICSharpCode.NRefactory.TypeSystem; using ICSharpCode.SharpDevelop; using ICSharpCode.SharpDevelop.Editor; using ICSharpCode.SharpDevelop.Editor.AvalonEdit; @@ -231,7 +232,12 @@ namespace ICSharpCode.AvalonEdit.AddIn } MemberResolveResult mrr = result as MemberResolveResult; if (mrr != null) { - HelpProvider.ShowHelp(mrr.Member); + if ((mrr.Member.DeclaringType.Kind == TypeKind.Enum) && + (mrr.Member.DeclaringType.GetDefinition() != null)) { + HelpProvider.ShowHelp(mrr.Member.DeclaringType.GetDefinition()); + } else { + HelpProvider.ShowHelp(mrr.Member); + } } } #endregion diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Controls/PanelMoveAdorner.cs b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Controls/PanelMoveAdorner.cs index 5333abb315..80053c4a89 100644 --- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Controls/PanelMoveAdorner.cs +++ b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Controls/PanelMoveAdorner.cs @@ -47,10 +47,14 @@ namespace ICSharpCode.WpfDesign.Designer.Controls { base.OnApplyTemplate(); + var bnd = new Binding("IsVisible") {Source = item.Component}; + bnd.Converter = CollapsedWhenFalse.Instance; + BindingOperations.SetBinding(this, UIElement.VisibilityProperty, bnd); + var surface = this.TryFindParent(); if (surface != null && surface.ZoomControl != null) { - var bnd = new Binding("CurrentZoom") {Source = surface.ZoomControl}; + bnd = new Binding("CurrentZoom") {Source = surface.ZoomControl}; bnd.Converter = InvertedZoomConverter.Instance; BindingOperations.SetBinding(scaleTransform, ScaleTransform.ScaleXProperty, bnd); diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/DesignPanel.cs b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/DesignPanel.cs index da4e767c12..b7af3ec784 100644 --- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/DesignPanel.cs +++ b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/DesignPanel.cs @@ -13,6 +13,7 @@ using System.Windows.Threading; using ICSharpCode.WpfDesign.Adorners; using ICSharpCode.WpfDesign.Designer.Controls; +using ICSharpCode.WpfDesign.Designer.Xaml; namespace ICSharpCode.WpfDesign.Designer { @@ -35,20 +36,29 @@ namespace ICSharpCode.WpfDesign.Designer } } - static void RunHitTest(Visual reference, Point point, HitTestFilterCallback filterCallback, HitTestResultCallback resultCallback) + void RunHitTest(Visual reference, Point point, HitTestFilterCallback filterCallback, HitTestResultCallback resultCallback) { VisualTreeHelper.HitTest(reference, filterCallback, resultCallback, new PointHitTestParameters(point)); } - static HitTestFilterBehavior FilterHitTestInvisibleElements(DependencyObject potentialHitTestTarget) + HitTestFilterBehavior FilterHitTestInvisibleElements(DependencyObject potentialHitTestTarget) { UIElement element = potentialHitTestTarget as UIElement; + if (element != null) { if (!(element.IsHitTestVisible && element.Visibility == Visibility.Visible)) { return HitTestFilterBehavior.ContinueSkipSelfAndChildren; } + + var designItem = Context.Services.Component.GetDesignItem(element) as XamlDesignItem; + + if (designItem != null && designItem.IsDesignTimeLocked) { + return HitTestFilterBehavior.ContinueSkipSelfAndChildren; + } + } + return HitTestFilterBehavior.Continue; } @@ -103,7 +113,7 @@ namespace ICSharpCode.WpfDesign.Designer if (continueHitTest && testDesignSurface) { RunHitTest( - this.Child, mousePosition, delegate { return HitTestFilterBehavior.Continue; }, + this.Child, mousePosition, FilterHitTestInvisibleElements, delegate(HitTestResult result) { if (result != null && result.VisualHit != null && result.VisualHit is Visual) { DesignPanelHitTestResult customResult = new DesignPanelHitTestResult((Visual)result.VisualHit); diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/DesignSurface.cs b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/DesignSurface.cs index ffbf2246d3..0de7db3e29 100644 --- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/DesignSurface.cs +++ b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/DesignSurface.cs @@ -31,7 +31,7 @@ namespace ICSharpCode.WpfDesign.Designer /// [TemplatePart(Name = "PART_DesignContent", Type = typeof(ContentControl))] [TemplatePart(Name = "PART_Zoom", Type = typeof(ZoomControl))] - public class DesignSurface : ContentControl + public partial class DesignSurface : ContentControl { private FocusNavigator _focusNav; @@ -73,10 +73,21 @@ namespace ICSharpCode.WpfDesign.Designer base.OnApplyTemplate(); } + + private bool enableBringIntoView = false; + + public void ScrollIntoView(DesignItem designItem) + { + enableBringIntoView = true; + LogicalTreeHelper.BringIntoView(designItem.View); + enableBringIntoView = false; + } void _partDesignContent_RequestBringIntoView(object sender, RequestBringIntoViewEventArgs e) { - e.Handled = true; + if (!enableBringIntoView) + e.Handled = true; + enableBringIntoView = false; } protected override void OnPreviewMouseLeftButtonDown(MouseButtonEventArgs e) diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Extensions/BorderForInvisibleControl.cs b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Extensions/BorderForInvisibleControl.cs index 0657413535..bd46bf04d2 100644 --- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Extensions/BorderForInvisibleControl.cs +++ b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Extensions/BorderForInvisibleControl.cs @@ -3,15 +3,17 @@ using System; using System.Collections.Generic; +using System.ComponentModel; using System.Linq; using System.Text; -using ICSharpCode.WpfDesign.Adorners; -using ICSharpCode.WpfDesign.Extensions; -using System.Windows.Controls; using System.Windows; -using ICSharpCode.WpfDesign.Designer.Controls; +using System.Windows.Controls; using System.Windows.Media; +using ICSharpCode.WpfDesign.Adorners; +using ICSharpCode.WpfDesign.Designer.Controls; +using ICSharpCode.WpfDesign.Extensions; + namespace ICSharpCode.WpfDesign.Designer.Extensions { [ExtensionFor(typeof(Panel))] @@ -21,6 +23,7 @@ namespace ICSharpCode.WpfDesign.Designer.Extensions public class BorderForInvisibleControl : PermanentAdornerProvider { AdornerPanel adornerPanel; + AdornerPanel cachedAdornerPanel; protected override void OnInitialized() { @@ -28,52 +31,79 @@ namespace ICSharpCode.WpfDesign.Designer.Extensions if (ExtendedItem.Component is Border) { - ExtendedItem.PropertyChanged+= (s, e) => ExtendedItem_PropertyChanged(); + ExtendedItem.PropertyChanged += (s, e) => UpdateAdorner(); + } + + // If component is a ContentControl it must be of type ContentControl specifically, and not derived types like Label and Button. + if (!(ExtendedItem.Component is ContentControl) || ExtendedItem.Component.GetType() == typeof(ContentControl)) { + UpdateAdorner(); - ExtendedItem_PropertyChanged(); + var element = ExtendedItem.Component as UIElement; + if (element != null) { + element.IsVisibleChanged += (s, e) => UpdateAdorner(); + } } - else if (ExtendedItem.Component is Panel || ExtendedItem.Component is Viewbox || ExtendedItem.Component is ContentControl) - { - CreateAdorner(); - } } - void ExtendedItem_PropertyChanged() + void UpdateAdorner() { - if (ExtendedItem.Component is Border) - { - var border = ExtendedItem.Component as Border; - if (border.ReadLocalValue(Border.BorderBrushProperty) == DependencyProperty.UnsetValue || border.ReadLocalValue(Border.BorderThicknessProperty) == DependencyProperty.UnsetValue) - { + var element = ExtendedItem.Component as UIElement; + if (element != null) { + var border = element as Border; + if (element.IsVisible && (border == null || IsAnyBorderEdgeInvisible(border))) { CreateAdorner(); + + if (border != null) { + var adornerBorder = (Border)adornerPanel.Children[0]; + + if (IsBorderBrushInvisible(border)) + adornerBorder.BorderThickness = new Thickness(1); + else + adornerBorder.BorderThickness = new Thickness(border.BorderThickness.Left > 0 ? 0 : 1, + border.BorderThickness.Top > 0 ? 0 : 1, + border.BorderThickness.Right > 0 ? 0 : 1, + border.BorderThickness.Bottom > 0 ? 0 : 1); + } } - else - { + else { RemoveAdorner(); } - } + } + } + + bool IsAnyBorderEdgeInvisible(Border border) + { + return IsBorderBrushInvisible(border) || border.BorderThickness.Left == 0 || border.BorderThickness.Top == 0 || border.BorderThickness.Right == 0 || border.BorderThickness.Bottom == 0; + } + + bool IsBorderBrushInvisible(Border border) + { + return border.BorderBrush == null || border.BorderBrush == Brushes.Transparent; } private void CreateAdorner() { - if (adornerPanel == null) - { - adornerPanel = new AdornerPanel(); - adornerPanel.Order = AdornerOrder.Background; - var border = new Border(); - border.BorderThickness = new Thickness(1); - border.BorderBrush = new SolidColorBrush(Color.FromRgb(0xCC, 0xCC, 0xCC)); - border.IsHitTestVisible = false; - AdornerPanel.SetPlacement(border, AdornerPlacement.FillContent); - adornerPanel.Children.Add(border); + if (adornerPanel == null) { + + if (cachedAdornerPanel == null) { + cachedAdornerPanel = new AdornerPanel(); + cachedAdornerPanel.Order = AdornerOrder.Background; + var border = new Border(); + border.BorderThickness = new Thickness(1); + border.BorderBrush = new SolidColorBrush(Color.FromRgb(0xCC, 0xCC, 0xCC)); + border.IsHitTestVisible = false; + AdornerPanel.SetPlacement(border, AdornerPlacement.FillContent); + cachedAdornerPanel.Children.Add(border); + } + + adornerPanel = cachedAdornerPanel; Adorners.Add(adornerPanel); } } private void RemoveAdorner() { - if (adornerPanel != null) - { + if (adornerPanel != null) { Adorners.Remove(adornerPanel); adornerPanel = null; } diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Extensions/DefaultPlacementBehavior.cs b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Extensions/DefaultPlacementBehavior.cs index 1eaa1533f3..f7a1c0b352 100644 --- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Extensions/DefaultPlacementBehavior.cs +++ b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Extensions/DefaultPlacementBehavior.cs @@ -18,10 +18,9 @@ using System.Windows.Controls.Primitives; namespace ICSharpCode.WpfDesign.Designer.Extensions { [ExtensionFor(typeof(Panel))] - [ExtensionFor(typeof(ContentControl))] + [ExtensionFor(typeof(Control))] [ExtensionFor(typeof(Border))] [ExtensionFor(typeof(Viewbox))] - [ExtensionFor(typeof(ItemsControl))] public class DefaultPlacementBehavior : BehaviorExtension, IPlacementBehavior { static List _contentControlsNotAllowedToAdd; diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Extensions/ResizeThumbExtension.cs b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Extensions/ResizeThumbExtension.cs index d0e4adc1c1..8229a351b6 100644 --- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Extensions/ResizeThumbExtension.cs +++ b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Extensions/ResizeThumbExtension.cs @@ -147,6 +147,15 @@ namespace ICSharpCode.WpfDesign.Designer.Extensions if (alignment.Vertical == VerticalAlignment.Bottom) dy = drag.Delta.Y; var designPanel = ExtendedItem.Services.DesignPanel as DesignPanel; + + if ((Keyboard.IsKeyDown(Key.LeftCtrl) || Keyboard.IsKeyDown(Key.RightCtrl)) && alignment.Horizontal != HorizontalAlignment.Center && alignment.Vertical != VerticalAlignment.Center) + { + if (dx > dy) + dx = dy; + else + dy = dx; + } + if (zoom != null) { dx = dx * (1 / zoom.CurrentZoom); diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Images/license.txt b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Images/license.txt index 5b3df7ad65..194fd7f1e1 100644 --- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Images/license.txt +++ b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Images/license.txt @@ -14,6 +14,7 @@ Copied from the Fugue Icon Library and left unmodified: - Icons.16x16.WpfOutline.EyeClosed.png - Icons.16x16.GuideSnap.png - Icons.16x16.GridSnap.png + - lock.png Copied from the Fugue Icon Library and modified or mashed up with other Fugue Icons or parts taken from them: diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Images/lock.png b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Images/lock.png new file mode 100644 index 0000000000..571c16d386 Binary files /dev/null and b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Images/lock.png differ diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/OutlineView/DragTreeView.cs b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/OutlineView/DragTreeView.cs index 1ee8f58adf..ac121b1bbd 100644 --- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/OutlineView/DragTreeView.cs +++ b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/OutlineView/DragTreeView.cs @@ -53,12 +53,34 @@ namespace ICSharpCode.WpfDesign.Designer.OutlineView get { return (object)GetValue(RootProperty); } set { SetValue(RootProperty, value); } } + + #region Filtering + + public static readonly DependencyProperty FilterProperty = + DependencyProperty.Register("Filter", typeof(string), typeof(DragTreeView), new PropertyMetadata(OnFilterPropertyChanged)); + + public string Filter { + get { return (string)GetValue(FilterProperty); } + set { SetValue(FilterProperty, value); } + } + + private static void OnFilterPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) + { + var ctl = d as DragTreeView; + var ev = ctl.FilterChanged; + if (ev != null) + ev(ctl.Filter); + } + + public event Action FilterChanged; + + public virtual bool ShouldItemBeVisible(DragTreeViewItem dragTreeViewitem) + { + return true; + } - //public object[] SelectedItems - //{ - // get { return Selection.Select(item => item.DataContext).ToArray(); } - //} - + #endregion + protected override void OnPropertyChanged(DependencyPropertyChangedEventArgs e) { base.OnPropertyChanged(e); @@ -261,7 +283,7 @@ namespace ICSharpCode.WpfDesign.Designer.OutlineView OnSelectionChanged(); } - void SelectOnly(DragTreeViewItem item) + protected virtual void SelectOnly(DragTreeViewItem item) { ClearSelection(); Select(item); diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/OutlineView/DragTreeViewItem.cs b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/OutlineView/DragTreeViewItem.cs index 8eb6ac705f..f510988d2b 100644 --- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/OutlineView/DragTreeViewItem.cs +++ b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/OutlineView/DragTreeViewItem.cs @@ -20,10 +20,12 @@ namespace ICSharpCode.WpfDesign.Designer.OutlineView { public class DragTreeViewItem : TreeViewItem { + ContentPresenter part_header; + static DragTreeViewItem() { DefaultStyleKeyProperty.OverrideMetadata(typeof(DragTreeViewItem), - new FrameworkPropertyMetadata(typeof(DragTreeViewItem))); + new FrameworkPropertyMetadata(typeof(DragTreeViewItem))); } public DragTreeViewItem() @@ -37,24 +39,50 @@ namespace ICSharpCode.WpfDesign.Designer.OutlineView ParentTree = this.GetVisualAncestors().OfType().FirstOrDefault(); if (ParentTree != null) { ParentTree.ItemAttached(this); + ParentTree.FilterChanged += ParentTree_FilterChanged; } } + void ParentTree_FilterChanged(string obj) + { + var v = ParentTree.ShouldItemBeVisible(this); + if (v) + part_header.Visibility = Visibility.Visible; + else + part_header.Visibility = Visibility.Collapsed; + } + void DragTreeViewItem_Unloaded(object sender, RoutedEventArgs e) { if (ParentTree != null) { ParentTree.ItemDetached(this); + ParentTree.FilterChanged -= ParentTree_FilterChanged; } ParentTree = null; } + + + public override void OnApplyTemplate() + { + base.OnApplyTemplate(); + + part_header = GetTemplateChild("PART_Header") as ContentPresenter; + } public new static readonly DependencyProperty IsSelectedProperty = - Selector.IsSelectedProperty.AddOwner(typeof(DragTreeViewItem)); + Selector.IsSelectedProperty.AddOwner(typeof(DragTreeViewItem), new FrameworkPropertyMetadata(OnIsSelectedChanged)); public new bool IsSelected { get { return (bool)GetValue(IsSelectedProperty); } set { SetValue(IsSelectedProperty, value); } } + + public static void OnIsSelectedChanged(DependencyObject s, DependencyPropertyChangedEventArgs e) + { + var el = s as FrameworkElement; + if (el != null) + el.BringIntoView(); + } public static readonly DependencyProperty IsDragHoverProperty = DependencyProperty.Register("IsDragHover", typeof(bool), typeof(DragTreeViewItem)); diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/OutlineView/Outline.xaml b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/OutlineView/Outline.xaml index 9fccd006d4..0132bebd87 100644 --- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/OutlineView/Outline.xaml +++ b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/OutlineView/Outline.xaml @@ -2,7 +2,8 @@ x:Name="root" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" - xmlns:Default="clr-namespace:ICSharpCode.WpfDesign.Designer.OutlineView"> + xmlns:Default="clr-namespace:ICSharpCode.WpfDesign.Designer.OutlineView" + xmlns:Controls="clr-namespace:ICSharpCode.WpfDesign.Designer.Controls"> @@ -34,9 +35,38 @@ + + + ItemsSource="{Binding Children}"> + @@ -44,15 +74,20 @@ - - - - - + + + + + + + + + + diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/OutlineView/OutlineNode.cs b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/OutlineView/OutlineNode.cs index ca01d3d1fb..f3e03c08ba 100644 --- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/OutlineView/OutlineNode.cs +++ b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/OutlineView/OutlineNode.cs @@ -2,19 +2,21 @@ // This code is distributed under the GNU LGPL (for details please see \doc\license.txt) using System; +using System.Collections; using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.ComponentModel; using System.Linq; using System.Text; -using System.ComponentModel; -using ICSharpCode.WpfDesign; -using System.Collections.ObjectModel; -using System.Collections; -using ICSharpCode.WpfDesign.Designer; -using ICSharpCode.WpfDesign.XamlDom; using System.Windows; using System.Windows.Controls; using System.Windows.Input; +using ICSharpCode.WpfDesign; +using ICSharpCode.WpfDesign.Designer; +using ICSharpCode.WpfDesign.Designer.Xaml; +using ICSharpCode.WpfDesign.XamlDom; + namespace ICSharpCode.WpfDesign.Designer.OutlineView { public class OutlineNode : INotifyPropertyChanged @@ -50,6 +52,11 @@ namespace ICSharpCode.WpfDesign.Designer.OutlineView ((FrameworkElement) this.DesignItem.Component).Visibility = Visibility.Hidden; } + var locked = designItem.Properties.GetAttachedProperty(DesignTimeProperties.IsLockedProperty).ValueOnInstance; + if (locked != null && (bool) locked == true) { + this._isDesignTimeLocked = true; + } + //TODO DesignItem.NameChanged += new EventHandler(DesignItem_NameChanged); DesignItem.PropertyChanged += new PropertyChangedEventHandler(DesignItem_PropertyChanged); @@ -90,13 +97,12 @@ namespace ICSharpCode.WpfDesign.Designer.OutlineView } } - bool _isDesignTimeVisible = true; public bool IsDesignTimeVisible { - get { - return _isDesignTimeVisible; + get { + return _isDesignTimeVisible; } set { _isDesignTimeVisible = value; @@ -112,6 +118,26 @@ namespace ICSharpCode.WpfDesign.Designer.OutlineView } } + bool _isDesignTimeLocked = false; + + public bool IsDesignTimeLocked + { + get { + return _isDesignTimeLocked; + } + set { + _isDesignTimeLocked = value; + ((XamlDesignItem)DesignItem).IsDesignTimeLocked = _isDesignTimeLocked; + + RaisePropertyChanged("IsDesignTimeLocked"); + +// if (value) +// DesignItem.Properties.GetAttachedProperty(DesignTimeProperties.IsLockedProperty).SetValue(true); +// else +// DesignItem.Properties.GetAttachedProperty(DesignTimeProperties.IsLockedProperty).Reset(); + } + } + ObservableCollection children = new ObservableCollection(); public ObservableCollection Children { @@ -168,6 +194,21 @@ namespace ICSharpCode.WpfDesign.Designer.OutlineView var node = OutlineNode.Create(item); Children.Add(node); } + else + { + var content = item.ContentProperty; + if (content != null) + { + if (content.IsCollection) { + UpdateChildrenCore(content.CollectionElements); + } + else { + if (content.Value != null) { + UpdateChildrenCore(new[] { content.Value }); + } + } + } + } } } diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/OutlineView/OutlineTreeView.cs b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/OutlineView/OutlineTreeView.cs index e5d4a3674c..f739db7366 100644 --- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/OutlineView/OutlineTreeView.cs +++ b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/OutlineView/OutlineTreeView.cs @@ -33,5 +33,23 @@ namespace ICSharpCode.WpfDesign.Designer.OutlineView foreach (var item in items) _customOutlineNodes.Add(item.DataContext as OutlineNode); } + + public override bool ShouldItemBeVisible(DragTreeViewItem dragTreeViewitem) + { + var node = dragTreeViewitem.DataContext as OutlineNode; + + return string.IsNullOrEmpty(Filter) || node.Name.ToLower().Contains(Filter.ToLower()); + } + + protected override void SelectOnly(DragTreeViewItem item) + { + base.SelectOnly(item); + + var node = item.DataContext as OutlineNode; + + var surface = node.DesignItem.View.TryFindParent(); + if (surface != null) + surface.ScrollIntoView(node.DesignItem); + } } } diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/OutlineView/OutlineView.xaml b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/OutlineView/OutlineView.xaml index 9e1cb270b6..6076383cd0 100644 --- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/OutlineView/OutlineView.xaml +++ b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/OutlineView/OutlineView.xaml @@ -98,20 +98,20 @@ - - - + @@ -144,7 +144,7 @@ Value="False"> + Value="Collapsed" /> diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/WpfDesign.Designer.csproj b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/WpfDesign.Designer.csproj index a3a415e657..35a81fdab4 100644 --- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/WpfDesign.Designer.csproj +++ b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/WpfDesign.Designer.csproj @@ -361,4 +361,7 @@ + + + \ No newline at end of file diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Xaml/XamlComponentService.cs b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Xaml/XamlComponentService.cs index edbb41d40d..36ca45e8c2 100644 --- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Xaml/XamlComponentService.cs +++ b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Xaml/XamlComponentService.cs @@ -90,24 +90,37 @@ namespace ICSharpCode.WpfDesign.Designer.Xaml } if (_context.RootItem != null && !string.IsNullOrEmpty(site.Name)) { - var nameScope = _context.RootItem.Component as INameScope; - nameScope = NameScope.GetNameScope((DependencyObject) _context.RootItem.Component); - var fnd = nameScope.FindName(site.Name); - - if (fnd != null) { - string newNm = site.Name + "_Copy"; - fnd = nameScope.FindName(newNm); - if (fnd == null) - site.Name = newNm; - else { + var nameScope = NameScopeHelper.GetNameScopeFromObject(_context.RootItem.Component); + + if (nameScope != null) { + // The object will be a part of the RootItem namescope, remove local namescope if set + NameScopeHelper.ClearNameScopeProperty(obj.Instance); + + string newName = site.Name; + if (nameScope.FindName(newName) != null) { + int copyIndex = newName.LastIndexOf("_Copy", StringComparison.Ordinal); + if (copyIndex < 0) { + newName += "_Copy"; + } + else if (!newName.EndsWith("_Copy", StringComparison.Ordinal)) { + string copyEnd = newName.Substring(copyIndex + "_Copy".Length); + int copyEndValue; + if (Int32.TryParse(copyEnd, out copyEndValue)) + newName = newName.Remove(copyIndex + "_Copy".Length); + else + newName += "_Copy"; + } + int i = 1; - while (fnd != null) { - newNm = site.Name + "_Copy" + i; - fnd = nameScope.FindName(newNm); - i++; + string newNameTemplate = newName; + while (nameScope.FindName(newName) != null) { + newName = newNameTemplate + i++; } - site.Name = newNm; + + site.Name = newName; } + + nameScope.RegisterName(newName, obj.Instance); } } return site; diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Xaml/XamlDesignItem.cs b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Xaml/XamlDesignItem.cs index abac9ec74c..1329a5c6bb 100644 --- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Xaml/XamlDesignItem.cs +++ b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Xaml/XamlDesignItem.cs @@ -145,6 +145,23 @@ namespace ICSharpCode.WpfDesign.Designer.Xaml } } + /// + /// Item is Locked at Design Time + /// + public bool IsDesignTimeLocked { + get { + var locked = Properties.GetAttachedProperty(DesignTimeProperties.IsLockedProperty).ValueOnInstance; + return (locked != null && (bool) locked == true); + } + set { + if (value) + Properties.GetAttachedProperty(DesignTimeProperties.IsLockedProperty).SetValue(true); + else + Properties.GetAttachedProperty(DesignTimeProperties.IsLockedProperty).Reset(); + } + + } + public override DesignItem Clone() { DesignItem item = null; diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Tests/AssemblyInfo.cs b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Tests/AssemblyInfo.cs index 80a76efffd..8942f2f568 100644 --- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Tests/AssemblyInfo.cs +++ b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Tests/AssemblyInfo.cs @@ -4,6 +4,7 @@ using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; +using System.Windows.Markup; using NUnit.Framework; @@ -20,4 +21,8 @@ using NUnit.Framework; [assembly: AssemblyCulture("")] // Run unit tests on STA thread. -[assembly: RequiresSTA] \ No newline at end of file +[assembly: RequiresSTA] + +[assembly: XmlnsPrefix("http://sharpdevelop.net/WpfDesign/Tests/Controls", "sdtcontrols")] + +[assembly: XmlnsDefinition("http://sharpdevelop.net/WpfDesign/Tests/Controls", "ICSharpCode.WpfDesign.Tests.Controls")] \ No newline at end of file diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Tests/Designer/EditOperationTests.cs b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Tests/Designer/EditOperationTests.cs index f36c1744e7..9df9884dcf 100644 --- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Tests/Designer/EditOperationTests.cs +++ b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Tests/Designer/EditOperationTests.cs @@ -151,5 +151,58 @@ namespace ICSharpCode.WpfDesign.Tests.Designer Assert.AreEqual(_name, grid.ContentProperty.CollectionElements[3].Name); Assert.AreEqual(grid.ContentProperty.CollectionElements[3], selection.PrimarySelection); } + + [Test] + public void PasteSameElementMultipleTimesCheckCopiesNames() + { + var grid = IntializePasteOperationsTest(); + var xamlContext = grid.Context as XamlDesignContext; + Assert.IsNotNull(xamlContext); + + var selection = grid.Services.Selection; + var innerGrid = grid.ContentProperty.CollectionElements[0]; + + selection.SetSelectedComponents(new[] {innerGrid}); + xamlContext.XamlEditAction.Paste(); + Assert.AreEqual(innerGrid.ContentProperty.CollectionElements[1], selection.PrimarySelection); + + selection.SetSelectedComponents(new[] {innerGrid}); + xamlContext.XamlEditAction.Paste(); + Assert.AreEqual(innerGrid.ContentProperty.CollectionElements[2], selection.PrimarySelection); + + selection.SetSelectedComponents(new[] {innerGrid}); + xamlContext.XamlEditAction.Paste(); + Assert.AreEqual(innerGrid.ContentProperty.CollectionElements[3], selection.PrimarySelection); + + selection.SetSelectedComponents(new[] {innerGrid}); + xamlContext.XamlEditAction.Paste(); + Assert.AreEqual(innerGrid.ContentProperty.CollectionElements[4], selection.PrimarySelection); + + Assert.IsNullOrEmpty(innerGrid.ContentProperty.CollectionElements[0].Name); + Assert.AreEqual(_name, innerGrid.ContentProperty.CollectionElements[1].Name); + Assert.AreEqual(_name + "_Copy", innerGrid.ContentProperty.CollectionElements[2].Name); + Assert.AreEqual(_name + "_Copy1", innerGrid.ContentProperty.CollectionElements[3].Name); + Assert.AreEqual(_name + "_Copy2", innerGrid.ContentProperty.CollectionElements[4].Name); + + xamlContext.XamlEditAction.Copy(new[] {innerGrid.ContentProperty.CollectionElements[3]}); + var cutXaml = Clipboard.GetText(TextDataFormat.Xaml); + Assert.That(cutXaml, Is.StringContaining(":Name=\"" + _name + "_Copy1\"")); + + selection.SetSelectedComponents(new[] {innerGrid}); + xamlContext.XamlEditAction.Paste(); + Assert.AreEqual(innerGrid.ContentProperty.CollectionElements[5], selection.PrimarySelection); + Assert.AreEqual(_name + "_Copy3", innerGrid.ContentProperty.CollectionElements[5].Name); + + var gridDepObj = grid.Component as DependencyObject; + Assert.IsNotNull(gridDepObj); + var nameScope = NameScope.GetNameScope(gridDepObj); + Assert.IsNotNull(nameScope); + Assert.IsNotNull(nameScope.FindName(_name)); + Assert.IsNotNull(nameScope.FindName(_name + "_Copy")); + Assert.IsNotNull(nameScope.FindName(_name + "_Copy1")); + Assert.IsNotNull(nameScope.FindName(_name + "_Copy2")); + Assert.IsNotNull(nameScope.FindName(_name + "_Copy3")); + Assert.IsNull(nameScope.FindName(_name + "_Copy4")); + } } } diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Tests/Designer/ModelTestHelper.cs b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Tests/Designer/ModelTestHelper.cs index 5a7e81211b..90cef16ea0 100644 --- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Tests/Designer/ModelTestHelper.cs +++ b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Tests/Designer/ModelTestHelper.cs @@ -59,14 +59,23 @@ namespace ICSharpCode.WpfDesign.Tests.Designer return canvasChild; } - protected void AssertCanvasDesignerOutput(string expectedXaml, DesignContext context) + protected void AssertCanvasDesignerOutput(string expectedXaml, DesignContext context, params String[] additionalXmlns) { + string canvasStartTag = + "\n" + expectedXaml.Trim(); + expectedXaml = "\n" + - ("\n" + expectedXaml.Trim()) - .Replace("\r", "").Replace("\n", "\n ") + expectedXaml.Replace("\r", "").Replace("\n", "\n ") + "\n"; StringWriter stringWriter = new StringWriter(); diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Tests/Designer/ModelTests.cs b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Tests/Designer/ModelTests.cs index 1b0c322563..d96af12a6d 100644 --- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Tests/Designer/ModelTests.cs +++ b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Tests/Designer/ModelTests.cs @@ -2,17 +2,19 @@ // This code is distributed under the GNU LGPL (for details please see \doc\license.txt) using System; -using System.Text; -using System.IO; -using System.Xml; using System.Diagnostics; +using System.IO; +using System.Text; using System.Windows; using System.Windows.Controls; using System.Windows.Data; -using NUnit.Framework; +using System.Windows.Media; +using System.Xml; + using ICSharpCode.WpfDesign.Designer; -using ICSharpCode.WpfDesign.Designer.Xaml; using ICSharpCode.WpfDesign.Designer.Services; +using ICSharpCode.WpfDesign.Designer.Xaml; +using NUnit.Framework; namespace ICSharpCode.WpfDesign.Tests.Designer { @@ -368,6 +370,34 @@ namespace ICSharpCode.WpfDesign.Tests.Designer { AddBindingWithStaticResourceWhereResourceOnSameElement(true); } + + [Test] + public void AddBrushAsResource() + { + DesignItem checkBox = CreateCanvasContext(""); + DesignItem canvas = checkBox.Parent; + + DesignItemProperty canvasResources = canvas.Properties.GetProperty("Resources"); + + DesignItem brush = canvas.Services.Component.RegisterComponentForDesigner(new SolidColorBrush()); + brush.Key = "testBrush"; + brush.Properties[SolidColorBrush.ColorProperty].SetValue(Colors.Fuchsia); + + Assert.IsTrue(canvasResources.IsCollection); + canvasResources.CollectionElements.Add(brush); + + checkBox.Properties[CheckBox.ForegroundProperty].SetValue(new StaticResourceExtension()); + DesignItemProperty prop = checkBox.Properties[CheckBox.ForegroundProperty]; + prop.Value.Properties["ResourceKey"].SetValue("testBrush"); + + string expectedXaml = "\n" + + " \n" + + "\n" + + ""; + + AssertCanvasDesignerOutput(expectedXaml, checkBox.Context); + AssertLog(""); + } } public class MyMultiConverter : IMultiValueConverter diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Tests/Designer/NamespaceTests.cs b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Tests/Designer/NamespaceTests.cs new file mode 100644 index 0000000000..42d41eca2f --- /dev/null +++ b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Tests/Designer/NamespaceTests.cs @@ -0,0 +1,184 @@ +// 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.Windows; +using System.Windows.Controls; + +using NUnit.Framework; + +namespace ICSharpCode.WpfDesign.Tests.Designer +{ + [TestFixture] + public class NamespaceTests : ModelTestHelper + { + + [Test] + public void AddControlFromTestNamespace() + { + DesignItem button = CreateCanvasContext("