Browse Source

Doozers comments and clean-up

git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/branches/shortcuts@4651 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61
shortcuts^2
Sergej Andrejev 16 years ago
parent
commit
dff9a21938
  1. 62
      AddIns/ICSharpCode.SharpDevelop.addin
  2. 8
      src/AddIns/Misc/SearchAndReplace/Project/SearchAndReplace.addin
  3. 10
      src/Main/Base/Project/Src/Commands/AutostartCommands.cs
  4. 13
      src/Main/Core/Project/ICSharpCode.Core.csproj
  5. 99
      src/Main/Core/Project/Src/AddInTree/AddIn/DefaultDoozers/Command/CommandBindingDescriptor.cs
  6. 52
      src/Main/Core/Project/Src/AddInTree/AddIn/DefaultDoozers/Command/CommandBindingDoozer.cs
  7. 117
      src/Main/Core/Project/Src/AddInTree/AddIn/DefaultDoozers/Command/CommandBindingInfoDescriptor.cs
  8. 76
      src/Main/Core/Project/Src/AddInTree/AddIn/DefaultDoozers/Command/CommandBindingInfoDoozer.cs
  9. 26
      src/Main/Core/Project/Src/AddInTree/AddIn/DefaultDoozers/Command/GesturesPlaceHolderDescriptor.cs
  10. 43
      src/Main/Core/Project/Src/AddInTree/AddIn/DefaultDoozers/Command/GesturesPlaceHolderDoozer.cs
  11. 47
      src/Main/Core/Project/Src/AddInTree/AddIn/DefaultDoozers/Command/InputBindingCategoryDescriptor.cs
  12. 43
      src/Main/Core/Project/Src/AddInTree/AddIn/DefaultDoozers/Command/InputBindingCategoryDoozer.cs
  13. 73
      src/Main/Core/Project/Src/AddInTree/AddIn/DefaultDoozers/Command/InputBindingDescriptor.cs
  14. 35
      src/Main/Core/Project/Src/AddInTree/AddIn/DefaultDoozers/Command/InputBindingDoozer.cs
  15. 87
      src/Main/Core/Project/Src/AddInTree/AddIn/DefaultDoozers/Command/InputBindingInfoDescriptor.cs
  16. 64
      src/Main/Core/Project/Src/AddInTree/AddIn/DefaultDoozers/Command/InputBindingInfoDoozer.cs
  17. 5
      src/Main/Core/Project/Src/AddInTree/AddInTree.cs
  18. 174
      src/Main/Core/Project/Src/Services/CommandsService/BaseGesturesPlaceHolderRegistry.cs
  19. 4
      src/Main/ICSharpCode.Core.Presentation/CommandsService/CommandsService.cs
  20. 14
      src/Main/ICSharpCode.Core.Presentation/CommandsService/Profile/UserGestureProfile.cs
  21. 82
      src/Main/ICSharpCode.Core.WinForms/CommandsService/GesturePlaceHolderRegistry.cs
  22. 1
      src/Main/ICSharpCode.Core.WinForms/ICSharpCode.Core.WinForms.csproj

62
AddIns/ICSharpCode.SharpDevelop.addin

@ -136,155 +136,155 @@
<Path name="/SharpDevelop/CommandManager/CommandBindings"> <Path name="/SharpDevelop/CommandManager/CommandBindings">
<CommandBinding <CommandBindingInfo
command="SDTestCommands.Test" command="SDTestCommands.Test"
class="ICSharpCode.SharpDevelop.Commands.TestCommand" class="ICSharpCode.SharpDevelop.Commands.TestCommand"
gestures="Ctrl+M" gestures="Ctrl+M"
categories="/Test" /> categories="/Test" />
<CommandBinding <CommandBindingInfo
command = "SDProjectCommands.ShowSelectedProjectBrowserNodeProperties" command = "SDProjectCommands.ShowSelectedProjectBrowserNodeProperties"
class = "ICSharpCode.SharpDevelop.Project.Commands.ShowPropertiesForNode" class = "ICSharpCode.SharpDevelop.Project.Commands.ShowPropertiesForNode"
categories="/ProjectViewer" /> categories="/ProjectViewer" />
<CommandBinding <CommandBindingInfo
command="SDBuildCommands.BuildSolution" command="SDBuildCommands.BuildSolution"
class="ICSharpCode.SharpDevelop.Project.Commands.Build" class="ICSharpCode.SharpDevelop.Project.Commands.Build"
gestures="F8" gestures="F8"
categories="/Building" categories="/Building"
/> />
<CommandBinding <CommandBindingInfo
command="SDBuildCommands.RebuildSolution" command="SDBuildCommands.RebuildSolution"
class="ICSharpCode.SharpDevelop.Project.Commands.Rebuild" class="ICSharpCode.SharpDevelop.Project.Commands.Rebuild"
gestures="Alt+F8" gestures="Alt+F8"
categories="/Building" categories="/Building"
/> />
<CommandBinding <CommandBindingInfo
command="SDBuildCommands.CleanSolution" command="SDBuildCommands.CleanSolution"
class="ICSharpCode.SharpDevelop.Project.Commands.Clean" class="ICSharpCode.SharpDevelop.Project.Commands.Clean"
categories="/Building" /> categories="/Building" />
<CommandBinding <CommandBindingInfo
command="SDBuildCommands.BuildProject" command="SDBuildCommands.BuildProject"
class="ICSharpCode.SharpDevelop.Project.Commands.BuildProject" class="ICSharpCode.SharpDevelop.Project.Commands.BuildProject"
gestures="F9" gestures="F9"
categories="/Building" /> categories="/Building" />
<CommandBinding <CommandBindingInfo
command="SDBuildCommands.RebuildProject" command="SDBuildCommands.RebuildProject"
class="ICSharpCode.SharpDevelop.Project.Commands.RebuildProject" class="ICSharpCode.SharpDevelop.Project.Commands.RebuildProject"
gestures="Alt+F9" gestures="Alt+F9"
categories="/Building" /> categories="/Building" />
<CommandBinding <CommandBindingInfo
command="SDBuildCommands.CleanProject" command="SDBuildCommands.CleanProject"
class="ICSharpCode.SharpDevelop.Project.Commands.CleanProject" class="ICSharpCode.SharpDevelop.Project.Commands.CleanProject"
categories="/Buildin" /> categories="/Buildin" />
<CommandBinding <CommandBindingInfo
command="SDBuildCommands.AbortBuild" command="SDBuildCommands.AbortBuild"
class="ICSharpCode.SharpDevelop.Project.Commands.AbortBuild" class="ICSharpCode.SharpDevelop.Project.Commands.AbortBuild"
categories="/Buildin" /> categories="/Buildin" />
<CommandBinding <CommandBindingInfo
command="SDBuildCommands.EditConfigurationsCommand" command="SDBuildCommands.EditConfigurationsCommand"
class="ICSharpCode.SharpDevelop.Project.Commands.EditConfigurationsCommand" class="ICSharpCode.SharpDevelop.Project.Commands.EditConfigurationsCommand"
categories="/Buildin" /> categories="/Buildin" />
<CommandBinding <CommandBindingInfo
command="SDProjectCommands.AddNewProjectToSolution" command="SDProjectCommands.AddNewProjectToSolution"
class="ICSharpCode.SharpDevelop.Project.Commands.AddNewProjectToSolution" class="ICSharpCode.SharpDevelop.Project.Commands.AddNewProjectToSolution"
categories="/Project" /> categories="/Project" />
<CommandBinding <CommandBindingInfo
command="SDProjectCommands.AddExitingProjectToSolution" command="SDProjectCommands.AddExitingProjectToSolution"
class="ICSharpCode.SharpDevelop.Project.Commands.AddExitingProjectToSolution" class="ICSharpCode.SharpDevelop.Project.Commands.AddExitingProjectToSolution"
categories="/Project" /> categories="/Project" />
<CommandBinding <CommandBindingInfo
command="SDProjectCommands.AddExistingItemToSolution" command="SDProjectCommands.AddExistingItemToSolution"
class="ICSharpCode.SharpDevelop.Project.Commands.AddExistingItemToSolution" class="ICSharpCode.SharpDevelop.Project.Commands.AddExistingItemToSolution"
categories="/Project" /> categories="/Project" />
<CommandBinding <CommandBindingInfo
command="SDProjectCommands.AddNewSolutionFolderToSolution" command="SDProjectCommands.AddNewSolutionFolderToSolution"
class="ICSharpCode.SharpDevelop.Project.Commands.AddNewSolutionFolderToSolution" class="ICSharpCode.SharpDevelop.Project.Commands.AddNewSolutionFolderToSolution"
categories="/Project" /> categories="/Project" />
<CommandBinding <CommandBindingInfo
command="SDDebugCommands.Execute" command="SDDebugCommands.Execute"
class="ICSharpCode.SharpDevelop.Project.Commands.Execute" class="ICSharpCode.SharpDevelop.Project.Commands.Execute"
gestures="F5" gestures="F5"
categories="/Debugger" /> categories="/Debugger" />
<CommandBinding <CommandBindingInfo
command="SDDebugCommands.ExecuteWithoutDebugger" command="SDDebugCommands.ExecuteWithoutDebugger"
class="ICSharpCode.SharpDevelop.Project.Commands.ExecuteWithoutDebugger" class="ICSharpCode.SharpDevelop.Project.Commands.ExecuteWithoutDebugger"
gestures="Ctrl+F5" gestures="Ctrl+F5"
categories="/Debugger" /> categories="/Debugger" />
<CommandBinding <CommandBindingInfo
command="SDDebugCommands.StopDebugging" command="SDDebugCommands.StopDebugging"
class="ICSharpCode.SharpDevelop.Project.Commands.StopDebuggingCommand" class="ICSharpCode.SharpDevelop.Project.Commands.StopDebuggingCommand"
categories="/Debugger" /> categories="/Debugger" />
<CommandBinding <CommandBindingInfo
command="SDDebugCommands.AttachToProcess" command="SDDebugCommands.AttachToProcess"
class="ICSharpCode.SharpDevelop.Project.Commands.AttachToProcessCommand" class="ICSharpCode.SharpDevelop.Project.Commands.AttachToProcessCommand"
categories="/Project" /> categories="/Project" />
<CommandBinding <CommandBindingInfo
command="SDDebugCommands.DetachFromProcess" command="SDDebugCommands.DetachFromProcess"
class="ICSharpCode.SharpDevelop.Project.Commands.DetachFromProcessCommand" class="ICSharpCode.SharpDevelop.Project.Commands.DetachFromProcessCommand"
categories="/Debugger" /> categories="/Debugger" />
<CommandBinding <CommandBindingInfo
command="SDDebugCommands.BreakDebugging" command="SDDebugCommands.BreakDebugging"
class="ICSharpCode.SharpDevelop.Project.Commands.BreakDebuggingCommand" class="ICSharpCode.SharpDevelop.Project.Commands.BreakDebuggingCommand"
gestures="Ctrl+Alt+B" gestures="Ctrl+Alt+B"
categories="/Debugger" /> categories="/Debugger" />
<CommandBinding <CommandBindingInfo
command="SDDebugCommands.ContinueDebugging" command="SDDebugCommands.ContinueDebugging"
class="ICSharpCode.SharpDevelop.Project.Commands.ContinueDebuggingCommand" class="ICSharpCode.SharpDevelop.Project.Commands.ContinueDebuggingCommand"
gestures="Ctrl+Alt+B; Ctrl+Alt+D" gestures="Ctrl+Alt+B; Ctrl+Alt+D"
categories="/Debugger" /> categories="/Debugger" />
<CommandBinding <CommandBindingInfo
command="SDDebugCommands.StepOver" command="SDDebugCommands.StepOver"
class="ICSharpCode.SharpDevelop.Project.Commands.StepDebuggingCommand" class="ICSharpCode.SharpDevelop.Project.Commands.StepDebuggingCommand"
gestures="F10" gestures="F10"
categories="/Debugger" /> categories="/Debugger" />
<CommandBinding <CommandBindingInfo
command="SDDebugCommands.StepInto" command="SDDebugCommands.StepInto"
class="ICSharpCode.SharpDevelop.Project.Commands.StepIntoDebuggingCommand" class="ICSharpCode.SharpDevelop.Project.Commands.StepIntoDebuggingCommand"
gestures="F11" gestures="F11"
categories="/Debugger" /> categories="/Debugger" />
<CommandBinding <CommandBindingInfo
command="SDDebugCommands.StepOut" command="SDDebugCommands.StepOut"
class="ICSharpCode.SharpDevelop.Project.Commands.StepOutDebuggingCommand" class="ICSharpCode.SharpDevelop.Project.Commands.StepOutDebuggingCommand"
gestures="Shift+F11" gestures="Shift+F11"
categories="/Debugger" /> categories="/Debugger" />
<CommandBinding <CommandBindingInfo
command="SDDebugCommands.ToggleBreakpoint" command="SDDebugCommands.ToggleBreakpoint"
class="ICSharpCode.SharpDevelop.Project.Commands.ToggleBreakpointCommand" class="ICSharpCode.SharpDevelop.Project.Commands.ToggleBreakpointCommand"
gestures="F7" gestures="F7"
categories="/Debugger" /> categories="/Debugger" />
<CommandBinding <CommandBindingInfo
command="SDSearchCommands.ToggleBookmark" command="SDSearchCommands.ToggleBookmark"
class="ICSharpCode.SharpDevelop.Bookmarks.ToggleBookmark" class="ICSharpCode.SharpDevelop.Bookmarks.ToggleBookmark"
gestures="Ctrl+F2" gestures="Ctrl+F2"
categories="/Search" /> categories="/Search" />
<CommandBinding <CommandBindingInfo
command="SDSearchCommands.PrevBookmark" command="SDSearchCommands.PrevBookmark"
class="ICSharpCode.SharpDevelop.Bookmarks.PrevBookmark" class="ICSharpCode.SharpDevelop.Bookmarks.PrevBookmark"
gestures="Alt+F2" gestures="Alt+F2"
categories="/Search" /> categories="/Search" />
<CommandBinding <CommandBindingInfo
command="SDSearchCommands.NextBookmark" command="SDSearchCommands.NextBookmark"
class="ICSharpCode.SharpDevelop.Bookmarks.NextBookmark" class="ICSharpCode.SharpDevelop.Bookmarks.NextBookmark"
gestures="F2" gestures="F2"
categories="/Search" /> categories="/Search" />
<CommandBinding <CommandBindingInfo
command="SDSearchCommands.ClearBookmarks" command="SDSearchCommands.ClearBookmarks"
class="ICSharpCode.SharpDevelop.Bookmarks.ClearBookmarks" class="ICSharpCode.SharpDevelop.Bookmarks.ClearBookmarks"
categories="/Search" /> categories="/Search" />
<CommandBinding <CommandBindingInfo
command="SDSearchCommands.GotoLineNumber" command="SDSearchCommands.GotoLineNumber"
class="ICSharpCode.SharpDevelop.DefaultEditor.Commands.GotoLineNumber" class="ICSharpCode.SharpDevelop.DefaultEditor.Commands.GotoLineNumber"
gestures="Ctrl+G" gestures="Ctrl+G"
categories="/Search" /> categories="/Search" />
<CommandBinding <CommandBindingInfo
command="SDSearchCommands.GotoBrace" command="SDSearchCommands.GotoBrace"
class="ICSharpCode.SharpDevelop.DefaultEditor.Commands.GotoMatchingBrace" class="ICSharpCode.SharpDevelop.DefaultEditor.Commands.GotoMatchingBrace"
gestures="Ctrl+B" gestures="Ctrl+B"

8
src/AddIns/Misc/SearchAndReplace/Project/SearchAndReplace.addin

@ -20,10 +20,10 @@
</Path> </Path>
<Path name="/SharpDevelop/CommandManager/CommandBindings"> <Path name="/SharpDevelop/CommandManager/CommandBindings">
<CommandBinding command="SDSearchAndReplace.Find" class="SearchAndReplace.Find" lazy="true" gestures="Ctrl+F" /> <CommandBindingInfo command="SDSearchAndReplace.Find" class="SearchAndReplace.Find" lazy="true" gestures="Ctrl+F" />
<CommandBinding command="SDSearchAndReplace.FindNext" class="SearchAndReplace.FindNext" lazy="true" gestures="F3" /> <CommandBindingInfo command="SDSearchAndReplace.FindNext" class="SearchAndReplace.FindNext" lazy="true" gestures="F3" />
<CommandBinding command="SDSearchAndReplace.FindNextSelected" class="SearchAndReplace.FindNextSelected" lazy="true" gestures="Ctrl+F3" /> <CommandBindingInfo command="SDSearchAndReplace.FindNextSelected" class="SearchAndReplace.FindNextSelected" lazy="true" gestures="Ctrl+F3" />
<CommandBinding command="SDSearchAndReplace.Replace" class="SearchAndReplace.Replace" lazy="true" gestures="Ctrl+R" /> <CommandBindingInfo command="SDSearchAndReplace.Replace" class="SearchAndReplace.Replace" lazy="true" gestures="Ctrl+R" />
</Path> </Path>
<!-- Commands registry test --> <!-- Commands registry test -->

10
src/Main/Base/Project/Src/Commands/AutostartCommands.cs

@ -126,16 +126,6 @@ namespace ICSharpCode.SharpDevelop.Commands
ParserService.StartParserThread(); ParserService.StartParserThread();
// Register gesture place holders
var placeHolderDescriptors = AddInTree.BuildItems<GesturesPlaceHolderDescriptor>("/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 ... // finally run the workbench window ...
//Application.AddMessageFilter(new FormKeyHandler()); //Application.AddMessageFilter(new FormKeyHandler());
//Application.Run(WorkbenchSingleton.MainForm); //Application.Run(WorkbenchSingleton.MainForm);

13
src/Main/Core/Project/ICSharpCode.Core.csproj

@ -60,12 +60,11 @@
<Compile Include="Src\AddInTree\AddIn\Codon.cs" /> <Compile Include="Src\AddInTree\AddIn\Codon.cs" />
<Compile Include="Src\AddInTree\AddIn\ComplexCondition.cs" /> <Compile Include="Src\AddInTree\AddIn\ComplexCondition.cs" />
<Compile Include="Src\AddInTree\AddIn\Condition.cs" /> <Compile Include="Src\AddInTree\AddIn\Condition.cs" />
<Compile Include="Src\AddInTree\AddIn\DefaultDoozers\Command\CommandBindingDescriptor.cs" /> <Compile Include="Src\AddInTree\AddIn\DefaultDoozers\Command\CommandBindingInfoDescriptor.cs" />
<Compile Include="Src\AddInTree\AddIn\DefaultDoozers\Command\CommandBindingDoozer.cs" /> <Compile Include="Src\AddInTree\AddIn\DefaultDoozers\Command\CommandBindingInfoDoozer.cs" />
<Compile Include="Src\AddInTree\AddIn\DefaultDoozers\Command\GesturesPlaceHolderDescriptor.cs" /> <Compile Include="Src\AddInTree\AddIn\DefaultDoozers\Command\InputBindingCategoryDescriptor.cs" />
<Compile Include="Src\AddInTree\AddIn\DefaultDoozers\Command\GesturesPlaceHolderDoozer.cs" /> <Compile Include="Src\AddInTree\AddIn\DefaultDoozers\Command\InputBindingInfoDescriptor.cs" />
<Compile Include="Src\AddInTree\AddIn\DefaultDoozers\Command\InputBindingDescriptor.cs" /> <Compile Include="Src\AddInTree\AddIn\DefaultDoozers\Command\InputBindingInfoDoozer.cs" />
<Compile Include="Src\AddInTree\AddIn\DefaultDoozers\Command\InputBindingDoozer.cs" />
<Compile Include="Src\AddInTree\AddIn\DefaultDoozers\Command\InputBindingCategoryDoozer.cs" /> <Compile Include="Src\AddInTree\AddIn\DefaultDoozers\Command\InputBindingCategoryDoozer.cs" />
<Compile Include="Src\AddInTree\AddIn\DefaultDoozers\Command\RoutedUICommandDescriptor.cs" /> <Compile Include="Src\AddInTree\AddIn\DefaultDoozers\Command\RoutedUICommandDescriptor.cs" />
<Compile Include="Src\AddInTree\AddIn\DefaultDoozers\Command\RoutedUICommandDoozer.cs" /> <Compile Include="Src\AddInTree\AddIn\DefaultDoozers\Command\RoutedUICommandDoozer.cs" />
@ -96,7 +95,6 @@
<Compile Include="Src\AddInTree\TreePathNotFoundException.cs" /> <Compile Include="Src\AddInTree\TreePathNotFoundException.cs" />
<Compile Include="Src\CoreException.cs" /> <Compile Include="Src\CoreException.cs" />
<Compile Include="Src\Services\ApplicationStateInfoService.cs" /> <Compile Include="Src\Services\ApplicationStateInfoService.cs" />
<Compile Include="Src\Services\CommandsService\BaseGesturesPlaceHolderRegistry.cs" />
<Compile Include="Src\Services\FileUtility\FileNameEventHandler.cs" /> <Compile Include="Src\Services\FileUtility\FileNameEventHandler.cs" />
<Compile Include="Src\Services\FileUtility\FileUtility.cs" /> <Compile Include="Src\Services\FileUtility\FileUtility.cs" />
<Compile Include="Src\Services\FileUtility\FileUtility.Minimal.cs" /> <Compile Include="Src\Services\FileUtility\FileUtility.Minimal.cs" />
@ -136,7 +134,6 @@
<ItemGroup> <ItemGroup>
<Folder Include="Src\AddInTree\AddIn\DefaultDoozers\Command" /> <Folder Include="Src\AddInTree\AddIn\DefaultDoozers\Command" />
<Folder Include="Src\Services\LoggingService" /> <Folder Include="Src\Services\LoggingService" />
<Folder Include="Src\Services\CommandsService" />
<Folder Include="Src\Services\ResourceService" /> <Folder Include="Src\Services\ResourceService" />
<Content Include="..\..\..\..\data\schemas\AddIn.xsd"> <Content Include="..\..\..\..\data\schemas\AddIn.xsd">
<Link>Src\AddInTree\AddIn\AddIn.xsd</Link> <Link>Src\AddInTree\AddIn\AddIn.xsd</Link>

99
src/Main/Core/Project/Src/AddInTree/AddIn/DefaultDoozers/Command/CommandBindingDescriptor.cs

@ -1,99 +0,0 @@
using System;
namespace ICSharpCode.Core
{
/// <summary>
/// Stores information about command binding loaded from add-in tree
/// </summary>
public class CommandBindingDescriptor
{
/// <summary>
/// Codon used to create this descriptor
/// </summary>
public Codon Codon {
get; private set;
}
public string Name {
get; private set;
}
/// <summary>
/// Full name of the command class which will be executed when this
/// binding is triggered
/// </summary>
public string Class {
get; private set;
}
/// <summary>
/// Full name of routed UI command which will trigger this binding
///
/// If command with provided name is not yet registered it's created automatically
/// </summary>
public string Command {
get; private set;
}
/// <summary>
/// Override routed command text (string visible to user) if specified
/// </summary>
public string CommandText {
get; private set;
}
public string OwnerInstanceName {
get; private set;
}
public string OwnerTypeName {
get; private set;
}
/// <summary>
/// Gestures.
///
/// Optional, if provided input bindings in the same context will be created
/// </summary>
public string Gestures {
get; private set;
}
/// <summary>
/// If input binding is created in the same context (this is done by setting <see cref="Gestures" /> property)
/// assign this input binding to provided category
/// </summary>
public string Categories {
get; private set;
}
/// <summary>
/// Lazy loading
///
/// If true add-in referenced assemblies are loaded when command is invoked.
/// Otherwise command can't be invoked until addin is loaded
/// </summary>
public bool Lazy {
get {
return Codon.Properties["lazy"] == "1" || Codon.Properties["lazy"] == "true";
}
}
/// <summary>
/// Constructor
/// </summary>
/// <param name="codon">Reference to codon used to create this descriptor</param>
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"];
}
}
}

52
src/Main/Core/Project/Src/AddInTree/AddIn/DefaultDoozers/Command/CommandBindingDoozer.cs

@ -1,52 +0,0 @@
using System;
namespace ICSharpCode.Core
{
/// <attribute name="command" use="required">
/// Name of routed UI command which triggers this binding.
///
/// Routed UI command details are specified in path '/SharpDevelop/Workbench/RoutedUICommands'
/// </attribute>
/// <attribute name="class" use="required">
/// Class implementing System.Window.Input.ICommand or
/// ICSharpCode.Core class. CanExecute and Executed methods
/// are used to handle raised event
/// </attribute>
/// <attribute name="context" use="optional">
/// Specified binding owner
///
/// If context is not specified binding is applied to default context
/// </attribute>
/// <attribute name="lazy" use="optional" enum="1;0;true;false">
/// Use lazy loading. If addin containing binded command is
/// not loaded yet, load asseblies referenced in add-in and then
/// invoke command
/// </attribute>
/// <attribute name="gestures" use="optional">
/// Create input bindings in the same context which will trigger specified routed UI command
/// </attribute>
/// <usage>Only in /SharpDevelop/Workbench/CommandBindings</usage>
/// <returns>
/// CommandBindingDescriptor object
/// </returns>
/// <summary>
/// Creates descriptor containing information about command binding
/// </summary>
public class CommandBindingDoozer : IDoozer
{
/// <see cref="IDoozer.HandleConditions" />
public bool HandleConditions {
get {
return false;
}
}
/// <see cref="IDoozer.BuildItem(object, Codon, System.Collections.ArrayList)">
/// Builds CommandBindingDescriptor
/// </see>
public object BuildItem(object caller, Codon codon, System.Collections.ArrayList subItems)
{
return new CommandBindingDescriptor(codon);
}
}
}

117
src/Main/Core/Project/Src/AddInTree/AddIn/DefaultDoozers/Command/CommandBindingInfoDescriptor.cs

@ -0,0 +1,117 @@
using System;
namespace ICSharpCode.Core
{
/// <summary>
/// Describes <see cref="ICSharpCode.Core.Presentation.CommandBindingInfo" />
/// </summary>
public class CommandBindingInfoDescriptor
{
/// <summary>
/// Gets codon used to create this descriptor
/// </summary>
public Codon Codon
{
get; private set;
}
/// <summary>
/// Gets full name of the command class containing user instructions
///
/// The class must implement <see cref="System.Windows.Input.ICommand" /> or <see cref="ICSharpCode.Core.ICommand" />
/// classes
/// </summary>
public string Class
{
get; private set;
}
/// <summary>
/// Gets name of <see cref="System.Window.Input.RoutedUICommand" /> associated with descriptor
/// The name should be associated to a command in code using <see cref="ICSharpCode.Core.Presentation.CommandManager" />
/// </summary>
public string Command
{
get; private set;
}
/// <summary>
/// Gets overriden routed command text (string visible to user)
///
/// If not provided <see cref="System.Window.Input.RoutedUICommand.Text" /> property value is used
/// </summary>
public string CommandText
{
get; private set;
}
/// <summary>
/// Gets name of binding owner type name.
///
/// A name can be assigned to type in code using <see cref="ICSharpCode.Core.Presentation.CommandManager" />.
/// If this property is set then <see cref="OwnerTypeName" /> property can be ignored
/// If neither owner type nor owner instance is specified default owner type is applied
/// </summary>
public string OwnerInstanceName
{
get; private set;
}
/// <summary>
/// Name of binding owner instance name.
///
/// A name can be assigned to instance in code using <see cref="ICSharpCode.Core.Presentation.CommandManager" />.
/// If this property is set then <see cref="OwnerInstanceName" /> property can be ignored
/// If neither owner type nor owner instance is specified default owner type is applied
/// </summary>
public string OwnerTypeName {
get; private set;
}
/// <summary>
/// Gets gestures associated with created <see cref="ICSharpCode.Core.Presentation.InputBindingInfo" />
///
/// Optional, if provided input binding info with the same owner will be created
/// </summary>
public string Gestures {
get; private set;
}
/// <summary>
/// Gets list of paths to input binding categories associated with created <see cref="ICSharpCode.Core.Presentation.InputBindingInfo" /> (separated by comma)
///
/// Can only be used together with <see cref="Gestures" /> property
/// </summary>
public string Categories {
get; private set;
}
/// <summary>
/// Lazy loading
///
/// If true add-in referenced assemblies are loaded when command is invoked.
/// Otherwise command can't be invoked until addin is loaded
/// </summary>
public bool Lazy {
get {
return Codon.Properties["lazy"] == "1" || Codon.Properties["lazy"] == "true";
}
}
/// <summary>
/// Creates new instance of <see cref="CommandBindingInfoDescriptor" />
/// </summary>
/// <param name="codon">Reference to codon used to create this descriptor</param>
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"];
}
}
}

76
src/Main/Core/Project/Src/AddInTree/AddIn/DefaultDoozers/Command/CommandBindingInfoDoozer.cs

@ -0,0 +1,76 @@
using System;
namespace ICSharpCode.Core
{
/// <attribute name="command" use="required">
/// 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
/// </attribute>
/// <attribute name="class" use="required">
/// Command class performing some action
/// The class should implement System.Window.Input.ICommand or ICSharpCode.Core.ICommand class.
/// </attribute>
/// <attribute name="ownertype" use="optional">
/// 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
/// </attribute>
/// <attribute name="ownertype" use="optional">
/// 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
/// </attribute>
/// <attribute name="lazy" use="optional" enum="1;0;true;false">
/// Use lazy loading.
/// </attribute>
/// <attribute name="gestures" use="optional">
/// Create input bindings assigned to the same owner type or owner instance and associated
/// with the same System.Window.Input.RoutedUICommand
/// </attribute>
/// <attribute name="commandtext" use="optional">
/// 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
/// </attribute>
/// <attribute name="categories" use="optional">
/// 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
/// </attribute>
/// <usage>Only in /SharpDevelop/Workbench/CommandBindings</usage>
/// <returns>
/// CommandBindingInfoDescriptor object
/// </returns>
/// <summary>
/// Creates descriptor containing data describing ICSharpCode.Core.Presentation.CommandBindingInfo
/// </summary>
public class CommandBindingInfoDoozer : IDoozer
{
/// <inheritdoc />
public bool HandleConditions {
get {
return false;
}
}
/// <summary>
/// Builds instance of <see cref="CommandBindingInfoDescriptor" /> from codon
/// </summary>
/// <param name="caller">Caller object</param>
/// <param name="codon">Codon</param>
/// <param name="subItems">Codon sub-items</param>
/// <returns>Instance of <see cref="CommandBindingInfoDescriptor" /></returns>
public object BuildItem(object caller, Codon codon, System.Collections.ArrayList subItems)
{
return new CommandBindingInfoDescriptor(codon);
}
}
}

26
src/Main/Core/Project/Src/AddInTree/AddIn/DefaultDoozers/Command/GesturesPlaceHolderDescriptor.cs

@ -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"];
}
}
}

43
src/Main/Core/Project/Src/AddInTree/AddIn/DefaultDoozers/Command/GesturesPlaceHolderDoozer.cs

@ -1,43 +0,0 @@
using System;
namespace ICSharpCode.Core
{
/// <attribute name="name" use="required">
/// Place holder name. This name should be unique application wide
/// </attribute>
/// <attribute name="text" use="required">
/// Text displayed to use
/// </attribute>
/// <attribute name="lazy" use="optional" enum="1;0;true;false">
/// Use lazy loading. If addin containing binded command is
/// not loaded yet, load asseblies referenced in add-in and then
/// invoke command
/// </attribute>
/// <attribute name="gestures" use="optional">
/// Keys which will invoke command
/// </attribute>
/// <usage>Only in /SharpDevelop/Workbench/CommandBindings</usage>
/// <returns>
/// GesturesPlaceHolder object
/// </returns>
/// <summary>
/// Creates descriptor containing information about command binding
/// </summary>
public class GesturesPlaceHolderDoozer : IDoozer
{
/// <see cref="IDoozer.HandleConditions" />
public bool HandleConditions {
get {
return false;
}
}
/// <see cref="IDoozer.BuildItem(object, Codon, System.Collections.ArrayList)">
/// Builds GesturesPlaceHolderDoozer
/// </see>
public object BuildItem(object caller, Codon codon, System.Collections.ArrayList subItems)
{
return new GesturesPlaceHolderDescriptor(codon);
}
}
}

47
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
{
/// <summary>
/// Describes <see cref="ICSharpCode.Core.Presentation.CommandBindingInfo" />
/// </summary>
public class InputBindingCategoryDescriptor
{
/// <summary>
/// Gets category Id used to create category path
/// </summary>
public string Id
{
get; private set;
}
/// <summary>
/// Gets category name displayed to user
/// </summary>
public string Text
{
get; private set;
}
/// <summary>
/// Gets children category descriptors
/// </summary>
public List<InputBindingCategoryDescriptor> Children
{
get; private set;
}
/// <summary>
/// Creates instance of <see cref="InputBindingCategoryDescriptor" />
/// </summary>
/// <param name="codon">Reference to codon used to create this descriptor</param>
/// <param name="subItems">List of sub-category descriptors</param>
public InputBindingCategoryDescriptor(Codon codon, System.Collections.ArrayList subItems) {
Id = codon.Properties["id"];
Text = codon.Properties["text"];
Children = subItems != null ? subItems.Cast<InputBindingCategoryDescriptor>().ToList() : new List<InputBindingCategoryDescriptor>();
}
}
}

43
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;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
namespace ICSharpCode.Core namespace ICSharpCode.Core
{ {
/// <attribute name="id" use="required">
/// Category Id used in category path
/// </attribute>
/// <attribute name="name" use="required">
/// Category name displayed to user
/// </attribute>
/// <usage>Only in /SharpDevelop/CommandManager/InputBindingCategories</usage>
/// <returns>
/// InputBindingCategory object
/// </returns>
/// <summary> /// <summary>
/// Description of InputBindingInfoCategory. /// Creates descriptor containing data describing ICSharpCode.Core.Presentation.InputBindingCategory
/// </summary> /// </summary>
public class InputBindingCategoryDoozer : IDoozer public class InputBindingCategoryDoozer : IDoozer
{ {
/// <see cref="IDoozer.HandleConditions" /> /// <inheritdoc />
public bool HandleConditions { public bool HandleConditions {
get { get {
return true; return true;
} }
} }
/// <see cref="IDoozer.BuildItem(object, Codon, System.Collections.ArrayList)"> /// <summary>
/// Builds InputBindingDescriptor /// Builds instance of <see cref="InputBindingCategoryDescriptor" /> from codon
/// </see> /// </summary>
/// <param name="caller">Caller object</param>
/// <param name="codon">Codon</param>
/// <param name="subItems">Codon sub-items</param>
/// <returns>Instance of <see cref="InputBindingCategoryDescriptor" /></returns>
public object BuildItem(object caller, Codon codon, System.Collections.ArrayList subItems) public object BuildItem(object caller, Codon codon, System.Collections.ArrayList subItems)
{ {
return new InputBindingCategoryDescriptor(codon, subItems); return new InputBindingCategoryDescriptor(codon, subItems);
} }
} }
public class InputBindingCategoryDescriptor
{
public string Id;
public string Text;
public List<InputBindingCategoryDescriptor> Children;
public InputBindingCategoryDescriptor(Codon codon, System.Collections.ArrayList subItems) {
Id = codon.Properties["id"];
Text = codon.Properties["text"];
Children = subItems != null ? subItems.Cast<InputBindingCategoryDescriptor>().ToList() : new List<InputBindingCategoryDescriptor>();
}
}
} }

73
src/Main/Core/Project/Src/AddInTree/AddIn/DefaultDoozers/Command/InputBindingDescriptor.cs

@ -1,73 +0,0 @@
using System;
namespace ICSharpCode.Core
{
/// <summary>
/// Stores information about input binding loaded from add-in tree
/// </summary>
public class InputBindingDescriptor
{
/// <summary>
/// Codon used to create this descriptor
/// </summary>
public Codon Codon {
get; private set;
}
/// <summary>
/// Full name of routed UI command which will be invoked when this binding is triggered
/// </summary>
public string Command {
get; private set;
}
public string Name {
get; private set;
}
/// <summary>
/// Override routed command text (string visible to user) if specified
/// </summary>
public string CommandText {
get; private set;
}
public string OwnerInstanceName {
get; private set;
}
public string OwnerTypeName {
get; private set;
}
/// <summary>
/// Description of gesture which will trigger this binding
/// </summary>
public string Gestures {
get; private set;
}
/// <summary>
/// Category to which this binding belongs
/// </summary>
public string Categories {
get; private set;
}
/// <summary>
/// Constructor
/// </summary>
/// <param name="codon">Reference to codon used to create this descriptor</param>
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"];
}
}
}

35
src/Main/Core/Project/Src/AddInTree/AddIn/DefaultDoozers/Command/InputBindingDoozer.cs

@ -1,35 +0,0 @@
using System;
namespace ICSharpCode.Core
{
/// <attribute name="command" use="required">
/// Name of routed UI command which is triggered by this binding
/// </attribute>
/// <attribute name="gesture" use="required">
/// Gesture which triggers this binding
/// </attribute>
/// <usage>Only in /SharpDevelop/Workbench/InputBindings</usage>
/// <returns>
/// InputBindingDescriptor object
/// </returns>
/// <summary>
/// Creates descriptor containing information about input binding
/// </summary>
public class InputBindingDoozer : IDoozer
{
/// <see cref="IDoozer.HandleConditions" />
public bool HandleConditions {
get {
return true;
}
}
/// <see cref="IDoozer.BuildItem(object, Codon, System.Collections.ArrayList)">
/// Builds InputBindingDescriptor
/// </see>
public object BuildItem(object caller, Codon codon, System.Collections.ArrayList subItems)
{
return new InputBindingDescriptor(codon);
}
}
}

87
src/Main/Core/Project/Src/AddInTree/AddIn/DefaultDoozers/Command/InputBindingInfoDescriptor.cs

@ -0,0 +1,87 @@
using System;
namespace ICSharpCode.Core
{
/// <summary>
/// Describes <see cref="ICSharpCode.Core.Presentation.InputBindingInfo" />
/// </summary>
public class InputBindingInfoDescriptor
{
/// <summary>
/// Codon used to create this descriptor
/// </summary>
public Codon Codon {
get; private set;
}
/// <summary>
/// Gets name of <see cref="System.Window.Input.RoutedUICommand" /> associated with descriptor
/// The name should be associated to a command in code using <see cref="ICSharpCode.Core.Presentation.CommandManager" />
/// </summary>
public string Command {
get; private set;
}
/// <summary>
/// Gets overriden routed command text (string visible to user)
///
/// If not provided <see cref="System.Window.Input.RoutedUICommand.Text" /> property value is used
/// </summary>
public string CommandText {
get; private set;
}
/// <summary>
/// Gets name of binding owner type name.
///
/// A name can be assigned to type in code using <see cref="ICSharpCode.Core.Presentation.CommandManager" />.
/// If this property is set then <see cref="OwnerTypeName" /> property can be ignored
/// If neither owner type nor owner instance is specified default owner type is applied
/// </summary>
public string OwnerInstanceName {
get; private set;
}
/// <summary>
/// Name of binding owner instance name.
///
/// A name can be assigned to instance in code using <see cref="ICSharpCode.Core.Presentation.CommandManager" />.
/// If this property is set then <see cref="OwnerInstanceName" /> property can be ignored
/// If neither owner type nor owner instance is specified default owner type is applied
/// </summary>
public string OwnerTypeName {
get; private set;
}
/// <summary>
/// Gets gestures associated with created <see cref="ICSharpCode.Core.Presentation.InputBindingInfo" />
/// </summary>
public string Gestures {
get; private set;
}
/// <summary>
/// List of paths to input binding categories associated with created <see cref="ICSharpCode.Core.Presentation.InputBindingInfo" /> (separated by comma)
/// </summary>
public string Categories {
get; private set;
}
/// <summary>
/// Creates new instance of <see cref="InputBindingInfoDescriptor" />
/// </summary>
/// <param name="codon">Reference to codon used to create this descriptor</param>
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"];
}
}
}

64
src/Main/Core/Project/Src/AddInTree/AddIn/DefaultDoozers/Command/InputBindingInfoDoozer.cs

@ -0,0 +1,64 @@
using System;
namespace ICSharpCode.Core
{
/// <attribute name="command" use="required">
/// 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
/// </attribute>
/// <attribute name="ownertype" use="optional">
/// 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
/// </attribute>
/// <attribute name="ownertype" use="optional">
/// 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
/// </attribute>
/// <attribute name="gestures" use="optional">
/// Gestures associated with created System.Windows.Input.InputBinding instances
/// </attribute>
/// <attribute name="commandtext" use="optional">
/// 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
/// </attribute>
/// <attribute name="categories" use="optional">
/// 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.
/// </attribute>
/// <usage>Only in /SharpDevelop/Workbench/InputBindings</usage>
/// <returns>
/// CommandBindingInfoDescriptor object
/// </returns>
/// <summary>
/// Creates descriptor containing data describing ICSharpCode.Core.Presentation.InputBindingInfo
/// </summary>
public class InputBindingInfoDoozer : IDoozer
{
/// <see cref="IDoozer.HandleConditions" />
public bool HandleConditions {
get {
return true;
}
}
/// <see cref="IDoozer.BuildItem(object, Codon, System.Collections.ArrayList)">
/// Builds InputBindingInfoDescriptor
/// </see>
public object BuildItem(object caller, Codon codon, System.Collections.ArrayList subItems)
{
return new InputBindingInfoDescriptor(codon);
}
}
}

5
src/Main/Core/Project/Src/AddInTree/AddInTree.cs

@ -35,11 +35,10 @@ namespace ICSharpCode.Core
doozers.Add("Include", new IncludeDoozer()); doozers.Add("Include", new IncludeDoozer());
// Command manager doozers // Command manager doozers
doozers.Add("InputBinding", new InputBindingDoozer()); doozers.Add("InputBindingInfo", new InputBindingInfoDoozer());
doozers.Add("InputBindingCategory", new InputBindingCategoryDoozer()); doozers.Add("InputBindingCategory", new InputBindingCategoryDoozer());
doozers.Add("CommandBinding", new CommandBindingDoozer()); doozers.Add("CommandBindingInfo", new CommandBindingInfoDoozer());
doozers.Add("RoutedUICommand", new RoutedUICommandDoozer()); doozers.Add("RoutedUICommand", new RoutedUICommandDoozer());
doozers.Add("GesturesPlaceHolder", new GesturesPlaceHolderDoozer());
doozers.Add("MenuLocation", new MenuLocationDoozer()); doozers.Add("MenuLocation", new MenuLocationDoozer());
conditionEvaluators.Add("Compare", new CompareConditionEvaluator()); conditionEvaluators.Add("Compare", new CompareConditionEvaluator());

174
src/Main/Core/Project/Src/Services/CommandsService/BaseGesturesPlaceHolderRegistry.cs

@ -1,174 +0,0 @@
using System;
using System.Collections.Generic;
using ICSharpCode.Core;
namespace ICSharpCode.Core
{
public delegate void GesturesPlaceHolderUpdate();
/// <summary>
/// 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
/// </summary>
public static class BaseGesturesPlaceHolderRegistry
{
private static Dictionary<string, GesturesPlaceHolderInfo> gesturePlaceHolders = new Dictionary<string, GesturesPlaceHolderInfo>();
private static Dictionary<string, string> commandTexts = new Dictionary<string, string>();
private static Dictionary<string, List<string>> registeredKeys = new Dictionary<string, List<string>>();
private static Dictionary<string, List<WeakReference>> commandKeysUpdateHandlers = new Dictionary<string, List<WeakReference>>();
/// <summary>
/// Register a place holder
/// </summary>
/// <param name="placeHolderName">Place holder name. Unique application wide</param>
/// <param name="placeHolderText">Place holder text visible to user</param>
public static void RegisterPlaceHolder(string placeHolderName, string placeHolderText) {
gesturePlaceHolders.Add(placeHolderName, new GesturesPlaceHolderInfo(placeHolderName, placeHolderText));
}
/// <summary>
/// Get gestures assigned to place holder
///
/// Use KeysCollectionConverter or InputGestureCollectionConverter
/// to convert returned value representation to required format
/// </summary>
/// <param name="placeHolderName">Place holder name</param>
/// <returns>Array of gestures</returns>
public static string[] GetGestures(string placeHolderName) {
if(!gesturePlaceHolders.ContainsKey(placeHolderName) || gesturePlaceHolders[placeHolderName].Gestures.Count == 0) {
return new string[] { };
}
return gesturePlaceHolders[placeHolderName].Gestures.ToArray();
}
/// <summary>
/// Add gestures to place holder
///
/// Use KeysCollectionConverter or InputGestureCollectionConverter
/// to convert gestures to string representation
/// </summary>
/// <param name="placeHolderName">Place holder name</param>
/// <param name="gestures">Added gestures</param>
public static void AddGestures(string placeHolderName, IEnumerable<string> 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);
}
}
}
/// <summary>
/// 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
/// </summary>
/// <param name="placeHolderName"></param>
/// <param name="gestures"></param>
public static void RemoveGestures(string placeHolderName, IEnumerable<string> 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);
}
}
}
}
}
}
/// <summary>
/// Register update handler which will trigger when gestures in
/// place holder are updated
/// </summary>
/// <param name="placeHolderName">Place holder name</param>
/// <param name="handler">Handler which handles place holder gestures update</param>
public static void RegisterUpdateHandler(string placeHolderName, GesturesPlaceHolderUpdate handler) {
if(!commandKeysUpdateHandlers.ContainsKey(placeHolderName)) {
commandKeysUpdateHandlers.Add(placeHolderName, new List<WeakReference>());
}
commandKeysUpdateHandlers[placeHolderName].Add(new WeakReference(handler));
}
/// <summary>
/// Invoke delegates which handle gestures update in place holder
///
/// If place holder is not provided all registered handlers are invoked
/// </summary>
/// <param name="placeHolderName"></param>
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();
}
}
}
}
}
/// <summary>
/// Intername representation of place holders
/// </summary>
class GesturesPlaceHolderInfo
{
/// <summary>
/// Place hollder name
/// </summary>
public string Name {
get; private set;
}
/// <summary>
/// Place holder text visible to user
/// </summary>
public string Text {
get; private set;
}
/// <summary>
/// Collection of gestures assigned to this place holder
/// </summary>
public List<string> Gestures {
get; private set;
}
/// <summary>
/// Constructor
/// </summary>
/// <param name="name">Place holder name</param>
/// <param name="text">Place holder text visible to user</param>
public GesturesPlaceHolderInfo(string name, string text) {
Name = name;
Text = text;
Gestures = new List<string>();
}
}
}
}

4
src/Main/ICSharpCode.Core.Presentation/CommandsService/CommandsService.cs

@ -194,7 +194,7 @@ namespace ICSharpCode.Core.Presentation
/// <param name="path">Path to codons</param> /// <param name="path">Path to codons</param>
public static void RegisterCommandBindings(object caller, string path) public static void RegisterCommandBindings(object caller, string path)
{ {
var descriptors = AddInTree.BuildItems<CommandBindingDescriptor>(path, caller, false); var descriptors = AddInTree.BuildItems<CommandBindingInfoDescriptor>(path, caller, false);
foreach(var desc in descriptors) { foreach(var desc in descriptors) {
var commandBindingInfoName = new StringBuilder(); var commandBindingInfoName = new StringBuilder();
@ -259,7 +259,7 @@ namespace ICSharpCode.Core.Presentation
/// <param name="path">Path to codons</param> /// <param name="path">Path to codons</param>
public static void RegisterInputBindings(object caller, string path) public static void RegisterInputBindings(object caller, string path)
{ {
var descriptors = AddInTree.BuildItems<InputBindingDescriptor>(path, caller, false); var descriptors = AddInTree.BuildItems<InputBindingInfoDescriptor>(path, caller, false);
foreach(var desc in descriptors) { foreach(var desc in descriptors) {
var gestures = (InputGestureCollection)new InputGestureCollectionConverter().ConvertFromString(desc.Gestures); var gestures = (InputGestureCollection)new InputGestureCollectionConverter().ConvertFromString(desc.Gestures);

14
src/Main/ICSharpCode.Core.Presentation/CommandsService/Profile/UserGestureProfile.cs

@ -76,16 +76,16 @@ namespace ICSharpCode.Core.Presentation
Name = rootNode.Attributes["name"].Value; Name = rootNode.Attributes["name"].Value;
Text = rootNode.Attributes["text"].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")) { foreach(XmlElement bindingInfoNode in xmlDocument.SelectNodes("//InputBinding")) {
string identifierInstanceName = null; string identifierInstanceName = null;
string identifierTypeName = null; string identifierTypeName = null;
var ownerInstanceAttribute = bindingInfoNode.Attributes["owner-instance"]; var ownerInstanceAttribute = bindingInfoNode.Attributes["ownerinstance"];
if(ownerInstanceAttribute != null) { if(ownerInstanceAttribute != null) {
identifierInstanceName = ownerInstanceAttribute.Value; identifierInstanceName = ownerInstanceAttribute.Value;
} else { } else {
var ownerTypeAttribute = bindingInfoNode.Attributes["owner-type"]; var ownerTypeAttribute = bindingInfoNode.Attributes["ownertype"];
identifierTypeName = ownerTypeAttribute.Value; identifierTypeName = ownerTypeAttribute.Value;
} }
@ -111,7 +111,7 @@ namespace ICSharpCode.Core.Presentation
textAttribute.Value = Text; textAttribute.Value = Text;
rootNode.Attributes.Append(textAttribute); rootNode.Attributes.Append(textAttribute);
var readOnlyAttribute = xmlDocument.CreateAttribute("read-only"); var readOnlyAttribute = xmlDocument.CreateAttribute("readonly");
readOnlyAttribute.Value = Convert.ToString(ReadOnly); readOnlyAttribute.Value = Convert.ToString(ReadOnly);
rootNode.Attributes.Append(readOnlyAttribute); rootNode.Attributes.Append(readOnlyAttribute);
@ -119,7 +119,7 @@ namespace ICSharpCode.Core.Presentation
var bindingInfoNode = xmlDocument.CreateElement("InputBinding"); var bindingInfoNode = xmlDocument.CreateElement("InputBinding");
if(definedGestures.Key.RoutedCommandName != null) { if(definedGestures.Key.RoutedCommandName != null) {
var routedCommandAttribute = xmlDocument.CreateAttribute("routed-command"); var routedCommandAttribute = xmlDocument.CreateAttribute("routedcommand");
routedCommandAttribute.Value = definedGestures.Key.RoutedCommandName; routedCommandAttribute.Value = definedGestures.Key.RoutedCommandName;
bindingInfoNode.Attributes.Append(routedCommandAttribute); bindingInfoNode.Attributes.Append(routedCommandAttribute);
} else { } else {
@ -127,11 +127,11 @@ namespace ICSharpCode.Core.Presentation
} }
if(definedGestures.Key.OwnerInstanceName != null) { if(definedGestures.Key.OwnerInstanceName != null) {
var ownerInstanceAttribute = xmlDocument.CreateAttribute("owner-instance"); var ownerInstanceAttribute = xmlDocument.CreateAttribute("ownerinstance");
ownerInstanceAttribute.Value = definedGestures.Key.OwnerInstanceName; ownerInstanceAttribute.Value = definedGestures.Key.OwnerInstanceName;
bindingInfoNode.Attributes.Append(ownerInstanceAttribute); bindingInfoNode.Attributes.Append(ownerInstanceAttribute);
} else if(definedGestures.Key.OwnerTypeName != null) { } else if(definedGestures.Key.OwnerTypeName != null) {
var ownerTypeAttribute = xmlDocument.CreateAttribute("owner-type"); var ownerTypeAttribute = xmlDocument.CreateAttribute("ownertype");
ownerTypeAttribute.Value = definedGestures.Key.OwnerTypeName; ownerTypeAttribute.Value = definedGestures.Key.OwnerTypeName;
bindingInfoNode.Attributes.Append(ownerTypeAttribute); bindingInfoNode.Attributes.Append(ownerTypeAttribute);
} else { } else {

82
src/Main/ICSharpCode.Core.WinForms/CommandsService/GesturePlaceHolderRegistry.cs

@ -1,82 +0,0 @@
using System;
using System.Windows.Forms;
using System.Collections.Generic;
using ICSharpCode.Core;
namespace ICSharpCode.Core.WinForms
{
/// <summary>
/// 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
/// </summary>
public static class GesturePlaceHolderRegistry
{
/// <summary>
/// Register a place holder
/// </summary>
/// <param name="placeHolderName">Place holder name. Unique application wide</param>
/// <param name="placeHolderText">Place holder text visible to user</param>
public static void RegisterPlaceHolder(string placeHolderName, string placeHolderText) {
BaseGesturesPlaceHolderRegistry.RegisterPlaceHolder(placeHolderName, placeHolderText);
}
/// <summary>
/// Get gestures assigned to place holder
/// </summary>
/// <param name="placeHolderName">Place holder name</param>
/// <returns>Array of keys</returns>
public static Keys[] GetGestures(string placeHolderName) {
var serializesGesturesColection = BaseGesturesPlaceHolderRegistry.GetGestures(placeHolderName);
var gestures = (Keys[])new KeysCollectionConverter().ConvertFrom(serializesGesturesColection);
return gestures;
}
/// <summary>
/// Add gestures to place holder
/// </summary>
/// <param name="placeHolderName">Place holder name</param>
/// <param name="gestures">Added gestures</param>
public static void AddGestures(string placeHolderName, IEnumerable<Keys> gestures) {
var serializedGestures = (string[])new KeysCollectionConverter().ConvertTo(gestures, typeof(string[]));
BaseGesturesPlaceHolderRegistry.AddGestures(placeHolderName, serializedGestures);
}
/// <summary>
/// Remove gestures from place holder
///
/// Null argumens are igonred and all gestures which specify
/// provided parameters are removed
/// </summary>
/// <param name="placeHolderName">Place holder name</param>
/// <param name="gestures">Gestures</param>
public static void RemoveGestures(string placeHolderName, IEnumerable<Keys> gestures) {
var serializedGestures = (string[])new KeysCollectionConverter().ConvertTo(gestures, typeof(string[]));
BaseGesturesPlaceHolderRegistry.RemoveGestures(placeHolderName, serializedGestures);
}
/// <summary>
/// Register update handler which will trigger when gestures in
/// place holder are updated
/// </summary>
/// <param name="placeHolderName">Place holder name</param>
/// <param name="handler">Handler which handles place holder gestures update</param>
public static void RegisterUpdateHandler(string placeHolderName, GesturesPlaceHolderUpdate handler) {
BaseGesturesPlaceHolderRegistry.RegisterUpdateHandler(placeHolderName, handler);
}
/// <summary>
/// Invoke delegates which handle gestures update in place holder
///
/// If place holder is not provided all registered handlers are invoked
/// </summary>
/// <param name="placeHolderName"></param>
public static void InvokeUpdateHandlers(string placeHolderName) {
BaseGesturesPlaceHolderRegistry.InvokeUpdateHandlers(placeHolderName);
}
}
}

1
src/Main/ICSharpCode.Core.WinForms/ICSharpCode.Core.WinForms.csproj

@ -50,7 +50,6 @@
<Compile Include="..\GlobalAssemblyInfo.cs"> <Compile Include="..\GlobalAssemblyInfo.cs">
<Link>Properties\GlobalAssemblyInfo.cs</Link> <Link>Properties\GlobalAssemblyInfo.cs</Link>
</Compile> </Compile>
<Compile Include="CommandsService\GesturePlaceHolderRegistry.cs" />
<Compile Include="CommandsService\KeysCollectionConverter.cs" /> <Compile Include="CommandsService\KeysCollectionConverter.cs" />
<Compile Include="Menu\IStatusUpdate.cs" /> <Compile Include="Menu\IStatusUpdate.cs" />
<Compile Include="Menu\ISubmenuBuilder.cs" /> <Compile Include="Menu\ISubmenuBuilder.cs" />

Loading…
Cancel
Save