From 0ee80f83cc0ce44fa41d9016eefb904d804015d0 Mon Sep 17 00:00:00 2001 From: jogibear9988 Date: Wed, 19 Nov 2014 22:56:43 +0100 Subject: [PATCH 01/44] - Parse of App.Xaml - Parse of Frameworktemplates wich have References to Parent Resources (not yet App.Xaml Resources) - Fixes in Xaml Parser (Attached Events, Attached Properties not always have both, a Setter and a Getter) --- .../WpfDesign.AddIn/Src/MyTypeFinder.cs | 16 +++ .../WpfDesign.AddIn/Src/WpfViewContent.cs | 47 +++++++ .../Tests/XamlDom/SamplesTests.cs | 20 +++ .../Project/TemplateHelper.cs | 121 +++++++++++++++--- .../Project/XamlObjectServiceProvider.cs | 2 +- .../WpfDesign.XamlDom/Project/XamlParser.cs | 58 ++++++++- .../WpfDesign.XamlDom/Project/XamlProperty.cs | 8 +- .../Project/XamlTypeFinder.cs | 6 + 8 files changed, 249 insertions(+), 29 deletions(-) diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.AddIn/Src/MyTypeFinder.cs b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.AddIn/Src/MyTypeFinder.cs index cb867140e6..e14941e535 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,21 @@ 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; + + var newUri = new Uri(("file://" + Path.Combine(prj.Directory, uri.OriginalString)).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..3389ff958f 100644 --- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.AddIn/Src/WpfViewContent.cs +++ b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.AddIn/Src/WpfViewContent.cs @@ -22,6 +22,7 @@ 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; @@ -32,6 +33,7 @@ using System.Xml; 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 +46,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 +63,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 +108,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); @@ -129,9 +138,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) + { } } } + 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 +331,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.Designer/Tests/XamlDom/SamplesTests.cs b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Tests/XamlDom/SamplesTests.cs index 6dc0487c85..91c1d4aa35 100644 --- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Tests/XamlDom/SamplesTests.cs +++ b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Tests/XamlDom/SamplesTests.cs @@ -504,6 +504,26 @@ namespace ICSharpCode.WpfDesign.Tests.XamlDom "); } + [Test] + public void Template2() + { + TestLoading(@" + + + + + + + + + + + + + +"); + } [Test] public void ListBox1() diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.XamlDom/Project/TemplateHelper.cs b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.XamlDom/Project/TemplateHelper.cs index 263659a057..7b868dd28b 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,39 +25,119 @@ using System.Reflection; using System.Windows; using System.Windows.Controls; using System.Windows.Markup; +using System.Xaml; using System.Xml; using System.Xml.XPath; namespace ICSharpCode.WpfDesign.XamlDom { - public static class TemplateHelper + public class TemplateHelperResourceDictionary : ResourceDictionary, IDictionary { - public static FrameworkTemplate GetFrameworkTemplate(XmlElement xmlElement) + void IDictionary.Add(object key, object value) { - var nav = xmlElement.CreateNavigator(); + base.Add(key == null ? "$$temp&&§§%%__" : key, value); + } + } - var ns = new Dictionary(); - while (true) + public static class TemplateHelper + { + public static FrameworkTemplate GetFrameworkTemplate(XmlElement xmlElement, XamlObject parentObject) + { + try { - var nsInScope = nav.GetNamespacesInScope(XmlNamespaceScope.ExcludeXml); - foreach (var ak in nsInScope) + var nav = xmlElement.CreateNavigator(); + + var ns = new Dictionary(); + while (true) { - if (!ns.ContainsKey(ak.Key) && ak.Key != "") - ns.Add(ak.Key, ak.Value); + var nsInScope = nav.GetNamespacesInScope(XmlNamespaceScope.ExcludeXml); + foreach (var ak in nsInScope) + { + if (!ns.ContainsKey(ak.Key) && ak.Key != "") + ns.Add(ak.Key, ak.Value); + } + if (!nav.MoveToParent()) + break; } - if (!nav.MoveToParent()) - break; - } - foreach (var dictentry in ns) - { - xmlElement.SetAttribute("xmlns:" + dictentry.Key, dictentry.Value); + foreach (var dictentry in ns) + { + xmlElement.SetAttribute("xmlns:" + dictentry.Key, dictentry.Value); + } + + var xaml = xmlElement.OuterXml; + xaml = "" + xaml + ""; + StringReader stringReader = new StringReader(xaml); + XmlReader xmlReader = XmlReader.Create(stringReader); + 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; } - - var xaml = xmlElement.OuterXml; - StringReader stringReader = new StringReader(xaml); - XmlReader xmlReader = XmlReader.Create(stringReader); - return (FrameworkTemplate)XamlReader.Load(xmlReader); + catch (Exception) + { } + + return null; + } + + + 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/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..5fc3c57c4e 100644 --- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.XamlDom/Project/XamlParser.cs +++ b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.XamlDom/Project/XamlParser.cs @@ -146,6 +146,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 +197,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 +325,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 +505,7 @@ namespace ICSharpCode.WpfDesign.XamlDom if (eventInfo != null) { return new XamlEventPropertyInfo(eventInfo); } + throw new XamlLoadException("property " + propertyName + " not found"); } @@ -507,23 +513,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 +580,12 @@ 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); } + return null; } @@ -759,7 +789,7 @@ namespace ICSharpCode.WpfDesign.XamlDom } } } - + /// /// Method use to parse a piece of Xaml. /// @@ -768,6 +798,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 +828,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..6e2e3fb176 100644 --- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.XamlDom/Project/XamlProperty.cs +++ b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.XamlDom/Project/XamlProperty.cs @@ -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..ac8f9ee102 100644 --- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.XamlDom/Project/XamlTypeFinder.cs +++ b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.XamlDom/Project/XamlTypeFinder.cs @@ -277,6 +277,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 +296,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 } } } From 513c7e193534caf419459cde57d76a899f4c53ae Mon Sep 17 00:00:00 2001 From: jogibear9988 Date: Thu, 20 Nov 2014 08:32:44 +0100 Subject: [PATCH 02/44] bugfix a few small issues: - Remove unnecessary special ResourceDictionary wich handled when Key was not specified (now I specify always one) - Find Properties and Events Not Only against the Instance also against the Element Type (This can be a different one, for Example ModernUiWindow instead of WindowClone) - When Collection Instance is not set, create one (bug appeared in ModerUi ModernWindow) --- .../Project/TemplateHelper.cs | 18 +++++------------- .../WpfDesign.XamlDom/Project/XamlObject.cs | 12 ++++++++++++ .../WpfDesign.XamlDom/Project/XamlParser.cs | 1 + 3 files changed, 18 insertions(+), 13 deletions(-) diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.XamlDom/Project/TemplateHelper.cs b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.XamlDom/Project/TemplateHelper.cs index 7b868dd28b..e2c71dfdfa 100644 --- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.XamlDom/Project/TemplateHelper.cs +++ b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.XamlDom/Project/TemplateHelper.cs @@ -31,14 +31,6 @@ using System.Xml.XPath; namespace ICSharpCode.WpfDesign.XamlDom { - public class TemplateHelperResourceDictionary : ResourceDictionary, IDictionary - { - void IDictionary.Add(object key, object value) - { - base.Add(key == null ? "$$temp&&§§%%__" : key, value); - } - } - public static class TemplateHelper { public static FrameworkTemplate GetFrameworkTemplate(XmlElement xmlElement, XamlObject parentObject) @@ -60,13 +52,13 @@ namespace ICSharpCode.WpfDesign.XamlDom break; } - foreach (var dictentry in ns) - { - 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 + ""; + xaml = "" + xaml + ""; StringReader stringReader = new StringReader(xaml); XmlReader xmlReader = XmlReader.Create(stringReader); var xamlReader = new XamlXmlReader(xmlReader, parentObject.ServiceProvider.SchemaContext); diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.XamlDom/Project/XamlObject.cs b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.XamlDom/Project/XamlObject.cs index 626d6849ee..846cf5c76a 100644 --- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.XamlDom/Project/XamlObject.cs +++ b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.XamlDom/Project/XamlObject.cs @@ -426,11 +426,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 { diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.XamlDom/Project/XamlParser.cs b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.XamlDom/Project/XamlParser.cs index 5fc3c57c4e..1b9a490537 100644 --- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.XamlDom/Project/XamlParser.cs +++ b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.XamlDom/Project/XamlParser.cs @@ -704,6 +704,7 @@ namespace ICSharpCode.WpfDesign.XamlDom else { collectionInstance = collectionProperty.propertyInfo.GetValue(obj.Instance); collectionProperty.ParserSetPropertyElement(element); + collectionInstance = collectionInstance ?? Activator.CreateInstance(collectionProperty.propertyInfo.ReturnType); } } From d87cf6a2ca1c1bdbf36e989c4944263567e8a348 Mon Sep 17 00:00:00 2001 From: jogibear9988 Date: Thu, 20 Nov 2014 21:29:17 +0100 Subject: [PATCH 03/44] A few fixes for better Parsing --- .../WpfDesign.AddIn/Src/MyTypeFinder.cs | 21 ++- .../Project/DesignInstanceExtension.cs | 27 ++++ .../Project/TemplateHelper.cs | 125 +++++++++--------- .../Project/WpfDesign.XamlDom.csproj | 1 + .../WpfDesign.XamlDom/Project/XamlParser.cs | 8 ++ 5 files changed, 116 insertions(+), 66 deletions(-) create mode 100644 src/AddIns/DisplayBindings/WpfDesign/WpfDesign.XamlDom/Project/DesignInstanceExtension.cs diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.AddIn/Src/MyTypeFinder.cs b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.AddIn/Src/MyTypeFinder.cs index e14941e535..ecd03af1c2 100644 --- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.AddIn/Src/MyTypeFinder.cs +++ b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.AddIn/Src/MyTypeFinder.cs @@ -81,9 +81,24 @@ namespace ICSharpCode.WpfDesign.AddIn var compilation = SD.ParserService.GetCompilationForFile(file.FileName); var assembly = this.typeResolutionService.LoadAssembly(compilation.MainAssembly); var prj = SD.ProjectService.CurrentProject; - - var newUri = new Uri(("file://" + Path.Combine(prj.Directory, uri.OriginalString)).Replace("\\","/"), UriKind.RelativeOrAbsolute); - return newUri; + + 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; 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/TemplateHelper.cs b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.XamlDom/Project/TemplateHelper.cs index e2c71dfdfa..69ff8f8958 100644 --- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.XamlDom/Project/TemplateHelper.cs +++ b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.XamlDom/Project/TemplateHelper.cs @@ -35,90 +35,89 @@ namespace ICSharpCode.WpfDesign.XamlDom { public static FrameworkTemplate GetFrameworkTemplate(XmlElement xmlElement, XamlObject parentObject) { - try - { - var nav = xmlElement.CreateNavigator(); - var ns = new Dictionary(); - while (true) + var nav = xmlElement.CreateNavigator(); + + var ns = new Dictionary(); + while (true) + { + var nsInScope = nav.GetNamespacesInScope(XmlNamespaceScope.ExcludeXml); + foreach (var ak in nsInScope) { - var nsInScope = nav.GetNamespacesInScope(XmlNamespaceScope.ExcludeXml); - foreach (var ak in nsInScope) - { - if (!ns.ContainsKey(ak.Key) && ak.Key != "") - ns.Add(ak.Key, ak.Value); - } - if (!nav.MoveToParent()) - break; + if (!ns.ContainsKey(ak.Key) && ak.Key != "") + ns.Add(ak.Key, ak.Value); } + if (!nav.MoveToParent()) + break; + } - var keyAttrib = xmlElement.GetAttribute("Key", XamlConstants.XamlNamespace); + foreach (var dictentry in ns) + { + xmlElement.SetAttribute("xmlns:" + dictentry.Key, dictentry.Value); + } + + var keyAttrib = xmlElement.GetAttribute("Key", XamlConstants.XamlNamespace); - if (string.IsNullOrEmpty(keyAttrib)) - xmlElement.SetAttribute("Key", XamlConstants.XamlNamespace, "$$temp&&§§%%__"); + 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); - var xamlReader = new XamlXmlReader(xmlReader, parentObject.ServiceProvider.SchemaContext); + var xaml = xmlElement.OuterXml; + xaml = "" + xaml + ""; + StringReader stringReader = new StringReader(xaml); + XmlReader xmlReader = XmlReader.Create(stringReader); + var xamlReader = new XamlXmlReader(xmlReader, parentObject.ServiceProvider.SchemaContext); - var seti = new XamlObjectWriterSettings(); + var seti = new XamlObjectWriterSettings(); - var resourceDictionary = new ResourceDictionary(); - var obj = parentObject; - while (obj != null) + var resourceDictionary = new ResourceDictionary(); + var obj = parentObject; + while (obj != null) + { + if (obj.Instance is ResourceDictionary) { - if (obj.Instance is ResourceDictionary) + var r = obj.Instance as ResourceDictionary; + foreach (var k in r.Keys) { - var r = obj.Instance as ResourceDictionary; - foreach (var k in r.Keys) - { - if (!resourceDictionary.Contains(k)) - resourceDictionary.Add(k, r[k]); - } + 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) => + else if (obj.Instance is FrameworkElement) { - if (seti.BeforePropertiesHandler != null) + var r = ((FrameworkElement)obj.Instance).Resources; + foreach (var k in r.Keys) { - var rr = e.Instance as ResourceDictionary; - rr.MergedDictionaries.Add(resourceDictionary); - seti.BeforePropertiesHandler = null; + if (!resourceDictionary.Contains(k)) + resourceDictionary.Add(k, r[k]); } - }; + } + + obj = obj.ParentObject; + } - var writer = new XamlObjectWriter(parentObject.ServiceProvider.SchemaContext, seti); + seti.BeforePropertiesHandler = (s, e) => + { + if (seti.BeforePropertiesHandler != null) + { + var rr = e.Instance as ResourceDictionary; + rr.MergedDictionaries.Add(resourceDictionary); + seti.BeforePropertiesHandler = null; + } + }; - XamlServices.Transform(xamlReader, writer); + var writer = new XamlObjectWriter(parentObject.ServiceProvider.SchemaContext, seti); - var result = (ResourceDictionary)writer.Result; + XamlServices.Transform(xamlReader, writer); - var enr = result.Keys.GetEnumerator(); - enr.MoveNext(); - var rdKey = enr.Current; + var result = (ResourceDictionary)writer.Result; - var template = result[rdKey] as FrameworkTemplate; - result.Remove(rdKey); - return template; - } - catch (Exception) - { } + var enr = result.Keys.GetEnumerator(); + enr.MoveNext(); + var rdKey = enr.Current; - return null; + var template = result[rdKey] as FrameworkTemplate; + result.Remove(rdKey); + return template; } 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/XamlParser.cs b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.XamlDom/Project/XamlParser.cs index 1b9a490537..410fc9fb84 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 { @@ -743,6 +744,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); From 237dee4803f382b057619a546da40069041520fb Mon Sep 17 00:00:00 2001 From: jkuehner Date: Fri, 21 Nov 2014 10:44:40 +0100 Subject: [PATCH 04/44] Massively speed up Property Reading of multiple Selected Objects --- .../Project/PropertyGrid/TypeHelper.cs | 35 +++++-------------- 1 file changed, 8 insertions(+), 27 deletions(-) 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; } - } } From dcaad07743d26881f44260bab0c2d52d1d739c5f Mon Sep 17 00:00:00 2001 From: jkuehner Date: Fri, 21 Nov 2014 15:00:58 +0100 Subject: [PATCH 05/44] Code to Fix References when the Name of a Framework Element Changes (don't know if this should be Standart!) (but I think it should be used on Paste from the Clipboard, so that Pasted Bindings work on Pasted Objects) (not active at the Moment!) --- .../Project/Xaml/XamlDesignItem.cs | 120 ++++++++++++++++-- 1 file changed, 108 insertions(+), 12 deletions(-) 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..ffa14b434b 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,7 +68,11 @@ namespace ICSharpCode.WpfDesign.Designer.Xaml void SetNameInternal(string newName) { + var oldName = Name; + _xamlObject.Name = newName; + + //FixReferencesOnNameChange(oldName, Name); } public override string Name { @@ -75,10 +82,99 @@ namespace ICSharpCode.WpfDesign.Designer.Xaml if (undoService != null) undoService.Execute(new SetNameAction(this, value)); else + { SetNameInternal(value); + } + } } - + + public void FixReferencesOnNameChange(string oldName, string newName) + { + var root = this.Parent; + while (root.Parent != null) + root = root.Parent; + + var references = GetAllChildDesignItems(((XamlDesignItem)root).XamlObject).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; + } + + var bindings = GetAllChildDesignItems(((XamlDesignItem)root).XamlObject).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; + } + } + + private IEnumerable GetAllChildDesignItems(XamlObject item) + { + //if (item.ContentProperty != null) + //{ + // if (item.ContentProperty.Value != null) + // { + // yield return item.ContentProperty.Value; + + // foreach (var i in GetAllChildDesignItems(item.ContentProperty.Value)) + // { + // yield return i; + // } + // } + + // if (item.ContentProperty.IsCollection) + // { + // foreach (var collectionElement in item.ContentProperty.CollectionElements) + // { + // yield return collectionElement; + + // foreach (var i in GetAllChildDesignItems(collectionElement)) + // { + // yield return i; + // } + // } + // } + //} + + + foreach (var prop in item.Properties) + { + if (prop.PropertyValue as XamlObject != null) + { + yield return prop.PropertyValue as XamlObject; + + foreach (var i in GetAllChildDesignItems(prop.PropertyValue as XamlObject)) + { + yield return i; + } + } + + if (prop.IsCollection) + { + foreach (var collectionElement in prop.CollectionElements) + { + if (collectionElement as XamlObject != null) + { + yield return collectionElement as XamlObject; + + foreach (var i in GetAllChildDesignItems(collectionElement as XamlObject)) + { + yield return i; + } + } + } + } + } + } + public override string Key { get { return XamlObject.GetXamlAttribute("Key"); } set { XamlObject.SetXamlAttribute("Key", value); } @@ -167,14 +263,14 @@ namespace ICSharpCode.WpfDesign.Designer.Xaml 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 +281,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 From fec443288fae4c306c10fc6b0c487d4e10f4b45c Mon Sep 17 00:00:00 2001 From: jogibear9988 Date: Fri, 21 Nov 2014 18:25:35 +0100 Subject: [PATCH 06/44] Renaming of Controls -> Bindings and x:References are fixed --- .../Project/Xaml/XamlDesignItem.cs | 89 ++++++++++--------- 1 file changed, 46 insertions(+), 43 deletions(-) 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 ffa14b434b..119b71f456 100644 --- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Xaml/XamlDesignItem.cs +++ b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Xaml/XamlDesignItem.cs @@ -72,9 +72,9 @@ namespace ICSharpCode.WpfDesign.Designer.Xaml _xamlObject.Name = newName; - //FixReferencesOnNameChange(oldName, Name); + FixDesignItemReferencesOnNameChange(oldName, Name); } - + public override string Name { get { return _xamlObject.Name; } set { @@ -89,14 +89,15 @@ namespace ICSharpCode.WpfDesign.Designer.Xaml } } - public void FixReferencesOnNameChange(string oldName, string newName) + /// + /// Fixes {x:Reference and {Binding ElementName to this Element in XamlDocument + /// + /// + /// + public void FixDesignItemReferencesOnNameChange(string oldName, string newName) { - var root = this.Parent; - while (root.Parent != null) - root = root.Parent; - - var references = GetAllChildDesignItems(((XamlDesignItem)root).XamlObject).Where(x => x.ElementType == typeof(Reference) && Equals(x.FindOrCreateProperty("Name").ValueOnInstance, oldName)); - + 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"); @@ -105,8 +106,8 @@ namespace ICSharpCode.WpfDesign.Designer.Xaml property.PropertyValue = propertyValue; } - var bindings = GetAllChildDesignItems(((XamlDesignItem)root).XamlObject).Where(x => x.ElementType == typeof(Binding) && Equals(x.FindOrCreateProperty("ElementName").ValueOnInstance, oldName)); - + 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"); @@ -116,44 +117,44 @@ namespace ICSharpCode.WpfDesign.Designer.Xaml } } - private IEnumerable GetAllChildDesignItems(XamlObject item) + /// + /// Find's the Root XamlObject (real Root, or Root Object in Namescope) + /// + /// + /// + /// + private XamlObject GetRootXamlObject(XamlObject item, bool onlyFromSameNamescope = false) { - //if (item.ContentProperty != null) - //{ - // if (item.ContentProperty.Value != null) - // { - // yield return item.ContentProperty.Value; - - // foreach (var i in GetAllChildDesignItems(item.ContentProperty.Value)) - // { - // yield return i; - // } - // } - - // if (item.ContentProperty.IsCollection) - // { - // foreach (var collectionElement in item.ContentProperty.CollectionElements) - // { - // yield return collectionElement; - - // foreach (var i in GetAllChildDesignItems(collectionElement)) - // { - // yield return i; - // } - // } - // } - //} + 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) { - yield return prop.PropertyValue as XamlObject; + if (!onlyFromSameNamescope || NameScopeHelper.GetNameScopeFromObject(item) == NameScopeHelper.GetNameScopeFromObject(prop.PropertyValue as XamlObject)) + yield return prop.PropertyValue as XamlObject; - foreach (var i in GetAllChildDesignItems(prop.PropertyValue as XamlObject)) + foreach (var i in GetAllChildXamlObjects(prop.PropertyValue as XamlObject)) { - yield return i; + if (!onlyFromSameNamescope || NameScopeHelper.GetNameScopeFromObject(item) == NameScopeHelper.GetNameScopeFromObject(i)) + yield return i; } } @@ -163,11 +164,13 @@ namespace ICSharpCode.WpfDesign.Designer.Xaml { if (collectionElement as XamlObject != null) { - yield return collectionElement as XamlObject; + if (!onlyFromSameNamescope || NameScopeHelper.GetNameScopeFromObject(item) == NameScopeHelper.GetNameScopeFromObject(collectionElement as XamlObject)) + yield return collectionElement as XamlObject; - foreach (var i in GetAllChildDesignItems(collectionElement as XamlObject)) + foreach (var i in GetAllChildXamlObjects(collectionElement as XamlObject)) { - yield return i; + if (!onlyFromSameNamescope || NameScopeHelper.GetNameScopeFromObject(item) == NameScopeHelper.GetNameScopeFromObject(i)) + yield return i; } } } From 54757a67f9e90085fc092feddd1f1d77e30f7a73 Mon Sep 17 00:00:00 2001 From: jogibear9988 Date: Fri, 21 Nov 2014 18:33:22 +0100 Subject: [PATCH 07/44] Log Exceptions when parsing app.xaml --- .../WpfDesign/WpfDesign.AddIn/Src/WpfViewContent.cs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.AddIn/Src/WpfViewContent.cs b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.AddIn/Src/WpfViewContent.cs index 3389ff958f..1b2f56266f 100644 --- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.AddIn/Src/WpfViewContent.cs +++ b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.AddIn/Src/WpfViewContent.cs @@ -30,6 +30,7 @@ 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; @@ -161,9 +162,9 @@ namespace ICSharpCode.WpfDesign.AddIn var dict = (ResourceDictionary)parsed.RootInstance; designer.DesignPanel.Resources.MergedDictionaries.Add(dict); } + } catch (Exception ex) { + LoggingService.Error("Error in loading app.xaml", ex); } - catch (Exception) - { } } } From 0922851312a81207383ab924e625cd56067f753a Mon Sep 17 00:00:00 2001 From: jogibear9988 Date: Sat, 22 Nov 2014 10:27:37 +0100 Subject: [PATCH 08/44] Fixes in Template helper: Remove Added Key and Namespaces... --- .../Extensions/CanvasPlacementSupport.cs | 12 +++++----- .../Extensions/DefaultPlacementBehavior.cs | 24 +++++++++---------- .../Project/TemplateHelper.cs | 21 +++++++++++++--- 3 files changed, 36 insertions(+), 21 deletions(-) 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/DefaultPlacementBehavior.cs b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Extensions/DefaultPlacementBehavior.cs index f894e939d2..363e8a5894 100644 --- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Extensions/DefaultPlacementBehavior.cs +++ b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Extensions/DefaultPlacementBehavior.cs @@ -81,17 +81,17 @@ 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) @@ -100,8 +100,8 @@ namespace ICSharpCode.WpfDesign.Designer.Extensions 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 +129,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 +139,7 @@ namespace ICSharpCode.WpfDesign.Designer.Extensions private bool internalCanEnterContainer(PlacementOperation operation) { - InfoTextEnterArea.Stop(ref infoTextEnterArea); + InfoTextEnterArea.Stop(ref infoTextEnterArea); if (ExtendedItem.Component is Expander) { @@ -164,8 +164,8 @@ namespace ICSharpCode.WpfDesign.Designer.Extensions } } - if (ExtendedItem.ContentProperty.ReturnType == typeof(string)) - return false; + if (ExtendedItem.ContentProperty.ReturnType == typeof(string)) + return false; if (!ExtendedItem.ContentProperty.IsSet) return true; @@ -188,7 +188,7 @@ namespace ICSharpCode.WpfDesign.Designer.Extensions foreach (var info in operation.PlacedItems) { SetPosition(info); } - } + } } } } diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.XamlDom/Project/TemplateHelper.cs b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.XamlDom/Project/TemplateHelper.cs index 69ff8f8958..8c105ace8d 100644 --- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.XamlDom/Project/TemplateHelper.cs +++ b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.XamlDom/Project/TemplateHelper.cs @@ -51,15 +51,21 @@ namespace ICSharpCode.WpfDesign.XamlDom break; } - foreach (var dictentry in ns) + foreach (var dictentry in ns.ToList()) { - xmlElement.SetAttribute("xmlns:" + dictentry.Key, dictentry.Value); + if (xmlElement.HasAttribute("xmlns:" + dictentry.Key)) + ns.Remove(dictentry.Key); + else + xmlElement.SetAttribute("xmlns:" + dictentry.Key, dictentry.Value); } var keyAttrib = xmlElement.GetAttribute("Key", XamlConstants.XamlNamespace); - if (string.IsNullOrEmpty(keyAttrib)) + bool keySet = false; + if (string.IsNullOrEmpty(keyAttrib)) { + keySet = true; xmlElement.SetAttribute("Key", XamlConstants.XamlNamespace, "$$temp&&§§%%__"); + } var xaml = xmlElement.OuterXml; xaml = "" + xaml + ""; @@ -111,11 +117,20 @@ namespace ICSharpCode.WpfDesign.XamlDom var result = (ResourceDictionary)writer.Result; + if (keySet) + xmlElement.RemoveAttribute("Key", XamlConstants.XamlNamespace); + + foreach (var dictentry in ns) + { + xmlElement.RemoveAttribute("xmlns:" + dictentry.Key); + } + var enr = result.Keys.GetEnumerator(); enr.MoveNext(); var rdKey = enr.Current; var template = result[rdKey] as FrameworkTemplate; + result.Remove(rdKey); return template; } From 54eedf44106688ce57d17d2f7412b92b03d6ae33 Mon Sep 17 00:00:00 2001 From: jogibear9988 Date: Sun, 23 Nov 2014 11:55:53 +0100 Subject: [PATCH 09/44] Templatehelper should Clone the Node and don't modify the original one --- .../WpfDesign.XamlDom/Project/TemplateHelper.cs | 17 +++-------------- 1 file changed, 3 insertions(+), 14 deletions(-) diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.XamlDom/Project/TemplateHelper.cs b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.XamlDom/Project/TemplateHelper.cs index 8c105ace8d..6624bb4ec1 100644 --- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.XamlDom/Project/TemplateHelper.cs +++ b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.XamlDom/Project/TemplateHelper.cs @@ -50,20 +50,17 @@ namespace ICSharpCode.WpfDesign.XamlDom if (!nav.MoveToParent()) break; } + + xmlElement = (XmlElement)xmlElement.CloneNode(true); foreach (var dictentry in ns.ToList()) { - if (xmlElement.HasAttribute("xmlns:" + dictentry.Key)) - ns.Remove(dictentry.Key); - else - xmlElement.SetAttribute("xmlns:" + dictentry.Key, dictentry.Value); + xmlElement.SetAttribute("xmlns:" + dictentry.Key, dictentry.Value); } var keyAttrib = xmlElement.GetAttribute("Key", XamlConstants.XamlNamespace); - bool keySet = false; if (string.IsNullOrEmpty(keyAttrib)) { - keySet = true; xmlElement.SetAttribute("Key", XamlConstants.XamlNamespace, "$$temp&&§§%%__"); } @@ -117,14 +114,6 @@ namespace ICSharpCode.WpfDesign.XamlDom var result = (ResourceDictionary)writer.Result; - if (keySet) - xmlElement.RemoveAttribute("Key", XamlConstants.XamlNamespace); - - foreach (var dictentry in ns) - { - xmlElement.RemoveAttribute("xmlns:" + dictentry.Key); - } - var enr = result.Keys.GetEnumerator(); enr.MoveNext(); var rdKey = enr.Current; From 6b2cf8714e2f5808e810381f4b993a0b72db86c2 Mon Sep 17 00:00:00 2001 From: jogibear9988 Date: Sun, 23 Nov 2014 11:56:36 +0100 Subject: [PATCH 10/44] Whitespace --- .../WpfDesign.Designer/Project/Extensions/Initializers.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) 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) From bb3a5419b6c79f1549c7cd2a52c9086292a2bb28 Mon Sep 17 00:00:00 2001 From: jogibear9988 Date: Sun, 23 Nov 2014 17:54:25 +0100 Subject: [PATCH 11/44] Activate a now working Unit Test --- .../WpfDesign/WpfDesign.Designer/Tests/XamlDom/SamplesTests.cs | 1 - 1 file changed, 1 deletion(-) 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 91c1d4aa35..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(@" Date: Mon, 24 Nov 2014 16:07:41 +0100 Subject: [PATCH 12/44] Bugfix: Copyied XAML contains d1p1 as Namespace Prefix for Added Name Attribute --- .../WpfDesign.XamlDom/Project/XamlObject.cs | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.XamlDom/Project/XamlObject.cs b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.XamlDom/Project/XamlObject.cs index 846cf5c76a..3813d9d835 100644 --- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.XamlDom/Project/XamlObject.cs +++ b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.XamlDom/Project/XamlObject.cs @@ -515,7 +515,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; From 19486b6cf2cc7fbaaea36d44fb589169d6089d87 Mon Sep 17 00:00:00 2001 From: jogibear9988 Date: Mon, 24 Nov 2014 20:49:48 +0100 Subject: [PATCH 13/44] Fix multiple XML-Namspaces for the same CLR-Namespace Now all UnitTests work --- .../Tests/XamlDom/SimpleLoadTests.cs | 1 - .../WpfDesign.XamlDom/Project/XamlDocument.cs | 10 +++++++ .../WpfDesign.XamlDom/Project/XamlProperty.cs | 8 +++--- .../Project/XamlTypeFinder.cs | 27 +++++++++++++++++++ 4 files changed, 41 insertions(+), 5 deletions(-) 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/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/XamlProperty.cs b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.XamlDom/Project/XamlProperty.cs index 6e2e3fb176..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; } diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.XamlDom/Project/XamlTypeFinder.cs b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.XamlDom/Project/XamlTypeFinder.cs index ac8f9ee102..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() From 535b4df471f9352911ea0211d557dc4355c3e298 Mon Sep 17 00:00:00 2001 From: jkuehner Date: Wed, 26 Nov 2014 22:28:53 +0100 Subject: [PATCH 14/44] Fixes ContextMenus when Designer is used inside of SD! --- .../WpfDesign.AddIn/Src/WpfViewContent.cs | 16 +++++++++- .../WpfDesign.Designer/Project/DesignPanel.cs | 29 +++++++++++++------ 2 files changed, 35 insertions(+), 10 deletions(-) diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.AddIn/Src/WpfViewContent.cs b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.AddIn/Src/WpfViewContent.cs index 1b2f56266f..7a9765cf85 100644 --- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.AddIn/Src/WpfViewContent.cs +++ b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.AddIn/Src/WpfViewContent.cs @@ -26,6 +26,7 @@ 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; @@ -127,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); diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/DesignPanel.cs b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/DesignPanel.cs index d13f23dcc8..5a02dfb314 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 @@ -461,6 +462,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 +487,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 From f92e6bef3bbbd8db2ca5a1c737118a9658bcdaf1 Mon Sep 17 00:00:00 2001 From: jkuehner Date: Wed, 26 Nov 2014 23:11:36 +0100 Subject: [PATCH 15/44] Content should be Addable to all ContentControls --- .../Extensions/DefaultPlacementBehavior.cs | 27 ++----------------- .../Project/Xaml/XamlEditOperations.cs | 2 +- 2 files changed, 3 insertions(+), 26 deletions(-) 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 363e8a5894..3100b99a8e 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(); @@ -158,12 +140,7 @@ 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; 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; } From 1d80551b9ec978cf1912220fa894f7c0404dbb0f Mon Sep 17 00:00:00 2001 From: jkuehner Date: Fri, 28 Nov 2014 13:02:59 +0100 Subject: [PATCH 16/44] Use the Same Context Menu for Outline View --- .../WpfDesign/WpfDesign.AddIn/WpfDesign.addin | 4 +- .../DefaultCommandsContextMenu.xaml | 38 ++++++++++++ .../DefaultCommandsContextMenu.xaml.cs | 43 ++++++++++++++ .../DefaultCommandsContextMenuExtension.cs | 54 ++++++++++++++++++ .../EditStyleContextMenuExtension.cs | 2 +- .../RightClickContextMenuExtension.cs | 1 + ...TextBlockRightClickContextMenuExtension.cs | 2 +- .../Project/Images/Icons.16x16.CopyIcon.png | Bin 0 -> 675 bytes .../Project/Images/Icons.16x16.CutIcon.png | Bin 0 -> 773 bytes .../Project/Images/Icons.16x16.DeleteIcon.png | Bin 0 -> 663 bytes .../Project/Images/Icons.16x16.PasteIcon.png | Bin 0 -> 685 bytes .../Project/Images/Icons.16x16.RedoIcon.png | Bin 0 -> 613 bytes .../Project/Images/Icons.16x16.UndoIcon.png | Bin 0 -> 631 bytes .../Project/OutlineView/OutlineView.xaml | 8 +-- .../Project/WpfDesign.Designer.csproj | 14 +++++ 15 files changed, 158 insertions(+), 8 deletions(-) create mode 100644 src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Extensions/DefaultCommandsContextMenu.xaml create mode 100644 src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Extensions/DefaultCommandsContextMenu.xaml.cs create mode 100644 src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Extensions/DefaultCommandsContextMenuExtension.cs create mode 100644 src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Images/Icons.16x16.CopyIcon.png create mode 100644 src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Images/Icons.16x16.CutIcon.png create mode 100644 src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Images/Icons.16x16.DeleteIcon.png create mode 100644 src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Images/Icons.16x16.PasteIcon.png create mode 100644 src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Images/Icons.16x16.RedoIcon.png create mode 100644 src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Images/Icons.16x16.UndoIcon.png 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/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/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Extensions/DefaultCommandsContextMenu.xaml.cs b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Extensions/DefaultCommandsContextMenu.xaml.cs new file mode 100644 index 0000000000..9aa571a360 --- /dev/null +++ b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Extensions/DefaultCommandsContextMenu.xaml.cs @@ -0,0 +1,43 @@ +// 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 System.Linq; +using System.Windows; +using System.Windows.Controls; +using System.Windows.Markup; +using System.Xml; +using ICSharpCode.WpfDesign.Designer.PropertyGrid.Editors.FormatedTextEditor; +using ICSharpCode.WpfDesign.Designer.Xaml; +using ICSharpCode.WpfDesign.XamlDom; + +namespace ICSharpCode.WpfDesign.Designer.Extensions +{ + public partial class DefaultCommandsContextMenu + { + private DesignItem designItem; + + public DefaultCommandsContextMenu(DesignItem designItem) + { + this.designItem = designItem; + + InitializeComponent(); + } + } +} 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/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/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/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/Images/Icons.16x16.CopyIcon.png b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Images/Icons.16x16.CopyIcon.png new file mode 100644 index 0000000000000000000000000000000000000000..7537994da49e10f1c253edeb4eafe2e434f04a33 GIT binary patch literal 675 zcmV;U0$lxxP)r&{-g-Dm~%%&|BQV=bagru9IG(k!sY9?t+ z(oQBb<9Tl~woIiL?%eq}=ef^0+>!2^COw#&BMjg7#VSeCGhQa?|6|8>-S3|3ig*=( zU~nSwN8H|ezr4I|_xsfIJaYJ*$HB#7k=|`?zC5|Wh9s|5yk9z0l z)ai7n-EPx|m6dh={+L7WB3^;PP#Ja1^8GBknMuQVSU5Z+MNtGu8y%(6!2#`+%QQ7U z{`BM4*3VzHT3+>dr|Xn|)M}JYr6?MS(3AOjLX4(ql-u8LB2o1QHD4$L;y5A@$}bic z=xr`Xt&$h|trrzN17Xa230KQbKRWb~N>h(GuaSs5)%x1Hs zax-rxlj2$7&73em3K?MahY%=tyIqlpt&n*IfD$T|is%6hV1i^M-kF#nJsK5fgkNGe za%_75Z~_Cqq`7g}H87ae^?%A(QHBo)&!%OK{4SL)0fq(uzydp`*dkDVy}J78)zZ?} z;KX{}ZtJYkm{OZ3C!~#y34=#7GvWXN;-Y^1TtnrEqI~&NF0X}7{+W7|&&O|@=1A}} zAs7Gv1#GC??sRM<@N8Trs5}kp__(D{PrspS29$Y8gaLmA7yxViVQW_88$tj8002ov JPDHLkV1lk@IJp1- literal 0 HcmV?d00001 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 0000000000000000000000000000000000000000..ca21cb2a7c7c21d33be3f452f505c5c4fb4dfcdc GIT binary patch literal 773 zcmV+g1N!`lP)?Wu#h8KxNA)59>R>EMSh9MNOm|_Ml z7i3{La?aZP+}k;ylk~=$UO1e;=Xu`u~y>H8q7; zEC!BsIvwGEZh4jIp?}UW*p;* z#{wEfK$8imHNf~_aA@!`Dk>@v2n6bCYHIvmueY3X@6d$$C3ap7B6lM&D+BVMxiO-u zkp*;6smm$1ljUN3Aa`BH4^w~hwc_=)58q9umPe48Gfq9W_ejn9NgytspP&~2I;7+? zTMLcO?Y6vv9Q}$MNh+7VhX=9dcvH0Qd~Gpdis`i?8k>&335EyyK8EwDc84skf-F~- zSPfNGjsnNi&hF96w;H=-S;pO#-frqW@YXkUbI$eqZLdD<*_Q8MJoA)2Kw^4F_3omQ zd#$fOjC>u7UOIWG?8*&auaIYaLZr^J=bY<5qm#dHH$8bzB-jk4Y;{ zi+>o(l{)n=wvMD2&paNZ1if(=)>a>7Dg64}hDfKMVxAE%yR1wKSVpFWiRQa%!$FEe z`0}h-Oh&r6X;`@OWT`Z9HXZX(lWEdkwO|v!{S{yUx2jPo2<~u!00000NkvXXu0mjf D<3(%H literal 0 HcmV?d00001 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 0000000000000000000000000000000000000000..70b59dc9debb268312321d0b10acd2f59f93c346 GIT binary patch literal 663 zcmV;I0%-k-P)I^#n zUT|vg3=v?B0yLT{7Bl;EImu8}t2{IFUY0^Yb4O?iifc1J27k5V$$FKm@>}!F+yzL@`vW zRF*VNJ1BUmxNA2jaBHx-y)9{6-sqR4J-RFhm+JLuDi%wqw!QGjvIb3Fv&Pmo>Rc?( zczs_weYnTx>#5Z1HQ6v8t~8q;LV-X8w(0i&=Ac6W_Oaer?8E_4l-3kweZw%GBjl%W zJo!ykr=os;7W!?Ar@KjDdwFLKqKikv;jCtwf6KD`3FjvYY;6y7bV}P3ZSB zJB)6@!(PMK7Fef^f*|aLVR(S(3c~&U7I~t|%fPB$aBdbph%*AgKBB%P(XIu?UUvxM xeB1;4p%%}~;yUBAou|gt6 zkY-_^2w7McZnUdb5V0Uw)MYny(tHkrVb}s-#+B5EjQW| z1l?90(D0Hl#hp`oTWaCzO!m^k{c#?DUU~Yv{;~J~X^7t5uY|=g@w4f^KzVk4VX9iK zB764*bX`L_JrXV)9htCg7YDEJA)n9VQ*o6AE`|;|{=kCkx@b0=ICy*$nx=)2Wf`95 zg=@)VGHl}Nvc zo~IN#RT|v$~|&e6%lj=BL^`N{*r*A)=c0`YH-2h|I1b2C&CUS zTJzZr|5DHuZW%^GeftZzaT*xcx+Ep$AmLfKbL|4+!Dhbi9`5bvnH6%o&yOkfejlT^ zPIfaT=zs#sz_^l)j0Hn&alQWY%fI>)>KdT{AzN!@rabhG{AgZJRfn%c+wP zau<(BNgTUz6anjWAPPg!cdO9$eK0Lcx{gA(W%r+3;7J0VAOKmlG=9{H8Jj|q@vRnq zPe4(}K!^!+i-^3uJr_a|)oKi`TsZDLcv79}iSPCk3tri2%<8bNx3FqO$M@2&H>o1jPDB{giC-YaGQQOAbQokKR!wj0qxV0>?^R00eOg?O4FEgBh4# zC@n*P5n1$LDo~hw!OkBq@rB^Di6NYV+Q-N+uhh+}8385ITGsjB_{2;``bx zG^)4R``JH6`71{H7&pmR=Unbpx?|+E)gk!yp~4sMJnJpXjx|6e7!za63Iw&MeEI%6 zxu6IpzY#gU-V6GdJraFLdW8KD7XOjZY$wB6x00000NkvXXu0mjf2YnK8 literal 0 HcmV?d00001 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 0000000000000000000000000000000000000000..2a361a0789d620a5f75f126091536fa83d15bf3e GIT binary patch literal 631 zcmV--0*L*IP)*_ z{hQg@@oj!eMM0zo2R>%^%{T9T@0%GSgn;7=3643Gsi!r_WV4{@I;fcpD5`2<{01t! zpAy_o=a4Lt1XvXHk#Igp@Jl)&te7!-^cw}iKeT|G8Kw4}Yh^R75PBZ)IR1MJgT2C{ zQDi^3J!Lu$2O5THcx{v#ae$~JZxQF!qY235lU0ilV$a?+&8;mDbY1ErJ)8jqgi%ae z9p9~QA2d2nIL{e-fgbpM1vCikhclPVjg24ujJ`kYALYA22p;-CDbtdKpDGr$B8$nr zc8jGZK1)rNbJbgW%PYH;E0@QOcAEmIGIV5sZ;61etbmu%p_k2pqvxPWbcq-81(b7^ z`N0}`v`@;jZvjbJcv;mEilrQthxuNg_no6e)K?Bl&!m8b%3%kdoT^D_njg z6CkOaZLSvfKCOJIoVj?xXntI8pf6P<%*9dkl84bk?DXESR{KM|v)kovuf$z9iwa(o zQ6+h-0`lZ_OFBK#zX$C7^D1v{{&sBI`DuWY?a zx%3(1V+aFL9?k}D)(zzCh|;+U RV`TsU002ovPDHLkV1oAS7YqOZ literal 0 HcmV?d00001 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/WpfDesign.Designer.csproj b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/WpfDesign.Designer.csproj index f3b0cc3433..c35f7c65f8 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 @@ -289,6 +294,7 @@ + Designer @@ -468,4 +474,12 @@ + + + + + + + + \ No newline at end of file From 92f9c3ab367f9ce5b715b4c3c516c79e8da0382b Mon Sep 17 00:00:00 2001 From: Matt Ward Date: Sat, 29 Nov 2014 13:36:15 +0000 Subject: [PATCH 17/44] Fix IOException when running code coverage. Running unit tests with code coverage would intermittently throw an IOException: System.IO.IOException: The process cannot access the file '...OpenCover\coverage.xml' --- .../CodeCoverage/Project/Src/CodeCoverageResultsReader.cs | 5 +++-- .../Project/Src/RunTestWithCodeCoverageCommand.cs | 7 ++++++- 2 files changed, 9 insertions(+), 3 deletions(-) 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) { From 0d69188c47344511481cf62b3ae3e207fb7e00d7 Mon Sep 17 00:00:00 2001 From: jkuehner Date: Mon, 1 Dec 2014 12:16:12 +0100 Subject: [PATCH 18/44] Possibilities to disable Extensions --- .../WpfDesign/Project/Extensions/Extension.cs | 15 +++++++++++++++ .../Project/Extensions/ExtensionManager.cs | 17 ++++++++++------- 2 files changed, 25 insertions(+), 7 deletions(-) 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)); } } } From 6719026a8b9c163005a5862689078107d432c0dc Mon Sep 17 00:00:00 2001 From: jkuehner Date: Mon, 1 Dec 2014 13:51:15 +0100 Subject: [PATCH 19/44] Fix a Null Ref Exception... --- .../Project/Extensions/SnaplinePlacementBehavior.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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..d9e6e8552a 100644 --- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Extensions/SnaplinePlacementBehavior.cs +++ b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Extensions/SnaplinePlacementBehavior.cs @@ -227,7 +227,7 @@ namespace ICSharpCode.WpfDesign.Designer.Extensions 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); From a1851881051eed76d41842c7ef4fc3e8bb9c9e3c Mon Sep 17 00:00:00 2001 From: Daniel Grunwald Date: Mon, 1 Dec 2014 18:54:26 +0100 Subject: [PATCH 20/44] Avoid problems saving files (with safe saving enabled) when the same project is also open in Visual Studio --- src/Main/Base/Project/Util/NativeMethods.cs | 34 +++++++++++++++++++ .../Base/Project/Workbench/File/OpenedFile.cs | 11 ++++-- 2 files changed, 43 insertions(+), 2 deletions(-) diff --git a/src/Main/Base/Project/Util/NativeMethods.cs b/src/Main/Base/Project/Util/NativeMethods.cs index 5e1b5ed5d0..9bcf34d226 100644 --- a/src/Main/Base/Project/Util/NativeMethods.cs +++ b/src/Main/Base/Project/Util/NativeMethods.cs @@ -17,6 +17,7 @@ // DEALINGS IN THE SOFTWARE. using System; +using System.ComponentModel; using System.IO; using System.Runtime.InteropServices; using System.Security; @@ -122,6 +123,39 @@ namespace ICSharpCode.SharpDevelop } #endregion + + #region SetFileTime + [StructLayout(LayoutKind.Sequential)] + struct FILETIME + { + internal uint ftTimeLow; + internal uint ftTimeHigh; + + public FILETIME(long fileTime) + { + unchecked { + this.ftTimeLow = (uint)fileTime; + this.ftTimeHigh = (uint)(fileTime >> 32); + } + } + } + + [DllImport("kernel32.dll", SetLastError = true)] + [return: MarshalAs(UnmanagedType.Bool)] + unsafe static extern bool SetFileTime(SafeFileHandle hFile, FILETIME* creationTime, FILETIME* lastAccessTime, FILETIME* lastWriteTime); + + /// + /// Update the file times on the given file handle. + /// + public unsafe static void SetFileCreationTime(SafeFileHandle hFile, DateTime creationTime) + { + FILETIME fileCreationTime = new FILETIME(creationTime.ToFileTimeUtc()); + if (!SetFileTime(hFile, &fileCreationTime, null, null)) { + throw new Win32Exception(Marshal.GetLastWin32Error()); + } + } + #endregion + #region Get OEM Encoding [DllImport("kernel32.dll")] static extern int GetOEMCP(); diff --git a/src/Main/Base/Project/Workbench/File/OpenedFile.cs b/src/Main/Base/Project/Workbench/File/OpenedFile.cs index 83e74192b6..b7bad5c0ae 100644 --- a/src/Main/Base/Project/Workbench/File/OpenedFile.cs +++ b/src/Main/Base/Project/Workbench/File/OpenedFile.cs @@ -230,6 +230,14 @@ namespace ICSharpCode.SharpDevelop.Workbench bool safeSaving = SD.FileService.SaveUsingTemporaryFile && File.Exists(FileName); string saveAs = safeSaving ? FileName + ".bak" : FileName; using (FileStream fs = new FileStream(saveAs, FileMode.Create, FileAccess.Write)) { + if (safeSaving) { + // Copy creation time from source file + // Because setting the time requires opening the file for write access, + // we can't use System.IO.File.SetCreationTimeUtc for this, as it would open the file twice, + // which causes problems when another process is monitoring the directory + // and reading our new file as soon as we're done writing. + NativeMethods.SetFileCreationTime(fs.SafeFileHandle, File.GetCreationTimeUtc(FileName)); + } if (currentView != null) { SaveCurrentViewToStream(fs); } else { @@ -237,7 +245,7 @@ namespace ICSharpCode.SharpDevelop.Workbench } } if (safeSaving) { - DateTime creationTime = File.GetCreationTimeUtc(FileName); + // TODO: we should probably use Win32 MoveFileEx to atomically move while replacing the old file File.Delete(FileName); try { File.Move(saveAs, FileName); @@ -247,7 +255,6 @@ namespace ICSharpCode.SharpDevelop.Workbench System.Threading.Thread.Sleep(250); File.Move(saveAs, FileName); } - File.SetCreationTimeUtc(FileName, creationTime); } IsDirty = false; } From cf41d839662870ecea4dc7487602f84e61f5b5e8 Mon Sep 17 00:00:00 2001 From: jkuehner Date: Tue, 2 Dec 2014 11:18:21 +0100 Subject: [PATCH 21/44] Possibility to disable Snaplines in a Derived Extension via returning CanPlace = false --- .../Project/Extensions/DefaultPlacementBehavior.cs | 7 ++++++- .../Project/Extensions/SnaplinePlacementBehavior.cs | 5 ++++- .../WpfDesign.Designer/Project/RootItemBehavior.cs | 9 +++------ .../WpfDesign/WpfDesign/Project/PlacementBehavior.cs | 2 +- 4 files changed, 14 insertions(+), 9 deletions(-) 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 3100b99a8e..26e7d9c46e 100644 --- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Extensions/DefaultPlacementBehavior.cs +++ b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Extensions/DefaultPlacementBehavior.cs @@ -50,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; } @@ -80,6 +80,11 @@ namespace ICSharpCode.WpfDesign.Designer.Extensions { } + public virtual bool CanPlaceItem(PlacementInformation info) + { + return true; + } + public virtual void SetPosition(PlacementInformation info) { if (info.Operation.Type != PlacementType.Move) 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 d9e6e8552a..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,7 +224,10 @@ 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=> x.View != null && !GetDisableSnaplines(x.View))) { 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/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. From 85da07adb6349a34f33c11368718cb936db32472 Mon Sep 17 00:00:00 2001 From: jkuehner Date: Tue, 2 Dec 2014 11:24:03 +0100 Subject: [PATCH 22/44] Mouse Gestures need to be public, to be used for a custom Extension in a custom DLL --- .../Project/Services/ClickOrDragMouseGesture.cs | 2 +- .../Project/Services/DragMoveMouseGesture.cs | 6 +++--- .../WpfDesign.Designer/Project/Services/MouseGestureBase.cs | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) 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. From 994a1561f5f13ca1919f921713dda741b3f651c4 Mon Sep 17 00:00:00 2001 From: jkuehner Date: Tue, 2 Dec 2014 12:00:43 +0100 Subject: [PATCH 23/44] Primary Selection but only when multiple Items Extension Server should be Reapplied on Selection changed --- .../WpfDesign/WpfDesign/Project/DesignItem.cs | 7 +++++++ .../WpfDesign/Project/Extensions/ExtensionServer.cs | 8 ++++++++ .../Project/Extensions/SelectionExtensionServer.cs | 5 +++++ 3 files changed, 20 insertions(+) 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/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. /// From 422b655c94cc18fdad0ac9b52c1002bde9215492 Mon Sep 17 00:00:00 2001 From: Christoph Wille Date: Wed, 3 Dec 2014 09:18:53 +0100 Subject: [PATCH 24/44] Fix for missing Wpf Tk dll in SDR (best solution would be to have dll once in bin) --- src/Setup/Files.wxs | 3 +++ src/Setup/Setup.wxs | 1 + 2 files changed, 4 insertions(+) diff --git a/src/Setup/Files.wxs b/src/Setup/Files.wxs index 9132581428..966cabdc25 100644 --- a/src/Setup/Files.wxs +++ b/src/Setup/Files.wxs @@ -1310,6 +1310,9 @@ + + + diff --git a/src/Setup/Setup.wxs b/src/Setup/Setup.wxs index 6135e85b2a..01e4f12b68 100644 --- a/src/Setup/Setup.wxs +++ b/src/Setup/Setup.wxs @@ -397,6 +397,7 @@ + From 56ee23ea8dcc2758a3a0d98513f04dfb6ed4106f Mon Sep 17 00:00:00 2001 From: gumme Date: Thu, 4 Dec 2014 21:19:51 +0100 Subject: [PATCH 25/44] Fixed so resize operation by using ctrl + arrow is working again, and also handles the case if the user releases ctrl while still pressing an arrow. --- .../WpfDesign.Designer/Project/DesignPanel.cs | 23 ++++++++++++------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/DesignPanel.cs b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/DesignPanel.cs index d13f23dcc8..d15d9fc93c 100644 --- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/DesignPanel.cs +++ b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/DesignPanel.cs @@ -389,10 +389,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 +421,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); } } From 4da4791daa82ff6febec96427686b8c8693c03a9 Mon Sep 17 00:00:00 2001 From: turbanoff Date: Tue, 9 Dec 2014 02:07:41 +0300 Subject: [PATCH 26/44] Allow Ctrl+A in ExceptionBox --- src/Main/SharpDevelop/Logging/ExceptionBox.cs | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/Main/SharpDevelop/Logging/ExceptionBox.cs b/src/Main/SharpDevelop/Logging/ExceptionBox.cs index 7c87c91379..13609bafed 100644 --- a/src/Main/SharpDevelop/Logging/ExceptionBox.cs +++ b/src/Main/SharpDevelop/Logging/ExceptionBox.cs @@ -241,6 +241,14 @@ namespace ICSharpCode.SharpDevelop.Logging } } + void ExceptionTextBoxKeyDown(object sender, KeyEventArgs e) + { + if (e.KeyData == (Keys.Control | Keys.A)) { + exceptionTextBox.SelectAll(); + e.Handled = e.SuppressKeyPress = true; + } + } + [SuppressMessage("Microsoft.Globalization", "CA1303")] void InitializeComponent() { @@ -327,6 +335,7 @@ namespace ICSharpCode.SharpDevelop.Logging this.exceptionTextBox.Size = new System.Drawing.Size(448, 184); this.exceptionTextBox.TabIndex = 1; this.exceptionTextBox.Text = "textBoxExceptionText"; + this.exceptionTextBox.KeyDown += new System.Windows.Forms.KeyEventHandler(this.ExceptionTextBoxKeyDown); // // pictureBox // From ca257e4a45a50bb8184783b2b480862b69cb6434 Mon Sep 17 00:00:00 2001 From: jkuehner Date: Tue, 9 Dec 2014 11:19:36 +0100 Subject: [PATCH 27/44] Bugfix Exception when Deleting Objects ... (Then Bindings should not be changed!) --- .../Project/Xaml/XamlDesignItem.cs | 36 ++++++++++--------- 1 file changed, 19 insertions(+), 17 deletions(-) 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 119b71f456..b873e2c6ee 100644 --- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Xaml/XamlDesignItem.cs +++ b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Xaml/XamlDesignItem.cs @@ -96,24 +96,26 @@ namespace ICSharpCode.WpfDesign.Designer.Xaml /// public void FixDesignItemReferencesOnNameChange(string oldName, string 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; - } + 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; + 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; + } } } From a502cf0eafc0968a5b2705794be2cef35986769c Mon Sep 17 00:00:00 2001 From: Andreas Weizel Date: Wed, 10 Dec 2014 00:34:14 +0100 Subject: [PATCH 28/44] Fix #613: NullReferenceException when I add `new DirectoryInfo(".")` to watches in debug. --- .../Debugger.AddIn/NRefactory/ExpressionEvaluationVisitor.cs | 2 +- src/AddIns/Debugger/Debugger.Core/Value.cs | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/AddIns/Debugger/Debugger.AddIn/NRefactory/ExpressionEvaluationVisitor.cs b/src/AddIns/Debugger/Debugger.AddIn/NRefactory/ExpressionEvaluationVisitor.cs index 7f39644774..72eeed38e7 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()); } 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) From 8d47f0467852ad6d9069556ca4b2e82698ac4972 Mon Sep 17 00:00:00 2001 From: gumme Date: Wed, 10 Dec 2014 21:42:41 +0100 Subject: [PATCH 29/44] Fixed bug; CanPrint was only checked for the first property using nested markup extension. --- .../Tests/Designer/ModelTests.cs | 32 ++++++++++++++----- .../Project/MarkupExtensionPrinter.cs | 4 +-- 2 files changed, 26 insertions(+), 10 deletions(-) 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..44a970f18b 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,33 @@ 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(""); 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; } } From a356868562efcc454ef4662bd878efa3655f2738 Mon Sep 17 00:00:00 2001 From: Andreas Weizel Date: Wed, 10 Dec 2014 22:14:18 +0100 Subject: [PATCH 30/44] Fix #616: Accessing an object list in ConsolePad causes unhandled exception --- .../NRefactory/ExpressionEvaluationVisitor.cs | 39 +++++++++++-------- 1 file changed, 23 insertions(+), 16 deletions(-) diff --git a/src/AddIns/Debugger/Debugger.AddIn/NRefactory/ExpressionEvaluationVisitor.cs b/src/AddIns/Debugger/Debugger.AddIn/NRefactory/ExpressionEvaluationVisitor.cs index 72eeed38e7..1e534faede 100644 --- a/src/AddIns/Debugger/Debugger.AddIn/NRefactory/ExpressionEvaluationVisitor.cs +++ b/src/AddIns/Debugger/Debugger.AddIn/NRefactory/ExpressionEvaluationVisitor.cs @@ -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); } } From 13002cf06569a3a220c23741bb00b4e0e2241b49 Mon Sep 17 00:00:00 2001 From: gumme Date: Thu, 11 Dec 2014 08:53:58 +0100 Subject: [PATCH 31/44] Added update of child markup extensions when markup extension chain is updated. --- .../Tests/Designer/ModelTests.cs | 6 ++++++ .../WpfDesign.XamlDom/Project/XamlObject.cs | 15 ++++++++++++++- 2 files changed, 20 insertions(+), 1 deletion(-) 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 44a970f18b..04444169e3 100644 --- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Tests/Designer/ModelTests.cs +++ b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Tests/Designer/ModelTests.cs @@ -627,6 +627,12 @@ namespace ICSharpCode.WpfDesign.Tests.Designer bindingItem.Properties["Source"].Value.Properties["ResourceKey"].SetValue("bindingSource"); } + var binding = bindingItem.Component as Binding; + Assert.IsNotNull(binding); + Assert.IsNotNull(binding.Source); + Assert.IsNotNull(exampleClassItem.Component); + Assert.AreSame(exampleClassItem.Component, binding.Source); + const string expectedXaml = " 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/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/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/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 - - From 3870c83f3f09f44bec73706f0ff22bfa4fe9258d Mon Sep 17 00:00:00 2001 From: jogibear9988 Date: Sun, 14 Dec 2014 11:54:04 +0100 Subject: [PATCH 35/44] Missing 1 DesignTimeProperty --- .../WpfDesign/WpfDesign.XamlDom/Project/XamlParser.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.XamlDom/Project/XamlParser.cs b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.XamlDom/Project/XamlParser.cs index 410fc9fb84..ab190e58ba 100644 --- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.XamlDom/Project/XamlParser.cs +++ b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.XamlDom/Project/XamlParser.cs @@ -585,6 +585,8 @@ namespace ICSharpCode.WpfDesign.XamlDom 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); } From 6b03044477a1b493f9efaf7ddef7be769cf59544 Mon Sep 17 00:00:00 2001 From: Matt Ward Date: Sun, 14 Dec 2014 11:57:21 +0000 Subject: [PATCH 36/44] Use NuGet's PackageSourceProvider. Move logic out of SharpDevelop and use NuGet's PackageSourceProvider to read and update NuGet package sources in NuGet.Config. --- .../Project/Src/Design/FakeSettings.cs | 6 +- .../Src/RegisteredPackageSourceSettings.cs | 70 ++++--------------- .../Test/Src/PackageManagementOptionsTests.cs | 47 ++++--------- 3 files changed, 32 insertions(+), 91 deletions(-) diff --git a/src/AddIns/Misc/PackageManagement/Project/Src/Design/FakeSettings.cs b/src/AddIns/Misc/PackageManagement/Project/Src/Design/FakeSettings.cs index 0c1980b65c..dc9f4785e3 100644 --- a/src/AddIns/Misc/PackageManagement/Project/Src/Design/FakeSettings.cs +++ b/src/AddIns/Misc/PackageManagement/Project/Src/Design/FakeSettings.cs @@ -159,7 +159,7 @@ 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) @@ -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/RegisteredPackageSourceSettings.cs b/src/AddIns/Misc/PackageManagement/Project/Src/RegisteredPackageSourceSettings.cs index 829c1bef8d..0663201646 100644 --- a/src/AddIns/Misc/PackageManagement/Project/Src/RegisteredPackageSourceSettings.cs +++ b/src/AddIns/Misc/PackageManagement/Project/Src/RegisteredPackageSourceSettings.cs @@ -37,12 +37,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 +57,7 @@ namespace ICSharpCode.PackageManagement this.defaultPackageSource = defaultPackageSource; settings = settingsProvider.LoadSettings(); + packageSourceProvider = CreatePackageSourceProvider(settings); ReadActivePackageSource(); RegisterSolutionEvents(); @@ -64,6 +68,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); @@ -81,28 +90,9 @@ namespace ICSharpCode.PackageManagement void ReadPackageSources() { - IEnumerable savedPackageSources = GetPackageSourcesFromSettings(); + IEnumerable savedPackageSources = packageSourceProvider.LoadPackageSources(); packageSources = new RegisteredPackageSources(savedPackageSources, defaultPackageSource); packageSources.CollectionChanged += PackageSourcesChanged; - - if (!savedPackageSources.Any()) { - UpdatePackageSourceSettingsWithChanges(); - } - } - - IEnumerable GetPackageSourcesFromSettings() - { - IList> savedPackageSources = settings.GetValues(PackageSourcesSectionName); - foreach (PackageSource packageSource in PackageSourceConverter.ConvertFromKeyValuePairs(savedPackageSources)) { - packageSource.IsEnabled = IsPackageSourceEnabled(packageSource); - yield return packageSource; - } - } - - bool IsPackageSourceEnabled(PackageSource packageSource) - { - string disabled = settings.GetValue(DisabledPackageSourceSectionName, packageSource.Name); - return String.IsNullOrEmpty(disabled); } void PackageSourcesChanged(object sender, NotifyCollectionChangedEventArgs e) @@ -112,42 +102,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 { @@ -193,6 +148,7 @@ namespace ICSharpCode.PackageManagement void SettingsChanged(object sender, EventArgs e) { settings = settingsProvider.LoadSettings(); + packageSourceProvider = new PackageSourceProvider(settings); ReadActivePackageSource(); ResetPackageSources(); } diff --git a/src/AddIns/Misc/PackageManagement/Test/Src/PackageManagementOptionsTests.cs b/src/AddIns/Misc/PackageManagement/Test/Src/PackageManagementOptionsTests.cs index 29a111a445..c5f5499f85 100644 --- a/src/AddIns/Misc/PackageManagement/Test/Src/PackageManagementOptionsTests.cs +++ b/src/AddIns/Misc/PackageManagement/Test/Src/PackageManagementOptionsTests.cs @@ -117,7 +117,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 +126,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 +147,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 +411,9 @@ namespace PackageManagement.Tests bool result = fakeSettings.AnyValuesPassedToSetValuesForDisabledPackageSourcesSection; - Assert.IsFalse(result); + IList> actualSavedPackageSourceSettings = + fakeSettings.GetValuesPassedToSetValuesForDisabledPackageSourcesSection(); + Assert.AreEqual(0, actualSavedPackageSourceSettings.Count); } [Test] @@ -498,18 +481,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 +507,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 +534,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 +547,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(); From 56ef4ff29332e92cf820f45a6b33d1be9fdd01b6 Mon Sep 17 00:00:00 2001 From: Matt Ward Date: Sun, 14 Dec 2014 13:00:44 +0000 Subject: [PATCH 37/44] Handle being unable to read or update NuGet.Config. --- .../Project/PackageManagement.csproj | 1 + .../Project/Src/Design/FakeSettings.cs | 8 +-- .../Project/Src/MessageServiceExtensions.cs | 53 +++++++++++++++++++ .../Src/PackageManagementOptionsView.xaml.cs | 13 +++-- .../Project/Src/PackageManagementServices.cs | 13 ++++- .../Src/RegisteredPackageSourceSettings.cs | 25 ++++++++- .../Src/RegisteredPackageSourcesView.xaml.cs | 12 ++++- .../Project/Src/SettingsProvider.cs | 8 ++- .../Test/PackageManagement.Tests.csproj | 1 + .../Test/Src/Helpers/FakeReadOnlySettings.cs | 46 ++++++++++++++++ .../Test/Src/PackageManagementOptionsTests.cs | 40 ++++++++++++++ .../Test/Src/SettingsProviderTests.cs | 14 +++++ 12 files changed, 221 insertions(+), 13 deletions(-) create mode 100644 src/AddIns/Misc/PackageManagement/Project/Src/MessageServiceExtensions.cs create mode 100644 src/AddIns/Misc/PackageManagement/Test/Src/Helpers/FakeReadOnlySettings.cs 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/FakeSettings.cs b/src/AddIns/Misc/PackageManagement/Project/Src/Design/FakeSettings.cs index dc9f4785e3..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; @@ -162,7 +162,7 @@ namespace ICSharpCode.PackageManagement.Design 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())); 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/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 0663201646..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; @@ -82,12 +83,26 @@ namespace ICSharpCode.PackageManagement public RegisteredPackageSources PackageSources { get { if (packageSources == null) { - ReadPackageSources(); + TryReadPackageSources(); } return packageSources; } } + void TryReadPackageSources() + { + 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(); + } + } + void ReadPackageSources() { IEnumerable savedPackageSources = packageSourceProvider.LoadPackageSources(); @@ -119,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 { @@ -148,7 +169,7 @@ namespace ICSharpCode.PackageManagement void SettingsChanged(object sender, EventArgs e) { settings = settingsProvider.LoadSettings(); - packageSourceProvider = new PackageSourceProvider(settings); + 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/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..b5c3c304a8 100644 --- a/src/AddIns/Misc/PackageManagement/Test/PackageManagement.Tests.csproj +++ b/src/AddIns/Misc/PackageManagement/Test/PackageManagement.Tests.csproj @@ -112,6 +112,7 @@ + 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 c5f5499f85..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(); @@ -559,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/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); + } } } From e5b17a327bd65f9d013a80ce9960906eae3aa746 Mon Sep 17 00:00:00 2001 From: Daniel Grunwald Date: Sun, 14 Dec 2014 16:34:46 +0100 Subject: [PATCH 38/44] Add 'CreateActions' to FileTemplate, and use them to start the report wizard instead of relying on IsDirty. --- .../EmptyReport.xft | 7 +- .../ICSharpCode.Reporting.addin | 5 + .../src/DesignerBinding/DesignerBinding.cs | 25 ----- .../src/ReportWizard/ReportWizardCommand.cs | 32 ++++-- .../Project/Templates/FileTemplateResult.cs | 12 ++ .../Templates/File/FileTemplateImpl.cs | 105 ++++++++++++------ 6 files changed, 114 insertions(+), 72 deletions(-) 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" /> + + + + diff --git a/src/Main/Base/Project/ICSharpCode.SharpDevelop.csproj b/src/Main/Base/Project/ICSharpCode.SharpDevelop.csproj index 04e9ce3c32..f566fed43b 100644 --- a/src/Main/Base/Project/ICSharpCode.SharpDevelop.csproj +++ b/src/Main/Base/Project/ICSharpCode.SharpDevelop.csproj @@ -297,13 +297,6 @@ OutputWindowOptionsPanel.xaml Code - - - AssemblyInfoPanel.xaml - - - - TaskViewResources.xaml @@ -911,10 +904,6 @@ - - Designer - MSBuild:Compile - @@ -944,10 +933,6 @@ ICSharpCode.NRefactory.Cecil False - - {53dca265-3c3c-42f9-b647-f72ba678122b} - ICSharpCode.NRefactory.CSharp - {DC393B66-92ED-4CAD-AB25-CFEF23F3D7C6} ICSharpCode.NRefactory.Xml diff --git a/src/Main/Base/Project/Src/Gui/Dialogs/OptionPanels/ProjectOptions/AssemblyInfo/AssemblyInfo.cs b/src/Main/Base/Project/Src/Gui/Dialogs/OptionPanels/ProjectOptions/AssemblyInfo/AssemblyInfo.cs deleted file mode 100644 index a1cd915acf..0000000000 --- a/src/Main/Base/Project/Src/Gui/Dialogs/OptionPanels/ProjectOptions/AssemblyInfo/AssemblyInfo.cs +++ /dev/null @@ -1,60 +0,0 @@ -// 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; - -namespace ICSharpCode.SharpDevelop.Gui.OptionPanels -{ - /// - /// Assembly info parameters model - /// - public class AssemblyInfo - { - 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; } - } -} \ No newline at end of file diff --git a/src/Main/Base/Project/Src/Gui/Dialogs/OptionPanels/ProjectOptions/AssemblyInfo/AssemblyInfoPanel.xaml b/src/Main/Base/Project/Src/Gui/Dialogs/OptionPanels/ProjectOptions/AssemblyInfo/AssemblyInfoPanel.xaml deleted file mode 100644 index 209fc08f7a..0000000000 --- a/src/Main/Base/Project/Src/Gui/Dialogs/OptionPanels/ProjectOptions/AssemblyInfo/AssemblyInfoPanel.xaml +++ /dev/null @@ -1,117 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -