From dff9a219380906c8f2b5a4d230a2934abb1ee3b9 Mon Sep 17 00:00:00 2001 From: Sergej Andrejev Date: Wed, 12 Aug 2009 10:18:20 +0000 Subject: [PATCH] Doozers comments and clean-up git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/branches/shortcuts@4651 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61 --- AddIns/ICSharpCode.SharpDevelop.addin | 62 +++---- .../Project/SearchAndReplace.addin | 8 +- .../Project/Src/Commands/AutostartCommands.cs | 10 - src/Main/Core/Project/ICSharpCode.Core.csproj | 13 +- .../Command/CommandBindingDescriptor.cs | 99 ---------- .../Command/CommandBindingDoozer.cs | 52 ------ .../Command/CommandBindingInfoDescriptor.cs | 117 ++++++++++++ .../Command/CommandBindingInfoDoozer.cs | 76 ++++++++ .../Command/GesturesPlaceHolderDescriptor.cs | 26 --- .../Command/GesturesPlaceHolderDoozer.cs | 43 ----- .../Command/InputBindingCategoryDescriptor.cs | 47 +++++ .../Command/InputBindingCategoryDoozer.cs | 45 ++--- .../Command/InputBindingDescriptor.cs | 73 -------- .../Command/InputBindingDoozer.cs | 35 ---- .../Command/InputBindingInfoDescriptor.cs | 87 +++++++++ .../Command/InputBindingInfoDoozer.cs | 64 +++++++ .../Core/Project/Src/AddInTree/AddInTree.cs | 5 +- .../BaseGesturesPlaceHolderRegistry.cs | 174 ------------------ .../CommandsService/CommandsService.cs | 4 +- .../Profile/UserGestureProfile.cs | 14 +- .../GesturePlaceHolderRegistry.cs | 82 --------- .../ICSharpCode.Core.WinForms.csproj | 1 - 22 files changed, 462 insertions(+), 675 deletions(-) delete mode 100644 src/Main/Core/Project/Src/AddInTree/AddIn/DefaultDoozers/Command/CommandBindingDescriptor.cs delete mode 100644 src/Main/Core/Project/Src/AddInTree/AddIn/DefaultDoozers/Command/CommandBindingDoozer.cs create mode 100644 src/Main/Core/Project/Src/AddInTree/AddIn/DefaultDoozers/Command/CommandBindingInfoDescriptor.cs create mode 100644 src/Main/Core/Project/Src/AddInTree/AddIn/DefaultDoozers/Command/CommandBindingInfoDoozer.cs delete mode 100644 src/Main/Core/Project/Src/AddInTree/AddIn/DefaultDoozers/Command/GesturesPlaceHolderDescriptor.cs delete mode 100644 src/Main/Core/Project/Src/AddInTree/AddIn/DefaultDoozers/Command/GesturesPlaceHolderDoozer.cs create mode 100644 src/Main/Core/Project/Src/AddInTree/AddIn/DefaultDoozers/Command/InputBindingCategoryDescriptor.cs delete mode 100644 src/Main/Core/Project/Src/AddInTree/AddIn/DefaultDoozers/Command/InputBindingDescriptor.cs delete mode 100644 src/Main/Core/Project/Src/AddInTree/AddIn/DefaultDoozers/Command/InputBindingDoozer.cs create mode 100644 src/Main/Core/Project/Src/AddInTree/AddIn/DefaultDoozers/Command/InputBindingInfoDescriptor.cs create mode 100644 src/Main/Core/Project/Src/AddInTree/AddIn/DefaultDoozers/Command/InputBindingInfoDoozer.cs delete mode 100644 src/Main/Core/Project/Src/Services/CommandsService/BaseGesturesPlaceHolderRegistry.cs delete mode 100644 src/Main/ICSharpCode.Core.WinForms/CommandsService/GesturePlaceHolderRegistry.cs diff --git a/AddIns/ICSharpCode.SharpDevelop.addin b/AddIns/ICSharpCode.SharpDevelop.addin index b6ac2df33e..2bc5437089 100644 --- a/AddIns/ICSharpCode.SharpDevelop.addin +++ b/AddIns/ICSharpCode.SharpDevelop.addin @@ -136,155 +136,155 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + diff --git a/src/Main/Base/Project/Src/Commands/AutostartCommands.cs b/src/Main/Base/Project/Src/Commands/AutostartCommands.cs index a833e9db06..4d121e11a2 100644 --- a/src/Main/Base/Project/Src/Commands/AutostartCommands.cs +++ b/src/Main/Base/Project/Src/Commands/AutostartCommands.cs @@ -125,16 +125,6 @@ namespace ICSharpCode.SharpDevelop.Commands //WorkbenchSingleton.MainForm.Focus(); // windows.forms focus workaround ParserService.StartParserThread(); - - // Register gesture place holders - var placeHolderDescriptors = AddInTree.BuildItems("/SharpDevelop/Workbench/GesturePlaceHolder", this, false); - foreach(var desc in placeHolderDescriptors) { - BaseGesturesPlaceHolderRegistry.RegisterPlaceHolder(desc.Name, desc.Text); - - if(!string.IsNullOrEmpty(desc.Gestures)) { - BaseGesturesPlaceHolderRegistry.AddGestures(desc.Name, desc.Gestures.Split(new []{'|'})); - } - } // finally run the workbench window ... //Application.AddMessageFilter(new FormKeyHandler()); diff --git a/src/Main/Core/Project/ICSharpCode.Core.csproj b/src/Main/Core/Project/ICSharpCode.Core.csproj index 8ee78e01a2..54d23f74fd 100644 --- a/src/Main/Core/Project/ICSharpCode.Core.csproj +++ b/src/Main/Core/Project/ICSharpCode.Core.csproj @@ -60,12 +60,11 @@ - - - - - - + + + + + @@ -96,7 +95,6 @@ - @@ -136,7 +134,6 @@ - Src\AddInTree\AddIn\AddIn.xsd diff --git a/src/Main/Core/Project/Src/AddInTree/AddIn/DefaultDoozers/Command/CommandBindingDescriptor.cs b/src/Main/Core/Project/Src/AddInTree/AddIn/DefaultDoozers/Command/CommandBindingDescriptor.cs deleted file mode 100644 index 103c94cd0e..0000000000 --- a/src/Main/Core/Project/Src/AddInTree/AddIn/DefaultDoozers/Command/CommandBindingDescriptor.cs +++ /dev/null @@ -1,99 +0,0 @@ -using System; - -namespace ICSharpCode.Core -{ - /// - /// Stores information about command binding loaded from add-in tree - /// - public class CommandBindingDescriptor - { - /// - /// Codon used to create this descriptor - /// - public Codon Codon { - get; private set; - } - - public string Name { - get; private set; - } - - /// - /// Full name of the command class which will be executed when this - /// binding is triggered - /// - public string Class { - get; private set; - } - - /// - /// Full name of routed UI command which will trigger this binding - /// - /// If command with provided name is not yet registered it's created automatically - /// - public string Command { - get; private set; - } - - /// - /// Override routed command text (string visible to user) if specified - /// - public string CommandText { - get; private set; - } - - public string OwnerInstanceName { - get; private set; - } - - public string OwnerTypeName { - get; private set; - } - - /// - /// Gestures. - /// - /// Optional, if provided input bindings in the same context will be created - /// - public string Gestures { - get; private set; - } - - /// - /// If input binding is created in the same context (this is done by setting property) - /// assign this input binding to provided category - /// - public string Categories { - get; private set; - } - - /// - /// Lazy loading - /// - /// If true add-in referenced assemblies are loaded when command is invoked. - /// Otherwise command can't be invoked until addin is loaded - /// - public bool Lazy { - get { - return Codon.Properties["lazy"] == "1" || Codon.Properties["lazy"] == "true"; - } - } - - /// - /// Constructor - /// - /// Reference to codon used to create this descriptor - public CommandBindingDescriptor(Codon codon) - { - Codon = codon; - Class = Codon.Properties["class"]; - Command = Codon.Properties["command"]; - CommandText = Codon.Properties["commandtext"]; - OwnerInstanceName = Codon.Properties["owner-instance"]; - OwnerTypeName = Codon.Properties["owner-type"]; - Gestures = Codon.Properties["gestures"]; - Categories = Codon.Properties["categories"]; - Name = Codon.Properties["name"]; - } - } -} diff --git a/src/Main/Core/Project/Src/AddInTree/AddIn/DefaultDoozers/Command/CommandBindingDoozer.cs b/src/Main/Core/Project/Src/AddInTree/AddIn/DefaultDoozers/Command/CommandBindingDoozer.cs deleted file mode 100644 index 2c9e9bc7cf..0000000000 --- a/src/Main/Core/Project/Src/AddInTree/AddIn/DefaultDoozers/Command/CommandBindingDoozer.cs +++ /dev/null @@ -1,52 +0,0 @@ -using System; - -namespace ICSharpCode.Core -{ - /// - /// Name of routed UI command which triggers this binding. - /// - /// Routed UI command details are specified in path '/SharpDevelop/Workbench/RoutedUICommands' - /// - /// - /// Class implementing System.Window.Input.ICommand or - /// ICSharpCode.Core class. CanExecute and Executed methods - /// are used to handle raised event - /// - /// - /// Specified binding owner - /// - /// If context is not specified binding is applied to default context - /// - /// - /// Use lazy loading. If addin containing binded command is - /// not loaded yet, load asseblies referenced in add-in and then - /// invoke command - /// - /// - /// Create input bindings in the same context which will trigger specified routed UI command - /// - /// Only in /SharpDevelop/Workbench/CommandBindings - /// - /// CommandBindingDescriptor object - /// - /// - /// Creates descriptor containing information about command binding - /// - public class CommandBindingDoozer : IDoozer - { - /// - public bool HandleConditions { - get { - return false; - } - } - - /// - /// Builds CommandBindingDescriptor - /// - public object BuildItem(object caller, Codon codon, System.Collections.ArrayList subItems) - { - return new CommandBindingDescriptor(codon); - } - } -} diff --git a/src/Main/Core/Project/Src/AddInTree/AddIn/DefaultDoozers/Command/CommandBindingInfoDescriptor.cs b/src/Main/Core/Project/Src/AddInTree/AddIn/DefaultDoozers/Command/CommandBindingInfoDescriptor.cs new file mode 100644 index 0000000000..ff878f5197 --- /dev/null +++ b/src/Main/Core/Project/Src/AddInTree/AddIn/DefaultDoozers/Command/CommandBindingInfoDescriptor.cs @@ -0,0 +1,117 @@ +using System; + +namespace ICSharpCode.Core +{ + /// + /// Describes + /// + public class CommandBindingInfoDescriptor + { + /// + /// Gets codon used to create this descriptor + /// + public Codon Codon + { + get; private set; + } + + /// + /// Gets full name of the command class containing user instructions + /// + /// The class must implement or + /// classes + /// + public string Class + { + get; private set; + } + + /// + /// Gets name of associated with descriptor + /// The name should be associated to a command in code using + /// + public string Command + { + get; private set; + } + + /// + /// Gets overriden routed command text (string visible to user) + /// + /// If not provided property value is used + /// + public string CommandText + { + get; private set; + } + + /// + /// Gets name of binding owner type name. + /// + /// A name can be assigned to type in code using . + /// If this property is set then property can be ignored + /// If neither owner type nor owner instance is specified default owner type is applied + /// + public string OwnerInstanceName + { + get; private set; + } + + /// + /// Name of binding owner instance name. + /// + /// A name can be assigned to instance in code using . + /// If this property is set then property can be ignored + /// If neither owner type nor owner instance is specified default owner type is applied + /// + public string OwnerTypeName { + get; private set; + } + + /// + /// Gets gestures associated with created + /// + /// Optional, if provided input binding info with the same owner will be created + /// + public string Gestures { + get; private set; + } + + /// + /// Gets list of paths to input binding categories associated with created (separated by comma) + /// + /// Can only be used together with property + /// + public string Categories { + get; private set; + } + + /// + /// Lazy loading + /// + /// If true add-in referenced assemblies are loaded when command is invoked. + /// Otherwise command can't be invoked until addin is loaded + /// + public bool Lazy { + get { + return Codon.Properties["lazy"] == "1" || Codon.Properties["lazy"] == "true"; + } + } + + /// + /// Creates new instance of + /// + /// Reference to codon used to create this descriptor + public CommandBindingInfoDescriptor(Codon codon) + { + Codon = codon; + Class = Codon.Properties["class"]; + Command = Codon.Properties["command"]; + CommandText = Codon.Properties["commandtext"]; + OwnerInstanceName = Codon.Properties["ownerinstance"]; + OwnerTypeName = Codon.Properties["ownertype"]; + Gestures = Codon.Properties["gestures"]; + Categories = Codon.Properties["categories"]; + } + } +} diff --git a/src/Main/Core/Project/Src/AddInTree/AddIn/DefaultDoozers/Command/CommandBindingInfoDoozer.cs b/src/Main/Core/Project/Src/AddInTree/AddIn/DefaultDoozers/Command/CommandBindingInfoDoozer.cs new file mode 100644 index 0000000000..4e9f57a720 --- /dev/null +++ b/src/Main/Core/Project/Src/AddInTree/AddIn/DefaultDoozers/Command/CommandBindingInfoDoozer.cs @@ -0,0 +1,76 @@ +using System; + +namespace ICSharpCode.Core +{ + /// + /// Name of System.Window.Input.RoutedUICommand associated with built CommandBindingInfoDescriptor + /// The name should be first registered in code using ICSharpCode.Core.Presentation.CommandManager + /// or in addin file using RoutedUICommand node + /// + /// + /// Command class performing some action + /// The class should implement System.Window.Input.ICommand or ICSharpCode.Core.ICommand class. + /// + /// + /// Name of binding owner type. + /// + /// A name can be assigned to type in code using ICSharpCode.Core.Presentation.CommandManager. + /// If this attribute is used "ownerinstance" attribute cannot be used + /// If neither owner type nor owner instance is specified default owner type is applied + /// + /// + /// Name of binding owner instance. + /// + /// A name can be assigned to instance in code using ICSharpCode.Core.Presentation.CommandManager. + /// If this attribute is used "ownertype" attribute cannot be used + /// If neither owner type nor owner instance is specified default owner type is applied + /// + /// + /// Use lazy loading. + /// + /// + /// Create input bindings assigned to the same owner type or owner instance and associated + /// with the same System.Window.Input.RoutedUICommand + /// + /// + /// Text displayed to user when managing input bindings (shortcuts) + /// + /// If this attribute is not used System.Window.Input.RoutedUICommand.Text property is used + /// This attribute can only be used together with "gestures" attribute + /// + /// + /// List of paths to input binding categories associated with created input binding info (separated by comma) + /// + /// Input binding categories can be created in code using ICSharpCode.Core.Presentation.CommandManager or by using InputBindingCategory node in addin file + /// Input binding categories are used to group shortcuts into separate sections when displaying to user. + /// This attribute can only be used together with "gestures" attribute + /// + /// Only in /SharpDevelop/Workbench/CommandBindings + /// + /// CommandBindingInfoDescriptor object + /// + /// + /// Creates descriptor containing data describing ICSharpCode.Core.Presentation.CommandBindingInfo + /// + public class CommandBindingInfoDoozer : IDoozer + { + /// + public bool HandleConditions { + get { + return false; + } + } + + /// + /// Builds instance of from codon + /// + /// Caller object + /// Codon + /// Codon sub-items + /// Instance of + public object BuildItem(object caller, Codon codon, System.Collections.ArrayList subItems) + { + return new CommandBindingInfoDescriptor(codon); + } + } +} diff --git a/src/Main/Core/Project/Src/AddInTree/AddIn/DefaultDoozers/Command/GesturesPlaceHolderDescriptor.cs b/src/Main/Core/Project/Src/AddInTree/AddIn/DefaultDoozers/Command/GesturesPlaceHolderDescriptor.cs deleted file mode 100644 index 51a8d498af..0000000000 --- a/src/Main/Core/Project/Src/AddInTree/AddIn/DefaultDoozers/Command/GesturesPlaceHolderDescriptor.cs +++ /dev/null @@ -1,26 +0,0 @@ -using System; - -namespace ICSharpCode.Core -{ - public class GesturesPlaceHolderDescriptor - { - public string Name { - get; private set; - } - - public string Text { - get; private set; - } - - public string Gestures { - get; private set; - } - - public GesturesPlaceHolderDescriptor(Codon codon) - { - Name = codon.Properties["name"]; - Text = codon.Properties["text"]; - Gestures = codon.Properties["gestures"]; - } - } -} diff --git a/src/Main/Core/Project/Src/AddInTree/AddIn/DefaultDoozers/Command/GesturesPlaceHolderDoozer.cs b/src/Main/Core/Project/Src/AddInTree/AddIn/DefaultDoozers/Command/GesturesPlaceHolderDoozer.cs deleted file mode 100644 index 1733f6d932..0000000000 --- a/src/Main/Core/Project/Src/AddInTree/AddIn/DefaultDoozers/Command/GesturesPlaceHolderDoozer.cs +++ /dev/null @@ -1,43 +0,0 @@ -using System; - -namespace ICSharpCode.Core -{ - /// - /// Place holder name. This name should be unique application wide - /// - /// - /// Text displayed to use - /// - /// - /// Use lazy loading. If addin containing binded command is - /// not loaded yet, load asseblies referenced in add-in and then - /// invoke command - /// - /// - /// Keys which will invoke command - /// - /// Only in /SharpDevelop/Workbench/CommandBindings - /// - /// GesturesPlaceHolder object - /// - /// - /// Creates descriptor containing information about command binding - /// - public class GesturesPlaceHolderDoozer : IDoozer - { - /// - public bool HandleConditions { - get { - return false; - } - } - - /// - /// Builds GesturesPlaceHolderDoozer - /// - public object BuildItem(object caller, Codon codon, System.Collections.ArrayList subItems) - { - return new GesturesPlaceHolderDescriptor(codon); - } - } -} diff --git a/src/Main/Core/Project/Src/AddInTree/AddIn/DefaultDoozers/Command/InputBindingCategoryDescriptor.cs b/src/Main/Core/Project/Src/AddInTree/AddIn/DefaultDoozers/Command/InputBindingCategoryDescriptor.cs new file mode 100644 index 0000000000..9c5a4cffa7 --- /dev/null +++ b/src/Main/Core/Project/Src/AddInTree/AddIn/DefaultDoozers/Command/InputBindingCategoryDescriptor.cs @@ -0,0 +1,47 @@ +using System; +using System.Linq; +using System.Collections.Generic; + +namespace ICSharpCode.Core +{ + /// + /// Describes + /// + public class InputBindingCategoryDescriptor + { + /// + /// Gets category Id used to create category path + /// + public string Id + { + get; private set; + } + + /// + /// Gets category name displayed to user + /// + public string Text + { + get; private set; + } + + /// + /// Gets children category descriptors + /// + public List Children + { + get; private set; + } + + /// + /// Creates instance of + /// + /// Reference to codon used to create this descriptor + /// List of sub-category descriptors + public InputBindingCategoryDescriptor(Codon codon, System.Collections.ArrayList subItems) { + Id = codon.Properties["id"]; + Text = codon.Properties["text"]; + Children = subItems != null ? subItems.Cast().ToList() : new List(); + } + } +} diff --git a/src/Main/Core/Project/Src/AddInTree/AddIn/DefaultDoozers/Command/InputBindingCategoryDoozer.cs b/src/Main/Core/Project/Src/AddInTree/AddIn/DefaultDoozers/Command/InputBindingCategoryDoozer.cs index 9527fdda66..7adf7b4167 100644 --- a/src/Main/Core/Project/Src/AddInTree/AddIn/DefaultDoozers/Command/InputBindingCategoryDoozer.cs +++ b/src/Main/Core/Project/Src/AddInTree/AddIn/DefaultDoozers/Command/InputBindingCategoryDoozer.cs @@ -1,48 +1,43 @@ -/* - * Created by SharpDevelop. - * User: Administrator - * Date: 7/3/2009 - * Time: 4:50 PM - * - * To change this template use Tools | Options | Coding | Edit Standard Headers. - */ using System; using System.Collections.Generic; using System.Linq; namespace ICSharpCode.Core { + /// + /// Category Id used in category path + /// + /// + /// Category name displayed to user + /// + /// Only in /SharpDevelop/CommandManager/InputBindingCategories + /// + /// InputBindingCategory object + /// /// - /// Description of InputBindingInfoCategory. + /// Creates descriptor containing data describing ICSharpCode.Core.Presentation.InputBindingCategory /// public class InputBindingCategoryDoozer : IDoozer { - /// + /// public bool HandleConditions { get { return true; } } - /// - /// Builds InputBindingDescriptor - /// + /// + /// Builds instance of from codon + /// + /// Caller object + /// Codon + /// Codon sub-items + /// Instance of public object BuildItem(object caller, Codon codon, System.Collections.ArrayList subItems) { return new InputBindingCategoryDescriptor(codon, subItems); } } - public class InputBindingCategoryDescriptor - { - public string Id; - public string Text; - public List Children; - - public InputBindingCategoryDescriptor(Codon codon, System.Collections.ArrayList subItems) { - Id = codon.Properties["id"]; - Text = codon.Properties["text"]; - Children = subItems != null ? subItems.Cast().ToList() : new List(); - } - } + } diff --git a/src/Main/Core/Project/Src/AddInTree/AddIn/DefaultDoozers/Command/InputBindingDescriptor.cs b/src/Main/Core/Project/Src/AddInTree/AddIn/DefaultDoozers/Command/InputBindingDescriptor.cs deleted file mode 100644 index 22b5ceaa3c..0000000000 --- a/src/Main/Core/Project/Src/AddInTree/AddIn/DefaultDoozers/Command/InputBindingDescriptor.cs +++ /dev/null @@ -1,73 +0,0 @@ -using System; - -namespace ICSharpCode.Core -{ - /// - /// Stores information about input binding loaded from add-in tree - /// - public class InputBindingDescriptor - { - /// - /// Codon used to create this descriptor - /// - public Codon Codon { - get; private set; - } - - /// - /// Full name of routed UI command which will be invoked when this binding is triggered - /// - public string Command { - get; private set; - } - - public string Name { - get; private set; - } - - /// - /// Override routed command text (string visible to user) if specified - /// - public string CommandText { - get; private set; - } - - public string OwnerInstanceName { - get; private set; - } - - public string OwnerTypeName { - get; private set; - } - - /// - /// Description of gesture which will trigger this binding - /// - public string Gestures { - get; private set; - } - - /// - /// Category to which this binding belongs - /// - public string Categories { - get; private set; - } - - /// - /// Constructor - /// - /// Reference to codon used to create this descriptor - public InputBindingDescriptor(Codon codon) - { - Codon = codon; - Command = codon.Properties["command"]; - CommandText = codon.Properties["commandtext"]; - OwnerInstanceName = codon.Properties["owner-instance"]; - OwnerTypeName = codon.Properties["owner-type"]; - Gestures = codon.Properties["gestures"]; - Categories = codon.Properties["categories"]; - Name = codon.Properties["name"]; - } - } -} diff --git a/src/Main/Core/Project/Src/AddInTree/AddIn/DefaultDoozers/Command/InputBindingDoozer.cs b/src/Main/Core/Project/Src/AddInTree/AddIn/DefaultDoozers/Command/InputBindingDoozer.cs deleted file mode 100644 index 973eab3f17..0000000000 --- a/src/Main/Core/Project/Src/AddInTree/AddIn/DefaultDoozers/Command/InputBindingDoozer.cs +++ /dev/null @@ -1,35 +0,0 @@ -using System; - -namespace ICSharpCode.Core -{ - /// - /// Name of routed UI command which is triggered by this binding - /// - /// - /// Gesture which triggers this binding - /// - /// Only in /SharpDevelop/Workbench/InputBindings - /// - /// InputBindingDescriptor object - /// - /// - /// Creates descriptor containing information about input binding - /// - public class InputBindingDoozer : IDoozer - { - /// - public bool HandleConditions { - get { - return true; - } - } - - /// - /// Builds InputBindingDescriptor - /// - public object BuildItem(object caller, Codon codon, System.Collections.ArrayList subItems) - { - return new InputBindingDescriptor(codon); - } - } -} diff --git a/src/Main/Core/Project/Src/AddInTree/AddIn/DefaultDoozers/Command/InputBindingInfoDescriptor.cs b/src/Main/Core/Project/Src/AddInTree/AddIn/DefaultDoozers/Command/InputBindingInfoDescriptor.cs new file mode 100644 index 0000000000..1b66405f07 --- /dev/null +++ b/src/Main/Core/Project/Src/AddInTree/AddIn/DefaultDoozers/Command/InputBindingInfoDescriptor.cs @@ -0,0 +1,87 @@ +using System; + +namespace ICSharpCode.Core +{ + /// + /// Describes + /// + public class InputBindingInfoDescriptor + { + /// + /// Codon used to create this descriptor + /// + public Codon Codon { + get; private set; + } + + /// + /// Gets name of associated with descriptor + /// The name should be associated to a command in code using + /// + public string Command { + get; private set; + } + + + /// + /// Gets overriden routed command text (string visible to user) + /// + /// If not provided property value is used + /// + public string CommandText { + get; private set; + } + + /// + /// Gets name of binding owner type name. + /// + /// A name can be assigned to type in code using . + /// If this property is set then property can be ignored + /// If neither owner type nor owner instance is specified default owner type is applied + /// + public string OwnerInstanceName { + get; private set; + } + + /// + /// Name of binding owner instance name. + /// + /// A name can be assigned to instance in code using . + /// If this property is set then property can be ignored + /// If neither owner type nor owner instance is specified default owner type is applied + /// + public string OwnerTypeName { + get; private set; + } + + /// + /// Gets gestures associated with created + /// + public string Gestures { + get; private set; + } + + + /// + /// List of paths to input binding categories associated with created (separated by comma) + /// + public string Categories { + get; private set; + } + + /// + /// Creates new instance of + /// + /// Reference to codon used to create this descriptor + public InputBindingInfoDescriptor(Codon codon) + { + Codon = codon; + Command = codon.Properties["command"]; + CommandText = codon.Properties["commandtext"]; + OwnerInstanceName = codon.Properties["ownerinstance"]; + OwnerTypeName = codon.Properties["ownertype"]; + Gestures = codon.Properties["gestures"]; + Categories = codon.Properties["categories"]; + } + } +} diff --git a/src/Main/Core/Project/Src/AddInTree/AddIn/DefaultDoozers/Command/InputBindingInfoDoozer.cs b/src/Main/Core/Project/Src/AddInTree/AddIn/DefaultDoozers/Command/InputBindingInfoDoozer.cs new file mode 100644 index 0000000000..d5e476e0ce --- /dev/null +++ b/src/Main/Core/Project/Src/AddInTree/AddIn/DefaultDoozers/Command/InputBindingInfoDoozer.cs @@ -0,0 +1,64 @@ +using System; + +namespace ICSharpCode.Core +{ + /// + /// Name of System.Window.Input.RoutedUICommand associated with built InputBindingInfoDescriptor + /// The name should be first registered in code using ICSharpCode.Core.Presentation.CommandManager + /// or in addin file using RoutedUICommand node + /// + /// + /// Name of binding owner type. + /// + /// A name can be assigned to type in code using ICSharpCode.Core.Presentation.CommandManager. + /// If this attribute is used "ownerinstance" attribute cannot be used + /// If neither owner type nor owner instance is specified default owner type is applied + /// + /// + /// Name of binding owner instance. + /// + /// A name can be assigned to instance in code using ICSharpCode.Core.Presentation.CommandManager. + /// If this attribute is used "ownertype" attribute cannot be used + /// If neither owner type nor owner instance is specified default owner type is applied + /// + /// + /// Gestures associated with created System.Windows.Input.InputBinding instances + /// + /// + /// Text displayed to user when managing input bindings (shortcuts) + /// + /// If this attribute is not used System.Window.Input.RoutedUICommand.Text property is used + /// This attribute can only be used together with "gestures" attribute + /// + /// + /// List of input binding category paths (separated using comma) associated with + /// created input binding infos + /// + /// Input binding categories can be created in code using ICSharpCode.Core.Presentation.CommandManager or by using InputBindingCategory node in addin file + /// Input binding categories are used to group shortcuts into separate sections when displaying to user. + /// + /// Only in /SharpDevelop/Workbench/InputBindings + /// + /// CommandBindingInfoDescriptor object + /// + /// + /// Creates descriptor containing data describing ICSharpCode.Core.Presentation.InputBindingInfo + /// + public class InputBindingInfoDoozer : IDoozer + { + /// + public bool HandleConditions { + get { + return true; + } + } + + /// + /// Builds InputBindingInfoDescriptor + /// + public object BuildItem(object caller, Codon codon, System.Collections.ArrayList subItems) + { + return new InputBindingInfoDescriptor(codon); + } + } +} diff --git a/src/Main/Core/Project/Src/AddInTree/AddInTree.cs b/src/Main/Core/Project/Src/AddInTree/AddInTree.cs index 4543ae104a..4691bae291 100644 --- a/src/Main/Core/Project/Src/AddInTree/AddInTree.cs +++ b/src/Main/Core/Project/Src/AddInTree/AddInTree.cs @@ -35,11 +35,10 @@ namespace ICSharpCode.Core doozers.Add("Include", new IncludeDoozer()); // Command manager doozers - doozers.Add("InputBinding", new InputBindingDoozer()); + doozers.Add("InputBindingInfo", new InputBindingInfoDoozer()); doozers.Add("InputBindingCategory", new InputBindingCategoryDoozer()); - doozers.Add("CommandBinding", new CommandBindingDoozer()); + doozers.Add("CommandBindingInfo", new CommandBindingInfoDoozer()); doozers.Add("RoutedUICommand", new RoutedUICommandDoozer()); - doozers.Add("GesturesPlaceHolder", new GesturesPlaceHolderDoozer()); doozers.Add("MenuLocation", new MenuLocationDoozer()); conditionEvaluators.Add("Compare", new CompareConditionEvaluator()); diff --git a/src/Main/Core/Project/Src/Services/CommandsService/BaseGesturesPlaceHolderRegistry.cs b/src/Main/Core/Project/Src/Services/CommandsService/BaseGesturesPlaceHolderRegistry.cs deleted file mode 100644 index c59bf5b2fa..0000000000 --- a/src/Main/Core/Project/Src/Services/CommandsService/BaseGesturesPlaceHolderRegistry.cs +++ /dev/null @@ -1,174 +0,0 @@ -using System; -using System.Collections.Generic; -using ICSharpCode.Core; - -namespace ICSharpCode.Core -{ - public delegate void GesturesPlaceHolderUpdate(); - - /// - /// Stores gestures place holders - /// - /// Through this class one can register a handler which which would be - /// called when gestures associated with place holder name are updated - /// - public static class BaseGesturesPlaceHolderRegistry - { - private static Dictionary gesturePlaceHolders = new Dictionary(); - - private static Dictionary commandTexts = new Dictionary(); - private static Dictionary> registeredKeys = new Dictionary>(); - private static Dictionary> commandKeysUpdateHandlers = new Dictionary>(); - - /// - /// Register a place holder - /// - /// Place holder name. Unique application wide - /// Place holder text visible to user - public static void RegisterPlaceHolder(string placeHolderName, string placeHolderText) { - gesturePlaceHolders.Add(placeHolderName, new GesturesPlaceHolderInfo(placeHolderName, placeHolderText)); - } - - /// - /// Get gestures assigned to place holder - /// - /// Use KeysCollectionConverter or InputGestureCollectionConverter - /// to convert returned value representation to required format - /// - /// Place holder name - /// Array of gestures - public static string[] GetGestures(string placeHolderName) { - if(!gesturePlaceHolders.ContainsKey(placeHolderName) || gesturePlaceHolders[placeHolderName].Gestures.Count == 0) { - return new string[] { }; - } - - return gesturePlaceHolders[placeHolderName].Gestures.ToArray(); - } - - /// - /// Add gestures to place holder - /// - /// Use KeysCollectionConverter or InputGestureCollectionConverter - /// to convert gestures to string representation - /// - /// Place holder name - /// Added gestures - public static void AddGestures(string placeHolderName, IEnumerable gestures) { - if(!gesturePlaceHolders.ContainsKey(placeHolderName)) { - throw new ApplicationException("No gestures place holder with name '" + placeHolderName + "' is registered"); - } - - foreach(string gesture in gestures) { - if(!gesturePlaceHolders[placeHolderName].Gestures.Contains(gesture)) { - gesturePlaceHolders[placeHolderName].Gestures.Add(gesture); - } - } - } - - /// - /// Remove gestures from place holder - /// - /// Use KeysCollectionConverter or InputGestureCollectionConverter - /// to convert gestures to string representation - /// - /// Null argumens are igonred and all gestures which specify - /// provided parameters are removed - /// - /// - /// - public static void RemoveGestures(string placeHolderName, IEnumerable gestures) { - if(gesturePlaceHolders.ContainsKey(placeHolderName)) { - if(gestures == null) { - gesturePlaceHolders[placeHolderName].Gestures.Clear(); - } else { - for(int i = gesturePlaceHolders[placeHolderName].Gestures.Count - 1; i >= 0; i--) { - foreach(string gesture in gestures) { - if(gesturePlaceHolders[placeHolderName].Gestures[i] == gesture) { - gesturePlaceHolders[placeHolderName].Gestures.RemoveAt(i); - } - } - } - } - } - } - - /// - /// Register update handler which will trigger when gestures in - /// place holder are updated - /// - /// Place holder name - /// Handler which handles place holder gestures update - public static void RegisterUpdateHandler(string placeHolderName, GesturesPlaceHolderUpdate handler) { - if(!commandKeysUpdateHandlers.ContainsKey(placeHolderName)) { - commandKeysUpdateHandlers.Add(placeHolderName, new List()); - } - - commandKeysUpdateHandlers[placeHolderName].Add(new WeakReference(handler)); - } - - /// - /// Invoke delegates which handle gestures update in place holder - /// - /// If place holder is not provided all registered handlers are invoked - /// - /// - public static void InvokeUpdateHandlers(string placeHolderName) { - if(placeHolderName == null) { - foreach(var handlers in commandKeysUpdateHandlers) { - foreach(var handler in handlers.Value) { - if(handler != null && handler.Target != null) { - ((GesturesPlaceHolderUpdate)handler.Target).Invoke(); - } - } - } - } else { - if(commandKeysUpdateHandlers.ContainsKey(placeHolderName)) { - foreach(var handler in commandKeysUpdateHandlers[placeHolderName]) { - if(handler != null && handler.Target != null) { - ((GesturesPlaceHolderUpdate)handler.Target).Invoke(); - } - } - } - } - } - - /// - /// Intername representation of place holders - /// - class GesturesPlaceHolderInfo - { - /// - /// Place hollder name - /// - public string Name { - get; private set; - } - - /// - /// Place holder text visible to user - /// - public string Text { - get; private set; - } - - /// - /// Collection of gestures assigned to this place holder - /// - public List Gestures { - get; private set; - } - - /// - /// Constructor - /// - /// Place holder name - /// Place holder text visible to user - public GesturesPlaceHolderInfo(string name, string text) { - Name = name; - Text = text; - Gestures = new List(); - } - - } - } -} diff --git a/src/Main/ICSharpCode.Core.Presentation/CommandsService/CommandsService.cs b/src/Main/ICSharpCode.Core.Presentation/CommandsService/CommandsService.cs index ddbdf1f2ce..0589d7ab03 100644 --- a/src/Main/ICSharpCode.Core.Presentation/CommandsService/CommandsService.cs +++ b/src/Main/ICSharpCode.Core.Presentation/CommandsService/CommandsService.cs @@ -194,7 +194,7 @@ namespace ICSharpCode.Core.Presentation /// Path to codons public static void RegisterCommandBindings(object caller, string path) { - var descriptors = AddInTree.BuildItems(path, caller, false); + var descriptors = AddInTree.BuildItems(path, caller, false); foreach(var desc in descriptors) { var commandBindingInfoName = new StringBuilder(); @@ -259,7 +259,7 @@ namespace ICSharpCode.Core.Presentation /// Path to codons public static void RegisterInputBindings(object caller, string path) { - var descriptors = AddInTree.BuildItems(path, caller, false); + var descriptors = AddInTree.BuildItems(path, caller, false); foreach(var desc in descriptors) { var gestures = (InputGestureCollection)new InputGestureCollectionConverter().ConvertFromString(desc.Gestures); diff --git a/src/Main/ICSharpCode.Core.Presentation/CommandsService/Profile/UserGestureProfile.cs b/src/Main/ICSharpCode.Core.Presentation/CommandsService/Profile/UserGestureProfile.cs index a15ca2a5b2..a3d18bcf88 100644 --- a/src/Main/ICSharpCode.Core.Presentation/CommandsService/Profile/UserGestureProfile.cs +++ b/src/Main/ICSharpCode.Core.Presentation/CommandsService/Profile/UserGestureProfile.cs @@ -76,16 +76,16 @@ namespace ICSharpCode.Core.Presentation Name = rootNode.Attributes["name"].Value; Text = rootNode.Attributes["text"].Value; - ReadOnly = Convert.ToBoolean(rootNode.Attributes["read-only"].Value); + ReadOnly = Convert.ToBoolean(rootNode.Attributes["readonly"].Value); foreach(XmlElement bindingInfoNode in xmlDocument.SelectNodes("//InputBinding")) { string identifierInstanceName = null; string identifierTypeName = null; - var ownerInstanceAttribute = bindingInfoNode.Attributes["owner-instance"]; + var ownerInstanceAttribute = bindingInfoNode.Attributes["ownerinstance"]; if(ownerInstanceAttribute != null) { identifierInstanceName = ownerInstanceAttribute.Value; } else { - var ownerTypeAttribute = bindingInfoNode.Attributes["owner-type"]; + var ownerTypeAttribute = bindingInfoNode.Attributes["ownertype"]; identifierTypeName = ownerTypeAttribute.Value; } @@ -111,7 +111,7 @@ namespace ICSharpCode.Core.Presentation textAttribute.Value = Text; rootNode.Attributes.Append(textAttribute); - var readOnlyAttribute = xmlDocument.CreateAttribute("read-only"); + var readOnlyAttribute = xmlDocument.CreateAttribute("readonly"); readOnlyAttribute.Value = Convert.ToString(ReadOnly); rootNode.Attributes.Append(readOnlyAttribute); @@ -119,7 +119,7 @@ namespace ICSharpCode.Core.Presentation var bindingInfoNode = xmlDocument.CreateElement("InputBinding"); if(definedGestures.Key.RoutedCommandName != null) { - var routedCommandAttribute = xmlDocument.CreateAttribute("routed-command"); + var routedCommandAttribute = xmlDocument.CreateAttribute("routedcommand"); routedCommandAttribute.Value = definedGestures.Key.RoutedCommandName; bindingInfoNode.Attributes.Append(routedCommandAttribute); } else { @@ -127,11 +127,11 @@ namespace ICSharpCode.Core.Presentation } if(definedGestures.Key.OwnerInstanceName != null) { - var ownerInstanceAttribute = xmlDocument.CreateAttribute("owner-instance"); + var ownerInstanceAttribute = xmlDocument.CreateAttribute("ownerinstance"); ownerInstanceAttribute.Value = definedGestures.Key.OwnerInstanceName; bindingInfoNode.Attributes.Append(ownerInstanceAttribute); } else if(definedGestures.Key.OwnerTypeName != null) { - var ownerTypeAttribute = xmlDocument.CreateAttribute("owner-type"); + var ownerTypeAttribute = xmlDocument.CreateAttribute("ownertype"); ownerTypeAttribute.Value = definedGestures.Key.OwnerTypeName; bindingInfoNode.Attributes.Append(ownerTypeAttribute); } else { diff --git a/src/Main/ICSharpCode.Core.WinForms/CommandsService/GesturePlaceHolderRegistry.cs b/src/Main/ICSharpCode.Core.WinForms/CommandsService/GesturePlaceHolderRegistry.cs deleted file mode 100644 index 2cae2a1a57..0000000000 --- a/src/Main/ICSharpCode.Core.WinForms/CommandsService/GesturePlaceHolderRegistry.cs +++ /dev/null @@ -1,82 +0,0 @@ -using System; -using System.Windows.Forms; -using System.Collections.Generic; -using ICSharpCode.Core; - -namespace ICSharpCode.Core.WinForms -{ - /// - /// Stores gestures place holders - /// - /// Through this class one can register a handler which which would be - /// called when gestures associated with place holder name are updated - /// - public static class GesturePlaceHolderRegistry - { - /// - /// Register a place holder - /// - /// Place holder name. Unique application wide - /// Place holder text visible to user - public static void RegisterPlaceHolder(string placeHolderName, string placeHolderText) { - BaseGesturesPlaceHolderRegistry.RegisterPlaceHolder(placeHolderName, placeHolderText); - } - - /// - /// Get gestures assigned to place holder - /// - /// Place holder name - /// Array of keys - public static Keys[] GetGestures(string placeHolderName) { - var serializesGesturesColection = BaseGesturesPlaceHolderRegistry.GetGestures(placeHolderName); - var gestures = (Keys[])new KeysCollectionConverter().ConvertFrom(serializesGesturesColection); - - return gestures; - } - - /// - /// Add gestures to place holder - /// - /// Place holder name - /// Added gestures - public static void AddGestures(string placeHolderName, IEnumerable gestures) { - var serializedGestures = (string[])new KeysCollectionConverter().ConvertTo(gestures, typeof(string[])); - - BaseGesturesPlaceHolderRegistry.AddGestures(placeHolderName, serializedGestures); - } - - /// - /// Remove gestures from place holder - /// - /// Null argumens are igonred and all gestures which specify - /// provided parameters are removed - /// - /// Place holder name - /// Gestures - public static void RemoveGestures(string placeHolderName, IEnumerable gestures) { - var serializedGestures = (string[])new KeysCollectionConverter().ConvertTo(gestures, typeof(string[])); - - BaseGesturesPlaceHolderRegistry.RemoveGestures(placeHolderName, serializedGestures); - } - - /// - /// Register update handler which will trigger when gestures in - /// place holder are updated - /// - /// Place holder name - /// Handler which handles place holder gestures update - public static void RegisterUpdateHandler(string placeHolderName, GesturesPlaceHolderUpdate handler) { - BaseGesturesPlaceHolderRegistry.RegisterUpdateHandler(placeHolderName, handler); - } - - /// - /// Invoke delegates which handle gestures update in place holder - /// - /// If place holder is not provided all registered handlers are invoked - /// - /// - public static void InvokeUpdateHandlers(string placeHolderName) { - BaseGesturesPlaceHolderRegistry.InvokeUpdateHandlers(placeHolderName); - } - } -} diff --git a/src/Main/ICSharpCode.Core.WinForms/ICSharpCode.Core.WinForms.csproj b/src/Main/ICSharpCode.Core.WinForms/ICSharpCode.Core.WinForms.csproj index 20e869026b..54a99d7583 100644 --- a/src/Main/ICSharpCode.Core.WinForms/ICSharpCode.Core.WinForms.csproj +++ b/src/Main/ICSharpCode.Core.WinForms/ICSharpCode.Core.WinForms.csproj @@ -50,7 +50,6 @@ Properties\GlobalAssemblyInfo.cs -