From fffcd64ee977d4fd72e52e326a05e46d1961e8c6 Mon Sep 17 00:00:00 2001 From: Ciprian Khlud Date: Mon, 16 Jun 2014 22:27:11 +0300 Subject: [PATCH 1/5] Added a search box for adding project references. It is important for big projects --- .../ReferenceDialog/ProjectReferencePanel.cs | 38 +++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/src/Main/Base/Project/Src/Gui/Dialogs/ReferenceDialog/ProjectReferencePanel.cs b/src/Main/Base/Project/Src/Gui/Dialogs/ReferenceDialog/ProjectReferencePanel.cs index b77ef92be8..7cd6010d48 100644 --- a/src/Main/Base/Project/Src/Gui/Dialogs/ReferenceDialog/ProjectReferencePanel.cs +++ b/src/Main/Base/Project/Src/Gui/Dialogs/ReferenceDialog/ProjectReferencePanel.cs @@ -27,6 +27,7 @@ namespace ICSharpCode.SharpDevelop.Gui public class ProjectReferencePanel : ListView, IReferencePanel { ISelectReferenceDialog selectDialog; + TextBox filterTextBox; public ProjectReferencePanel(ISelectReferenceDialog selectDialog) { @@ -48,6 +49,15 @@ namespace ICSharpCode.SharpDevelop.Gui ItemActivate += delegate { AddReference(); }; PopulateListView(); + + + Panel upperPanel = new Panel { Dock = DockStyle.Top, Height = 20 }; + filterTextBox = new TextBox { Width = 150, Dock = DockStyle.Right }; + filterTextBox.TextChanged += delegate { Search(); }; + + upperPanel.Controls.Add(filterTextBox); + + this.Controls.Add(upperPanel); } public void AddReference() @@ -60,6 +70,7 @@ namespace ICSharpCode.SharpDevelop.Gui new ProjectReferenceProjectItem(selectDialog.ConfigureProject, project) ); } + filterTextBox.Text = ""; } void PopulateListView() @@ -74,5 +85,32 @@ namespace ICSharpCode.SharpDevelop.Gui Items.Add(newItem); } } + + static bool ContainsAnyOfTokens(string bigText, string[] tokens) + { + if(tokens.Length==0) + return true; + foreach(var token in tokens) + { + if(bigText.Contains(token)) + return true; + } + return false; + } + + void Search() + { + Items.Clear(); + var tokens = filterTextBox.Text.Split(new []{' '}, StringSplitOptions.RemoveEmptyEntries); + + foreach (IProject project in ProjectService.OpenSolution.Projects. + Where(pr=>ContainsAnyOfTokens(pr.Name, tokens)) + .OrderBy(p => p.Name, StringComparer.OrdinalIgnoreCase) + ) { + ListViewItem newItem = new ListViewItem(new string[] { project.Name, project.Directory }); + newItem.Tag = project; + Items.Add(newItem); + } + } } } From 577eb9c329ccc5bdb6793192f43a434afc8268dc Mon Sep 17 00:00:00 2001 From: gumme Date: Tue, 24 Jun 2014 12:05:08 +0200 Subject: [PATCH 2/5] A StaticResource that references a resource on the same element is now printed in element style. --- .../Tests/Designer/ModelTests.cs | 28 ++++++++ .../Project/MarkupExtensionPrinter.cs | 69 +++++++++++-------- 2 files changed, 67 insertions(+), 30 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 84bcd70377..1419521e82 100644 --- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Tests/Designer/ModelTests.cs +++ b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Tests/Designer/ModelTests.cs @@ -639,6 +639,34 @@ namespace ICSharpCode.WpfDesign.Tests.Designer AddBindingWithStaticResourceWhereResourceOnSameElement(true); } + [Test] + public void AddStaticResourceWhereResourceOnSameElement() + { + DesignItem button = CreateCanvasContext(""; + + AssertCanvasDesignerOutput(expectedXaml, button.Context); + AssertLog(""); + } + [Test] public void AddBrushAsResource() { diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.XamlDom/Project/MarkupExtensionPrinter.cs b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.XamlDom/Project/MarkupExtensionPrinter.cs index d7b1b1949e..dd23b6eef2 100644 --- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.XamlDom/Project/MarkupExtensionPrinter.cs +++ b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.XamlDom/Project/MarkupExtensionPrinter.cs @@ -38,36 +38,7 @@ namespace ICSharpCode.WpfDesign.XamlDom return false; } - foreach (var property in obj.Properties.Where((prop) => prop.IsSet)) - { - var value = property.PropertyValue; - if (value is XamlTextValue) - continue; - else - { - XamlObject xamlObject = value as XamlObject; - if (xamlObject == null || !xamlObject.IsMarkupExtension) - return false; - else { - var staticResource = xamlObject.Instance as System.Windows.StaticResourceExtension; - if (staticResource != null && - staticResource.ResourceKey != null) { - XamlObject parent = GetNonMarkupExtensionParent(xamlObject); - - if (parent != null) { - var parentLocalResource = parent.ServiceProvider.Resolver.FindLocalResource(staticResource.ResourceKey); - - // If resource with the specified key is declared locally on the same object as the StaticResource is being used the markup extension - // must be printed as element to find the resource, otherwise it will search from parent-parent and find none or another resource. - if (parentLocalResource != null) - return false; - } - } - } - } - } - - return true; + return CanPrint(obj, false, GetNonMarkupExtensionParent(obj)); } /// @@ -115,6 +86,28 @@ namespace ICSharpCode.WpfDesign.XamlDom return sb.ToString(); } + private static bool CanPrint(XamlObject obj, bool isNested, XamlObject nonMarkupExtensionParent) + { + if ((isNested || obj.ParentObject == nonMarkupExtensionParent) && IsStaticResourceThatReferencesLocalResource(obj, nonMarkupExtensionParent)) { + return false; + } + + foreach (var property in obj.Properties.Where((prop) => prop.IsSet)) { + var value = property.PropertyValue; + if (value is XamlTextValue) + continue; + else { + var xamlObject = value as XamlObject; + if (xamlObject == null || !xamlObject.IsMarkupExtension) + return false; + else + return CanPrint(xamlObject, true, nonMarkupExtensionParent); + } + } + + return true; + } + private static XamlObject GetNonMarkupExtensionParent(XamlObject markupExtensionObject) { System.Diagnostics.Debug.Assert(markupExtensionObject.IsMarkupExtension); @@ -125,5 +118,21 @@ namespace ICSharpCode.WpfDesign.XamlDom } return obj; } + + private static bool IsStaticResourceThatReferencesLocalResource(XamlObject obj, XamlObject nonMarkupExtensionParent) + { + var staticResource = obj.Instance as System.Windows.StaticResourceExtension; + if (staticResource != null && staticResource.ResourceKey != null && nonMarkupExtensionParent != null) { + + var parentLocalResource = nonMarkupExtensionParent.ServiceProvider.Resolver.FindLocalResource(staticResource.ResourceKey); + + // If resource with the specified key is declared locally on the same object as the StaticResource is being used the markup extension + // must be printed as element to find the resource, otherwise it will search from parent-parent and find none or another resource. + if (parentLocalResource != null) + return true; + } + + return false; + } } } From 10177584452aa4fe0c69cb8275f6c6d70d8181ea Mon Sep 17 00:00:00 2001 From: Ciprian Khlud Date: Tue, 24 Jun 2014 14:35:07 +0300 Subject: [PATCH 3/5] Make case search insensitive. --- .../Gui/Dialogs/ReferenceDialog/ProjectReferencePanel.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Main/Base/Project/Src/Gui/Dialogs/ReferenceDialog/ProjectReferencePanel.cs b/src/Main/Base/Project/Src/Gui/Dialogs/ReferenceDialog/ProjectReferencePanel.cs index 7cd6010d48..1e7ac464a9 100644 --- a/src/Main/Base/Project/Src/Gui/Dialogs/ReferenceDialog/ProjectReferencePanel.cs +++ b/src/Main/Base/Project/Src/Gui/Dialogs/ReferenceDialog/ProjectReferencePanel.cs @@ -92,10 +92,10 @@ namespace ICSharpCode.SharpDevelop.Gui return true; foreach(var token in tokens) { - if(bigText.Contains(token)) - return true; + if(bigText.IndexOf(token, StringComparison.OrdinalIgnoreCase)<0) + return false; } - return false; + return true; } void Search() From f06d1aa36e8217a15460f8576d858bdd4f0aa534 Mon Sep 17 00:00:00 2001 From: Christoph Wille Date: Tue, 24 Jun 2014 20:49:08 +0200 Subject: [PATCH 4/5] B5 designation --- src/Main/GlobalAssemblyInfo.cs.template | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Main/GlobalAssemblyInfo.cs.template b/src/Main/GlobalAssemblyInfo.cs.template index 24cb65ee69..abf126b695 100644 --- a/src/Main/GlobalAssemblyInfo.cs.template +++ b/src/Main/GlobalAssemblyInfo.cs.template @@ -46,7 +46,7 @@ internal static class RevisionClass public const string Minor = "0"; public const string Build = "0"; public const string Revision = "$INSERTREVISION$"; - public const string VersionName = "Beta 4"; // "" is not valid for no version name, you have to use null if you don't want a version name (eg "Beta 1") + public const string VersionName = "Beta 5"; // "" is not valid for no version name, you have to use null if you don't want a version name (eg "Beta 1") public const string FullVersion = Major + "." + Minor + "." + Build + ".$INSERTREVISION$$INSERTBRANCHPOSTFIX$$INSERTVERSIONNAMEPOSTFIX$"; } From 06662458287326e10be89ca2bc93ddcfa4e50329 Mon Sep 17 00:00:00 2001 From: dr-BEat Date: Tue, 24 Jun 2014 23:15:42 +0200 Subject: [PATCH 5/5] Correctly handle ServiceCreatorCallback in GetFutureService --- src/Main/Base/Project/Util/SharpDevelopServiceContainer.cs | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/Main/Base/Project/Util/SharpDevelopServiceContainer.cs b/src/Main/Base/Project/Util/SharpDevelopServiceContainer.cs index cb85ac4348..af97190bf2 100644 --- a/src/Main/Base/Project/Util/SharpDevelopServiceContainer.cs +++ b/src/Main/Base/Project/Util/SharpDevelopServiceContainer.cs @@ -161,9 +161,8 @@ namespace ICSharpCode.SharpDevelop { Type serviceType = typeof(T); lock (services) { - object instance; - if (services.TryGetValue(serviceType, out instance)) { - return Task.FromResult((T)instance); + if (services.ContainsKey(serviceType)) { + return Task.FromResult((T)GetService(serviceType)); } else { object taskCompletionSource; if (taskCompletionSources.TryGetValue(serviceType, out taskCompletionSource)) {