diff --git a/data/resources/StringResources.resx b/data/resources/StringResources.resx index 9c4b48eb3a..49d65c8075 100644 --- a/data/resources/StringResources.resx +++ b/data/resources/StringResources.resx @@ -8377,67 +8377,4 @@ Press Esc to cancel this operation. Press "Alt" to enter Container - - Assembly Info - - - Assembly version: - - - Company: - - - Copyright: - - - Description: - - - File version: - - - GUID: - - - Make assembly COM-visible - - - Neutral language: - - - Product: - - - Title: - - - Trademark: - - - Assembly info file was not found. Please ensure that the project contains assembly info file. - - - CLS compliant - - - Default alias: - - - Informational version: - - - JIT optimization - - - JIT tracking - - - New GUID - - - One of the assembly info values is incorrect. - - - None - \ No newline at end of file diff --git a/data/templates/file/CSharp/CSharp.Exception.xft b/data/templates/file/CSharp/CSharp.Exception.xft index ac825703d8..fdaa09aed9 100644 --- a/data/templates/file/CSharp/CSharp.Exception.xft +++ b/data/templates/file/CSharp/CSharp.Exception.xft @@ -28,7 +28,7 @@ using System.Runtime.Serialization; namespace ${StandardNamespace} { /// - /// Desctiption of ${ClassName}. + /// Description of ${ClassName}. /// public class ${ClassName} : Exception, ISerializable { diff --git a/data/templates/file/VB/VB.Exception.xft b/data/templates/file/VB/VB.Exception.xft index 77c92f1eca..8bced5fe62 100644 --- a/data/templates/file/VB/VB.Exception.xft +++ b/data/templates/file/VB/VB.Exception.xft @@ -27,7 +27,7 @@ Imports System.Runtime.Serialization Namespace ${StandardNamespace} ''' - ''' Desctiption of ${ClassName}. + ''' Description of ${ClassName}. ''' Public Class ${ClassName} Inherits Exception diff --git a/src/AddIns/Analysis/CodeCoverage/Project/Src/CodeCoverageResultsReader.cs b/src/AddIns/Analysis/CodeCoverage/Project/Src/CodeCoverageResultsReader.cs index b53be5572f..9f5bdde79b 100644 --- a/src/AddIns/Analysis/CodeCoverage/Project/Src/CodeCoverageResultsReader.cs +++ b/src/AddIns/Analysis/CodeCoverage/Project/Src/CodeCoverageResultsReader.cs @@ -52,8 +52,9 @@ namespace ICSharpCode.CodeCoverage CodeCoverageResults ReadCodeCoverageResults(string fileName) { - TextReader reader = fileSystem.OpenText(FileName.Create(fileName)); - return new CodeCoverageResults(reader); + using (TextReader reader = fileSystem.OpenText(FileName.Create(fileName))) { + return new CodeCoverageResults(reader); + } } public IEnumerable GetMissingResultsFiles() diff --git a/src/AddIns/Analysis/CodeCoverage/Project/Src/RunTestWithCodeCoverageCommand.cs b/src/AddIns/Analysis/CodeCoverage/Project/Src/RunTestWithCodeCoverageCommand.cs index b60ff8f777..aafd3f7464 100644 --- a/src/AddIns/Analysis/CodeCoverage/Project/Src/RunTestWithCodeCoverageCommand.cs +++ b/src/AddIns/Analysis/CodeCoverage/Project/Src/RunTestWithCodeCoverageCommand.cs @@ -119,13 +119,18 @@ namespace ICSharpCode.CodeCoverage void DisplayCodeCoverageResults(CodeCoverageResultsReader coverageResultsReader) { - foreach (CodeCoverageResults result in coverageResultsReader.GetResults()) { + foreach (CodeCoverageResults result in GetResults(coverageResultsReader)) { DisplayCodeCoverageResults(result); } foreach (string missingFile in coverageResultsReader.GetMissingResultsFiles()) { DisplayNoCodeCoverageResultsGeneratedMessage(missingFile); } } + + IEnumerable GetResults(CodeCoverageResultsReader coverageResultsReader) + { + return SD.MainThread.InvokeIfRequired(() => coverageResultsReader.GetResults().ToList()); + } void DisplayCodeCoverageResults(CodeCoverageResults results) { diff --git a/src/AddIns/Analysis/Profiler/Frontend/AddIn/Properties/AssemblyInfo.cs b/src/AddIns/Analysis/Profiler/Frontend/AddIn/Properties/AssemblyInfo.cs index 19351e6298..2a20a546a7 100644 --- a/src/AddIns/Analysis/Profiler/Frontend/AddIn/Properties/AssemblyInfo.cs +++ b/src/AddIns/Analysis/Profiler/Frontend/AddIn/Properties/AssemblyInfo.cs @@ -50,4 +50,4 @@ using System.Windows; // // You can specify all the values or you can use the default the Revision and // Build Numbers by using the '*' as shown below: -[assembly: AssemblyVersion("1.0.*")] \ No newline at end of file +[assembly: AssemblyVersion("1.0.*")] diff --git a/src/AddIns/BackendBindings/CSharpBinding/Project/CSharpBinding.addin b/src/AddIns/BackendBindings/CSharpBinding/Project/CSharpBinding.addin index 11db4687c6..785b7fcd74 100644 --- a/src/AddIns/BackendBindings/CSharpBinding/Project/CSharpBinding.addin +++ b/src/AddIns/BackendBindings/CSharpBinding/Project/CSharpBinding.addin @@ -115,9 +115,6 @@ - diff --git a/src/AddIns/Debugger/Debugger.AddIn/NRefactory/ExpressionEvaluationVisitor.cs b/src/AddIns/Debugger/Debugger.AddIn/NRefactory/ExpressionEvaluationVisitor.cs index 7f39644774..1e534faede 100644 --- a/src/AddIns/Debugger/Debugger.AddIn/NRefactory/ExpressionEvaluationVisitor.cs +++ b/src/AddIns/Debugger/Debugger.AddIn/NRefactory/ExpressionEvaluationVisitor.cs @@ -444,7 +444,7 @@ namespace Debugger.AddIn } else throw new GetValueException("Invoked member must be a method or property"); Value target = null; - if (!usedMethod.IsStatic) + if (!usedMethod.IsStatic && !usedMethod.IsConstructor) target = Convert(result.TargetResult).GetPermanentReference(evalThread); return InvokeMethod(target, usedMethod, result.Arguments.Select(rr => Convert(rr).GetPermanentReference(evalThread)).ToArray()); } @@ -479,26 +479,33 @@ namespace Debugger.AddIn } sb.Append("}"); return sb.ToString(); - } else if (val.Type.GetAllBaseTypeDefinitions().Any(def => def.IsKnownType(KnownTypeCode.ICollection))) { - StringBuilder sb = new StringBuilder(); - sb.Append(new CSharpAmbience().ConvertType(val.Type)); - sb.Append(" {"); - val = val.GetPermanentReference(evalThread); - var countProp = val.Type.GetProperties(p => p.Name == "Count" && !p.IsExplicitInterfaceImplementation).Single(); - int count = (int)val.GetMemberValue(evalThread, countProp).PrimitiveValue; - for(int i = 0; i < count; i++) { - if (i > 0) sb.Append(", "); - var itemProperty = val.Type.GetProperties(p => p.IsIndexer && p.Name == "Item" && !p.IsExplicitInterfaceImplementation).Single(); - Value item = val.GetPropertyValue(evalThread, itemProperty, Eval.CreateValue(evalThread, i)); - sb.Append(FormatValue(evalThread, item)); + } else if (val.Type.GetAllBaseTypeDefinitions().Any(def => def.IsKnownType(KnownTypeCode.ICollection) || def.IsKnownType(KnownTypeCode.ICollectionOfT))) { + var countProp = val.Type.GetProperties(p => p.Name == "Count" && !p.IsExplicitInterfaceImplementation).SingleOrDefault(); + if (countProp != null) { + StringBuilder sb = new StringBuilder(); + sb.Append(new CSharpAmbience().ConvertType(val.Type)); + val = val.GetPermanentReference(evalThread); + int count = (int)val.GetMemberValue(evalThread, countProp).PrimitiveValue; + var itemProperty = val.Type.GetProperties(p => p.IsIndexer && p.Name == "Item" && !p.IsExplicitInterfaceImplementation).SingleOrDefault(); + if (itemProperty != null) { + sb.Append(" {"); + for (int i = 0; i < count; i++) { + if (i > 0) + sb.Append(", "); + Value item = val.GetPropertyValue(evalThread, itemProperty, Eval.CreateValue(evalThread, i)); + sb.Append(FormatValue(evalThread, item)); + } + sb.Append("}"); + } else { + sb.AppendFormat(" ({0} elements)", count); + } + return sb.ToString(); } - sb.Append("}"); - return sb.ToString(); } else if (val.Type.IsKnownType(KnownTypeCode.String) || val.Type.IsPrimitiveType()) { return TextWriterTokenWriter.PrintPrimitiveValue(val.PrimitiveValue); - } else { - return val.InvokeToString(evalThread); } + + return val.InvokeToString(evalThread); } } diff --git a/src/AddIns/Debugger/Debugger.Core/Value.cs b/src/AddIns/Debugger/Debugger.Core/Value.cs index 8b7ba28b67..c18a5560ef 100644 --- a/src/AddIns/Debugger/Debugger.Core/Value.cs +++ b/src/AddIns/Debugger/Debugger.Core/Value.cs @@ -416,6 +416,8 @@ namespace Debugger if (memberInfo == null) throw new DebuggerException("memberInfo is null"); if (!memberInfo.IsStatic) { + if (memberInfo.SymbolKind == SymbolKind.Constructor) + throw new GetValueException("Constructor expression"); if (objectInstance == null) throw new DebuggerException("No target object specified"); if (objectInstance.IsNull) diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.AddIn/Src/MyTypeFinder.cs b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.AddIn/Src/MyTypeFinder.cs index cb867140e6..ecd03af1c2 100644 --- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.AddIn/Src/MyTypeFinder.cs +++ b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.AddIn/Src/MyTypeFinder.cs @@ -17,6 +17,7 @@ // DEALINGS IN THE SOFTWARE. using System; +using System.IO; using System.Linq; using System.Reflection; using System.Runtime.ExceptionServices; @@ -73,6 +74,36 @@ namespace ICSharpCode.WpfDesign.AddIn } } + public override Uri ConvertUriToLocalUri(Uri uri) + { + if (!uri.IsAbsoluteUri) + { + var compilation = SD.ParserService.GetCompilationForFile(file.FileName); + var assembly = this.typeResolutionService.LoadAssembly(compilation.MainAssembly); + var prj = SD.ProjectService.CurrentProject; + + if (uri.OriginalString.Contains(";")) + { + var parts = uri.OriginalString.Split(';'); + if (prj.Name == parts[0].Substring(1)) + { + var newUri = new Uri(("file://" + Path.Combine(prj.Directory, parts[1].Substring("component".Length + 1))).Replace("\\", "/"), UriKind.RelativeOrAbsolute); + return newUri; + } + } + else + { + var strg = uri.OriginalString; + if (strg.StartsWith("/")) + strg = strg.Substring(1); + var newUri = new Uri(("file://" + Path.Combine(prj.Directory, strg)).Replace("\\", "/"), UriKind.RelativeOrAbsolute); + return newUri; + } + } + + return uri; + } + Assembly FindAssemblyInProjectReferences(string name) { IProject pc = GetProject(file); diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.AddIn/Src/WpfViewContent.cs b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.AddIn/Src/WpfViewContent.cs index fdca8ae69b..7a9765cf85 100644 --- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.AddIn/Src/WpfViewContent.cs +++ b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.AddIn/Src/WpfViewContent.cs @@ -22,16 +22,20 @@ using System.ComponentModel; using System.Diagnostics; using System.IO; using System.Linq; +using System.Reflection; using System.Threading; using System.Threading.Tasks; using System.Windows; +using System.Windows.Controls; using System.Windows.Input; using System.Windows.Markup; using System.Xml; +using ICSharpCode.Core; using ICSharpCode.Core.Presentation; using ICSharpCode.NRefactory.TypeSystem; using ICSharpCode.SharpDevelop; +using ICSharpCode.SharpDevelop.Designer; using ICSharpCode.SharpDevelop.Dom; using ICSharpCode.SharpDevelop.Editor; using ICSharpCode.SharpDevelop.Gui; @@ -44,6 +48,7 @@ using ICSharpCode.WpfDesign.Designer.OutlineView; using ICSharpCode.WpfDesign.Designer.PropertyGrid; using ICSharpCode.WpfDesign.Designer.Services; using ICSharpCode.WpfDesign.Designer.Xaml; +using ICSharpCode.WpfDesign.XamlDom; namespace ICSharpCode.WpfDesign.AddIn { @@ -60,6 +65,10 @@ namespace ICSharpCode.WpfDesign.AddIn this.TabPageText = "${res:FormsDesigner.DesignTabPages.DesignTabPage}"; this.IsActiveViewContentChanged += OnIsActiveViewContentChanged; + + var compilation = SD.ParserService.GetCompilationForFile(file.FileName); + _path = Path.GetDirectoryName(compilation.MainAssembly.UnresolvedAssembly.Location); + AppDomain.CurrentDomain.AssemblyResolve += CurrentDomain_AssemblyResolve; } static WpfViewContent() @@ -101,6 +110,8 @@ namespace ICSharpCode.WpfDesign.AddIn if (outline != null) { outline.Root = null; } + + using (XmlTextReader r = new XmlTextReader(stream)) { XamlLoadSettings settings = new XamlLoadSettings(); settings.DesignerAssemblies.Add(typeof(WpfViewContent).Assembly); @@ -117,7 +128,20 @@ namespace ICSharpCode.WpfDesign.AddIn settings.ReportErrors = UpdateTasks; designer.LoadDesigner(r, settings); - designer.ContextMenuOpening += (sender, e) => MenuService.ShowContextMenu(e.OriginalSource as UIElement, designer, "/AddIns/WpfDesign/Designer/ContextMenu"); + designer.DesignPanel.ContextMenuHandler = (contextMenu) => { + var newContextmenu = new ContextMenu(); + var sdContextMenuItems = MenuService.CreateMenuItems(newContextmenu, designer, "/AddIns/WpfDesign/Designer/ContextMenu", "ContextMenu"); + foreach(var entry in sdContextMenuItems) + newContextmenu.Items.Add(entry); + newContextmenu.Items.Add(new Separator()); + + var items = contextMenu.Items.Cast().ToList(); + contextMenu.Items.Clear(); + foreach(var entry in items) + newContextmenu.Items.Add(entry); + + designer.DesignPanel.ContextMenu = newContextmenu; + }; if (outline != null && designer.DesignContext != null && designer.DesignContext.RootItem != null) { outline.Root = OutlineNode.Create(designer.DesignContext.RootItem); @@ -129,9 +153,46 @@ namespace ICSharpCode.WpfDesign.AddIn } catch (Exception e) { this.UserContent = new WpfDocumentError(e); } + + try{ + var appXaml = SD.ProjectService.CurrentProject.Items.FirstOrDefault(x=>x.FileName.GetFileName().ToLower() == ("app.xaml")); + if (appXaml!=null){ + var f=appXaml as FileProjectItem; + OpenedFile a = SD.FileService.GetOrCreateOpenedFile(f.FileName); + + var xml = XmlReader.Create(a.OpenRead()); + var doc=new XmlDocument(); + doc.Load(xml); + var node = doc.FirstChild.ChildNodes.Cast().FirstOrDefault(x=>x.Name=="Application.Resources"); + + foreach (XmlAttribute att in doc.FirstChild.Attributes.Cast().ToList()) + { + if (att.Name.StartsWith("xmlns")) + node.Attributes.Append(att); + } + + var appXamlXml = XmlReader.Create(new StringReader(node.InnerXml)); + var parsed = XamlParser.Parse(appXamlXml, ((XamlDesignContext) designer.DesignContext).ParserSettings); + var dict = (ResourceDictionary)parsed.RootInstance; + designer.DesignPanel.Resources.MergedDictionaries.Add(dict); + } + } catch (Exception ex) { + LoggingService.Error("Error in loading app.xaml", ex); + } } } + System.Reflection.Assembly CurrentDomain_AssemblyResolve(object sender, ResolveEventArgs args) + { + var assemblyName = (new AssemblyName(args.Name)); + string fileName = Path.Combine(_path, assemblyName.Name) + ".dll"; + if (File.Exists(fileName)) + return typeResolutionService.LoadAssembly(fileName); + return null; + } + + private TypeResolutionService typeResolutionService = new TypeResolutionService(); + private string _path; private MemoryStream _stream; bool wasChangedInDesigner; @@ -285,6 +346,7 @@ namespace ICSharpCode.WpfDesign.AddIn public override void Dispose() { + AppDomain.CurrentDomain.AssemblyResolve -= CurrentDomain_AssemblyResolve; SD.ProjectService.ProjectItemAdded -= OnReferenceAdded; propertyContainer.Clear(); diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.AddIn/WpfDesign.addin b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.AddIn/WpfDesign.addin index dcbb41145f..90edda34b7 100644 --- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.AddIn/WpfDesign.addin +++ b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.AddIn/WpfDesign.addin @@ -49,7 +49,7 @@ --> - + diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Controls/EnumBar.xaml.cs b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Controls/EnumBar.xaml.cs index bac98b7a54..7237de2a42 100644 --- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Controls/EnumBar.xaml.cs +++ b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Controls/EnumBar.xaml.cs @@ -30,6 +30,7 @@ using System.Windows.Media.Imaging; using System.Windows.Navigation; using System.Windows.Shapes; using System.Windows.Controls.Primitives; +using ICSharpCode.WpfDesign.Designer.themes; namespace ICSharpCode.WpfDesign.Designer.Controls { @@ -37,7 +38,21 @@ namespace ICSharpCode.WpfDesign.Designer.Controls { public EnumBar() { - InitializeComponent(); + SpecialInitializeComponent(); + } + + /// + /// Fixes InitializeComponent with multiple Versions of same Assembly loaded + /// + public void SpecialInitializeComponent() + { + if (!this._contentLoaded) { + this._contentLoaded = true; + Uri resourceLocator = new Uri(VersionedAssemblyResourceDictionary.GetXamlNameForType(this.GetType()), UriKind.Relative); + Application.LoadComponent(this, resourceLocator); + } + + this.InitializeComponent(); } Type currentEnumType; diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Controls/GridUnitSelector.xaml.cs b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Controls/GridUnitSelector.xaml.cs index 3d6d9443de..b8620f489a 100644 --- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Controls/GridUnitSelector.xaml.cs +++ b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Controls/GridUnitSelector.xaml.cs @@ -25,83 +25,98 @@ using System.Windows.Data; using System.Windows.Documents; using System.Windows.Input; using System.Windows.Media; +using ICSharpCode.WpfDesign.Designer.themes; namespace ICSharpCode.WpfDesign.Designer.Controls { /// /// Interaction logic for GridUnitSelector.xaml /// - public partial class GridUnitSelector : UserControl - { - GridRailAdorner rail; + public partial class GridUnitSelector : UserControl + { + GridRailAdorner rail; - public GridUnitSelector(GridRailAdorner rail) - { - InitializeComponent(); + public GridUnitSelector(GridRailAdorner rail) + { + SpecialInitializeComponent(); - this.rail = rail; - } + this.rail = rail; + } + + /// + /// Fixes InitializeComponent with multiple Versions of same Assembly loaded + /// + public void SpecialInitializeComponent() + { + if (!this._contentLoaded) { + this._contentLoaded = true; + Uri resourceLocator = new Uri(VersionedAssemblyResourceDictionary.GetXamlNameForType(this.GetType()), UriKind.Relative); + Application.LoadComponent(this, resourceLocator); + } + + this.InitializeComponent(); + } - void FixedChecked(object sender, RoutedEventArgs e) - { - this.rail.SetGridLengthUnit(Unit); - } + void FixedChecked(object sender, RoutedEventArgs e) + { + this.rail.SetGridLengthUnit(Unit); + } - void StarChecked(object sender, RoutedEventArgs e) - { - this.rail.SetGridLengthUnit(Unit); - } + void StarChecked(object sender, RoutedEventArgs e) + { + this.rail.SetGridLengthUnit(Unit); + } - void AutoChecked(object sender, RoutedEventArgs e) - { - this.rail.SetGridLengthUnit(Unit); - } + void AutoChecked(object sender, RoutedEventArgs e) + { + this.rail.SetGridLengthUnit(Unit); + } - public static readonly DependencyProperty OrientationProperty = - DependencyProperty.Register("Orientation", typeof(Orientation), typeof(GridUnitSelector), - new FrameworkPropertyMetadata()); + public static readonly DependencyProperty OrientationProperty = + DependencyProperty.Register("Orientation", typeof(Orientation), typeof(GridUnitSelector), + new FrameworkPropertyMetadata()); - public Orientation Orientation - { - get { return (Orientation)GetValue(OrientationProperty); } - set { SetValue(OrientationProperty, value); } - } + public Orientation Orientation + { + get { return (Orientation)GetValue(OrientationProperty); } + set { SetValue(OrientationProperty, value); } + } - public DesignItem SelectedItem { get; set; } + public DesignItem SelectedItem { get; set; } - public GridUnitType Unit - { - get - { - if (auto.IsChecked == true) - return GridUnitType.Auto; - if (star.IsChecked == true) - return GridUnitType.Star; + public GridUnitType Unit + { + get + { + if (auto.IsChecked == true) + return GridUnitType.Auto; + if (star.IsChecked == true) + return GridUnitType.Star; - return GridUnitType.Pixel; - } - set - { - switch (value) - { - case GridUnitType.Auto: - auto.IsChecked = true; - break; - case GridUnitType.Star: - star.IsChecked = true; - break; - default: - @fixed.IsChecked = true; - break; - } - } + return GridUnitType.Pixel; + } + set + { + switch (value) + { + case GridUnitType.Auto: + auto.IsChecked = true; + break; + case GridUnitType.Star: + star.IsChecked = true; + break; + default: + @fixed.IsChecked = true; + break; + } + } - } - protected override void OnMouseLeave(MouseEventArgs e) - { - base.OnMouseLeave(e); - this.Visibility = Visibility.Hidden; - } - } + } + protected override void OnMouseLeave(MouseEventArgs e) + { + base.OnMouseLeave(e); + this.Visibility = Visibility.Hidden; + } + } } diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/DesignPanel.cs b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/DesignPanel.cs index d13f23dcc8..f8204dfc66 100644 --- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/DesignPanel.cs +++ b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/DesignPanel.cs @@ -32,6 +32,7 @@ using System.Windows.Threading; using ICSharpCode.WpfDesign.Adorners; using ICSharpCode.WpfDesign.Designer.Controls; +using ICSharpCode.WpfDesign.Designer.UIExtensions; using ICSharpCode.WpfDesign.Designer.Xaml; namespace ICSharpCode.WpfDesign.Designer @@ -389,10 +390,17 @@ namespace ICSharpCode.WpfDesign.Designer if (e.Key == Key.Left || e.Key == Key.Right || e.Key == Key.Up || e.Key == Key.Down) { e.Handled = true; + PlacementType placementType = Keyboard.IsKeyDown(Key.LeftCtrl) ? PlacementType.Resize : PlacementType.Move; + + if (placementOp != null && placementOp.Type != placementType) { + placementOp.Commit(); + placementOp = null; + } + if (placementOp == null) { dx = 0; dy = 0; - placementOp = PlacementOperation.Start(Context.Services.Selection.SelectedItems, PlacementType.Move); + placementOp = PlacementOperation.Start(Context.Services.Selection.SelectedItems, placementType); } switch (e.Key) { @@ -414,17 +422,17 @@ namespace ICSharpCode.WpfDesign.Designer { var bounds = info.OriginalBounds; - if (!Keyboard.IsKeyDown(Key.LeftCtrl)) { + if (placementType == PlacementType.Move) { info.Bounds = new Rect(bounds.Left + dx, 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, - info.OriginalBounds.Top, - info.OriginalBounds.Width + dx, - info.OriginalBounds.Height + dy); + } else if (placementType == PlacementType.Resize) { + if (bounds.Width + dx >= 0 && bounds.Height + dy >= 0) { + info.Bounds = new Rect(bounds.Left, + bounds.Top, + bounds.Width + dx, + bounds.Height + dy); } } @@ -461,6 +469,8 @@ namespace ICSharpCode.WpfDesign.Designer private Dictionary>> contextMenusAndEntries = new Dictionary>>(); + public Action ContextMenuHandler { get; set; } + public void AddContextMenu(ContextMenu contextMenu) { contextMenusAndEntries.Add(contextMenu, new Tuple>(contextMenusAndEntries.Count, new List(contextMenu.Items.Cast()))); @@ -484,24 +494,32 @@ namespace ICSharpCode.WpfDesign.Designer private void UpdateContextMenu() { - if (contextMenusAndEntries.Count == 0) + if (this.ContextMenu != null) + { + this.ContextMenu.Items.Clear(); this.ContextMenu = null; - - if (this.ContextMenu == null) - this.ContextMenu = new ContextMenu(); + } + + var contextMenu = new ContextMenu(); - this.ContextMenu.Items.Clear(); - foreach (var entries in contextMenusAndEntries.Values.OrderBy(x => x.Item1).Select(x => x.Item2)) { - if (this.ContextMenu.Items.Count > 0) - this.ContextMenu.Items.Add(new Separator()); + if (contextMenu.Items.Count > 0) + contextMenu.Items.Add(new Separator()); foreach (var entry in entries) { - ContextMenu.Items.Add(entry); + var ctl = ((FrameworkElement)entry).TryFindParent(); + if (ctl != null) + ctl.Items.Remove(entry); + contextMenu.Items.Add(entry); } } + + if (ContextMenuHandler != null) + ContextMenuHandler(contextMenu); + else + this.ContextMenu = contextMenu; } #endregion diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Extensions/ArrangeItemsContextMenu.xaml.cs b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Extensions/ArrangeItemsContextMenu.xaml.cs index aa54654c24..f6ce767cd1 100644 --- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Extensions/ArrangeItemsContextMenu.xaml.cs +++ b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Extensions/ArrangeItemsContextMenu.xaml.cs @@ -18,6 +18,8 @@ using System; using System.Linq; +using System.Windows; +using ICSharpCode.WpfDesign.Designer.themes; namespace ICSharpCode.WpfDesign.Designer.Extensions { @@ -29,7 +31,21 @@ namespace ICSharpCode.WpfDesign.Designer.Extensions { this.designItem = designItem; - InitializeComponent(); + SpecialInitializeComponent(); + } + + /// + /// Fixes InitializeComponent with multiple Versions of same Assembly loaded + /// + public void SpecialInitializeComponent() + { + if (!this._contentLoaded) { + this._contentLoaded = true; + Uri resourceLocator = new Uri(VersionedAssemblyResourceDictionary.GetXamlNameForType(this.GetType()), UriKind.Relative); + Application.LoadComponent(this, resourceLocator); + } + + this.InitializeComponent(); } void Click_ArrangeLeft(object sender, System.Windows.RoutedEventArgs e) diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Extensions/CanvasPlacementSupport.cs b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Extensions/CanvasPlacementSupport.cs index e1e6b469ec..0f45fd9f4c 100644 --- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Extensions/CanvasPlacementSupport.cs +++ b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Extensions/CanvasPlacementSupport.cs @@ -70,21 +70,21 @@ namespace ICSharpCode.WpfDesign.Designer.Extensions if (IsPropertySet(child, Canvas.LeftProperty) || !IsPropertySet(child, Canvas.RightProperty)) { x = GetCanvasProperty(child, Canvas.LeftProperty); } else { - x = extendedComponent.ActualWidth - GetCanvasProperty(child, Canvas.RightProperty) - PlacementOperation.GetRealElementSize(child).Width; + x = extendedComponent.ActualWidth - GetCanvasProperty(child, Canvas.RightProperty) - PlacementOperation.GetRealElementSize(child).Width; } if (IsPropertySet(child, Canvas.TopProperty) || !IsPropertySet(child, Canvas.BottomProperty)) { y = GetCanvasProperty(child, Canvas.TopProperty); } else { - y = extendedComponent.ActualHeight - GetCanvasProperty(child, Canvas.BottomProperty) - PlacementOperation.GetRealElementSize(child).Height; + y = extendedComponent.ActualHeight - GetCanvasProperty(child, Canvas.BottomProperty) - PlacementOperation.GetRealElementSize(child).Height; } var p = new Point(x, y); - //Fixes, Empty Image Resized to 0 - //return new Rect(p, child.RenderSize); - return new Rect(p, PlacementOperation.GetRealElementSize(item.View)); - } + //Fixes, Empty Image Resized to 0 + //return new Rect(p, child.RenderSize); + return new Rect(p, PlacementOperation.GetRealElementSize(item.View)); + } public override void SetPosition(PlacementInformation info) { diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Extensions/DefaultCommandsContextMenu.xaml b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Extensions/DefaultCommandsContextMenu.xaml new file mode 100644 index 0000000000..9ad1f8cd64 --- /dev/null +++ b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Extensions/DefaultCommandsContextMenu.xaml @@ -0,0 +1,38 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/Main/Base/Project/Src/Gui/Dialogs/OptionPanels/ProjectOptions/AssemblyInfo/AssemblyInfo.cs b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Extensions/DefaultCommandsContextMenu.xaml.cs similarity index 55% rename from src/Main/Base/Project/Src/Gui/Dialogs/OptionPanels/ProjectOptions/AssemblyInfo/AssemblyInfo.cs rename to src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Extensions/DefaultCommandsContextMenu.xaml.cs index a1cd915acf..613888248b 100644 --- a/src/Main/Base/Project/Src/Gui/Dialogs/OptionPanels/ProjectOptions/AssemblyInfo/AssemblyInfo.cs +++ b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Extensions/DefaultCommandsContextMenu.xaml.cs @@ -1,4 +1,4 @@ -// Copyright (c) 2014 AlphaSierraPapa for the SharpDevelop Team +// Copyright (c) 2014 AlphaSierraPapa for the SharpDevelop Team // // Permission is hereby granted, free of charge, to any person obtaining a copy of this // software and associated documentation files (the "Software"), to deal in the Software @@ -17,44 +17,35 @@ // DEALINGS IN THE SOFTWARE. using System; +using System.Linq; +using System.Windows; +using ICSharpCode.WpfDesign.Designer.themes; -namespace ICSharpCode.SharpDevelop.Gui.OptionPanels +namespace ICSharpCode.WpfDesign.Designer.Extensions { - /// - /// Assembly info parameters model - /// - public class AssemblyInfo + public partial class DefaultCommandsContextMenu { - public string Title { get; set; } - - public string Description { get; set; } - - public string Company { get; set; } - - public string Product { get; set; } - - public string Copyright { get; set; } - - public string Trademark { get; set; } - - public string DefaultAlias { get; set; } - - public Version AssemblyVersion { get; set; } - - public Version AssemblyFileVersion { get; set; } - - public Version InformationalVersion { get; set; } - - public Guid? Guid { get; set; } - - public string NeutralLanguage { get; set; } - - public bool ComVisible { get; set; } - - public bool ClsCompliant { get; set; } - - public bool JitOptimization { get; set; } - - public bool JitTracking { get; set; } + private DesignItem designItem; + + public DefaultCommandsContextMenu(DesignItem designItem) + { + this.designItem = designItem; + + SpecialInitializeComponent(); + } + + /// + /// Fixes InitializeComponent with multiple Versions of same Assembly loaded + /// + public void SpecialInitializeComponent() + { + if (!this._contentLoaded) { + this._contentLoaded = true; + Uri resourceLocator = new Uri(VersionedAssemblyResourceDictionary.GetXamlNameForType(this.GetType()), UriKind.Relative); + Application.LoadComponent(this, resourceLocator); + } + + this.InitializeComponent(); + } } -} \ No newline at end of file +} diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Extensions/DefaultCommandsContextMenuExtension.cs b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Extensions/DefaultCommandsContextMenuExtension.cs new file mode 100644 index 0000000000..18fb12cc55 --- /dev/null +++ b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Extensions/DefaultCommandsContextMenuExtension.cs @@ -0,0 +1,54 @@ +// Copyright (c) 2014 AlphaSierraPapa for the SharpDevelop Team +// +// Permission is hereby granted, free of charge, to any person obtaining a copy of this +// software and associated documentation files (the "Software"), to deal in the Software +// without restriction, including without limitation the rights to use, copy, modify, merge, +// publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons +// to whom the Software is furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all copies or +// substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, +// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR +// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE +// FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +// DEALINGS IN THE SOFTWARE. + +using System; +using System.Linq; +using System.Windows; +using System.Windows.Controls; +using ICSharpCode.WpfDesign.Adorners; +using ICSharpCode.WpfDesign.Extensions; + +namespace ICSharpCode.WpfDesign.Designer.Extensions +{ + [ExtensionServer(typeof(PrimarySelectionExtensionServer))] + [ExtensionFor(typeof (UIElement))] + [Extension(Order = 10)] + public class DefaultCommandsContextMenuExtension : SelectionAdornerProvider + { + DesignPanel panel; + ContextMenu contextMenu; + + protected override void OnInitialized() + { + base.OnInitialized(); + + contextMenu = new DefaultCommandsContextMenu(ExtendedItem); + panel = ExtendedItem.Context.Services.DesignPanel as DesignPanel; + if (panel != null) + panel.AddContextMenu(contextMenu); + } + + protected override void OnRemove() + { + if (panel != null) + panel.RemoveContextMenu(contextMenu); + + base.OnRemove(); + } + } +} 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 f894e939d2..26e7d9c46e 100644 --- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Extensions/DefaultPlacementBehavior.cs +++ b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Extensions/DefaultPlacementBehavior.cs @@ -38,27 +38,9 @@ namespace ICSharpCode.WpfDesign.Designer.Extensions [ExtensionFor(typeof(Viewbox))] public class DefaultPlacementBehavior : BehaviorExtension, IPlacementBehavior { - static List _contentControlsNotAllowedToAdd; - static DefaultPlacementBehavior() - { - _contentControlsNotAllowedToAdd = new List(); - _contentControlsNotAllowedToAdd.Add(typeof (Frame)); - _contentControlsNotAllowedToAdd.Add(typeof (GroupItem)); - _contentControlsNotAllowedToAdd.Add(typeof (HeaderedContentControl)); - _contentControlsNotAllowedToAdd.Add(typeof (Label)); - _contentControlsNotAllowedToAdd.Add(typeof (ListBoxItem)); - //_contentControlsNotAllowedToAdd.Add(typeof (ButtonBase)); - _contentControlsNotAllowedToAdd.Add(typeof (StatusBarItem)); - _contentControlsNotAllowedToAdd.Add(typeof (ToolTip)); - } + { } - public static bool CanContentControlAdd(ContentControl control) - { - Debug.Assert(control != null); - return !_contentControlsNotAllowedToAdd.Any(type => type.IsAssignableFrom(control.GetType())); - } - protected override void OnInitialized() { base.OnInitialized(); @@ -68,7 +50,7 @@ namespace ICSharpCode.WpfDesign.Designer.Extensions ExtendedItem.AddBehavior(typeof(IPlacementBehavior), this); } - public virtual bool CanPlace(ICollection childItems, PlacementType type, PlacementAlignment position) + public virtual bool CanPlace(IEnumerable childItems, PlacementType type, PlacementAlignment position) { return true; } @@ -81,27 +63,32 @@ namespace ICSharpCode.WpfDesign.Designer.Extensions { InfoTextEnterArea.Stop(ref infoTextEnterArea); - this.ExtendedItem.Services.Selection.SetSelectedComponents(null); - this.ExtendedItem.Services.Selection.SetSelectedComponents(operation.PlacedItems.Select(x => x.Item).ToList()); - } + this.ExtendedItem.Services.Selection.SetSelectedComponents(null); + this.ExtendedItem.Services.Selection.SetSelectedComponents(operation.PlacedItems.Select(x => x.Item).ToList()); + } public virtual Rect GetPosition(PlacementOperation operation, DesignItem item) { if (item.View == null) return Rect.Empty; var p = item.View.TranslatePoint(new Point(), operation.CurrentContainer.View); - - return new Rect(p, PlacementOperation.GetRealElementSize(item.View)); + + return new Rect(p, PlacementOperation.GetRealElementSize(item.View)); } public virtual void BeforeSetPosition(PlacementOperation operation) { } + public virtual bool CanPlaceItem(PlacementInformation info) + { + return true; + } + public virtual void SetPosition(PlacementInformation info) { - if (info.Operation.Type != PlacementType.Move) - ModelTools.Resize(info.Item, info.Bounds.Width, info.Bounds.Height); + if (info.Operation.Type != PlacementType.Move) + ModelTools.Resize(info.Item, info.Bounds.Width, info.Bounds.Height); } public virtual bool CanLeaveContainer(PlacementOperation operation) @@ -129,7 +116,7 @@ namespace ICSharpCode.WpfDesign.Designer.Extensions if (canEnter && !shouldAlwaysEnter && !Keyboard.IsKeyDown(Key.LeftAlt) && !Keyboard.IsKeyDown(Key.RightAlt)) { var b = new Rect(0, 0, ((FrameworkElement)this.ExtendedItem.View).ActualWidth, ((FrameworkElement)this.ExtendedItem.View).ActualHeight); - InfoTextEnterArea.Start(ref infoTextEnterArea, this.Services, this.ExtendedItem.View, b, Translations.Instance.PressAltText); + InfoTextEnterArea.Start(ref infoTextEnterArea, this.Services, this.ExtendedItem.View, b, Translations.Instance.PressAltText); return false; } @@ -139,7 +126,7 @@ namespace ICSharpCode.WpfDesign.Designer.Extensions private bool internalCanEnterContainer(PlacementOperation operation) { - InfoTextEnterArea.Stop(ref infoTextEnterArea); + InfoTextEnterArea.Stop(ref infoTextEnterArea); if (ExtendedItem.Component is Expander) { @@ -158,14 +145,9 @@ namespace ICSharpCode.WpfDesign.Designer.Extensions if (ExtendedItem.ContentProperty.IsCollection) return CollectionSupport.CanCollectionAdd(ExtendedItem.ContentProperty.ReturnType, operation.PlacedItems.Select(p => p.Item.Component)); - if (ExtendedItem.View is ContentControl) { - if (!CanContentControlAdd((ContentControl) ExtendedItem.View)) { - return false; - } - } - - if (ExtendedItem.ContentProperty.ReturnType == typeof(string)) - return false; + + if (ExtendedItem.ContentProperty.ReturnType == typeof(string)) + return false; if (!ExtendedItem.ContentProperty.IsSet) return true; @@ -188,7 +170,7 @@ namespace ICSharpCode.WpfDesign.Designer.Extensions foreach (var info in operation.PlacedItems) { SetPosition(info); } - } + } } } } diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Extensions/EditStyleContextMenu.xaml.cs b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Extensions/EditStyleContextMenu.xaml.cs index f23051132e..b3363e9644 100644 --- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Extensions/EditStyleContextMenu.xaml.cs +++ b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Extensions/EditStyleContextMenu.xaml.cs @@ -26,6 +26,7 @@ using System.Xml; using ICSharpCode.WpfDesign.Designer.PropertyGrid.Editors.FormatedTextEditor; using ICSharpCode.WpfDesign.Designer.Xaml; using ICSharpCode.WpfDesign.XamlDom; +using ICSharpCode.WpfDesign.Designer.themes; namespace ICSharpCode.WpfDesign.Designer.Extensions { @@ -37,7 +38,21 @@ namespace ICSharpCode.WpfDesign.Designer.Extensions { this.designItem = designItem; - InitializeComponent(); + SpecialInitializeComponent(); + } + + /// + /// Fixes InitializeComponent with multiple Versions of same Assembly loaded + /// + public void SpecialInitializeComponent() + { + if (!this._contentLoaded) { + this._contentLoaded = true; + Uri resourceLocator = new Uri(VersionedAssemblyResourceDictionary.GetXamlNameForType(this.GetType()), UriKind.Relative); + Application.LoadComponent(this, resourceLocator); + } + + this.InitializeComponent(); } void Click_EditStyle(object sender, RoutedEventArgs e) diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Extensions/EditStyleContextMenuExtension.cs b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Extensions/EditStyleContextMenuExtension.cs index 685936eccb..d6b3b8aaf1 100644 --- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Extensions/EditStyleContextMenuExtension.cs +++ b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Extensions/EditStyleContextMenuExtension.cs @@ -26,7 +26,7 @@ namespace ICSharpCode.WpfDesign.Designer.Extensions { [ExtensionServer(typeof (OnlyOneItemSelectedExtensionServer))] [ExtensionFor(typeof (Control))] - [Extension(Order = 10)] + [Extension(Order = 30)] public class EditStyleContextMenuExtension : PrimarySelectionAdornerProvider { DesignPanel panel; diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Extensions/Initializers.cs b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Extensions/Initializers.cs index 05e79f50ed..b6b4aa941b 100644 --- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Extensions/Initializers.cs +++ b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Extensions/Initializers.cs @@ -63,9 +63,9 @@ namespace ICSharpCode.WpfDesign.Designer.Extensions.Initializers if (textProperty.ValueOnInstance == null || textProperty.ValueOnInstance.ToString() == "") { textProperty.SetValue(item.ComponentType.Name); - item.Properties[FrameworkElement.WidthProperty].Reset(); - item.Properties[FrameworkElement.HeightProperty].Reset(); - } + item.Properties[FrameworkElement.WidthProperty].Reset(); + item.Properties[FrameworkElement.HeightProperty].Reset(); + } DesignItemProperty verticalAlignmentProperty = item.Properties["VerticalAlignment"]; if (verticalAlignmentProperty.ValueOnInstance == null) diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Extensions/RightClickContextMenu.xaml.cs b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Extensions/RightClickContextMenu.xaml.cs index 932b57f4c3..83db9b6a4f 100644 --- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Extensions/RightClickContextMenu.xaml.cs +++ b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Extensions/RightClickContextMenu.xaml.cs @@ -20,6 +20,7 @@ using System; using System.Collections.Generic; using System.Linq; using System.Windows; +using ICSharpCode.WpfDesign.Designer.themes; namespace ICSharpCode.WpfDesign.Designer.Extensions { @@ -31,7 +32,21 @@ namespace ICSharpCode.WpfDesign.Designer.Extensions { this.designItem = designItem; - InitializeComponent(); + SpecialInitializeComponent(); + } + + /// + /// Fixes InitializeComponent with multiple Versions of same Assembly loaded + /// + public void SpecialInitializeComponent() + { + if (!this._contentLoaded) { + this._contentLoaded = true; + Uri resourceLocator = new Uri(VersionedAssemblyResourceDictionary.GetXamlNameForType(this.GetType()), UriKind.Relative); + Application.LoadComponent(this, resourceLocator); + } + + this.InitializeComponent(); } void Click_BringToFront(object sender, RoutedEventArgs e) diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Extensions/RightClickContextMenuExtension.cs b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Extensions/RightClickContextMenuExtension.cs index 49b65fb72b..83cc515f82 100644 --- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Extensions/RightClickContextMenuExtension.cs +++ b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Extensions/RightClickContextMenuExtension.cs @@ -30,6 +30,7 @@ namespace ICSharpCode.WpfDesign.Designer.Extensions /// [ExtensionServer(typeof(OnlyOneItemSelectedExtensionServer))] [ExtensionFor(typeof(UIElement))] + [Extension(Order = 20)] public sealed class RightClickContextMenuExtension : PrimarySelectionAdornerProvider { DesignPanel panel; diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Extensions/SnaplinePlacementBehavior.cs b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Extensions/SnaplinePlacementBehavior.cs index b8cb90fd95..d2d187561e 100644 --- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Extensions/SnaplinePlacementBehavior.cs +++ b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Extensions/SnaplinePlacementBehavior.cs @@ -224,10 +224,13 @@ namespace ICSharpCode.WpfDesign.Designer.Extensions AddLines(containerRect, -Margin, false); AddLines(containerRect, 0, false); - + + if (!CanPlace(operation.PlacedItems.Select(x => x.Item), operation.Type, PlacementAlignment.Center)) + return; + foreach (var item in AllDesignItems() /* ExtendedItem.ContentProperty.CollectionElements */ .Except(operation.PlacedItems.Select(f => f.Item)) - .Where(x=>!GetDisableSnaplines(x.View))) { + .Where(x=> x.View != null && !GetDisableSnaplines(x.View))) { if (item != null) { var bounds = GetPosition(operation, item); diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Extensions/TextBlockRightClickContextMenu.xaml.cs b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Extensions/TextBlockRightClickContextMenu.xaml.cs index 262fd14e57..1b8a1f5d48 100644 --- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Extensions/TextBlockRightClickContextMenu.xaml.cs +++ b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Extensions/TextBlockRightClickContextMenu.xaml.cs @@ -21,6 +21,7 @@ using System.Linq; using System.Windows; using ICSharpCode.WpfDesign.Designer.PropertyGrid.Editors.FormatedTextEditor; using ICSharpCode.WpfDesign.Designer.UIExtensions; +using ICSharpCode.WpfDesign.Designer.themes; namespace ICSharpCode.WpfDesign.Designer.Extensions { @@ -32,7 +33,21 @@ namespace ICSharpCode.WpfDesign.Designer.Extensions { this.designItem = designItem; - InitializeComponent(); + SpecialInitializeComponent(); + } + + /// + /// Fixes InitializeComponent with multiple Versions of same Assembly loaded + /// + public void SpecialInitializeComponent() + { + if (!this._contentLoaded) { + this._contentLoaded = true; + Uri resourceLocator = new Uri(VersionedAssemblyResourceDictionary.GetXamlNameForType(this.GetType()), UriKind.Relative); + Application.LoadComponent(this, resourceLocator); + } + + this.InitializeComponent(); } void Click_EditFormatedText(object sender, RoutedEventArgs e) diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Extensions/TextBlockRightClickContextMenuExtension.cs b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Extensions/TextBlockRightClickContextMenuExtension.cs index bb9fd11261..b9f81007ef 100644 --- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Extensions/TextBlockRightClickContextMenuExtension.cs +++ b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Extensions/TextBlockRightClickContextMenuExtension.cs @@ -26,7 +26,7 @@ namespace ICSharpCode.WpfDesign.Designer.Extensions { [ExtensionServer(typeof (OnlyOneItemSelectedExtensionServer))] [ExtensionFor(typeof (TextBlock))] - [Extension(Order = 10)] + [Extension(Order = 40)] public class TextBlockRightClickContextMenuExtension : PrimarySelectionAdornerProvider { DesignPanel panel; diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Extensions/WrapItemContextMenu.xaml.cs b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Extensions/WrapItemContextMenu.xaml.cs index 610b88f283..d179952403 100644 --- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Extensions/WrapItemContextMenu.xaml.cs +++ b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Extensions/WrapItemContextMenu.xaml.cs @@ -18,7 +18,9 @@ using System; using System.Linq; +using System.Windows; using System.Windows.Controls; +using ICSharpCode.WpfDesign.Designer.themes; namespace ICSharpCode.WpfDesign.Designer.Extensions { @@ -26,16 +28,30 @@ namespace ICSharpCode.WpfDesign.Designer.Extensions { private DesignItem designItem; - public WrapItemContextMenu(DesignItem designItem) + public WrapItemContextMenu(DesignItem designItem) { this.designItem = designItem; - InitializeComponent(); + SpecialInitializeComponent(); + } + + /// + /// Fixes InitializeComponent with multiple Versions of same Assembly loaded + /// + public void SpecialInitializeComponent() + { + if (!this._contentLoaded) { + this._contentLoaded = true; + Uri resourceLocator = new Uri(VersionedAssemblyResourceDictionary.GetXamlNameForType(this.GetType()), UriKind.Relative); + Application.LoadComponent(this, resourceLocator); + } + + this.InitializeComponent(); } - void Click_WrapInViewbox(object sender, System.Windows.RoutedEventArgs e) + void Click_WrapInViewbox(object sender, System.Windows.RoutedEventArgs e) { ModelTools.WrapItemsNewContainer(this.designItem.Services.Selection.SelectedItems, typeof(Viewbox)); - } + } } } diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Extensions/WrapItemsContextMenu.xaml.cs b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Extensions/WrapItemsContextMenu.xaml.cs index 4a61038d34..982b48a364 100644 --- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Extensions/WrapItemsContextMenu.xaml.cs +++ b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Extensions/WrapItemsContextMenu.xaml.cs @@ -18,7 +18,9 @@ using System; using System.Linq; +using System.Windows; using System.Windows.Controls; +using ICSharpCode.WpfDesign.Designer.themes; namespace ICSharpCode.WpfDesign.Designer.Extensions { @@ -30,7 +32,21 @@ namespace ICSharpCode.WpfDesign.Designer.Extensions { this.designItem = designItem; - InitializeComponent(); + SpecialInitializeComponent(); + } + + /// + /// Fixes InitializeComponent with multiple Versions of same Assembly loaded + /// + public void SpecialInitializeComponent() + { + if (!this._contentLoaded) { + this._contentLoaded = true; + Uri resourceLocator = new Uri(VersionedAssemblyResourceDictionary.GetXamlNameForType(this.GetType()), UriKind.Relative); + Application.LoadComponent(this, resourceLocator); + } + + this.InitializeComponent(); } void Click_WrapInCanvas(object sender, System.Windows.RoutedEventArgs e) diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Images/Icons.16x16.CopyIcon.png b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Images/Icons.16x16.CopyIcon.png new file mode 100644 index 0000000000..7537994da4 Binary files /dev/null and b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Images/Icons.16x16.CopyIcon.png differ diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Images/Icons.16x16.CutIcon.png b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Images/Icons.16x16.CutIcon.png new file mode 100644 index 0000000000..ca21cb2a7c Binary files /dev/null and b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Images/Icons.16x16.CutIcon.png differ diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Images/Icons.16x16.DeleteIcon.png b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Images/Icons.16x16.DeleteIcon.png new file mode 100644 index 0000000000..70b59dc9de Binary files /dev/null and b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Images/Icons.16x16.DeleteIcon.png differ diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Images/Icons.16x16.PasteIcon.png b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Images/Icons.16x16.PasteIcon.png new file mode 100644 index 0000000000..0cf8887292 Binary files /dev/null and b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Images/Icons.16x16.PasteIcon.png differ diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Images/Icons.16x16.RedoIcon.png b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Images/Icons.16x16.RedoIcon.png new file mode 100644 index 0000000000..56776f5fdb Binary files /dev/null and b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Images/Icons.16x16.RedoIcon.png differ diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Images/Icons.16x16.UndoIcon.png b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Images/Icons.16x16.UndoIcon.png new file mode 100644 index 0000000000..2a361a0789 Binary files /dev/null and b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Images/Icons.16x16.UndoIcon.png differ diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/ModelTools.cs b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/ModelTools.cs index b7099f6144..c5a0aba8e7 100644 --- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/ModelTools.cs +++ b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/ModelTools.cs @@ -236,7 +236,7 @@ namespace ICSharpCode.WpfDesign.Designer return itemPos; } - public static void WrapItemsNewContainer(IEnumerable items, Type containerType) + public static Tuple WrapItemsNewContainer(IEnumerable items, Type containerType, bool doInsert = true) { var collection = items; @@ -245,18 +245,17 @@ namespace ICSharpCode.WpfDesign.Designer var container = collection.First().Parent; if (collection.Any(x => x.Parent != container)) - return; + return null; //Change Code to use the Placment Operation! var placement = container.Extensions.OfType().FirstOrDefault(); if (placement == null) - return; + return null; var operation = PlacementOperation.Start(items.ToList(), PlacementType.Move); - var newInstance = Activator.CreateInstance(containerType); + var newInstance = _context.Services.ExtensionManager.CreateInstanceWithCustomInstanceFactory(containerType, null); DesignItem newPanel = _context.Services.Component.RegisterComponentForDesigner(newInstance); - //var changeGroup = newPanel.OpenGroup("Wrap in Container"); List itemList = new List(); @@ -325,19 +324,24 @@ namespace ICSharpCode.WpfDesign.Designer newPanel.ContentProperty.SetValue(item.DesignItem); } } - - PlacementOperation operation2 = PlacementOperation.TryStartInsertNewComponents( - container, - new[] { newPanel }, - new[] { new Rect(xmin, ymin, xmax - xmin, ymax - ymin).Round() }, - PlacementType.AddItem - ); - - operation2.Commit(); + + if (doInsert) + { + PlacementOperation operation2 = PlacementOperation.TryStartInsertNewComponents( + container, + new[] {newPanel}, + new[] {new Rect(xmin, ymin, xmax - xmin, ymax - ymin).Round()}, + PlacementType.AddItem + ); + + operation2.Commit(); + + _context.Services.Selection.SetSelectedComponents(new[] {newPanel}); + } operation.Commit(); - - _context.Services.Selection.SetSelectedComponents(new []{ newPanel }); + + return new Tuple(newPanel, new Rect(xmin, ymin, xmax - xmin, ymax - ymin).Round()); } public static void ArrangeItems(IEnumerable items, ArrangeDirection arrangeDirection) diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/OutlineView/Outline.xaml.cs b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/OutlineView/Outline.xaml.cs index 43f5702af4..68455b11de 100644 --- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/OutlineView/Outline.xaml.cs +++ b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/OutlineView/Outline.xaml.cs @@ -29,6 +29,7 @@ using System.Windows.Media; using System.Windows.Media.Imaging; using System.Windows.Navigation; using System.Windows.Shapes; +using ICSharpCode.WpfDesign.Designer.themes; namespace ICSharpCode.WpfDesign.Designer.OutlineView { @@ -36,7 +37,21 @@ namespace ICSharpCode.WpfDesign.Designer.OutlineView { public Outline() { - InitializeComponent(); + SpecialInitializeComponent(); + } + + /// + /// Fixes InitializeComponent with multiple Versions of same Assembly loaded + /// + public void SpecialInitializeComponent() + { + if (!this._contentLoaded) { + this._contentLoaded = true; + Uri resourceLocator = new Uri(VersionedAssemblyResourceDictionary.GetXamlNameForType(this.GetType()), UriKind.Relative); + Application.LoadComponent(this, resourceLocator); + } + + this.InitializeComponent(); } public static readonly DependencyProperty RootProperty = 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 6076383cd0..8df463ac80 100644 --- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/OutlineView/OutlineView.xaml +++ b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/OutlineView/OutlineView.xaml @@ -97,7 +97,7 @@ - + - - + + diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/PropertyGrid/Editors/BoolEditor.xaml.cs b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/PropertyGrid/Editors/BoolEditor.xaml.cs index 6660a60afb..40913cdd7a 100644 --- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/PropertyGrid/Editors/BoolEditor.xaml.cs +++ b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/PropertyGrid/Editors/BoolEditor.xaml.cs @@ -17,19 +17,10 @@ // 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.themes; namespace ICSharpCode.WpfDesign.Designer.PropertyGrid.Editors { @@ -38,7 +29,21 @@ namespace ICSharpCode.WpfDesign.Designer.PropertyGrid.Editors { public BoolEditor() { - InitializeComponent(); + SpecialInitializeComponent(); + } + + /// + /// Fixes InitializeComponent with multiple Versions of same Assembly loaded + /// + public void SpecialInitializeComponent() + { + if (!this._contentLoaded) { + this._contentLoaded = true; + Uri resourceLocator = new Uri(VersionedAssemblyResourceDictionary.GetXamlNameForType(this.GetType()), UriKind.Relative); + Application.LoadComponent(this, resourceLocator); + } + + this.InitializeComponent(); } } } diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/PropertyGrid/Editors/BrushEditor/BrushEditorPopup.xaml.cs b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/PropertyGrid/Editors/BrushEditor/BrushEditorPopup.xaml.cs index 0fb9e293de..1aa26198f2 100644 --- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/PropertyGrid/Editors/BrushEditor/BrushEditorPopup.xaml.cs +++ b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/PropertyGrid/Editors/BrushEditor/BrushEditorPopup.xaml.cs @@ -17,19 +17,10 @@ // 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 System.Diagnostics; +using ICSharpCode.WpfDesign.Designer.themes; namespace ICSharpCode.WpfDesign.Designer.PropertyGrid.Editors.BrushEditor { @@ -37,13 +28,27 @@ namespace ICSharpCode.WpfDesign.Designer.PropertyGrid.Editors.BrushEditor { public BrushEditorPopup() { - InitializeComponent(); + SpecialInitializeComponent(); + } + + /// + /// Fixes InitializeComponent with multiple Versions of same Assembly loaded + /// + public void SpecialInitializeComponent() + { + if (!this._contentLoaded) { + this._contentLoaded = true; + Uri resourceLocator = new Uri(VersionedAssemblyResourceDictionary.GetXamlNameForType(this.GetType()), UriKind.Relative); + Application.LoadComponent(this, resourceLocator); + } + + this.InitializeComponent(); } protected override void OnClosed(EventArgs e) { - base.OnClosed(e); - BrushEditorView.BrushEditor.Commit(); + base.OnClosed(e); + BrushEditorView.BrushEditor.Commit(); } protected override void OnKeyDown(KeyEventArgs e) diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/PropertyGrid/Editors/BrushEditor/BrushEditorView.xaml.cs b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/PropertyGrid/Editors/BrushEditor/BrushEditorView.xaml.cs index 6df1ca9488..c1cf4480be 100644 --- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/PropertyGrid/Editors/BrushEditor/BrushEditorView.xaml.cs +++ b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/PropertyGrid/Editors/BrushEditor/BrushEditorView.xaml.cs @@ -31,6 +31,7 @@ using System.Windows.Navigation; using System.Windows.Shapes; using System.Diagnostics; using System.Globalization; +using ICSharpCode.WpfDesign.Designer.themes; namespace ICSharpCode.WpfDesign.Designer.PropertyGrid.Editors.BrushEditor { @@ -41,12 +42,26 @@ namespace ICSharpCode.WpfDesign.Designer.PropertyGrid.Editors.BrushEditor BrushEditor = new BrushEditor(); DataContext = BrushEditor; - InitializeComponent(); + SpecialInitializeComponent(); SetBinding(HeightProperty, new Binding("Brush") { Converter = HeightConverter.Instance }); } + + /// + /// Fixes InitializeComponent with multiple Versions of same Assembly loaded + /// + public void SpecialInitializeComponent() + { + if (!this._contentLoaded) { + this._contentLoaded = true; + Uri resourceLocator = new Uri(VersionedAssemblyResourceDictionary.GetXamlNameForType(this.GetType()), UriKind.Relative); + Application.LoadComponent(this, resourceLocator); + } + + this.InitializeComponent(); + } public BrushEditor BrushEditor { get; private set; } diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/PropertyGrid/Editors/BrushEditor/BrushTypeEditor.xaml.cs b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/PropertyGrid/Editors/BrushEditor/BrushTypeEditor.xaml.cs index 44cfdfd640..f71c0c5680 100644 --- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/PropertyGrid/Editors/BrushEditor/BrushTypeEditor.xaml.cs +++ b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/PropertyGrid/Editors/BrushEditor/BrushTypeEditor.xaml.cs @@ -31,6 +31,7 @@ using System.Windows.Navigation; using System.Windows.Shapes; using ICSharpCode.WpfDesign.PropertyGrid; using System.Windows.Controls.Primitives; +using ICSharpCode.WpfDesign.Designer.themes; namespace ICSharpCode.WpfDesign.Designer.PropertyGrid.Editors.BrushEditor { @@ -39,7 +40,21 @@ namespace ICSharpCode.WpfDesign.Designer.PropertyGrid.Editors.BrushEditor { public BrushTypeEditor() { - InitializeComponent(); + SpecialInitializeComponent(); + } + + /// + /// Fixes InitializeComponent with multiple Versions of same Assembly loaded + /// + public void SpecialInitializeComponent() + { + if (!this._contentLoaded) { + this._contentLoaded = true; + Uri resourceLocator = new Uri(VersionedAssemblyResourceDictionary.GetXamlNameForType(this.GetType()), UriKind.Relative); + Application.LoadComponent(this, resourceLocator); + } + + this.InitializeComponent(); } static BrushEditorPopup brushEditorPopup = new BrushEditorPopup(); diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/PropertyGrid/Editors/BrushEditor/GradientBrushEditor.xaml.cs b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/PropertyGrid/Editors/BrushEditor/GradientBrushEditor.xaml.cs index 5f9477467b..f10c17b1cb 100644 --- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/PropertyGrid/Editors/BrushEditor/GradientBrushEditor.xaml.cs +++ b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/PropertyGrid/Editors/BrushEditor/GradientBrushEditor.xaml.cs @@ -17,18 +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.themes; namespace ICSharpCode.WpfDesign.Designer.PropertyGrid.Editors.BrushEditor { @@ -36,7 +27,21 @@ namespace ICSharpCode.WpfDesign.Designer.PropertyGrid.Editors.BrushEditor { public GradientBrushEditor() { - InitializeComponent(); + SpecialInitializeComponent(); + } + + /// + /// Fixes InitializeComponent with multiple Versions of same Assembly loaded + /// + public void SpecialInitializeComponent() + { + if (!this._contentLoaded) { + this._contentLoaded = true; + Uri resourceLocator = new Uri(VersionedAssemblyResourceDictionary.GetXamlNameForType(this.GetType()), UriKind.Relative); + Application.LoadComponent(this, resourceLocator); + } + + this.InitializeComponent(); } } } diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/PropertyGrid/Editors/BrushEditor/GradientSlider.xaml.cs b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/PropertyGrid/Editors/BrushEditor/GradientSlider.xaml.cs index 92a9e980de..1bfd390e50 100644 --- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/PropertyGrid/Editors/BrushEditor/GradientSlider.xaml.cs +++ b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/PropertyGrid/Editors/BrushEditor/GradientSlider.xaml.cs @@ -31,6 +31,7 @@ using System.Windows.Navigation; using System.Windows.Shapes; using System.Windows.Controls.Primitives; using System.ComponentModel; +using ICSharpCode.WpfDesign.Designer.themes; namespace ICSharpCode.WpfDesign.Designer.PropertyGrid.Editors.BrushEditor { @@ -38,7 +39,7 @@ namespace ICSharpCode.WpfDesign.Designer.PropertyGrid.Editors.BrushEditor { public GradientSlider() { - InitializeComponent(); + SpecialInitializeComponent(); BindingOperations.SetBinding(this, SelectedStopProperty, new Binding("SelectedItem") { Source = itemsControl, @@ -49,6 +50,19 @@ namespace ICSharpCode.WpfDesign.Designer.PropertyGrid.Editors.BrushEditor strip.DragDelta += new DragDeltaEventHandler(strip_DragDelta); } + /// + /// Fixes InitializeComponent with multiple Versions of same Assembly loaded + /// + public void SpecialInitializeComponent() + { + if (!this._contentLoaded) { + this._contentLoaded = true; + Uri resourceLocator = new Uri(VersionedAssemblyResourceDictionary.GetXamlNameForType(this.GetType()), UriKind.Relative); + Application.LoadComponent(this, resourceLocator); + } + + this.InitializeComponent(); + } static GradientSlider() { EventManager.RegisterClassHandler(typeof(GradientSlider), diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/PropertyGrid/Editors/BrushEditor/SolidBrushEditor.xaml.cs b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/PropertyGrid/Editors/BrushEditor/SolidBrushEditor.xaml.cs index 573644054e..073f6f53b4 100644 --- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/PropertyGrid/Editors/BrushEditor/SolidBrushEditor.xaml.cs +++ b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/PropertyGrid/Editors/BrushEditor/SolidBrushEditor.xaml.cs @@ -17,18 +17,10 @@ // 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.themes; namespace ICSharpCode.WpfDesign.Designer.PropertyGrid.Editors.BrushEditor { @@ -36,7 +28,21 @@ namespace ICSharpCode.WpfDesign.Designer.PropertyGrid.Editors.BrushEditor { public SolidBrushEditor() { - InitializeComponent(); + SpecialInitializeComponent(); + } + + /// + /// Fixes InitializeComponent with multiple Versions of same Assembly loaded + /// + public void SpecialInitializeComponent() + { + if (!this._contentLoaded) { + this._contentLoaded = true; + Uri resourceLocator = new Uri(VersionedAssemblyResourceDictionary.GetXamlNameForType(this.GetType()), UriKind.Relative); + Application.LoadComponent(this, resourceLocator); + } + + this.InitializeComponent(); } public static readonly DependencyProperty ColorProperty = diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/PropertyGrid/Editors/CollectionEditor.xaml.cs b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/PropertyGrid/Editors/CollectionEditor.xaml.cs index e592e37cf2..e7de245efc 100644 --- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/PropertyGrid/Editors/CollectionEditor.xaml.cs +++ b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/PropertyGrid/Editors/CollectionEditor.xaml.cs @@ -28,6 +28,7 @@ using System.Windows.Documents; using System.Windows.Input; using System.Windows.Media; using ICSharpCode.WpfDesign.Designer.OutlineView; +using ICSharpCode.WpfDesign.Designer.themes; namespace ICSharpCode.WpfDesign.Designer.PropertyGrid.Editors { @@ -49,11 +50,25 @@ namespace ICSharpCode.WpfDesign.Designer.PropertyGrid.Editors private IComponentService _componentService; public CollectionEditor() { - InitializeComponent(); + SpecialInitializeComponent(); this.Owner = Application.Current.MainWindow; } + /// + /// Fixes InitializeComponent with multiple Versions of same Assembly loaded + /// + public void SpecialInitializeComponent() + { + if (!this._contentLoaded) { + this._contentLoaded = true; + Uri resourceLocator = new Uri(VersionedAssemblyResourceDictionary.GetXamlNameForType(this.GetType()), UriKind.Relative); + Application.LoadComponent(this, resourceLocator); + } + + this.InitializeComponent(); + } + public void LoadItemsCollection(DesignItem item) { Debug.Assert(item.View is ItemsControl); 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 index 033175be75..25d1a5b844 100644 --- 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 @@ -2,19 +2,11 @@ // 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; +using ICSharpCode.WpfDesign.Designer.themes; namespace ICSharpCode.WpfDesign.Designer.PropertyGrid.Editors { @@ -23,7 +15,21 @@ namespace ICSharpCode.WpfDesign.Designer.PropertyGrid.Editors { public ColorEditor() { - InitializeComponent(); + SpecialInitializeComponent(); + } + + /// + /// Fixes InitializeComponent with multiple Versions of same Assembly loaded + /// + public void SpecialInitializeComponent() + { + if (!this._contentLoaded) { + this._contentLoaded = true; + Uri resourceLocator = new Uri(VersionedAssemblyResourceDictionary.GetXamlNameForType(this.GetType()), UriKind.Relative); + Application.LoadComponent(this, resourceLocator); + } + + this.InitializeComponent(); } } } \ No newline at end of file diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/PropertyGrid/Editors/ComboBoxEditor.xaml b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/PropertyGrid/Editors/ComboBoxEditor.xaml similarity index 83% rename from src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/PropertyGrid/Editors/ComboBoxEditor.xaml rename to src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/PropertyGrid/Editors/ComboBoxEditor.xaml index 88e8dab911..fdbf774116 100644 --- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/PropertyGrid/Editors/ComboBoxEditor.xaml +++ b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/PropertyGrid/Editors/ComboBoxEditor.xaml @@ -1,5 +1,5 @@  @@ -42,9 +42,23 @@ namespace ICSharpCode.WpfDesign.PropertyGrid.Editors /// public ComboBoxEditor() { - InitializeComponent(); + SpecialInitializeComponent(); } + /// + /// Fixes InitializeComponent with multiple Versions of same Assembly loaded + /// + public void SpecialInitializeComponent() + { + if (!this._contentLoaded) { + this._contentLoaded = true; + Uri resourceLocator = new Uri(VersionedAssemblyResourceDictionary.GetXamlNameForType(this.GetType()), UriKind.Relative); + Application.LoadComponent(this, resourceLocator); + } + + this.InitializeComponent(); + } + /// public override void OnApplyTemplate() { diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/PropertyGrid/Editors/EventEditor.xaml.cs b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/PropertyGrid/Editors/EventEditor.xaml.cs index 09b682c112..617cff5195 100644 --- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/PropertyGrid/Editors/EventEditor.xaml.cs +++ b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/PropertyGrid/Editors/EventEditor.xaml.cs @@ -17,19 +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.themes; namespace ICSharpCode.WpfDesign.Designer.PropertyGrid.Editors { @@ -38,7 +31,21 @@ namespace ICSharpCode.WpfDesign.Designer.PropertyGrid.Editors { public EventEditor() { - InitializeComponent(); + SpecialInitializeComponent(); + } + + /// + /// Fixes InitializeComponent with multiple Versions of same Assembly loaded + /// + public void SpecialInitializeComponent() + { + if (!this._contentLoaded) { + this._contentLoaded = true; + Uri resourceLocator = new Uri(VersionedAssemblyResourceDictionary.GetXamlNameForType(this.GetType()), UriKind.Relative); + Application.LoadComponent(this, resourceLocator); + } + + this.InitializeComponent(); } public PropertyNode PropertyNode { 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 bffd2a8f4e..5174d86306 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 @@ -30,6 +30,7 @@ using System.Windows.Input; using System.Windows.Media; using System.Linq; using ICSharpCode.WpfDesign.Designer.OutlineView; +using ICSharpCode.WpfDesign.Designer.themes; namespace ICSharpCode.WpfDesign.Designer.PropertyGrid.Editors { @@ -52,11 +53,25 @@ namespace ICSharpCode.WpfDesign.Designer.PropertyGrid.Editors public FlatCollectionEditor() { - InitializeComponent(); + SpecialInitializeComponent(); this.Owner = Application.Current.MainWindow; } + /// + /// Fixes InitializeComponent with multiple Versions of same Assembly loaded + /// + public void SpecialInitializeComponent() + { + if (!this._contentLoaded) { + this._contentLoaded = true; + Uri resourceLocator = new Uri(VersionedAssemblyResourceDictionary.GetXamlNameForType(this.GetType()), UriKind.Relative); + Application.LoadComponent(this, resourceLocator); + } + + this.InitializeComponent(); + } + public Type GetItemsSourceType(Type t) { Type tp = t.GetInterfaces().FirstOrDefault(x => x.IsGenericType && x.GetGenericTypeDefinition() == typeof(ICollection<>)); diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/PropertyGrid/Editors/FormatedTextEditor/FormatedTextEditor.xaml.cs b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/PropertyGrid/Editors/FormatedTextEditor/FormatedTextEditor.xaml.cs index 6cff46e6a1..e198361c5c 100644 --- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/PropertyGrid/Editors/FormatedTextEditor/FormatedTextEditor.xaml.cs +++ b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/PropertyGrid/Editors/FormatedTextEditor/FormatedTextEditor.xaml.cs @@ -16,6 +16,7 @@ // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. +using System; using System.Collections.Generic; using System.Linq; using System.Windows; @@ -24,6 +25,7 @@ using System.Windows.Documents; using System.Windows.Media; using ICSharpCode.WpfDesign.Designer.Xaml; using ICSharpCode.WpfDesign.Designer.UIExtensions; +using ICSharpCode.WpfDesign.Designer.themes; namespace ICSharpCode.WpfDesign.Designer.PropertyGrid.Editors.FormatedTextEditor { @@ -36,7 +38,7 @@ namespace ICSharpCode.WpfDesign.Designer.PropertyGrid.Editors.FormatedTextEditor public FormatedTextEditor(DesignItem designItem) { - InitializeComponent(); + SpecialInitializeComponent(); this.designItem = designItem; @@ -53,6 +55,20 @@ namespace ICSharpCode.WpfDesign.Designer.PropertyGrid.Editors.FormatedTextEditor richTextBox.Foreground = tb.Foreground; richTextBox.Background = tb.Background; } + + /// + /// Fixes InitializeComponent with multiple Versions of same Assembly loaded + /// + public void SpecialInitializeComponent() + { + if (!this._contentLoaded) { + this._contentLoaded = true; + Uri resourceLocator = new Uri(VersionedAssemblyResourceDictionary.GetXamlNameForType(this.GetType()), UriKind.Relative); + Application.LoadComponent(this, resourceLocator); + } + + this.InitializeComponent(); + } private void GetDesignItems(TextElementCollection blocks, List list) { diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/PropertyGrid/Editors/NumberEditor.xaml.cs b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/PropertyGrid/Editors/NumberEditor.xaml.cs index 4f8c7bbcf6..7ef21b23fa 100644 --- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/PropertyGrid/Editors/NumberEditor.xaml.cs +++ b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/PropertyGrid/Editors/NumberEditor.xaml.cs @@ -19,18 +19,11 @@ 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 System.Reflection; +using ICSharpCode.WpfDesign.Designer.themes; namespace ICSharpCode.WpfDesign.Designer.PropertyGrid.Editors { @@ -76,10 +69,23 @@ namespace ICSharpCode.WpfDesign.Designer.PropertyGrid.Editors public NumberEditor() { - InitializeComponent(); + SpecialInitializeComponent(); DataContextChanged += new DependencyPropertyChangedEventHandler(NumberEditor_DataContextChanged); } - + + /// + /// Fixes InitializeComponent with multiple Versions of same Assembly loaded + /// + public void SpecialInitializeComponent() + { + if (!this._contentLoaded) { + this._contentLoaded = true; + Uri resourceLocator = new Uri(VersionedAssemblyResourceDictionary.GetXamlNameForType(this.GetType()), UriKind.Relative); + Application.LoadComponent(this, resourceLocator); + } + + this.InitializeComponent(); + } static Dictionary minimums = new Dictionary(); static Dictionary maximums = new Dictionary(); diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/PropertyGrid/Editors/OpenCollectionEditor.xaml.cs b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/PropertyGrid/Editors/OpenCollectionEditor.xaml.cs index fcd84591b8..74395df02a 100644 --- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/PropertyGrid/Editors/OpenCollectionEditor.xaml.cs +++ b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/PropertyGrid/Editors/OpenCollectionEditor.xaml.cs @@ -14,6 +14,7 @@ using System.Windows.Navigation; using System.Windows.Shapes; using ICSharpCode.WpfDesign.PropertyGrid; +using ICSharpCode.WpfDesign.Designer.themes; //using Xceed.Wpf.Toolkit; namespace ICSharpCode.WpfDesign.Designer.PropertyGrid.Editors @@ -23,7 +24,21 @@ namespace ICSharpCode.WpfDesign.Designer.PropertyGrid.Editors { public OpenCollectionEditor() { - InitializeComponent(); + SpecialInitializeComponent(); + } + + /// + /// Fixes InitializeComponent with multiple Versions of same Assembly loaded + /// + public void SpecialInitializeComponent() + { + if (!this._contentLoaded) { + this._contentLoaded = true; + Uri resourceLocator = new Uri(VersionedAssemblyResourceDictionary.GetXamlNameForType(this.GetType()), UriKind.Relative); + Application.LoadComponent(this, resourceLocator); + } + + this.InitializeComponent(); } void open_Click(object sender, RoutedEventArgs e) diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/PropertyGrid/Editors/TextBoxEditor.xaml b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/PropertyGrid/Editors/TextBoxEditor.xaml similarity index 75% rename from src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/PropertyGrid/Editors/TextBoxEditor.xaml rename to src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/PropertyGrid/Editors/TextBoxEditor.xaml index a36db00d81..1fee98e4bf 100644 --- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/PropertyGrid/Editors/TextBoxEditor.xaml +++ b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/PropertyGrid/Editors/TextBoxEditor.xaml @@ -1,5 +1,5 @@  public TextBoxEditor() { - InitializeComponent(); + SpecialInitializeComponent(); + } + + /// + /// Fixes InitializeComponent with multiple Versions of same Assembly loaded + /// + public void SpecialInitializeComponent() + { + if (!this._contentLoaded) { + this._contentLoaded = true; + Uri resourceLocator = new Uri(VersionedAssemblyResourceDictionary.GetXamlNameForType(this.GetType()), UriKind.Relative); + Application.LoadComponent(this, resourceLocator); + } + + this.InitializeComponent(); } /// diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/PropertyGrid/Editors/TimeSpanEditor.xaml.cs b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/PropertyGrid/Editors/TimeSpanEditor.xaml.cs index 7a35df4b4d..9729cb7d85 100644 --- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/PropertyGrid/Editors/TimeSpanEditor.xaml.cs +++ b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/PropertyGrid/Editors/TimeSpanEditor.xaml.cs @@ -15,6 +15,7 @@ using System.Windows.Media.Imaging; using System.Windows.Navigation; using System.Windows.Shapes; using ICSharpCode.WpfDesign.PropertyGrid; +using ICSharpCode.WpfDesign.Designer.themes; namespace ICSharpCode.WpfDesign.Designer.PropertyGrid.Editors @@ -24,7 +25,21 @@ namespace ICSharpCode.WpfDesign.Designer.PropertyGrid.Editors { public TimeSpanEditor() { - InitializeComponent(); + SpecialInitializeComponent(); + } + + /// + /// Fixes InitializeComponent with multiple Versions of same Assembly loaded + /// + public void SpecialInitializeComponent() + { + if (!this._contentLoaded) { + this._contentLoaded = true; + Uri resourceLocator = new Uri(VersionedAssemblyResourceDictionary.GetXamlNameForType(this.GetType()), UriKind.Relative); + Application.LoadComponent(this, resourceLocator); + } + + this.InitializeComponent(); } } } \ No newline at end of file diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/PropertyGrid/PropertyContextMenu.xaml.cs b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/PropertyGrid/PropertyContextMenu.xaml.cs index 6d9fdf0c76..f2ec89a9d3 100644 --- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/PropertyGrid/PropertyContextMenu.xaml.cs +++ b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/PropertyGrid/PropertyContextMenu.xaml.cs @@ -30,6 +30,7 @@ using System.Windows.Media.Imaging; using System.Windows.Navigation; using System.Windows.Shapes; using ICSharpCode.WpfDesign.PropertyGrid; +using ICSharpCode.WpfDesign.Designer.themes; namespace ICSharpCode.WpfDesign.Designer.PropertyGrid { @@ -37,9 +38,23 @@ namespace ICSharpCode.WpfDesign.Designer.PropertyGrid { public PropertyContextMenu() { - InitializeComponent(); + SpecialInitializeComponent(); } + /// + /// Fixes InitializeComponent with multiple Versions of same Assembly loaded + /// + public void SpecialInitializeComponent() + { + if (!this._contentLoaded) { + this._contentLoaded = true; + Uri resourceLocator = new Uri(VersionedAssemblyResourceDictionary.GetXamlNameForType(this.GetType()), UriKind.Relative); + Application.LoadComponent(this, resourceLocator); + } + + this.InitializeComponent(); + } + public PropertyNode PropertyNode { get { return DataContext as PropertyNode; } } diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/RootItemBehavior.cs b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/RootItemBehavior.cs index 7d96801a4f..4b436dba98 100644 --- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/RootItemBehavior.cs +++ b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/RootItemBehavior.cs @@ -37,13 +37,10 @@ namespace ICSharpCode.WpfDesign.Designer this._rootItem=context.RootItem; _rootItem.AddBehavior(typeof(IRootPlacementBehavior),this); } - - public bool CanPlace(System.Collections.Generic.ICollection childItems, PlacementType type, PlacementAlignment position) + + public bool CanPlace(IEnumerable childItems, PlacementType type, PlacementAlignment position) { - return type == PlacementType.Resize && - (position == PlacementAlignment.Right - || position == PlacementAlignment.BottomRight - || position == PlacementAlignment.Bottom); + return type == PlacementType.Resize && (position == PlacementAlignment.Right || position == PlacementAlignment.BottomRight || position == PlacementAlignment.Bottom); } public void BeginPlacement(PlacementOperation operation) diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Services/ChooseClassDialog.xaml.cs b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Services/ChooseClassDialog.xaml.cs index e9661ce0c9..4bbfef468c 100644 --- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Services/ChooseClassDialog.xaml.cs +++ b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Services/ChooseClassDialog.xaml.cs @@ -25,6 +25,7 @@ using System.Windows.Controls; using System.Windows.Controls.Primitives; using System.Windows.Data; using System.Windows.Input; +using ICSharpCode.WpfDesign.Designer.themes; namespace ICSharpCode.WpfDesign.Designer.Services { @@ -33,7 +34,7 @@ namespace ICSharpCode.WpfDesign.Designer.Services public ChooseClassDialog(ChooseClass core) { DataContext = core; - InitializeComponent(); + SpecialInitializeComponent(); uxFilter.Focus(); uxList.MouseDoubleClick += uxList_MouseDoubleClick; @@ -46,6 +47,20 @@ namespace ICSharpCode.WpfDesign.Designer.Services true); } + /// + /// Fixes InitializeComponent with multiple Versions of same Assembly loaded + /// + public void SpecialInitializeComponent() + { + if (!this._contentLoaded) { + this._contentLoaded = true; + Uri resourceLocator = new Uri(VersionedAssemblyResourceDictionary.GetXamlNameForType(this.GetType()), UriKind.Relative); + Application.LoadComponent(this, resourceLocator); + } + + this.InitializeComponent(); + } + //HACK: listbox is always highlighted public static DependencyPropertyKey IsSelectionActivePropertyKey = (DependencyPropertyKey)typeof(Selector).GetField("IsSelectionActivePropertyKey", diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Services/ClickOrDragMouseGesture.cs b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Services/ClickOrDragMouseGesture.cs index 47dd6ead18..4f28713327 100644 --- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Services/ClickOrDragMouseGesture.cs +++ b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Services/ClickOrDragMouseGesture.cs @@ -26,7 +26,7 @@ namespace ICSharpCode.WpfDesign.Designer.Services /// /// Base class for mouse gestures that should start dragging only after a minimum drag distance. /// - abstract class ClickOrDragMouseGesture : MouseGestureBase + public abstract class ClickOrDragMouseGesture : MouseGestureBase { protected Point startPoint; protected bool hasDragStarted; diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Services/DragMoveMouseGesture.cs b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Services/DragMoveMouseGesture.cs index 1c3c4c05dd..583c4924dc 100644 --- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Services/DragMoveMouseGesture.cs +++ b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Services/DragMoveMouseGesture.cs @@ -28,13 +28,13 @@ namespace ICSharpCode.WpfDesign.Designer.Services /// Mouse gesture for moving elements inside a container or between containers. /// Belongs to the PointerTool. /// - sealed class DragMoveMouseGesture : ClickOrDragMouseGesture + public sealed class DragMoveMouseGesture : ClickOrDragMouseGesture { bool isDoubleClick; bool setSelectionIfNotMoving; MoveLogic moveLogic; - - internal DragMoveMouseGesture(DesignItem clickedOn, bool isDoubleClick, bool setSelectionIfNotMoving = false) + + public DragMoveMouseGesture(DesignItem clickedOn, bool isDoubleClick, bool setSelectionIfNotMoving = false) { Debug.Assert(clickedOn != null); diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Services/MouseGestureBase.cs b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Services/MouseGestureBase.cs index 4ed0c295b1..ae5cc76262 100644 --- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Services/MouseGestureBase.cs +++ b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Services/MouseGestureBase.cs @@ -25,7 +25,7 @@ namespace ICSharpCode.WpfDesign.Designer.Services /// /// Base class for classes handling mouse gestures on the design surface. /// - abstract class MouseGestureBase + public abstract class MouseGestureBase { /// /// Checks if is the only button that is currently pressed. 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 f3b0cc3433..2e7e313a62 100644 --- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/WpfDesign.Designer.csproj +++ b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/WpfDesign.Designer.csproj @@ -86,6 +86,11 @@ + + DefaultCommandsContextMenu.xaml + Code + + EditStyleContextMenu.xaml @@ -119,6 +124,9 @@ ColorEditor.xaml + + ComboBoxEditor.xaml + FlatCollectionEditor.xaml Code @@ -129,9 +137,13 @@ OpenCollectionEditor.xaml + + TextBoxEditor.xaml + TimeSpanEditor.xaml + @@ -289,6 +301,7 @@ + Designer @@ -306,12 +319,20 @@ Designer + + MSBuild:Compile + Designer + Designer MSBuild:Compile + + MSBuild:Compile + Designer + @@ -468,4 +489,12 @@ + + + + + + + + \ 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 5fbc9df801..17aa91f9bf 100644 --- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Xaml/XamlComponentService.cs +++ b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Xaml/XamlComponentService.cs @@ -28,6 +28,8 @@ namespace ICSharpCode.WpfDesign.Designer.Xaml { sealed class XamlComponentService : IComponentService { + public event EventHandler PropertyChanged; + #region IdentityEqualityComparer sealed class IdentityEqualityComparer : IEqualityComparer { @@ -140,5 +142,16 @@ namespace ICSharpCode.WpfDesign.Designer.Xaml } return site; } + + /// + /// raises the Property changed Events + /// + internal void RaisePropertyChanged(XamlModelProperty property) + { + var ev = this.PropertyChanged; + if (ev != null) { + ev(this, new DesignItemPropertyChangedEventArgs(property.DesignItem, property)); + } + } } } diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Xaml/XamlDesignContext.cs b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Xaml/XamlDesignContext.cs index 60bdac192a..f75dc27d7f 100644 --- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Xaml/XamlDesignContext.cs +++ b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Xaml/XamlDesignContext.cs @@ -27,6 +27,7 @@ using ICSharpCode.WpfDesign.Extensions; using ICSharpCode.WpfDesign.PropertyGrid; using System.Threading; using System.Globalization; +using ICSharpCode.WpfDesign.Designer.PropertyGrid.Editors; namespace ICSharpCode.WpfDesign.Designer.Xaml { @@ -91,6 +92,9 @@ namespace ICSharpCode.WpfDesign.Designer.Xaml this.Services.AddService(typeof(ITopLevelWindowService), new WpfTopLevelWindowService()); } + EditorManager.SetDefaultTextBoxEditorType(typeof(TextBoxEditor)); + EditorManager.SetDefaultComboBoxEditorType(typeof(ComboBoxEditor)); + // register extensions from the designer assemblies: foreach (Assembly designerAssembly in loadSettings.DesignerAssemblies) { this.Services.ExtensionManager.RegisterAssembly(designerAssembly); @@ -113,16 +117,16 @@ namespace ICSharpCode.WpfDesign.Designer.Xaml message = "Could not load document."; throw new XamlLoadException(message); } - + _rootItem = _componentService.RegisterXamlComponentRecursive(_doc.RootElement); - - if(_rootItem!=null){ - var rootBehavior=new RootItemBehavior(); + + if (_rootItem != null) { + var rootBehavior = new RootItemBehavior(); rootBehavior.Intialize(this); } - + + _xamlEditOperations = new XamlEditOperations(this, _parserSettings); - _xamlEditOperations=new XamlEditOperations(this,_parserSettings); } @@ -145,8 +149,8 @@ namespace ICSharpCode.WpfDesign.Designer.Xaml /// Gets the parser Settings being used /// public XamlParserSettings ParserSettings { - get { return _parserSettings; } - } + get { return _parserSettings; } + } /// /// Opens a new change group used to batch several changes. 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 736a8ef126..f877a734a9 100644 --- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Xaml/XamlDesignItem.cs +++ b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Xaml/XamlDesignItem.cs @@ -20,8 +20,11 @@ //#define EventHandlerDebugging using System; +using System.Collections.Generic; using System.Diagnostics; +using System.Linq; using System.Windows; +using System.Windows.Data; using ICSharpCode.WpfDesign.XamlDom; using ICSharpCode.WpfDesign.Designer.Services; using System.Windows.Markup; @@ -65,9 +68,13 @@ namespace ICSharpCode.WpfDesign.Designer.Xaml void SetNameInternal(string newName) { + var oldName = Name; + _xamlObject.Name = newName; + + FixDesignItemReferencesOnNameChange(oldName, Name); } - + public override string Name { get { return _xamlObject.Name; } set { @@ -75,10 +82,104 @@ namespace ICSharpCode.WpfDesign.Designer.Xaml if (undoService != null) undoService.Execute(new SetNameAction(this, value)); else + { SetNameInternal(value); + } + } } - + + /// + /// Fixes {x:Reference and {Binding ElementName to this Element in XamlDocument + /// + /// + /// + public void FixDesignItemReferencesOnNameChange(string oldName, string newName) + { + if (!string.IsNullOrEmpty(oldName) && !string.IsNullOrEmpty(newName)) { + var root = GetRootXamlObject(this.XamlObject); + var references = GetAllChildXamlObjects(root).Where(x => x.ElementType == typeof(Reference) && Equals(x.FindOrCreateProperty("Name").ValueOnInstance, oldName)); + foreach (var designItem in references) + { + var property = designItem.FindOrCreateProperty("Name"); + var propertyValue = designItem.OwnerDocument.CreatePropertyValue(newName, property); + this.ComponentService.RegisterXamlComponentRecursive(propertyValue as XamlObject); + property.PropertyValue = propertyValue; + } + + root = GetRootXamlObject(this.XamlObject, true); + var bindings = GetAllChildXamlObjects(root, true).Where(x => x.ElementType == typeof(Binding) && Equals(x.FindOrCreateProperty("ElementName").ValueOnInstance, oldName)); + foreach (var designItem in bindings) + { + var property = designItem.FindOrCreateProperty("ElementName"); + var propertyValue = designItem.OwnerDocument.CreatePropertyValue(newName, property); + this.ComponentService.RegisterXamlComponentRecursive(propertyValue as XamlObject); + property.PropertyValue = propertyValue; + } + } + } + + /// + /// Find's the Root XamlObject (real Root, or Root Object in Namescope) + /// + /// + /// + /// + private XamlObject GetRootXamlObject(XamlObject item, bool onlyFromSameNamescope = false) + { + var root = item; + while (root.ParentObject != null) + { + if (onlyFromSameNamescope && NameScopeHelper.GetNameScopeFromObject(root) != NameScopeHelper.GetNameScopeFromObject(root.ParentObject)) + break; + root = root.ParentObject; + } + + return root; + } + + /// + /// Get's all Child XamlObject Instances + /// + /// + /// + /// + private IEnumerable GetAllChildXamlObjects(XamlObject item, bool onlyFromSameNamescope = false) + { + foreach (var prop in item.Properties) + { + if (prop.PropertyValue as XamlObject != null) + { + if (!onlyFromSameNamescope || NameScopeHelper.GetNameScopeFromObject(item) == NameScopeHelper.GetNameScopeFromObject(prop.PropertyValue as XamlObject)) + yield return prop.PropertyValue as XamlObject; + + foreach (var i in GetAllChildXamlObjects(prop.PropertyValue as XamlObject)) + { + if (!onlyFromSameNamescope || NameScopeHelper.GetNameScopeFromObject(item) == NameScopeHelper.GetNameScopeFromObject(i)) + yield return i; + } + } + + if (prop.IsCollection) + { + foreach (var collectionElement in prop.CollectionElements) + { + if (collectionElement as XamlObject != null) + { + if (!onlyFromSameNamescope || NameScopeHelper.GetNameScopeFromObject(item) == NameScopeHelper.GetNameScopeFromObject(collectionElement as XamlObject)) + yield return collectionElement as XamlObject; + + foreach (var i in GetAllChildXamlObjects(collectionElement as XamlObject)) + { + if (!onlyFromSameNamescope || NameScopeHelper.GetNameScopeFromObject(item) == NameScopeHelper.GetNameScopeFromObject(i)) + yield return i; + } + } + } + } + } + } + public override string Key { get { return XamlObject.GetXamlAttribute("Key"); } set { XamlObject.SetXamlAttribute("Key", value); } @@ -163,18 +264,20 @@ namespace ICSharpCode.WpfDesign.Designer.Xaml { Debug.Assert(property != null); OnPropertyChanged(new System.ComponentModel.PropertyChangedEventArgs(property.Name)); + + ((XamlComponentService)this.Services.Component).RaisePropertyChanged(property); } public override string ContentPropertyName { get { - return XamlObject.ContentPropertyName; + return XamlObject.ContentPropertyName; } } /// /// Item is Locked at Design Time /// - public bool IsDesignTimeLocked { + public bool IsDesignTimeLocked { get { var locked = Properties.GetAttachedProperty(DesignTimeProperties.IsLockedProperty).ValueOnInstance; return (locked != null && (bool) locked == true); @@ -185,20 +288,20 @@ namespace ICSharpCode.WpfDesign.Designer.Xaml else Properties.GetAttachedProperty(DesignTimeProperties.IsLockedProperty).Reset(); } - + } public override DesignItem Clone() { DesignItem item = null; - var xaml = XamlStaticTools.GetXaml(this.XamlObject); - XamlDesignItem rootItem = Context.RootItem as XamlDesignItem; - var obj = XamlParser.ParseSnippet(rootItem.XamlObject, xaml, ((XamlDesignContext) Context).ParserSettings); - if (obj != null) - { - item = ((XamlDesignContext)Context)._componentService.RegisterXamlComponentRecursive(obj); - } - return item; + var xaml = XamlStaticTools.GetXaml(this.XamlObject); + XamlDesignItem rootItem = Context.RootItem as XamlDesignItem; + var obj = XamlParser.ParseSnippet(rootItem.XamlObject, xaml, ((XamlDesignContext) Context).ParserSettings); + if (obj != null) + { + item = ((XamlDesignContext)Context)._componentService.RegisterXamlComponentRecursive(obj); + } + return item; } sealed class SetNameAction : ITransactionItem diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Xaml/XamlEditOperations.cs b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Xaml/XamlEditOperations.cs index e50b2798c2..be2964d11a 100644 --- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Xaml/XamlEditOperations.cs +++ b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Xaml/XamlEditOperations.cs @@ -131,7 +131,7 @@ namespace ICSharpCode.WpfDesign.Designer.Xaml AddInParent(parent, pastedItems); pasted = true; } - } else if (pastedItems.Count == 1 && parent.ContentProperty.Value == null && parent.ContentProperty.ValueOnInstance == null && parent.View is ContentControl && DefaultPlacementBehavior.CanContentControlAdd((ContentControl)parent.View)) { + } else if (pastedItems.Count == 1 && parent.ContentProperty.Value == null && parent.ContentProperty.ValueOnInstance == null && parent.View is ContentControl) { AddInParent(parent, pastedItems); pasted = true; } diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/themes/VersionedAssemblyResourceDictionary.cs b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/themes/VersionedAssemblyResourceDictionary.cs new file mode 100644 index 0000000000..24c679b196 --- /dev/null +++ b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/themes/VersionedAssemblyResourceDictionary.cs @@ -0,0 +1,52 @@ +// Copyright (c) 2014 AlphaSierraPapa for the SharpDevelop Team +// +// Permission is hereby granted, free of charge, to any person obtaining a copy of this +// software and associated documentation files (the "Software"), to deal in the Software +// without restriction, including without limitation the rights to use, copy, modify, merge, +// publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons +// to whom the Software is furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all copies or +// substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, +// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR +// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE +// FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +// DEALINGS IN THE SOFTWARE. + +using System; +using System.ComponentModel; +using System.Windows; + +namespace ICSharpCode.WpfDesign.Designer.themes +{ + public class VersionedAssemblyResourceDictionary : ResourceDictionary, ISupportInitialize + { + private static readonly string _uriStart; + + private static readonly int _subLength; + + static VersionedAssemblyResourceDictionary() + { + var nm = typeof(VersionedAssemblyResourceDictionary).Assembly.GetName(); + _uriStart = string.Format( @"{0};v{1};component/", nm.Name, nm.Version); + + _subLength = "ICSharpCode.WpfDesign.Designer.".Length; + } + + public string RelativePath {get;set;} + + void ISupportInitialize.EndInit() + { + this.Source = new Uri(_uriStart + this.RelativePath, UriKind.Relative); + base.EndInit(); + } + + public static string GetXamlNameForType(Type t) + { + return _uriStart + t.FullName.Substring(_subLength).Replace(".","/").ToLower() + ".xaml"; + } + } +} diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/themes/generic.xaml b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/themes/generic.xaml index 0b149ec427..99acb3ace4 100644 --- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/themes/generic.xaml +++ b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/themes/generic.xaml @@ -1,10 +1,13 @@ - + - - - - - + + + + + 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 9356d98579..5355a3d4bf 100644 --- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Tests/Designer/ModelTests.cs +++ b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Tests/Designer/ModelTests.cs @@ -596,7 +596,13 @@ namespace ICSharpCode.WpfDesign.Tests.Designer DesignItem textBox = canvas.Services.Component.RegisterComponentForDesigner(new TextBox()); canvas.Properties["Children"].CollectionElements.Add(textBox); - DesignItemProperty resProp = textBox.Properties.GetProperty("Resources"); + DesignItemProperty resProp = button.Properties.GetProperty("Resources"); + Assert.IsTrue(resProp.IsCollection); + DesignItem dummyItem = canvas.Services.Component.RegisterComponentForDesigner(new ExampleClass()); + dummyItem.Key = "dummy"; + resProp.CollectionElements.Add(dummyItem); + + resProp = textBox.Properties.GetProperty("Resources"); Assert.IsTrue(resProp.IsCollection); DesignItem exampleClassItem = canvas.Services.Component.RegisterComponentForDesigner(new ExampleClass()); exampleClassItem.Key = "bindingSource"; @@ -605,23 +611,39 @@ namespace ICSharpCode.WpfDesign.Tests.Designer DesignItem bindingItem = canvas.Services.Component.RegisterComponentForDesigner(new Binding()); if (!setBindingPropertiesAfterSet) { bindingItem.Properties["Path"].SetValue("StringProp"); + // Using resource "dummy" before "bindingSource" to enable test where not the first set property will require element-style print of the binding + bindingItem.Properties["ConverterParameter"].SetValue(new StaticResourceExtension()); + bindingItem.Properties["ConverterParameter"].Value.Properties["ResourceKey"].SetValue("dummy"); bindingItem.Properties["Source"].SetValue(new StaticResourceExtension()); bindingItem.Properties["Source"].Value.Properties["ResourceKey"].SetValue("bindingSource"); } textBox.Properties[TextBox.TextProperty].SetValue(bindingItem); if (setBindingPropertiesAfterSet) { bindingItem.Properties["Path"].SetValue("StringProp"); + // Using resource "dummy" before "bindingSource" to enable test where not the first set property will require element-style print of the binding + bindingItem.Properties["ConverterParameter"].SetValue(new StaticResourceExtension()); + bindingItem.Properties["ConverterParameter"].Value.Properties["ResourceKey"].SetValue("dummy"); bindingItem.Properties["Source"].SetValue(new StaticResourceExtension()); bindingItem.Properties["Source"].Value.Properties["ResourceKey"].SetValue("bindingSource"); } - string expectedXaml = "\n" + + "\n" + + " \n" + + " \n" + + " \n" + + " \n" + + ""; AssertCanvasDesignerOutput(expectedXaml, button.Context); AssertLog(""); @@ -667,6 +689,36 @@ namespace ICSharpCode.WpfDesign.Tests.Designer AssertLog(""); } + [Test] + public void AddMarkupExtensionWithoutWrapperToCollection() + { + DesignItem textBox = CreateCanvasContext(""); + + DesignItem multiBindingItem = textBox.Context.Services.Component.RegisterComponentForDesigner(new System.Windows.Data.MultiBinding()); + multiBindingItem.Properties["Converter"].SetValue(new ICSharpCode.WpfDesign.Tests.XamlDom.MyMultiConverter()); + DesignItemProperty bindingsProp = multiBindingItem.ContentProperty; + + // MyBindingExtension is a markup extension that will not use a wrapper. + DesignItem myBindingExtension = textBox.Context.Services.Component.RegisterComponentForDesigner(new ICSharpCode.WpfDesign.Tests.XamlDom.MyBindingExtension()); + + // Adding it to MultiBinding "Bindings" collection. + bindingsProp.CollectionElements.Add(myBindingExtension); + + textBox.ContentProperty.SetValue(multiBindingItem); + + const string expectedXaml = "\n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + ""; + + AssertCanvasDesignerOutput(expectedXaml, textBox.Context, "xmlns:Controls0=\"" + ICSharpCode.WpfDesign.Tests.XamlDom.XamlTypeFinderTests.XamlDomTestsNamespace + "\""); + AssertLog(""); + } + [Test] public void AddBrushAsResource() { diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Tests/XamlDom/MarkupExtensionTests.cs b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Tests/XamlDom/MarkupExtensionTests.cs index c9510b1638..8899379cae 100644 --- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Tests/XamlDom/MarkupExtensionTests.cs +++ b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Tests/XamlDom/MarkupExtensionTests.cs @@ -133,6 +133,7 @@ namespace ICSharpCode.WpfDesign.Tests.XamlDom + "; @@ -157,7 +158,7 @@ namespace ICSharpCode.WpfDesign.Tests.XamlDom var converter = expr.ParentMultiBinding.Converter as MyMultiConverter; Assert.IsNotNull(converter); - Assert.AreEqual(expr.ParentMultiBinding.Bindings.Count, 1); + Assert.AreEqual(expr.ParentMultiBinding.Bindings.Count, 2); } [Test] @@ -267,4 +268,23 @@ namespace ICSharpCode.WpfDesign.Tests.XamlDom #endregion } + + public class MyBindingExtension : MarkupExtension + { + readonly Binding binding = new Binding(); + + public MyBindingExtension() + { + var exampleClass = new ExampleClass(); + exampleClass.StringProp = "Test"; + + binding.Source = exampleClass; + binding.Path = new PropertyPath("StringProp"); + } + + public override object ProvideValue(IServiceProvider serviceProvider) + { + return binding.ProvideValue(serviceProvider); + } + } } diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Tests/XamlDom/SamplesTests.cs b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Tests/XamlDom/SamplesTests.cs index 6dc0487c85..dafb25d8d9 100644 --- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Tests/XamlDom/SamplesTests.cs +++ b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Tests/XamlDom/SamplesTests.cs @@ -452,7 +452,6 @@ namespace ICSharpCode.WpfDesign.Tests.XamlDom } [Test] - [Ignore("Xaml writer creates different XAML")] public void Style3() { TestLoading(@""); } + [Test] + public void Template2() + { + TestLoading(@" + + + + + + + + + + + + + +"); + } [Test] public void ListBox1() diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Tests/XamlDom/SimpleLoadTests.cs b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Tests/XamlDom/SimpleLoadTests.cs index 1854242157..b60120ff35 100644 --- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Tests/XamlDom/SimpleLoadTests.cs +++ b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Tests/XamlDom/SimpleLoadTests.cs @@ -293,7 +293,6 @@ namespace ICSharpCode.WpfDesign.Tests.XamlDom } [Test] - [Ignore("Own XamlParser should handle different namespaces pointing to same types, because builtin XamlReader does.")] public void ResourceDictionaryExplicitNetfx2007() { // The reason this test case fails is because own XamlParser cannot always handle the case where multiple xmlns points to the same type. diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.XamlDom/Project/DesignInstanceExtension.cs b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.XamlDom/Project/DesignInstanceExtension.cs new file mode 100644 index 0000000000..fddb3fcadf --- /dev/null +++ b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.XamlDom/Project/DesignInstanceExtension.cs @@ -0,0 +1,27 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Windows.Markup; + +namespace ICSharpCode.WpfDesign.XamlDom +{ + public class DesignInstanceExtension : MarkupExtension + { + public DesignInstanceExtension(Type type) + { + this.Type = type; + } + + public Type Type { get; set; } + + public bool IsDesignTimeCreatable { get; set; } + + public bool CreateList { get; set; } + + public override object ProvideValue(IServiceProvider serviceProvider) + { + return null; + } + } +} diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.XamlDom/Project/MarkupExtensionPrinter.cs b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.XamlDom/Project/MarkupExtensionPrinter.cs index c2b1ba243b..aaea8be6e7 100644 --- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.XamlDom/Project/MarkupExtensionPrinter.cs +++ b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.XamlDom/Project/MarkupExtensionPrinter.cs @@ -137,8 +137,8 @@ namespace ICSharpCode.WpfDesign.XamlDom var xamlObject = value as XamlObject; if (xamlObject == null || !xamlObject.IsMarkupExtension) return false; - else - return CanPrint(xamlObject, true, nonMarkupExtensionParent); + else if (!CanPrint(xamlObject, true, nonMarkupExtensionParent)) + return false; } } diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.XamlDom/Project/TemplateHelper.cs b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.XamlDom/Project/TemplateHelper.cs index 263659a057..6624bb4ec1 100644 --- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.XamlDom/Project/TemplateHelper.cs +++ b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.XamlDom/Project/TemplateHelper.cs @@ -17,6 +17,7 @@ // DEALINGS IN THE SOFTWARE. using System; +using System.Collections; using System.Collections.Generic; using System.IO; using System.Linq; @@ -24,6 +25,7 @@ using System.Reflection; using System.Windows; using System.Windows.Controls; using System.Windows.Markup; +using System.Xaml; using System.Xml; using System.Xml.XPath; @@ -31,8 +33,9 @@ namespace ICSharpCode.WpfDesign.XamlDom { public static class TemplateHelper { - public static FrameworkTemplate GetFrameworkTemplate(XmlElement xmlElement) + public static FrameworkTemplate GetFrameworkTemplate(XmlElement xmlElement, XamlObject parentObject) { + var nav = xmlElement.CreateNavigator(); var ns = new Dictionary(); @@ -47,16 +50,89 @@ namespace ICSharpCode.WpfDesign.XamlDom if (!nav.MoveToParent()) break; } + + xmlElement = (XmlElement)xmlElement.CloneNode(true); - foreach (var dictentry in ns) + foreach (var dictentry in ns.ToList()) { xmlElement.SetAttribute("xmlns:" + dictentry.Key, dictentry.Value); } - + + var keyAttrib = xmlElement.GetAttribute("Key", XamlConstants.XamlNamespace); + + if (string.IsNullOrEmpty(keyAttrib)) { + xmlElement.SetAttribute("Key", XamlConstants.XamlNamespace, "$$temp&&§§%%__"); + } + var xaml = xmlElement.OuterXml; + xaml = "" + xaml + ""; StringReader stringReader = new StringReader(xaml); XmlReader xmlReader = XmlReader.Create(stringReader); - return (FrameworkTemplate)XamlReader.Load(xmlReader); + var xamlReader = new XamlXmlReader(xmlReader, parentObject.ServiceProvider.SchemaContext); + + var seti = new XamlObjectWriterSettings(); + + var resourceDictionary = new ResourceDictionary(); + var obj = parentObject; + while (obj != null) + { + if (obj.Instance is ResourceDictionary) + { + var r = obj.Instance as ResourceDictionary; + foreach (var k in r.Keys) + { + if (!resourceDictionary.Contains(k)) + resourceDictionary.Add(k, r[k]); + } + } + else if (obj.Instance is FrameworkElement) + { + var r = ((FrameworkElement)obj.Instance).Resources; + foreach (var k in r.Keys) + { + if (!resourceDictionary.Contains(k)) + resourceDictionary.Add(k, r[k]); + } + } + + obj = obj.ParentObject; + } + + seti.BeforePropertiesHandler = (s, e) => + { + if (seti.BeforePropertiesHandler != null) + { + var rr = e.Instance as ResourceDictionary; + rr.MergedDictionaries.Add(resourceDictionary); + seti.BeforePropertiesHandler = null; + } + }; + + var writer = new XamlObjectWriter(parentObject.ServiceProvider.SchemaContext, seti); + + XamlServices.Transform(xamlReader, writer); + + var result = (ResourceDictionary)writer.Result; + + var enr = result.Keys.GetEnumerator(); + enr.MoveNext(); + var rdKey = enr.Current; + + var template = result[rdKey] as FrameworkTemplate; + + result.Remove(rdKey); + return template; + } + + + private static Stream GenerateStreamFromString(string s) + { + MemoryStream stream = new MemoryStream(); + StreamWriter writer = new StreamWriter(stream); + writer.Write(s); + writer.Flush(); + stream.Position = 0; + return stream; } } } diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.XamlDom/Project/WpfDesign.XamlDom.csproj b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.XamlDom/Project/WpfDesign.XamlDom.csproj index dc41471707..20d8f9dbf5 100644 --- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.XamlDom/Project/WpfDesign.XamlDom.csproj +++ b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.XamlDom/Project/WpfDesign.XamlDom.csproj @@ -69,6 +69,7 @@ + diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.XamlDom/Project/XamlDocument.cs b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.XamlDom/Project/XamlDocument.cs index b09468d7c8..49abdacf13 100644 --- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.XamlDom/Project/XamlDocument.cs +++ b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.XamlDom/Project/XamlDocument.cs @@ -228,6 +228,16 @@ namespace ICSharpCode.WpfDesign.XamlDom return _typeFinder.GetXmlNamespaceFor(type.Assembly, type.Namespace, getClrNamespace); } + + internal List GetNamespacesFor(Type type, bool getClrNamespace = false) + { + if (type == typeof (DesignTimeProperties)) + return new List(){XamlConstants.DesignTimeNamespace}; + if (type == typeof (MarkupCompatibilityProperties)) + return new List(){XamlConstants.MarkupCompatibilityNamespace}; + + return _typeFinder.GetXmlNamespacesFor(type.Assembly, type.Namespace, getClrNamespace); + } internal string GetPrefixForNamespace(string @namespace) { diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.XamlDom/Project/XamlObject.cs b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.XamlDom/Project/XamlObject.cs index 626d6849ee..9068d2e3d4 100644 --- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.XamlDom/Project/XamlObject.cs +++ b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.XamlDom/Project/XamlObject.cs @@ -272,10 +272,23 @@ namespace ICSharpCode.WpfDesign.XamlDom NameChanged(this, EventArgs.Empty); } } + + void UpdateChildMarkupExtensions(XamlObject obj) + { + foreach (XamlObject propXamlObject in obj.Properties.Where((prop) => prop.IsSet).Select((prop) => prop.PropertyValue).OfType()) { + UpdateChildMarkupExtensions(propXamlObject); + } + + if (obj.IsMarkupExtension && obj.ParentProperty != null) { + obj.ParentProperty.UpdateValueOnInstance(); + } + } void UpdateMarkupExtensionChain() { - var obj = this; + UpdateChildMarkupExtensions(this); + + var obj = this.ParentObject; while (obj != null && obj.IsMarkupExtension && obj.ParentProperty != null) { obj.ParentProperty.UpdateValueOnInstance(); obj = obj.ParentObject; @@ -426,11 +439,23 @@ namespace ICSharpCode.WpfDesign.XamlDom PropertyDescriptorCollection propertyDescriptors = TypeDescriptor.GetProperties(instance); PropertyDescriptor propertyInfo = propertyDescriptors[propertyName]; XamlProperty newProperty; + + if (propertyInfo == null) { + propertyDescriptors = TypeDescriptor.GetProperties(this.elementType); + propertyInfo = propertyDescriptors[propertyName]; + } + if (propertyInfo != null) { newProperty = new XamlProperty(this, new XamlNormalPropertyInfo(propertyInfo)); } else { EventDescriptorCollection events = TypeDescriptor.GetEvents(instance); EventDescriptor eventInfo = events[propertyName]; + + if (eventInfo == null) { + events = TypeDescriptor.GetEvents(this.elementType); + eventInfo = events[propertyName]; + } + if (eventInfo != null) { newProperty = new XamlProperty(this, new XamlEventPropertyInfo(eventInfo)); } else { @@ -503,7 +528,17 @@ namespace ICSharpCode.WpfDesign.XamlDom if (value == null) element.RemoveAttribute(name, XamlConstants.XamlNamespace); else - element.SetAttribute(name, XamlConstants.XamlNamespace, value); + { + var prefix = element.GetPrefixOfNamespace(XamlConstants.XamlNamespace); + if (!string.IsNullOrEmpty(prefix)) + { + var attribute = element.OwnerDocument.CreateAttribute(prefix, name, XamlConstants.XamlNamespace); + attribute.InnerText = value; + element.SetAttributeNode(attribute); + } + else + element.SetAttribute(name, XamlConstants.XamlNamespace, value); + } if (isNameChange) { bool nameChangedAlreadyRaised = false; @@ -548,7 +583,7 @@ namespace ICSharpCode.WpfDesign.XamlDom if (wrapper != null) { return wrapper.ProvideValue(); } - if (this.ParentObject.ElementType == typeof (Setter) && this.ElementType == typeof(DynamicResourceExtension)) + if (this.ParentObject != null && this.ParentObject.ElementType == typeof (Setter) && this.ElementType == typeof(DynamicResourceExtension)) return Instance; return (Instance as MarkupExtension).ProvideValue(ServiceProvider); } diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.XamlDom/Project/XamlObjectServiceProvider.cs b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.XamlDom/Project/XamlObjectServiceProvider.cs index 0afa53096f..76fb65d3a4 100644 --- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.XamlDom/Project/XamlObjectServiceProvider.cs +++ b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.XamlDom/Project/XamlObjectServiceProvider.cs @@ -136,7 +136,7 @@ namespace ICSharpCode.WpfDesign.XamlDom { get { - return iCsharpXamlSchemaContext = iCsharpXamlSchemaContext ?? new XamlSchemaContext(); + return iCsharpXamlSchemaContext = iCsharpXamlSchemaContext ?? System.Windows.Markup.XamlReader.GetWpfSchemaContext(); // new XamlSchemaContext(); } } diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.XamlDom/Project/XamlParser.cs b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.XamlDom/Project/XamlParser.cs index 06f637ddcb..ab190e58ba 100644 --- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.XamlDom/Project/XamlParser.cs +++ b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.XamlDom/Project/XamlParser.cs @@ -28,6 +28,7 @@ using System.Windows; using System.Windows.Interop; using System.Windows.Markup; using System.Xml; +using System.Windows.Media; namespace ICSharpCode.WpfDesign.XamlDom { @@ -146,6 +147,8 @@ namespace ICSharpCode.WpfDesign.XamlDom static Type FindType(XamlTypeFinder typeFinder, string namespaceUri, string localName) { Type elementType = typeFinder.GetType(namespaceUri, localName); + if (elementType == null) + elementType = typeFinder.GetType(namespaceUri, localName+"Extension"); if (elementType == null) throw new XamlLoadException("Cannot find type " + localName + " in " + namespaceUri); return elementType; @@ -195,7 +198,7 @@ namespace ICSharpCode.WpfDesign.XamlDom if (typeof (FrameworkTemplate).IsAssignableFrom(elementType)) { - var xamlObj = new XamlObject(document, element, elementType, TemplateHelper.GetFrameworkTemplate(element)); + var xamlObj = new XamlObject(document, element, elementType, TemplateHelper.GetFrameworkTemplate(element, currentXamlObject)); xamlObj.ParentObject = currentXamlObject; return xamlObj; } @@ -323,8 +326,11 @@ namespace ICSharpCode.WpfDesign.XamlDom if (defaultProperty == null && obj.Instance != null && CollectionSupport.IsCollectionType(obj.Instance.GetType())) { XamlObject parentObj = obj.ParentObject; var parentElement = element.ParentNode; - XamlPropertyInfo propertyInfo = GetPropertyInfo(settings.TypeFinder, parentObj.Instance, parentObj.ElementType, parentElement.NamespaceURI, parentElement.LocalName); - collectionProperty = FindExistingXamlProperty(parentObj, propertyInfo); + XamlPropertyInfo propertyInfo; + if (parentObj != null) { + propertyInfo = GetPropertyInfo(settings.TypeFinder, parentObj.Instance, parentObj.ElementType, parentElement.NamespaceURI, parentElement.LocalName); + collectionProperty = FindExistingXamlProperty(parentObj, propertyInfo); + } collectionInstance = obj.Instance; collectionType = obj.ElementType; collectionPropertyElement = element; @@ -500,6 +506,7 @@ namespace ICSharpCode.WpfDesign.XamlDom if (eventInfo != null) { return new XamlEventPropertyInfo(eventInfo); } + throw new XamlLoadException("property " + propertyName + " not found"); } @@ -507,23 +514,42 @@ namespace ICSharpCode.WpfDesign.XamlDom { MethodInfo getMethod = elementType.GetMethod("Get" + propertyName, BindingFlags.Public | BindingFlags.Static); MethodInfo setMethod = elementType.GetMethod("Set" + propertyName, BindingFlags.Public | BindingFlags.Static); - if (getMethod != null && setMethod != null) { + if (getMethod != null || setMethod != null) { FieldInfo field = elementType.GetField(propertyName + "Property", BindingFlags.Public | BindingFlags.Static); if (field != null && field.FieldType == typeof(DependencyProperty)) { return new XamlDependencyPropertyInfo((DependencyProperty)field.GetValue(null), true); } } - + if (elementType.BaseType != null) { return TryFindAttachedProperty(elementType.BaseType, propertyName); } return null; } - + + internal static XamlPropertyInfo TryFindAttachedEvent(Type elementType, string propertyName) + { + FieldInfo fieldEvent = elementType.GetField(propertyName + "Event", BindingFlags.Public | BindingFlags.Static); + if (fieldEvent != null && fieldEvent.FieldType == typeof(RoutedEvent)) + { + return new XamlEventPropertyInfo(TypeDescriptor.GetEvents(elementType)[propertyName]); + } + + if (elementType.BaseType != null) + { + return TryFindAttachedEvent(elementType.BaseType, propertyName); + } + + return null; + } static XamlPropertyInfo FindAttachedProperty(Type elementType, string propertyName) { XamlPropertyInfo pi = TryFindAttachedProperty(elementType, propertyName); + + if (pi == null) { + pi = TryFindAttachedEvent(elementType, propertyName); + } if (pi != null) { return pi; } else { @@ -555,7 +581,14 @@ namespace ICSharpCode.WpfDesign.XamlDom return FindAttachedProperty(typeof(DesignTimeProperties), attribute.LocalName); } else if (attribute.LocalName == "IsLocked" && attribute.NamespaceURI == XamlConstants.DesignTimeNamespace) { return FindAttachedProperty(typeof(DesignTimeProperties), attribute.LocalName); + } else if (attribute.LocalName == "LayoutOverrides" && attribute.NamespaceURI == XamlConstants.DesignTimeNamespace) { + return FindAttachedProperty(typeof(DesignTimeProperties), attribute.LocalName); + } else if (attribute.LocalName == "LayoutRounding" && attribute.NamespaceURI == XamlConstants.DesignTimeNamespace) { + return FindAttachedProperty(typeof(DesignTimeProperties), attribute.LocalName); + } else if (attribute.LocalName == "DataContext" && attribute.NamespaceURI == XamlConstants.DesignTimeNamespace) { + return FindAttachedProperty(typeof(DesignTimeProperties), attribute.LocalName); } + return null; } @@ -674,6 +707,7 @@ namespace ICSharpCode.WpfDesign.XamlDom else { collectionInstance = collectionProperty.propertyInfo.GetValue(obj.Instance); collectionProperty.ParserSetPropertyElement(element); + collectionInstance = collectionInstance ?? Activator.CreateInstance(collectionProperty.propertyInfo.ReturnType); } } @@ -712,6 +746,13 @@ namespace ICSharpCode.WpfDesign.XamlDom internal static object CreateObjectFromAttributeText(string valueText, XamlPropertyInfo targetProperty, XamlObject scope) { + if (targetProperty.ReturnType == typeof(Uri)) { + return scope.OwnerDocument.TypeFinder.ConvertUriToLocalUri(new Uri(valueText, UriKind.RelativeOrAbsolute)); + } else if (targetProperty.ReturnType == typeof(ImageSource)) { + var uri = scope.OwnerDocument.TypeFinder.ConvertUriToLocalUri(new Uri(valueText, UriKind.RelativeOrAbsolute)); + return targetProperty.TypeConverter.ConvertFromString(scope.OwnerDocument.GetTypeDescriptorContext(scope), CultureInfo.InvariantCulture, uri.ToString()); + } + return targetProperty.TypeConverter.ConvertFromString( scope.OwnerDocument.GetTypeDescriptorContext(scope), CultureInfo.InvariantCulture, valueText); @@ -759,7 +800,7 @@ namespace ICSharpCode.WpfDesign.XamlDom } } } - + /// /// Method use to parse a piece of Xaml. /// @@ -768,6 +809,19 @@ namespace ICSharpCode.WpfDesign.XamlDom /// Parser settings used by . /// Returns the XamlObject of the parsed . public static XamlObject ParseSnippet(XamlObject root, string xaml, XamlParserSettings settings) + { + return ParseSnippet(root, xaml, settings, null); + } + + /// + /// Method use to parse a piece of Xaml. + /// + /// The Root XamlObject of the current document. + /// The Xaml being parsed. + /// Parser settings used by . + /// Parent Object, where the Parsed snippet will be inserted (Needed for Example for Bindings). + /// Returns the XamlObject of the parsed . + public static XamlObject ParseSnippet(XamlObject root, string xaml, XamlParserSettings settings, XamlObject parentObject) { XmlTextReader reader = new XmlTextReader(new StringReader(xaml)); var element = root.OwnerDocument.XmlDocument.ReadNode(reader); @@ -785,6 +839,7 @@ namespace ICSharpCode.WpfDesign.XamlDom parser.settings = settings; parser.errorSink = (IXamlErrorSink)settings.ServiceProvider.GetService(typeof(IXamlErrorSink)); parser.document = root.OwnerDocument; + parser.currentXamlObject = parentObject; var xamlObject = parser.ParseObject(element as XmlElement); RemoveRootNamespacesFromNodeAndChildNodes(root, element); diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.XamlDom/Project/XamlProperty.cs b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.XamlDom/Project/XamlProperty.cs index 3c5cab4bce..d408c95746 100644 --- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.XamlDom/Project/XamlProperty.cs +++ b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.XamlDom/Project/XamlProperty.cs @@ -356,19 +356,19 @@ namespace ICSharpCode.WpfDesign.XamlDom static XmlNode FindChildNode(XmlNode node, Type elementType, string propertyName, XamlDocument xamlDocument) { var localName = elementType.Name + "." + propertyName; - var namespaceURI = xamlDocument.GetNamespaceFor(elementType); + var namespacesURI = xamlDocument.GetNamespacesFor(elementType); var clrNamespaceURI = xamlDocument.GetNamespaceFor(elementType, true); foreach (XmlNode childNode in node.ChildNodes) { - if (childNode.LocalName == localName && (childNode.NamespaceURI == namespaceURI || childNode.NamespaceURI == clrNamespaceURI)) + if (childNode.LocalName == localName && (namespacesURI.Contains(childNode.NamespaceURI) || childNode.NamespaceURI == clrNamespaceURI)) { return childNode; } } var type = elementType.BaseType; - namespaceURI = xamlDocument.GetNamespaceFor(type); + namespacesURI = xamlDocument.GetNamespacesFor(type); while (type != typeof(object)) { @@ -379,7 +379,7 @@ namespace ICSharpCode.WpfDesign.XamlDom foreach (XmlNode childNode in node.ChildNodes) { - if (childNode.LocalName == localName && childNode.NamespaceURI == namespaceURI) + if (childNode.LocalName == localName && namespacesURI.Contains(childNode.NamespaceURI)) { return childNode; } @@ -556,7 +556,13 @@ namespace ICSharpCode.WpfDesign.XamlDom } } set { - propertyInfo.SetValue(parentObject.Instance, value); + var setValue = value; + if (propertyInfo.ReturnType == typeof(Uri)) + { + setValue = this.ParentObject.OwnerDocument.TypeFinder.ConvertUriToLocalUri((Uri)value); + } + + propertyInfo.SetValue(parentObject.Instance, setValue); if (ValueOnInstanceChanged != null) ValueOnInstanceChanged(this, EventArgs.Empty); } diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.XamlDom/Project/XamlTypeFinder.cs b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.XamlDom/Project/XamlTypeFinder.cs index 7d341859c8..3373b4772d 100644 --- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.XamlDom/Project/XamlTypeFinder.cs +++ b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.XamlDom/Project/XamlTypeFinder.cs @@ -19,6 +19,7 @@ using System; using System.Collections.Generic; using System.Diagnostics; +using System.Linq; using System.Reflection; using System.Windows.Markup; using System.Xaml; @@ -82,6 +83,7 @@ namespace ICSharpCode.WpfDesign.XamlDom Dictionary namespaces = new Dictionary(); Dictionary reverseDict = new Dictionary(); + Dictionary> reverseDictList = new Dictionary>(); /// /// Gets a type referenced in XAML. @@ -128,6 +130,20 @@ namespace ICSharpCode.WpfDesign.XamlDom } } + /// + /// Gets the XML namespaces that can be used for the specified assembly/namespace combination. + /// + public List GetXmlNamespacesFor(Assembly assembly, string @namespace, bool getClrNamespace = false) + { + AssemblyNamespaceMapping mapping = new AssemblyNamespaceMapping(assembly, @namespace); + List xmlNamespaces; + if (!getClrNamespace && reverseDictList.TryGetValue(mapping, out xmlNamespaces)) { + return xmlNamespaces; + } else { + return new List() { "clr-namespace:" + mapping.Namespace + ";assembly=" + mapping.Assembly.GetName().Name }; + } + } + /// /// Gets the prefix to use for the specified XML namespace, /// or null if no suitable prefix could be found. @@ -178,6 +194,14 @@ namespace ICSharpCode.WpfDesign.XamlDom { ns.ClrNamespaces.Add(mapping); + List xmlNamespaceList; + if (reverseDictList.TryGetValue(mapping, out xmlNamespaceList)) { + if (!xmlNamespaceList.Contains(ns.XmlNamespace)) + xmlNamespaceList.Add(ns.XmlNamespace); + } + else + reverseDictList.Add(mapping, new List(){ ns.XmlNamespace }); + string xmlNamespace; if (reverseDict.TryGetValue(mapping, out xmlNamespace)) { if (xmlNamespace == XamlConstants.PresentationNamespace) { @@ -262,6 +286,9 @@ namespace ICSharpCode.WpfDesign.XamlDom foreach (KeyValuePair pair in source.reverseDict) { this.reverseDict.Add(pair.Key, pair.Value); } + foreach (KeyValuePair> pair in source.reverseDictList) { + this.reverseDictList.Add(pair.Key, pair.Value.ToList()); + } } object ICloneable.Clone() @@ -277,6 +304,11 @@ namespace ICSharpCode.WpfDesign.XamlDom return WpfTypeFinder.Instance.Clone(); } + public virtual Uri ConvertUriToLocalUri(Uri uri) + { + return uri; + } + static class WpfTypeFinder { internal static readonly XamlTypeFinder Instance; @@ -291,6 +323,7 @@ namespace ICSharpCode.WpfDesign.XamlDom Instance.RegisterAssembly(typeof(IAddChild).Assembly); // PresentationCore Instance.RegisterAssembly(typeof(XamlReader).Assembly); // PresentationFramework Instance.RegisterAssembly(typeof(XamlType).Assembly); // System.Xaml + Instance.RegisterAssembly(typeof(Type).Assembly); // mscorelib } } } diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/DesignItem.cs b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/DesignItem.cs index 0d31aabc6c..287f8833da 100644 --- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/DesignItem.cs +++ b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/DesignItem.cs @@ -161,6 +161,13 @@ namespace ICSharpCode.WpfDesign for (int i = 0; i < _extensionServers.Length; i++) { if (_extensionServers[i] == server) { bool shouldApply = server.ShouldApplyExtensions(this); + + if (server.ShouldBeReApplied() && shouldApply && shouldApply == _extensionServerIsApplied[i]) + { + _extensionServerIsApplied[i] = false; + ApplyUnapplyExtensionServer(extensionManager, false, server); + } + if (shouldApply != _extensionServerIsApplied[i]) { _extensionServerIsApplied[i] = shouldApply; ApplyUnapplyExtensionServer(extensionManager, shouldApply, server); diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/EventArgs.cs b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/EventArgs.cs index 048a4fb335..f137b3ee99 100644 --- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/EventArgs.cs +++ b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/EventArgs.cs @@ -44,6 +44,29 @@ namespace ICSharpCode.WpfDesign } } + /// + /// Event arguments specifying a component and property as parameter. + /// + public class DesignItemPropertyChangedEventArgs : DesignItemEventArgs + { + readonly DesignItemProperty _itemProperty; + + /// + /// Creates a new ComponentEventArgs instance. + /// + public DesignItemPropertyChangedEventArgs(DesignItem item, DesignItemProperty itemProperty) : base(item) + { + _itemProperty = itemProperty; + } + + /// + /// The property affected by the event. + /// + public DesignItemProperty ItemProperty { + get { return _itemProperty; } + } + } + /// /// Event arguments specifying a component as parameter. /// diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/Extensions/Extension.cs b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/Extensions/Extension.cs index d7c989da3f..6c0dafc0d5 100644 --- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/Extensions/Extension.cs +++ b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/Extensions/Extension.cs @@ -18,6 +18,7 @@ using System; using System.Diagnostics; +using System.Windows; namespace ICSharpCode.WpfDesign.Extensions { @@ -32,5 +33,19 @@ namespace ICSharpCode.WpfDesign.Extensions /// public abstract class Extension { + public static string GetDisabledExtensions(DependencyObject obj) + { + return (string)obj.GetValue(DisabledExtensionsProperty); + } + + public static void SetDisabledExtensions(DependencyObject obj, string value) + { + obj.SetValue(DisabledExtensionsProperty, value); + } + + public static readonly DependencyProperty DisabledExtensionsProperty = + DependencyProperty.RegisterAttached("DisabledExtensions", typeof(string), typeof(Extension), new PropertyMetadata(null)); + + } } diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/Extensions/ExtensionManager.cs b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/Extensions/ExtensionManager.cs index 676e2400da..4b9ea25979 100644 --- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/Extensions/ExtensionManager.cs +++ b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/Extensions/ExtensionManager.cs @@ -65,14 +65,14 @@ namespace ICSharpCode.WpfDesign.Extensions internal readonly Type ExtensionType; internal readonly ExtensionServer Server; internal readonly Type OverriddenExtensionType; - internal readonly int Order; + internal readonly int Order; - public ExtensionEntry(Type extensionType, ExtensionServer server, Type overriddenExtensionType, int Order) + public ExtensionEntry(Type extensionType, ExtensionServer server, Type overriddenExtensionType, int Order) { this.ExtensionType = extensionType; this.Server = server; this.OverriddenExtensionType = overriddenExtensionType; - this.Order = Order; + this.Order = Order; } } @@ -106,7 +106,7 @@ namespace ICSharpCode.WpfDesign.Extensions result.Add(entry); } } - return result.OrderBy(x => x.Order).ToList(); + return result.OrderBy(x => x.Order).ToList(); } /// @@ -151,7 +151,10 @@ namespace ICSharpCode.WpfDesign.Extensions foreach (ExtensionEntry entry in GetExtensionEntries(item)) { if (entry.Server == server) { - yield return server.CreateExtension(entry.ExtensionType, item); + + var disabledExtensions = Extension.GetDisabledExtensions(item.View); + if (disabledExtensions == null || !disabledExtensions.Split(';').Contains(entry.ExtensionType.Name)) + yield return server.CreateExtension(entry.ExtensionType, item); } } } @@ -186,8 +189,8 @@ namespace ICSharpCode.WpfDesign.Extensions foreach (ExtensionForAttribute designerFor in extensionForAttributes) { ExtensionServer server = GetServerForExtension(type); - ExtensionAttribute extensionAttribute = type.GetCustomAttributes(typeof(ExtensionAttribute), false).FirstOrDefault() as ExtensionAttribute; - AddExtensionEntry(designerFor.DesignedItemType, new ExtensionEntry(type, server, designerFor.OverrideExtension, extensionAttribute != null ? extensionAttribute.Order : 0)); + ExtensionAttribute extensionAttribute = type.GetCustomAttributes(typeof(ExtensionAttribute), false).FirstOrDefault() as ExtensionAttribute; + AddExtensionEntry(designerFor.DesignedItemType, new ExtensionEntry(type, server, designerFor.OverrideExtension, extensionAttribute != null ? extensionAttribute.Order : 0)); } } } diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/Extensions/ExtensionServer.cs b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/Extensions/ExtensionServer.cs index b7b5595dac..6628bb1607 100644 --- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/Extensions/ExtensionServer.cs +++ b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/Extensions/ExtensionServer.cs @@ -74,6 +74,14 @@ namespace ICSharpCode.WpfDesign.Extensions /// public abstract bool ShouldApplyExtensions(DesignItem extendedItem); + // + /// Set if the Extension Server should be reaplied (For multiple Selection extension Server for Example!) + /// + public virtual bool ShouldBeReApplied() + { + return false; + } + /// /// Create an extension of the specified type. /// Is called by the ExtensionManager. diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/Extensions/SelectionExtensionServer.cs b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/Extensions/SelectionExtensionServer.cs index fc88c441a9..3a9011716d 100644 --- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/Extensions/SelectionExtensionServer.cs +++ b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/Extensions/SelectionExtensionServer.cs @@ -121,6 +121,11 @@ namespace ICSharpCode.WpfDesign.Extensions ReapplyExtensions(this.Services.Selection.SelectedItems); } + public override bool ShouldBeReApplied() + { + return true; + } + /// /// Gets if the item is in the secondary selection. /// diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/PlacementBehavior.cs b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/PlacementBehavior.cs index c4b393519f..f34341e7bb 100644 --- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/PlacementBehavior.cs +++ b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/PlacementBehavior.cs @@ -31,7 +31,7 @@ namespace ICSharpCode.WpfDesign /// /// Gets if the child element can be resized. /// - bool CanPlace(ICollection childItems, PlacementType type, PlacementAlignment position); + bool CanPlace(IEnumerable childItems, PlacementType type, PlacementAlignment position); /// /// Starts placement mode for this container. diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/PropertyGrid/EditorManager.cs b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/PropertyGrid/EditorManager.cs index 57529eef10..9569b09d95 100644 --- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/PropertyGrid/EditorManager.cs +++ b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/PropertyGrid/EditorManager.cs @@ -17,13 +17,10 @@ // DEALINGS IN THE SOFTWARE. using System; -using System.ComponentModel; -using System.Diagnostics; using System.Collections.Generic; using System.Reflection; using System.Windows; -using System.Windows.Input; -using ICSharpCode.WpfDesign.PropertyGrid.Editors; +using System.Windows.Controls; namespace ICSharpCode.WpfDesign.PropertyGrid { @@ -37,6 +34,10 @@ namespace ICSharpCode.WpfDesign.PropertyGrid // property full name => editor type static Dictionary propertyEditors = new Dictionary(); + static Type defaultComboboxEditor; + + static Type defaultTextboxEditor; + /// /// Creates a property editor for the specified /// @@ -61,14 +62,32 @@ namespace ICSharpCode.WpfDesign.PropertyGrid if (editorType == null) { var standardValues = Metadata.GetStandardValues(property.ReturnType); if (standardValues != null) { - return new ComboBoxEditor() { ItemsSource = standardValues }; + var itemsControl = (ItemsControl)Activator.CreateInstance(defaultComboboxEditor); + itemsControl.ItemsSource = standardValues; + return itemsControl; } - return new TextBoxEditor(); + return (FrameworkElement)Activator.CreateInstance(defaultTextboxEditor); } } return (FrameworkElement)Activator.CreateInstance(editorType); } + /// + /// Registers the Textbox Editor. + /// + public static void SetDefaultTextBoxEditorType(Type type) + { + defaultTextboxEditor = type; + } + + /// + /// Registers the Combobox Editor. + /// + public static void SetDefaultComboBoxEditorType(Type type) + { + defaultComboboxEditor = type; + } + /// /// Registers property editors defined in the specified assembly. /// diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/PropertyGrid/TypeHelper.cs b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/PropertyGrid/TypeHelper.cs index 6af5d1e222..f975780533 100644 --- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/PropertyGrid/TypeHelper.cs +++ b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/PropertyGrid/TypeHelper.cs @@ -102,7 +102,6 @@ namespace ICSharpCode.WpfDesign.PropertyGrid } else { - var l=TypeDescriptor.GetProperties(element); foreach(PropertyDescriptor p in TypeDescriptor.GetProperties(element)){ if (!p.IsBrowsable) continue; if (p.IsReadOnly && !typeof(ICollection).IsAssignableFrom(p.PropertyType)) continue; @@ -111,7 +110,7 @@ namespace ICSharpCode.WpfDesign.PropertyGrid } } } - + /// /// Gets common properties between . Includes attached properties too. /// @@ -119,32 +118,14 @@ namespace ICSharpCode.WpfDesign.PropertyGrid /// public static IEnumerable GetCommonAvailableProperties(IEnumerable elements) { - foreach (var pd1 in GetAvailableProperties(elements.First())) { - bool propertyOk = true; - foreach (var element in elements.Skip(1)) { - bool typeOk = false; - foreach (var pd2 in GetAvailableProperties(element)) { - if (pd1 == pd2) { - typeOk = true; - break; - } - - /* Check if it is attached property.*/ - if(pd1.Name.Contains(".") && pd2.Name.Contains(".")){ - if(pd1.Name==pd2.Name){ - typeOk=true; - break; - } - } - } - if (!typeOk) { - propertyOk = false; - break; - } - } - if (propertyOk) yield return pd1; + var properties = TypeDescriptor.GetProperties(elements.First()).Cast(); + foreach (var element in elements.Skip(1)) + { + var currentProperties = TypeDescriptor.GetProperties(element).Cast(); + properties = Enumerable.Intersect(properties, currentProperties); } + + return properties; } - } } diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/Services.cs b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/Services.cs index 2f95f1b266..2a3a41cebf 100644 --- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/Services.cs +++ b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/Services.cs @@ -126,6 +126,9 @@ namespace ICSharpCode.WpfDesign /// Event raised whenever a component is registered event EventHandler ComponentRegistered; + + /// Property Changed + event EventHandler PropertyChanged; } #endregion diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/WpfDesign.csproj b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/WpfDesign.csproj index 0159bd0b0f..2111deb033 100644 --- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/WpfDesign.csproj +++ b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/WpfDesign.csproj @@ -103,12 +103,6 @@ - - ComboBoxEditor.xaml - - - TextBoxEditor.xaml - @@ -120,16 +114,6 @@ - - - MSBuild:Compile - Designer - - - MSBuild:Compile - Designer - - diff --git a/src/AddIns/Misc/PackageManagement/Project/PackageManagement.csproj b/src/AddIns/Misc/PackageManagement/Project/PackageManagement.csproj index 7875954521..8804cfaecf 100644 --- a/src/AddIns/Misc/PackageManagement/Project/PackageManagement.csproj +++ b/src/AddIns/Misc/PackageManagement/Project/PackageManagement.csproj @@ -224,6 +224,7 @@ + diff --git a/src/AddIns/Misc/PackageManagement/Project/Src/Design/FakeFileSystem.cs b/src/AddIns/Misc/PackageManagement/Project/Src/Design/FakeFileSystem.cs index ddc74b13b7..9c3a5a0367 100644 --- a/src/AddIns/Misc/PackageManagement/Project/Src/Design/FakeFileSystem.cs +++ b/src/AddIns/Misc/PackageManagement/Project/Src/Design/FakeFileSystem.cs @@ -59,7 +59,12 @@ namespace ICSharpCode.PackageManagement.Design public string GetFullPath(string path) { - return PathToReturnFromGetFullPath; + if (PathToReturnFromGetFullPath != null) { + return PathToReturnFromGetFullPath; + } else if (Root == null) { + return null; + } + return Path.Combine(Root, path); } public void DeleteFile(string path) @@ -70,9 +75,16 @@ namespace ICSharpCode.PackageManagement.Design public bool FileExists(string path) { PathPassedToFileExists = path; + + if (ExistingFiles.Contains(path)) { + return true; + } + return FileExistsReturnValue; } + public List ExistingFiles = new List(); + public bool DirectoryExists(string path) { PathPassedToDirectoryExists = path; diff --git a/src/AddIns/Misc/PackageManagement/Project/Src/Design/FakePackageManagementProject.cs b/src/AddIns/Misc/PackageManagement/Project/Src/Design/FakePackageManagementProject.cs index 973b15ab92..3d490b2f96 100644 --- a/src/AddIns/Misc/PackageManagement/Project/Src/Design/FakePackageManagementProject.cs +++ b/src/AddIns/Misc/PackageManagement/Project/Src/Design/FakePackageManagementProject.cs @@ -20,6 +20,7 @@ using System; using System.Collections.Generic; using System.Linq; +using System.Runtime.Versioning; using ICSharpCode.PackageManagement; using ICSharpCode.PackageManagement.EnvDTE; using NuGet; @@ -41,6 +42,7 @@ namespace ICSharpCode.PackageManagement.Design this.Name = name; ConstraintProvider = NullConstraintProvider.Instance; + TargetFramework = new FrameworkName(".NETFramework", new Version("4.0")); } private FakeInstallPackageAction FakeInstallPackageAction; @@ -283,5 +285,7 @@ namespace ICSharpCode.PackageManagement.Design } public IPackageConstraintProvider ConstraintProvider { get; set; } + + public FrameworkName TargetFramework { get; set; } } } diff --git a/src/AddIns/Misc/PackageManagement/Project/Src/Design/FakeSettings.cs b/src/AddIns/Misc/PackageManagement/Project/Src/Design/FakeSettings.cs index 0c1980b65c..1dee7984f6 100644 --- a/src/AddIns/Misc/PackageManagement/Project/Src/Design/FakeSettings.cs +++ b/src/AddIns/Misc/PackageManagement/Project/Src/Design/FakeSettings.cs @@ -100,14 +100,14 @@ namespace ICSharpCode.PackageManagement.Design return SavedSectionValueLists[RegisteredPackageSourceSettings.PackageSourcesSectionName]; } - public bool DeleteValue(string section, string key) + public virtual bool DeleteValue(string section, string key) { throw new NotImplementedException(); } public List SectionsDeleted = new List(); - public bool DeleteSection(string section) + public virtual bool DeleteSection(string section) { SectionsDeleted.Add(section); return true; @@ -159,10 +159,10 @@ namespace ICSharpCode.PackageManagement.Design public IList> GetNestedValues(string section, string key) { - throw new NotImplementedException(); + return new List>(); } - public void SetNestedValues(string section, string key, IList> values) + public virtual void SetNestedValues(string section, string key, IList> values) { throw new NotImplementedException(); } @@ -184,7 +184,7 @@ namespace ICSharpCode.PackageManagement.Design } } - public void SetPackageRestoreSetting(bool enabled) + public virtual void SetPackageRestoreSetting(bool enabled) { var items = new List>(); items.Add(new KeyValuePair("enabled", enabled.ToString())); @@ -218,7 +218,9 @@ namespace ICSharpCode.PackageManagement.Design public IList GetSettingValues(string section, bool isPath) { - throw new NotImplementedException(); + return Sections[section] + .Select(item => new SettingValue(item.Key, item.Value, false)) + .ToList(); } public void SetRepositoryPathSetting(string fullPath) diff --git a/src/AddIns/Misc/PackageManagement/Project/Src/IPackageManagementProject.cs b/src/AddIns/Misc/PackageManagement/Project/Src/IPackageManagementProject.cs index 629e24c367..82b782409f 100644 --- a/src/AddIns/Misc/PackageManagement/Project/Src/IPackageManagementProject.cs +++ b/src/AddIns/Misc/PackageManagement/Project/Src/IPackageManagementProject.cs @@ -20,6 +20,7 @@ using System; using System.Collections.Generic; using System.Linq; +using System.Runtime.Versioning; using ICSharpCode.PackageManagement.EnvDTE; using NuGet; @@ -33,6 +34,7 @@ namespace ICSharpCode.PackageManagement event EventHandler PackageReferenceRemoving; string Name { get; } + FrameworkName TargetFramework { get; } ILogger Logger { get; set; } IPackageRepository SourceRepository { get; } diff --git a/src/AddIns/Misc/PackageManagement/Project/Src/MessageServiceExtensions.cs b/src/AddIns/Misc/PackageManagement/Project/Src/MessageServiceExtensions.cs new file mode 100644 index 0000000000..ab9d95aa79 --- /dev/null +++ b/src/AddIns/Misc/PackageManagement/Project/Src/MessageServiceExtensions.cs @@ -0,0 +1,53 @@ +// Copyright (c) 2014 AlphaSierraPapa for the SharpDevelop Team +// +// Permission is hereby granted, free of charge, to any person obtaining a copy of this +// software and associated documentation files (the "Software"), to deal in the Software +// without restriction, including without limitation the rights to use, copy, modify, merge, +// publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons +// to whom the Software is furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all copies or +// substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, +// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR +// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE +// FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +// DEALINGS IN THE SOFTWARE. + +using System; +using System.IO; +using ICSharpCode.Core; + +namespace ICSharpCode.PackageManagement +{ + public static class MessageServiceExtensions + { + public static void ShowNuGetConfigFileSaveError(string message) + { + MessageService.ShowError( + String.Format("{0}{1}{1}{2}", + message, + Environment.NewLine, + GetSaveNuGetConfigFileErrorMessage())); + } + + /// + /// Returns a non-Windows specific error message instead of the one NuGet returns. + /// + /// NuGet returns a Windows specific error: + /// + /// "DeleteSection" cannot be called on a NullSettings. This may be caused on account of + /// insufficient permissions to read or write to "%AppData%\NuGet\NuGet.config". + /// + static string GetSaveNuGetConfigFileErrorMessage() + { + string path = Path.Combine ( + Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), + "NuGet", + "NuGet.config"); + return String.Format("Unable to read or write to \"{0}\".", path); + } + } +} diff --git a/src/AddIns/Misc/PackageManagement/Project/Src/PackageManagementOptionsView.xaml.cs b/src/AddIns/Misc/PackageManagement/Project/Src/PackageManagementOptionsView.xaml.cs index e3c037d788..e6a9182181 100644 --- a/src/AddIns/Misc/PackageManagement/Project/Src/PackageManagementOptionsView.xaml.cs +++ b/src/AddIns/Misc/PackageManagement/Project/Src/PackageManagementOptionsView.xaml.cs @@ -17,6 +17,7 @@ // DEALINGS IN THE SOFTWARE. using System; +using ICSharpCode.Core; using ICSharpCode.SharpDevelop.Gui; namespace ICSharpCode.PackageManagement @@ -30,9 +31,15 @@ namespace ICSharpCode.PackageManagement public override bool SaveOptions() { - var viewModel = DataContext as PackageManagementOptionsViewModel; - viewModel.SaveOptions(); - return true; + try { + var viewModel = DataContext as PackageManagementOptionsViewModel; + viewModel.SaveOptions(); + return true; + } catch (Exception ex) { + LoggingService.Error("Unable to save NuGet.config changes", ex); + MessageServiceExtensions.ShowNuGetConfigFileSaveError("Unable to save package management options."); + } + return false; } } } diff --git a/src/AddIns/Misc/PackageManagement/Project/Src/PackageManagementProject.cs b/src/AddIns/Misc/PackageManagement/Project/Src/PackageManagementProject.cs index 2b206d57bd..3892191f4d 100644 --- a/src/AddIns/Misc/PackageManagement/Project/Src/PackageManagementProject.cs +++ b/src/AddIns/Misc/PackageManagement/Project/Src/PackageManagementProject.cs @@ -20,6 +20,7 @@ using System; using System.Collections.Generic; using System.Linq; +using System.Runtime.Versioning; using ICSharpCode.PackageManagement.EnvDTE; using ICSharpCode.SharpDevelop.Project; using NuGet; @@ -32,6 +33,7 @@ namespace ICSharpCode.PackageManagement ISharpDevelopProjectManager projectManager; IPackageManagementEvents packageManagementEvents; MSBuildBasedProject msbuildProject; + ProjectTargetFramework targetFramework; public PackageManagementProject( IPackageRepository sourceRepository, @@ -41,6 +43,7 @@ namespace ICSharpCode.PackageManagement { SourceRepository = sourceRepository; msbuildProject = project; + targetFramework = new ProjectTargetFramework(project); this.packageManagementEvents = packageManagementEvents; packageManager = packageManagerFactory.CreatePackageManager(sourceRepository, project); @@ -51,6 +54,10 @@ namespace ICSharpCode.PackageManagement get { return msbuildProject.Name; } } + public FrameworkName TargetFramework { + get { return targetFramework.TargetFrameworkName; } + } + public IPackageRepository SourceRepository { get; private set; } public ILogger Logger { diff --git a/src/AddIns/Misc/PackageManagement/Project/Src/PackageManagementServices.cs b/src/AddIns/Misc/PackageManagement/Project/Src/PackageManagementServices.cs index a1fe7eb4f6..1053b5db00 100644 --- a/src/AddIns/Misc/PackageManagement/Project/Src/PackageManagementServices.cs +++ b/src/AddIns/Misc/PackageManagement/Project/Src/PackageManagementServices.cs @@ -17,6 +17,7 @@ // DEALINGS IN THE SOFTWARE. using System; +using ICSharpCode.Core; using ICSharpCode.PackageManagement.Scripting; using NuGet; @@ -61,13 +62,23 @@ namespace ICSharpCode.PackageManagement static void InitializeCredentialProvider() { - ISettings settings = Settings.LoadDefaultSettings(null, null, null); + ISettings settings = LoadSettings(); var packageSourceProvider = new PackageSourceProvider(settings); var credentialProvider = new SettingsCredentialProvider(new SharpDevelopCredentialProvider(), packageSourceProvider); HttpClient.DefaultCredentialProvider = credentialProvider; } + static ISettings LoadSettings () + { + try { + return Settings.LoadDefaultSettings(null, null, null); + } catch (Exception ex) { + LoggingService.Error("Unable to load NuGet.Config.", ex); + } + return NullSettings.Instance; + } + public static PackageManagementOptions Options { get { return options; } } diff --git a/src/AddIns/Misc/PackageManagement/Project/Src/RegisteredPackageSourceSettings.cs b/src/AddIns/Misc/PackageManagement/Project/Src/RegisteredPackageSourceSettings.cs index 829c1bef8d..04a4ae12f9 100644 --- a/src/AddIns/Misc/PackageManagement/Project/Src/RegisteredPackageSourceSettings.cs +++ b/src/AddIns/Misc/PackageManagement/Project/Src/RegisteredPackageSourceSettings.cs @@ -21,6 +21,7 @@ using System.Collections.Generic; using System.Collections.Specialized; using System.Linq; +using ICSharpCode.Core; using ICSharpCode.SharpDevelop.Project; using NuGet; @@ -37,12 +38,15 @@ namespace ICSharpCode.PackageManagement ISettings settings; ISettingsProvider settingsProvider; + IPackageSourceProvider packageSourceProvider; PackageSource defaultPackageSource; RegisteredPackageSources packageSources; PackageSource activePackageSource; public RegisteredPackageSourceSettings(ISettingsProvider settingsProvider) - : this(settingsProvider, RegisteredPackageSources.DefaultPackageSource) + : this( + settingsProvider, + RegisteredPackageSources.DefaultPackageSource) { } @@ -54,6 +58,7 @@ namespace ICSharpCode.PackageManagement this.defaultPackageSource = defaultPackageSource; settings = settingsProvider.LoadSettings(); + packageSourceProvider = CreatePackageSourceProvider(settings); ReadActivePackageSource(); RegisterSolutionEvents(); @@ -64,6 +69,11 @@ namespace ICSharpCode.PackageManagement settingsProvider.SettingsChanged += SettingsChanged; } + static IPackageSourceProvider CreatePackageSourceProvider(ISettings settings) + { + return new PackageSourceProvider(settings, new [] { RegisteredPackageSources.DefaultPackageSource }); + } + void ReadActivePackageSource() { IList> packageSources = settings.GetValues(ActivePackageSourceSectionName); @@ -73,36 +83,31 @@ namespace ICSharpCode.PackageManagement public RegisteredPackageSources PackageSources { get { if (packageSources == null) { - ReadPackageSources(); + TryReadPackageSources(); } return packageSources; } } - void ReadPackageSources() - { - IEnumerable savedPackageSources = GetPackageSourcesFromSettings(); - packageSources = new RegisteredPackageSources(savedPackageSources, defaultPackageSource); - packageSources.CollectionChanged += PackageSourcesChanged; - - if (!savedPackageSources.Any()) { - UpdatePackageSourceSettingsWithChanges(); - } - } - - IEnumerable GetPackageSourcesFromSettings() + void TryReadPackageSources() { - IList> savedPackageSources = settings.GetValues(PackageSourcesSectionName); - foreach (PackageSource packageSource in PackageSourceConverter.ConvertFromKeyValuePairs(savedPackageSources)) { - packageSource.IsEnabled = IsPackageSourceEnabled(packageSource); - yield return packageSource; + try { + ReadPackageSources(); + } catch (Exception ex) { + LoggingService.Warn("Unable to read NuGet.config file.", ex); + + // Fallback to using the default package source only (nuget.org) + // and treat NuGet.config as read-only. + packageSourceProvider = CreatePackageSourceProvider(NullSettings.Instance); + ReadPackageSources(); } } - bool IsPackageSourceEnabled(PackageSource packageSource) + void ReadPackageSources() { - string disabled = settings.GetValue(DisabledPackageSourceSectionName, packageSource.Name); - return String.IsNullOrEmpty(disabled); + IEnumerable savedPackageSources = packageSourceProvider.LoadPackageSources(); + packageSources = new RegisteredPackageSources(savedPackageSources, defaultPackageSource); + packageSources.CollectionChanged += PackageSourcesChanged; } void PackageSourcesChanged(object sender, NotifyCollectionChangedEventArgs e) @@ -112,42 +117,7 @@ namespace ICSharpCode.PackageManagement void UpdatePackageSourceSettingsWithChanges() { - IList> newPackageSourceSettings = GetSettingsFromPackageSources(); - SavePackageSourceSettings(newPackageSourceSettings); - IList> disabledPackageSourceSettings = GetSettingsForDisabledPackageSources(); - SaveDisabledPackageSourceSettings(disabledPackageSourceSettings); - } - - IList> GetSettingsFromPackageSources() - { - return PackageSourceConverter.ConvertToKeyValuePairList(packageSources); - } - - KeyValuePair CreateKeyValuePairFromPackageSource(PackageSource source) - { - return new KeyValuePair(source.Name, source.Source); - } - - void SavePackageSourceSettings(IList> newPackageSourceSettings) - { - settings.DeleteSection(PackageSourcesSectionName); - settings.SetValues(PackageSourcesSectionName, newPackageSourceSettings); - } - - IList> GetSettingsForDisabledPackageSources() - { - return packageSources - .Where(source => !source.IsEnabled) - .Select(source => new KeyValuePair(source.Name, "true")) - .ToList(); - } - - void SaveDisabledPackageSourceSettings(IList> disabledPackageSourceSettings) - { - settings.DeleteSection(DisabledPackageSourceSectionName); - if (disabledPackageSourceSettings.Any()) { - settings.SetValues(DisabledPackageSourceSectionName, disabledPackageSourceSettings); - } + packageSourceProvider.SavePackageSources(packageSources); } public PackageSource ActivePackageSource { @@ -164,6 +134,12 @@ namespace ICSharpCode.PackageManagement } set { activePackageSource = value; + + if (settings is NullSettings) { + // NuGet failed to load settings so do not try to update them since this will fail. + return; + } + if (activePackageSource == null) { RemoveActivePackageSourceSetting(); } else { @@ -193,6 +169,7 @@ namespace ICSharpCode.PackageManagement void SettingsChanged(object sender, EventArgs e) { settings = settingsProvider.LoadSettings(); + packageSourceProvider = CreatePackageSourceProvider(settings); ReadActivePackageSource(); ResetPackageSources(); } diff --git a/src/AddIns/Misc/PackageManagement/Project/Src/RegisteredPackageSourcesView.xaml.cs b/src/AddIns/Misc/PackageManagement/Project/Src/RegisteredPackageSourcesView.xaml.cs index feb2d327ee..d777ef36ae 100644 --- a/src/AddIns/Misc/PackageManagement/Project/Src/RegisteredPackageSourcesView.xaml.cs +++ b/src/AddIns/Misc/PackageManagement/Project/Src/RegisteredPackageSourcesView.xaml.cs @@ -17,6 +17,8 @@ // DEALINGS IN THE SOFTWARE. using System; +using System.IO; +using ICSharpCode.Core; using ICSharpCode.SharpDevelop.Gui; namespace ICSharpCode.PackageManagement @@ -46,8 +48,14 @@ namespace ICSharpCode.PackageManagement public override bool SaveOptions() { - ViewModel.Save(); - return true; + try { + ViewModel.Save(); + return true; + } catch (Exception ex) { + LoggingService.Error("Unable to save NuGet.config changes", ex); + MessageServiceExtensions.ShowNuGetConfigFileSaveError("Unable to save package source changes."); + } + return false; } } } diff --git a/src/AddIns/Misc/PackageManagement/Project/Src/Scripting/IPackageScriptFileName.cs b/src/AddIns/Misc/PackageManagement/Project/Src/Scripting/IPackageScriptFileName.cs index 620c2366cd..79dcb47427 100644 --- a/src/AddIns/Misc/PackageManagement/Project/Src/Scripting/IPackageScriptFileName.cs +++ b/src/AddIns/Misc/PackageManagement/Project/Src/Scripting/IPackageScriptFileName.cs @@ -17,6 +17,8 @@ // DEALINGS IN THE SOFTWARE. using System; +using System.Runtime.Versioning; +using NuGet; namespace ICSharpCode.PackageManagement.Scripting { @@ -27,5 +29,6 @@ namespace ICSharpCode.PackageManagement.Scripting bool ScriptDirectoryExists(); bool FileExists(); string GetScriptDirectory(); + void UseTargetSpecificFileName(IPackage package, FrameworkName frameworkName); } } diff --git a/src/AddIns/Misc/PackageManagement/Project/Src/Scripting/PackageInstallScript.cs b/src/AddIns/Misc/PackageManagement/Project/Src/Scripting/PackageInstallScript.cs index 257d1ed39f..257d9346a4 100644 --- a/src/AddIns/Misc/PackageManagement/Project/Src/Scripting/PackageInstallScript.cs +++ b/src/AddIns/Misc/PackageManagement/Project/Src/Scripting/PackageInstallScript.cs @@ -26,6 +26,7 @@ namespace ICSharpCode.PackageManagement.Scripting public PackageInstallScript(IPackage package, IPackageScriptFileName fileName) : base(package, fileName) { + UseTargetSpecificScript = true; } } } diff --git a/src/AddIns/Misc/PackageManagement/Project/Src/Scripting/PackageScript.cs b/src/AddIns/Misc/PackageManagement/Project/Src/Scripting/PackageScript.cs index 5bcf8134b2..ceb6e3ea5d 100644 --- a/src/AddIns/Misc/PackageManagement/Project/Src/Scripting/PackageScript.cs +++ b/src/AddIns/Misc/PackageManagement/Project/Src/Scripting/PackageScript.cs @@ -17,6 +17,9 @@ // DEALINGS IN THE SOFTWARE. using System; +using System.Collections.Generic; +using System.Linq; +using System.Runtime.Versioning; using ICSharpCode.PackageManagement.EnvDTE; using NuGet; @@ -24,6 +27,8 @@ namespace ICSharpCode.PackageManagement.Scripting { public class PackageScript : IPackageScript { + bool lookedForTargetSpecificScript; + public PackageScript(IPackage package, IPackageScriptFileName fileName) { this.Package = package; @@ -32,12 +37,14 @@ namespace ICSharpCode.PackageManagement.Scripting protected IPackageScriptFileName ScriptFileName { get; private set; } protected IPackageScriptSession Session { get; private set; } + protected bool UseTargetSpecificScript { get; set; } public IPackage Package { get; set; } public IPackageManagementProject Project { get; set; } public bool Exists() { + FindTargetSpecificScriptFileName(); return ScriptFileName.FileExists(); } @@ -97,5 +104,18 @@ namespace ICSharpCode.PackageManagement.Scripting Session.RemoveVariable("__package"); Session.RemoveVariable("__project"); } + + void FindTargetSpecificScriptFileName() + { + if (UseTargetSpecificScript && !lookedForTargetSpecificScript) { + ScriptFileName.UseTargetSpecificFileName(Package, GetTargetFramework()); + lookedForTargetSpecificScript = true; + } + } + + FrameworkName GetTargetFramework() + { + return Project.TargetFramework; + } } } diff --git a/src/AddIns/Misc/PackageManagement/Project/Src/Scripting/PackageScriptFileName.cs b/src/AddIns/Misc/PackageManagement/Project/Src/Scripting/PackageScriptFileName.cs index 590fe081de..3344a4601f 100644 --- a/src/AddIns/Misc/PackageManagement/Project/Src/Scripting/PackageScriptFileName.cs +++ b/src/AddIns/Misc/PackageManagement/Project/Src/Scripting/PackageScriptFileName.cs @@ -17,7 +17,10 @@ // DEALINGS IN THE SOFTWARE. using System; +using System.Collections.Generic; using System.IO; +using System.Linq; +using System.Runtime.Versioning; using NuGet; namespace ICSharpCode.PackageManagement.Scripting @@ -68,5 +71,16 @@ namespace ICSharpCode.PackageManagement.Scripting { return fileSystem.GetFullPath("tools"); } + + public void UseTargetSpecificFileName(IPackage package, FrameworkName targetFramework) + { + IEnumerable files; + if (VersionUtility.TryGetCompatibleItems(targetFramework, package.GetToolFiles(), out files)) { + IPackageFile matchingScriptFile = files.FirstOrDefault(file => file.EffectivePath.Equals(Name, StringComparison.OrdinalIgnoreCase)); + if (matchingScriptFile != null) { + relativeScriptFilePath = matchingScriptFile.Path; + } + } + } } } diff --git a/src/AddIns/Misc/PackageManagement/Project/Src/Scripting/PackageUninstallScript.cs b/src/AddIns/Misc/PackageManagement/Project/Src/Scripting/PackageUninstallScript.cs index 27eaa94a54..4007bef931 100644 --- a/src/AddIns/Misc/PackageManagement/Project/Src/Scripting/PackageUninstallScript.cs +++ b/src/AddIns/Misc/PackageManagement/Project/Src/Scripting/PackageUninstallScript.cs @@ -26,6 +26,7 @@ namespace ICSharpCode.PackageManagement.Scripting public PackageUninstallScript(IPackage package, IPackageScriptFileName fileName) : base(package, fileName) { + UseTargetSpecificScript = true; } } } diff --git a/src/AddIns/Misc/PackageManagement/Project/Src/SettingsProvider.cs b/src/AddIns/Misc/PackageManagement/Project/Src/SettingsProvider.cs index 7dfa1a5a25..3e3e6c059c 100644 --- a/src/AddIns/Misc/PackageManagement/Project/Src/SettingsProvider.cs +++ b/src/AddIns/Misc/PackageManagement/Project/Src/SettingsProvider.cs @@ -3,6 +3,7 @@ using System; using System.IO; +using ICSharpCode.Core; using ICSharpCode.SharpDevelop.Project; using NuGet; @@ -38,7 +39,12 @@ namespace ICSharpCode.PackageManagement public ISettings LoadSettings() { - return LoadSettings(GetSolutionDirectory()); + try { + return LoadSettings(GetSolutionDirectory()); + } catch (Exception ex) { + LoggingService.Error("Unable to load NuGet.Config file.", ex); + } + return NullSettings.Instance; } string GetSolutionDirectory() diff --git a/src/AddIns/Misc/PackageManagement/Test/PackageManagement.Tests.csproj b/src/AddIns/Misc/PackageManagement/Test/PackageManagement.Tests.csproj index 580664fc67..e08013ea35 100644 --- a/src/AddIns/Misc/PackageManagement/Test/PackageManagement.Tests.csproj +++ b/src/AddIns/Misc/PackageManagement/Test/PackageManagement.Tests.csproj @@ -112,6 +112,7 @@ + @@ -197,6 +198,7 @@ + diff --git a/src/AddIns/Misc/PackageManagement/Test/Src/Helpers/FakePackageScriptFileName.cs b/src/AddIns/Misc/PackageManagement/Test/Src/Helpers/FakePackageScriptFileName.cs index 29991ea814..1a0918e63e 100644 --- a/src/AddIns/Misc/PackageManagement/Test/Src/Helpers/FakePackageScriptFileName.cs +++ b/src/AddIns/Misc/PackageManagement/Test/Src/Helpers/FakePackageScriptFileName.cs @@ -17,7 +17,9 @@ // DEALINGS IN THE SOFTWARE. using System; +using System.Runtime.Versioning; using ICSharpCode.PackageManagement.Scripting; +using NuGet; namespace PackageManagement.Tests.Helpers { @@ -52,5 +54,9 @@ namespace PackageManagement.Tests.Helpers { return ToStringReturnValue; } + + public void UseTargetSpecificFileName(IPackage package, FrameworkName frameworkName) + { + } } } diff --git a/src/AddIns/Misc/PackageManagement/Test/Src/Helpers/FakeReadOnlySettings.cs b/src/AddIns/Misc/PackageManagement/Test/Src/Helpers/FakeReadOnlySettings.cs new file mode 100644 index 0000000000..52bb051684 --- /dev/null +++ b/src/AddIns/Misc/PackageManagement/Test/Src/Helpers/FakeReadOnlySettings.cs @@ -0,0 +1,46 @@ +// Copyright (c) 2014 AlphaSierraPapa for the SharpDevelop Team +// +// Permission is hereby granted, free of charge, to any person obtaining a copy of this +// software and associated documentation files (the "Software"), to deal in the Software +// without restriction, including without limitation the rights to use, copy, modify, merge, +// publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons +// to whom the Software is furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all copies or +// substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, +// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR +// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE +// FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +// DEALINGS IN THE SOFTWARE. + +using System; +using ICSharpCode.PackageManagement.Design; + +namespace PackageManagement.Tests.Helpers +{ + public class FakeReadOnlySettings : FakeSettings + { + public override bool DeleteSection(string section) + { + throw new ApplicationException("DeleteSection called"); + } + + public override bool DeleteValue(string section, string key) + { + throw new ApplicationException("DeleteValue called"); + } + + public override void SetNestedValues(string section, string key, System.Collections.Generic.IList> values) + { + throw new ApplicationException("SetNestedValues called"); + } + + public override void SetPackageRestoreSetting(bool enabled) + { + throw new ApplicationException("SetPackageRestoreSetting called"); + } + } +} diff --git a/src/AddIns/Misc/PackageManagement/Test/Src/PackageManagementOptionsTests.cs b/src/AddIns/Misc/PackageManagement/Test/Src/PackageManagementOptionsTests.cs index 29a111a445..1b9ca7b30a 100644 --- a/src/AddIns/Misc/PackageManagement/Test/Src/PackageManagementOptionsTests.cs +++ b/src/AddIns/Misc/PackageManagement/Test/Src/PackageManagementOptionsTests.cs @@ -39,6 +39,13 @@ namespace PackageManagement.Tests SettingsProvider settingsProvider; FakePackageManagementProjectService projectService; + [TearDown] + public void TearDown() + { + // This resets SettingsProvider.LoadDefaultSettings. + TestablePackageManagementOptions.CreateSettingsProvider(fakeSettings, projectService); + } + void CreateOptions() { CreateProperties(); @@ -69,6 +76,12 @@ namespace PackageManagement.Tests options = new PackageManagementOptions(properties, settingsProvider); } + void CreateOptions(Properties properties, ISettingsProvider provider) + { + CreateSettings(); + options = new PackageManagementOptions(properties, provider); + } + void CreateSettingsProvider(FakeSettings fakeSettings) { projectService = new FakePackageManagementProjectService(); @@ -117,7 +130,7 @@ namespace PackageManagement.Tests } [Test] - public void PackageSources_OnePackageSourceInSettings_ContainsSinglePackageSourceFromSettings() + public void PackageSources_OnePackageSourceInSettings_ContainsSinglePackageSourceFromSettingsAndDefaultPackageSource() { CreateSettings(); var packageSource = new PackageSource("http://codeplex.com", "Test"); @@ -126,8 +139,9 @@ namespace PackageManagement.Tests RegisteredPackageSources actualSources = options.PackageSources; - List expectedSources = new List(); + var expectedSources = new List(); expectedSources.Add(packageSource); + expectedSources.Add(new PackageSource("https://www.nuget.org/api/v2/", "nuget.org")); Assert.AreEqual(expectedSources, actualSources); } @@ -146,26 +160,6 @@ namespace PackageManagement.Tests CollectionAssert.AreEqual(expectedSources, actualPackageSources); } - [Test] - public void PackageSources_NoPackageSourceInSavedSettings_DefaultPackageSourceAddedToSettings() - { - CreateSettings(); - CreateOptions(fakeSettings); - - RegisteredPackageSources packageSources = options.PackageSources; - - PackageSource defaultSource = RegisteredPackageSources.DefaultPackageSource; - - var expectedSavedPackageSourceSettings = new List>(); - string name = defaultSource.Name; - string sourceUrl = defaultSource.Source; - expectedSavedPackageSourceSettings.Add(new KeyValuePair(name, sourceUrl)); - - IList> actualSavedPackageSourceSettings = fakeSettings.GetValuesPassedToSetValuesForPackageSourcesSection(); - - Assert.AreEqual(expectedSavedPackageSourceSettings, actualSavedPackageSourceSettings); - } - [Test] public void PackageSources_OnePackageSourceAdded_PackageSourceSavedInSettings() { @@ -430,7 +424,9 @@ namespace PackageManagement.Tests bool result = fakeSettings.AnyValuesPassedToSetValuesForDisabledPackageSourcesSection; - Assert.IsFalse(result); + IList> actualSavedPackageSourceSettings = + fakeSettings.GetValuesPassedToSetValuesForDisabledPackageSourcesSection(); + Assert.AreEqual(0, actualSavedPackageSourceSettings.Count); } [Test] @@ -498,18 +494,18 @@ namespace PackageManagement.Tests public void PackageSources_SolutionOpenedAfterInitialPackageSourcesLoaded_ContainsPackageSourceFromSolutionSpecificSettings() { CreateSettings(); - var packageSource = new PackageSource("http://codeplex.com", "Test"); + var packageSource = new PackageSource("https://www.nuget.org/api/v2/", "Official NuGet Gallery"); fakeSettings.AddFakePackageSource(packageSource); CreateOptions(fakeSettings); RegisteredPackageSources initialSources = options.PackageSources; var expectedInitialSources = new List(); expectedInitialSources.Add(packageSource); ChangeSettingsReturnedBySettingsProvider(); - packageSource = new PackageSource("http://codeplex.com", "Test"); + packageSource = new PackageSource("https://www.nuget.org/api/v2/", "Official NuGet Gallery"); fakeSettings.AddFakePackageSource(packageSource); var expectedSources = new List(); expectedSources.Add(packageSource); - packageSource = new PackageSource("http://nuget.org", "ProjectSource"); + packageSource = new PackageSource("http://codeplex.com", "ProjectSource"); fakeSettings.AddFakePackageSource(packageSource); expectedSources.Add(packageSource); OpenSolution(); @@ -524,18 +520,18 @@ namespace PackageManagement.Tests public void PackageSources_SolutionClosedAfterInitialPackageSourcesLoaded_PackageSourcesReloaded() { CreateSettings(); - var packageSource = new PackageSource("http://codeplex.com", "Test"); + var packageSource = new PackageSource("https://www.nuget.org/api/v2/", "Official NuGet Gallery"); fakeSettings.AddFakePackageSource(packageSource); var expectedInitialSources = new List(); expectedInitialSources.Add(packageSource); - packageSource = new PackageSource("http://nuget.org", "ProjectSource"); + packageSource = new PackageSource("http://projectsource.org", "ProjectSource"); fakeSettings.AddFakePackageSource(packageSource); expectedInitialSources.Add(packageSource); OpenSolution(); CreateOptions(fakeSettings); RegisteredPackageSources initialSources = options.PackageSources; ChangeSettingsReturnedBySettingsProvider(); - packageSource = new PackageSource("http://codeplex.com", "Test"); + packageSource = new PackageSource("https://www.nuget.org/api/v2/", "Official NuGet Gallery"); fakeSettings.AddFakePackageSource(packageSource); var expectedSources = new List(); expectedSources.Add(packageSource); @@ -551,11 +547,11 @@ namespace PackageManagement.Tests public void PackageSources_SolutionClosedAfterInitialPackageSourcesLoaded_ActivePackageSourceReloaded() { CreateSettings(); - var packageSource = new PackageSource("http://codeplex.com", "Test"); + var packageSource = new PackageSource("https://www.nuget.org/api/v2/", "Official NuGet Gallery"); fakeSettings.AddFakePackageSource(packageSource); var expectedInitialSources = new List(); expectedInitialSources.Add(packageSource); - var initialActivePackageSource = new PackageSource("http://nuget.org", "ProjectSource"); + var initialActivePackageSource = new PackageSource("http://projectsource.org", "ProjectSource"); fakeSettings.AddFakePackageSource(initialActivePackageSource); fakeSettings.SetFakeActivePackageSource(initialActivePackageSource); expectedInitialSources.Add(initialActivePackageSource); @@ -564,7 +560,7 @@ namespace PackageManagement.Tests RegisteredPackageSources actualInitialPackageSources = options.PackageSources; PackageSource actualInitialActivePackageSource = options.ActivePackageSource; ChangeSettingsReturnedBySettingsProvider(); - var expectedActivePackageSource = new PackageSource("http://codeplex.com", "Test"); + var expectedActivePackageSource = new PackageSource("https://www.nuget.org/api/v2/", "Official NuGet Gallery"); fakeSettings.SetFakeActivePackageSource(expectedActivePackageSource); fakeSettings.AddFakePackageSource(expectedActivePackageSource); CloseSolution(); @@ -576,5 +572,32 @@ namespace PackageManagement.Tests Assert.AreEqual(expectedInitialSources, actualInitialPackageSources); Assert.AreEqual(new PackageSource[] { expectedActivePackageSource }, options.PackageSources); } + + [Test] + public void PackageSources_ReadOnlyNuGetConfigFile_DoesNotThrowException() + { + var settings = new FakeReadOnlySettings(); + CreateOptions(settings); + + int count = 0; + Assert.DoesNotThrow(() => count = options.PackageSources.Count); + Assert.AreEqual(1, count); + Assert.AreEqual(options.PackageSources[0], new PackageSource("https://www.nuget.org/api/v2/", "nuget.org")); + } + + [Test] + public void PackageSources_UpdateActivePackageSourceWhenNuGetConfigAccessIsUnauthorized_DoesNotThrowException() + { + CreateProperties(); + fakeSettings = new FakeReadOnlySettings(); + CreateSettingsProvider(fakeSettings); + SettingsProvider.LoadDefaultSettings = (fileSystem, configFile, machineSettings) => { + throw new UnauthorizedAccessException(); + }; + CreateOptions(properties, settingsProvider); + + var packageSource = new PackageSource("http://test.com"); + Assert.DoesNotThrow(() => options.ActivePackageSource = packageSource); + } } } diff --git a/src/AddIns/Misc/PackageManagement/Test/Src/PackageManagementProjectTests.cs b/src/AddIns/Misc/PackageManagement/Test/Src/PackageManagementProjectTests.cs index 3c1c06b677..d2929838d8 100644 --- a/src/AddIns/Misc/PackageManagement/Test/Src/PackageManagementProjectTests.cs +++ b/src/AddIns/Misc/PackageManagement/Test/Src/PackageManagementProjectTests.cs @@ -20,6 +20,7 @@ using System; using System.Collections.Generic; using System.Linq; +using System.Runtime.Versioning; using ICSharpCode.PackageManagement; using ICSharpCode.PackageManagement.Design; using ICSharpCode.PackageManagement.EnvDTE; @@ -46,17 +47,25 @@ namespace PackageManagement.Tests UpdatePackagesAction updatePackagesAction; void CreateProject() + { + fakeMSBuildProject = ProjectHelper.CreateTestProject(); + fakeMSBuildProject.SetProperty("TargetFrameworkIdentifier", null); + fakeMSBuildProject.SetProperty("TargetFrameworkVersion", "v4.0"); + fakeMSBuildProject.SetProperty("TargetFrameworkProfile", null); + CreateProject(fakeMSBuildProject); + } + + void CreateProject(MSBuildBasedProject msbuildProject) { fakePackageManagerFactory = new FakePackageManagerFactory(); fakePackageManager = fakePackageManagerFactory.FakePackageManager; fakeProjectManager = fakePackageManager.FakeProjectManager; fakeSourceRepository = new FakePackageRepository(); - fakeMSBuildProject = ProjectHelper.CreateTestProject(); fakePackageManagementEvents = new FakePackageManagementEvents(); project = new PackageManagementProject( fakeSourceRepository, - fakeMSBuildProject, + msbuildProject, fakePackageManagementEvents, fakePackageManagerFactory); } @@ -761,25 +770,40 @@ namespace PackageManagement.Tests } [Test] - public void ConstraintProvider_LocalRepositoryDoesNotImplementIConstraintProvider_ReturnsNullConstraintProviderInstance () + public void ConstraintProvider_LocalRepositoryDoesNotImplementIConstraintProvider_ReturnsNullConstraintProviderInstance() { - CreateProject (); + CreateProject(); IPackageConstraintProvider provider = project.ConstraintProvider; - Assert.AreEqual (NullConstraintProvider.Instance, provider); + Assert.AreEqual(NullConstraintProvider.Instance, provider); } [Test] - public void ConstraintProvider_LocalRepositoryImplementsIConstraintProvider_ReturnsLocalRepository () + public void ConstraintProvider_LocalRepositoryImplementsIConstraintProvider_ReturnsLocalRepository() { - CreateProject (); - var localRepository = new FakePackageRepositoryWithConstraintProvider (); + CreateProject(); + var localRepository = new FakePackageRepositoryWithConstraintProvider(); fakeProjectManager.FakeLocalRepository = localRepository; IPackageConstraintProvider provider = project.ConstraintProvider; - Assert.AreEqual (localRepository, provider); + Assert.AreEqual(localRepository, provider); + } + + [Test] + public void TargetFramework_TargetFrameworkVersion40DefinedInProject_ReturnsFullDotNetFramework40() + { + fakeMSBuildProject = ProjectHelper.CreateTestProject(); + fakeMSBuildProject.SetProperty("TargetFrameworkIdentifier", null); + fakeMSBuildProject.SetProperty("TargetFrameworkVersion", "v4.0"); + fakeMSBuildProject.SetProperty("TargetFrameworkProfile", null); + CreateProject(fakeMSBuildProject); + var expectedName = new FrameworkName(".NETFramework, Version=v4.0"); + + FrameworkName targetFramework = project.TargetFramework; + + Assert.AreEqual(expectedName, targetFramework); } } } diff --git a/src/AddIns/Misc/PackageManagement/Test/Src/Scripting/PackageInstallScriptTests.cs b/src/AddIns/Misc/PackageManagement/Test/Src/Scripting/PackageInstallScriptTests.cs index 382564c402..1159bd5fe2 100644 --- a/src/AddIns/Misc/PackageManagement/Test/Src/Scripting/PackageInstallScriptTests.cs +++ b/src/AddIns/Misc/PackageManagement/Test/Src/Scripting/PackageInstallScriptTests.cs @@ -17,6 +17,7 @@ // DEALINGS IN THE SOFTWARE. using System; +using System.Runtime.Versioning; using ICSharpCode.PackageManagement.Design; using ICSharpCode.PackageManagement.EnvDTE; using ICSharpCode.PackageManagement.Scripting; @@ -34,6 +35,7 @@ namespace PackageManagement.Tests.Scripting PackageInstallScript script; FakeFileSystem fakeFileSystem; FakePackage fakePackage; + FakePackageManagementProject fakeProject; void CreateScript() { @@ -45,7 +47,10 @@ namespace PackageManagement.Tests.Scripting fakeSession = new FakePackageScriptSession(); fakePackage = new FakePackage(); + fakeProject = new FakePackageManagementProject(); + script = new PackageInstallScript(fakePackage, scriptFileName); + script.Project = fakeProject; } void ExecuteScript() @@ -123,5 +128,35 @@ namespace PackageManagement.Tests.Scripting Assert.AreEqual(fakePackage, package); } + + [Test] + public void Run_PackageHasTargetFrameworkSpecificInstallPowerShellScript_InstallPowerShellScriptIsRun() + { + CreateScript(); + fakeFileSystem.Root = @"d:\projects\MyProject\packages\MyPackage.1.0"; + fakePackage.AddFile(@"tools\net40\Install.ps1"); + fakeProject.TargetFramework = new FrameworkName(".NETFramework", new Version("4.0")); + + script.Run(fakeSession); + + bool result = fakeSession.ScriptPassedToInvokeScript.StartsWith( + @"& 'd:\projects\MyProject\packages\MyPackage.1.0\tools\net40\Install.ps1'"); + Assert.IsTrue(result, fakeSession.ScriptPassedToInvokeScript); + } + + [Test] + public void Exists_PackageHasTargetFrameworkSpecificInstallPowerShellScript_ReturnsTrue() + { + CreateScript(); + fakeFileSystem.Root = @"d:\projects\MyProject\packages\MyPackage.1.0"; + fakeFileSystem.ExistingFiles.Add(@"tools\net40\install.ps1"); + fakeFileSystem.FileExistsReturnValue = false; + fakePackage.AddFile(@"tools\net40\install.ps1"); + fakeProject.TargetFramework = new FrameworkName(".NETFramework", new Version("4.0")); + + bool exists = script.Exists(); + + Assert.IsTrue(exists); + } } } diff --git a/src/AddIns/Misc/PackageManagement/Test/Src/Scripting/PackageUninstallScriptTests.cs b/src/AddIns/Misc/PackageManagement/Test/Src/Scripting/PackageUninstallScriptTests.cs new file mode 100644 index 0000000000..30058975da --- /dev/null +++ b/src/AddIns/Misc/PackageManagement/Test/Src/Scripting/PackageUninstallScriptTests.cs @@ -0,0 +1,76 @@ +// Copyright (c) 2014 AlphaSierraPapa for the SharpDevelop Team +// +// Permission is hereby granted, free of charge, to any person obtaining a copy of this +// software and associated documentation files (the "Software"), to deal in the Software +// without restriction, including without limitation the rights to use, copy, modify, merge, +// publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons +// to whom the Software is furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all copies or +// substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, +// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR +// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE +// FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +// DEALINGS IN THE SOFTWARE. + +using System; +using System.Runtime.Versioning; +using ICSharpCode.PackageManagement.Design; +using ICSharpCode.PackageManagement.EnvDTE; +using ICSharpCode.PackageManagement.Scripting; +using NuGet; +using NUnit.Framework; +using PackageManagement.Tests.Helpers; + +namespace PackageManagement.Tests.Scripting +{ + [TestFixture] + public class PackageUninstallScriptTests + { + PackageUninstallScriptFileName scriptFileName; + FakePackageScriptSession fakeSession; + PackageUninstallScript script; + FakeFileSystem fakeFileSystem; + FakePackage fakePackage; + FakePackageManagementProject fakeProject; + + void CreateScript() + { + fakeFileSystem = new FakeFileSystem(); + fakeFileSystem.FileExistsReturnValue = true; + fakeFileSystem.DirectoryExistsReturnValue = true; + scriptFileName = new PackageUninstallScriptFileName(fakeFileSystem); + + fakeSession = new FakePackageScriptSession(); + fakePackage = new FakePackage(); + + fakeProject = new FakePackageManagementProject(); + + script = new PackageUninstallScript(fakePackage, scriptFileName); + script.Project = fakeProject; + } + + void ExecuteScript() + { + script.Run(fakeSession); + } + + [Test] + public void Run_PackageHasTargetFrameworkSpecificUnistallPowerShellScript_UninstallPowerShellScriptIsRun() + { + CreateScript(); + fakeFileSystem.Root = @"d:\projects\MyProject\packages\MyPackage.1.0"; + fakePackage.AddFile(@"tools\net40\uninstall.ps1"); + fakeProject.TargetFramework = new FrameworkName(".NETFramework", new Version("4.0")); + + script.Run(fakeSession); + + bool result = fakeSession.ScriptPassedToInvokeScript.StartsWith( + @"& 'd:\projects\MyProject\packages\MyPackage.1.0\tools\net40\uninstall.ps1'"); + Assert.IsTrue(result, fakeSession.ScriptPassedToInvokeScript); + } + } +} diff --git a/src/AddIns/Misc/PackageManagement/Test/Src/SettingsProviderTests.cs b/src/AddIns/Misc/PackageManagement/Test/Src/SettingsProviderTests.cs index 10c2efd9fe..f7fc941a9f 100644 --- a/src/AddIns/Misc/PackageManagement/Test/Src/SettingsProviderTests.cs +++ b/src/AddIns/Misc/PackageManagement/Test/Src/SettingsProviderTests.cs @@ -76,5 +76,19 @@ namespace PackageManagement.Tests Assert.AreEqual(@"d:\projects\MyProject\.nuget", fileSystemUsedToLoadSettings.Root); Assert.AreEqual(fakeSettings, settings); } + + [Test] + public void LoadSettings_NuGetSettingsThrowsUnauthorizedAccessException_ExceptionHandledAndSettingsNullObjectReturned() + { + fileSystemUsedToLoadSettings = new FakeFileSystem(); + configFileUsedToLoadSettings = "configFile"; + SettingsProvider.LoadDefaultSettings = (fileSystem, configFile, machineSettings) => { + throw new UnauthorizedAccessException(); + }; + + ISettings settings = settingsProvider.LoadSettings(); + + Assert.IsInstanceOf(settings); + } } } diff --git a/src/AddIns/Misc/Reporting/ICSharpCode.Reporting.Addin/EmptyReport.xft b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting.Addin/EmptyReport.xft index 2df9438229..a2c4d6164a 100644 --- a/src/AddIns/Misc/Reporting/ICSharpCode.Reporting.Addin/EmptyReport.xft +++ b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting.Addin/EmptyReport.xft @@ -9,11 +9,16 @@ language = "SharpDevelopReports"/> ${res:Templates.SharpReport.NewReport} - + + + + + + diff --git a/src/AddIns/Misc/Reporting/ICSharpCode.Reporting.Addin/ICSharpCode.Reporting.addin b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting.Addin/ICSharpCode.Reporting.addin index e2632686af..38573fc75a 100644 --- a/src/AddIns/Misc/Reporting/ICSharpCode.Reporting.Addin/ICSharpCode.Reporting.addin +++ b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting.Addin/ICSharpCode.Reporting.addin @@ -26,6 +26,11 @@ class="ICSharpCode.Reporting.Addin.DesignerBinding.ReportDesignerBinding" /> + + + +