diff --git a/src/AddIns/Misc/ShortcutsManagement/ShortcutsManagement.sln b/src/AddIns/Misc/ShortcutsManagement/ShortcutsManagement.sln new file mode 100644 index 0000000000..b68e9ed658 --- /dev/null +++ b/src/AddIns/Misc/ShortcutsManagement/ShortcutsManagement.sln @@ -0,0 +1,23 @@ + +Microsoft Visual Studio Solution File, Format Version 10.00 +# Visual Studio 2008 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ShortcutsManagement", "ShortcutsManagement\ShortcutsManagement.csproj", "{CF2FF1D1-A5FE-4848-936A-E2DFBE154562}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug in SharpDevelop|Any CPU = Debug in SharpDevelop|Any CPU + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {CF2FF1D1-A5FE-4848-936A-E2DFBE154562}.Debug in SharpDevelop|Any CPU.ActiveCfg = Debug in SharpDevelop|Any CPU + {CF2FF1D1-A5FE-4848-936A-E2DFBE154562}.Debug in SharpDevelop|Any CPU.Build.0 = Debug in SharpDevelop|Any CPU + {CF2FF1D1-A5FE-4848-936A-E2DFBE154562}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {CF2FF1D1-A5FE-4848-936A-E2DFBE154562}.Debug|Any CPU.Build.0 = Debug|Any CPU + {CF2FF1D1-A5FE-4848-936A-E2DFBE154562}.Release|Any CPU.ActiveCfg = Release|Any CPU + {CF2FF1D1-A5FE-4848-936A-E2DFBE154562}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/src/AddIns/Misc/ShortcutsManagement/ShortcutsManagement.suo b/src/AddIns/Misc/ShortcutsManagement/ShortcutsManagement.suo new file mode 100644 index 0000000000..83f9efbd2a Binary files /dev/null and b/src/AddIns/Misc/ShortcutsManagement/ShortcutsManagement.suo differ diff --git a/src/AddIns/Misc/ShortcutsManagement/ShortcutsManagement/App.xaml b/src/AddIns/Misc/ShortcutsManagement/ShortcutsManagement/App.xaml new file mode 100644 index 0000000000..2580950ff6 --- /dev/null +++ b/src/AddIns/Misc/ShortcutsManagement/ShortcutsManagement/App.xaml @@ -0,0 +1,8 @@ + + + + + diff --git a/src/AddIns/Misc/ShortcutsManagement/ShortcutsManagement/App.xaml.cs b/src/AddIns/Misc/ShortcutsManagement/ShortcutsManagement/App.xaml.cs new file mode 100644 index 0000000000..a456dce54f --- /dev/null +++ b/src/AddIns/Misc/ShortcutsManagement/ShortcutsManagement/App.xaml.cs @@ -0,0 +1,11 @@ +using System.Windows; + +namespace ICSharpCode.ShortcutsManagement +{ + /// + /// Interaction logic for App.xaml + /// + public partial class App : Application + { + } +} diff --git a/src/AddIns/Misc/ShortcutsManagement/ShortcutsManagement/Properties/AssemblyInfo.cs b/src/AddIns/Misc/ShortcutsManagement/ShortcutsManagement/Properties/AssemblyInfo.cs new file mode 100644 index 0000000000..1b7cb88293 --- /dev/null +++ b/src/AddIns/Misc/ShortcutsManagement/ShortcutsManagement/Properties/AssemblyInfo.cs @@ -0,0 +1,55 @@ +using System.Reflection; +using System.Resources; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; +using System.Windows; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("ShortcutsManagement")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("Nexum Insurance Technologies")] +[assembly: AssemblyProduct("ShortcutsManagement")] +[assembly: AssemblyCopyright("Copyright © Nexum Insurance Technologies 2009")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +//In order to begin building localizable applications, set +//CultureYouAreCodingWith in your .csproj file +//inside a . For example, if you are using US english +//in your source files, set the to en-US. Then uncomment +//the NeutralResourceLanguage attribute below. Update the "en-US" in +//the line below to match the UICulture setting in the project file. + +//[assembly: NeutralResourcesLanguage("en-US", UltimateResourceFallbackLocation.Satellite)] + + +[assembly: ThemeInfo( + ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located + //(used if a resource is not found in the page, + // or application resource dictionaries) + ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located + //(used if a resource is not found in the page, + // app, or any theme specific resource dictionaries) +)] + + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Build and Revision Numbers +// by using the '*' as shown below: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/src/AddIns/Misc/ShortcutsManagement/ShortcutsManagement/Properties/Resources.Designer.cs b/src/AddIns/Misc/ShortcutsManagement/ShortcutsManagement/Properties/Resources.Designer.cs new file mode 100644 index 0000000000..04cdec7e18 --- /dev/null +++ b/src/AddIns/Misc/ShortcutsManagement/ShortcutsManagement/Properties/Resources.Designer.cs @@ -0,0 +1,63 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Runtime Version:2.0.50727.3082 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace ICSharpCode.ShortcutsManagement.Properties { + using System; + + + /// + /// A strongly-typed resource class, for looking up localized strings, etc. + /// + // This class was auto-generated by the StronglyTypedResourceBuilder + // class via a tool like ResGen or Visual Studio. + // To add or remove a member, edit your .ResX file then rerun ResGen + // with the /str option, or rebuild your VS project. + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "2.0.0.0")] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + internal class Resources { + + private static global::System.Resources.ResourceManager resourceMan; + + private static global::System.Globalization.CultureInfo resourceCulture; + + [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] + internal Resources() { + } + + /// + /// Returns the cached ResourceManager instance used by this class. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Resources.ResourceManager ResourceManager { + get { + if (object.ReferenceEquals(resourceMan, null)) { + global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("ICSharpCode.ShortcutsManagement.Properties.Resources", typeof(Resources).Assembly); + resourceMan = temp; + } + return resourceMan; + } + } + + /// + /// Overrides the current thread's CurrentUICulture property for all + /// resource lookups using this strongly typed resource class. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Globalization.CultureInfo Culture { + get { + return resourceCulture; + } + set { + resourceCulture = value; + } + } + } +} diff --git a/src/AddIns/Misc/ShortcutsManagement/ShortcutsManagement/Properties/Resources.resx b/src/AddIns/Misc/ShortcutsManagement/ShortcutsManagement/Properties/Resources.resx new file mode 100644 index 0000000000..af7dbebbac --- /dev/null +++ b/src/AddIns/Misc/ShortcutsManagement/ShortcutsManagement/Properties/Resources.resx @@ -0,0 +1,117 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/src/AddIns/Misc/ShortcutsManagement/ShortcutsManagement/Properties/Settings.Designer.cs b/src/AddIns/Misc/ShortcutsManagement/ShortcutsManagement/Properties/Settings.Designer.cs new file mode 100644 index 0000000000..f2395b7165 --- /dev/null +++ b/src/AddIns/Misc/ShortcutsManagement/ShortcutsManagement/Properties/Settings.Designer.cs @@ -0,0 +1,26 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Runtime Version:2.0.50727.3082 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace ICSharpCode.ShortcutsManagement.Properties { + + + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "9.0.0.0")] + internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase { + + private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); + + public static Settings Default { + get { + return defaultInstance; + } + } + } +} diff --git a/src/AddIns/Misc/ShortcutsManagement/ShortcutsManagement/Properties/Settings.settings b/src/AddIns/Misc/ShortcutsManagement/ShortcutsManagement/Properties/Settings.settings new file mode 100644 index 0000000000..033d7a5e9e --- /dev/null +++ b/src/AddIns/Misc/ShortcutsManagement/ShortcutsManagement/Properties/Settings.settings @@ -0,0 +1,7 @@ + + + + + + + \ No newline at end of file diff --git a/src/AddIns/Misc/ShortcutsManagement/ShortcutsManagement/Resources/key_enter.png b/src/AddIns/Misc/ShortcutsManagement/ShortcutsManagement/Resources/key_enter.png new file mode 100644 index 0000000000..0182ca646e Binary files /dev/null and b/src/AddIns/Misc/ShortcutsManagement/ShortcutsManagement/Resources/key_enter.png differ diff --git a/src/AddIns/Misc/ShortcutsManagement/ShortcutsManagement/Resources/key_enter_pressed.png b/src/AddIns/Misc/ShortcutsManagement/ShortcutsManagement/Resources/key_enter_pressed.png new file mode 100644 index 0000000000..a3ced2f3eb Binary files /dev/null and b/src/AddIns/Misc/ShortcutsManagement/ShortcutsManagement/Resources/key_enter_pressed.png differ diff --git a/src/AddIns/Misc/ShortcutsManagement/ShortcutsManagement/ShortcutsManagement.addin b/src/AddIns/Misc/ShortcutsManagement/ShortcutsManagement/ShortcutsManagement.addin new file mode 100644 index 0000000000..926b5fdc90 --- /dev/null +++ b/src/AddIns/Misc/ShortcutsManagement/ShortcutsManagement/ShortcutsManagement.addin @@ -0,0 +1,19 @@ + + + + + + + + + + + + + + diff --git a/src/AddIns/Misc/ShortcutsManagement/ShortcutsManagement/ShortcutsManagement.csproj b/src/AddIns/Misc/ShortcutsManagement/ShortcutsManagement/ShortcutsManagement.csproj new file mode 100644 index 0000000000..c4b85c436d --- /dev/null +++ b/src/AddIns/Misc/ShortcutsManagement/ShortcutsManagement/ShortcutsManagement.csproj @@ -0,0 +1,156 @@ + + + + Debug + AnyCPU + 9.0.30729 + 2.0 + {CF2FF1D1-A5FE-4848-936A-E2DFBE154562} + WinExe + Properties + ICSharpCode.ShortcutsManagement + ICSharpCode.ShortcutsManagement + v3.5 + 512 + {60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} + 4 + + + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + true + ..\..\..\..\..\AddIns\AddIns\Misc\ShortcutsManagement\ + DEBUG;TRACE + full + AnyCPU + true + GlobalSuppressions.cs + prompt + + + + False + ..\..\..\..\..\bin\ICSharpCode.Core.dll + + + False + ..\..\..\..\..\bin\ICSharpCode.SharpDevelop.dll + + + + 3.5 + + + 3.5 + + + 3.5 + + + + + 3.0 + + + 3.0 + + + 3.0 + + + 3.0 + + + + + MSBuild:Compile + Designer + + + MSBuild:Compile + Designer + + + MSBuild:Compile + Designer + + + MSBuild:Compile + Designer + + + App.xaml + Code + + + Window1.xaml + Code + + + + + + + Code + + + True + True + Resources.resx + + + True + Settings.settings + True + + + + + ShortcutsManagementOptionsPanel.xaml + + + + + + + + ResXFileCodeGenerator + Resources.Designer.cs + + + SettingsSingleFileGenerator + Settings.Designer.cs + + + + + + + + Always + + + + + \ No newline at end of file diff --git a/src/AddIns/Misc/ShortcutsManagement/ShortcutsManagement/ShortcutsManagement.csproj.user b/src/AddIns/Misc/ShortcutsManagement/ShortcutsManagement/ShortcutsManagement.csproj.user new file mode 100644 index 0000000000..fa85230431 --- /dev/null +++ b/src/AddIns/Misc/ShortcutsManagement/ShortcutsManagement/ShortcutsManagement.csproj.user @@ -0,0 +1,6 @@ + + + Program + C:\VSC\SharpDevelop40\SharpDevelop\bin\SharpDevelop.exe + + \ No newline at end of file diff --git a/src/AddIns/Misc/ShortcutsManagement/ShortcutsManagement/Src/Converters/GesturesListConverter.cs b/src/AddIns/Misc/ShortcutsManagement/ShortcutsManagement/Src/Converters/GesturesListConverter.cs new file mode 100644 index 0000000000..0137209f1c --- /dev/null +++ b/src/AddIns/Misc/ShortcutsManagement/ShortcutsManagement/Src/Converters/GesturesListConverter.cs @@ -0,0 +1,27 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Globalization; +using System.Windows.Data; + +namespace ICSharpCode.ShortcutsManagement +{ + public class GesturesListConverter : IValueConverter + { + public object Convert(object value, Type targetType, object parameter, CultureInfo culture) + { + if (value is IEnumerable && (targetType == typeof(string) || targetType.IsSubclassOf(typeof(string)))) + { + var enumerableValue = (IEnumerable)value; + return string.Join(" | ", enumerableValue.ToArray()); + } + + return value.ToString(); + } + + public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) + { + throw new NotImplementedException("Reverse convertion is not implemented:"); + } + } +} diff --git a/src/AddIns/Misc/ShortcutsManagement/ShortcutsManagement/Src/Converters/ShortcutsTreeConverter.cs b/src/AddIns/Misc/ShortcutsManagement/ShortcutsManagement/Src/Converters/ShortcutsTreeConverter.cs new file mode 100644 index 0000000000..3255d1466f --- /dev/null +++ b/src/AddIns/Misc/ShortcutsManagement/ShortcutsManagement/Src/Converters/ShortcutsTreeConverter.cs @@ -0,0 +1,25 @@ +using System; +using System.Collections.Generic; +using System.Globalization; +using System.Linq; +using System.Windows.Data; + +namespace ICSharpCode.ShortcutsManagement +{ + public class ShortcutsTreeConverter : IMultiValueConverter + { + public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture) + { + var items = new List(); + items.AddRange(((IEnumerable)values[0]).Cast()); + items.AddRange(((IEnumerable)values[1]).Cast()); + + return items; + } + + public object[] ConvertBack(object value, Type[] targetTypes, object parameter, CultureInfo culture) + { + throw new System.NotImplementedException(); + } + } +} diff --git a/src/AddIns/Misc/ShortcutsManagement/ShortcutsManagement/Src/Converters/TypeNameConverter.cs b/src/AddIns/Misc/ShortcutsManagement/ShortcutsManagement/Src/Converters/TypeNameConverter.cs new file mode 100644 index 0000000000..eba1046599 --- /dev/null +++ b/src/AddIns/Misc/ShortcutsManagement/ShortcutsManagement/Src/Converters/TypeNameConverter.cs @@ -0,0 +1,19 @@ +using System; +using System.Globalization; +using System.Windows.Data; + +namespace ICSharpCode.ShortcutsManagement +{ + class TypeNameConverter : IValueConverter + { + public object Convert(object value, Type targetType, object parameter, CultureInfo culture) + { + return value.GetType().Name; + } + + public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) + { + throw new System.NotImplementedException(); + } + } +} diff --git a/src/AddIns/Misc/ShortcutsManagement/ShortcutsManagement/Src/Data/AddIn.cs b/src/AddIns/Misc/ShortcutsManagement/ShortcutsManagement/Src/Data/AddIn.cs new file mode 100644 index 0000000000..a4fa2d85b2 --- /dev/null +++ b/src/AddIns/Misc/ShortcutsManagement/ShortcutsManagement/Src/Data/AddIn.cs @@ -0,0 +1,84 @@ +using System.Collections.Generic; +using System.ComponentModel; + +namespace ICSharpCode.ShortcutsManagement +{ + /// + /// Add-in where shortcuts were registered + /// + public class AddIn : INotifyPropertyChanged + { + private string name; + + /// + /// Add-in name + /// + /// Dependency property + /// + public string Name + { + get + { + return name; + } + set + { + if (name != value) + { + name = value; + InvokePropertyChanged("Name"); + } + } + } + + private bool isVisible; + + /// + /// Is category visible in shortcuts tree + /// + /// Dependency property + /// + public bool IsVisible + { + get + { + return isVisible; + } + set + { + if (isVisible != value) + { + isVisible = value; + InvokePropertyChanged("IsVisible"); + } + } + } + + public List Categories + { + get; + private set; + } + + public AddIn(string addInName) + { + IsVisible = true; + Name = addInName; + Categories = new List(); + } + + /// + /// Invoke dependency property changed event + /// + /// Name of dependency property from this classs + private void InvokePropertyChanged(string propertyName) + { + if (PropertyChanged != null) + { + PropertyChanged(this, new PropertyChangedEventArgs(propertyName)); + } + } + + public event PropertyChangedEventHandler PropertyChanged; + } +} diff --git a/src/AddIns/Misc/ShortcutsManagement/ShortcutsManagement/Src/Data/Shortcut.cs b/src/AddIns/Misc/ShortcutsManagement/ShortcutsManagement/Src/Data/Shortcut.cs new file mode 100644 index 0000000000..91278bd297 --- /dev/null +++ b/src/AddIns/Misc/ShortcutsManagement/ShortcutsManagement/Src/Data/Shortcut.cs @@ -0,0 +1,90 @@ +using System.Collections.Generic; +using System.ComponentModel; + +namespace ICSharpCode.ShortcutsManagement +{ + /// + /// Shortcut + /// + public class Shortcut : INotifyPropertyChanged + { + /// + /// List of keyboard gestures which will invoke provided action + /// + public List Gestures + { + get; + private set; + } + + private string name; + + /// + /// Shortcut action name + /// + public string Name + { + get + { + return name; + } + set + { + if(name != value) + { + name = value; + InvokePropertyChanged("Name"); + } + } + } + + private bool isVisible; + + /// + /// Is category visible in shortcuts tree + /// + /// Dependency property + /// + public bool IsVisible + { + get + { + return isVisible; + } + set + { + if(isVisible != value) + { + isVisible = value; + InvokePropertyChanged("IsVisible"); + } + } + } + + /// + /// Create new shortcut + /// + /// Shortcut action name + /// Gestures + public Shortcut(string shortcutName, List gestures) + { + IsVisible = true; + Name = shortcutName; + Gestures = gestures ?? new List(); + } + + public event PropertyChangedEventHandler PropertyChanged; + + /// + /// Invoke dependency property changed event + /// + /// Name of dependency property from this classs + private void InvokePropertyChanged(string propertyName) + { + if (PropertyChanged != null) + { + PropertyChanged(this, new PropertyChangedEventArgs(propertyName)); + } + } + } +} diff --git a/src/AddIns/Misc/ShortcutsManagement/ShortcutsManagement/Src/Data/ShortcutCategory.cs b/src/AddIns/Misc/ShortcutsManagement/ShortcutsManagement/Src/Data/ShortcutCategory.cs new file mode 100644 index 0000000000..8c1a6e14e5 --- /dev/null +++ b/src/AddIns/Misc/ShortcutsManagement/ShortcutsManagement/Src/Data/ShortcutCategory.cs @@ -0,0 +1,101 @@ +using System.Collections.Generic; +using System.ComponentModel; + +namespace ICSharpCode.ShortcutsManagement +{ + /// + /// Shortcut category + /// + public class ShortcutCategory : INotifyPropertyChanged + { + private string name; + + /// + /// Category name + /// + /// Dependency property + /// + public string Name + { + get + { + return name; + } + set + { + if (name != value) + { + name = value; + InvokePropertyChanged("Name"); + } + } + } + + private bool isVisible; + + /// + /// Is category visible in shortcuts tree + /// + /// Dependency property + /// + public bool IsVisible + { + get + { + return isVisible; + } + set + { + if (isVisible != value) + { + isVisible = value; + InvokePropertyChanged("IsVisible"); + } + } + } + + /// + /// Sub cateories + /// + public List SubCategories + { + get; + private set; + } + + /// + /// Shortcuts assigned to this category + /// + public List Shortcuts + { + get; + private set; + } + + /// + /// Create new category + /// + /// Category name + public ShortcutCategory(string categoryName) + { + IsVisible = true; + Shortcuts = new List(); + SubCategories = new List(); + Name = categoryName; + } + + /// + /// Invoke dependency property changed event + /// + /// Name of dependency property from this classs + private void InvokePropertyChanged(string propertyName) + { + if (PropertyChanged != null) + { + PropertyChanged(this, new PropertyChangedEventArgs(propertyName)); + } + } + + public event PropertyChangedEventHandler PropertyChanged; + } +} diff --git a/src/AddIns/Misc/ShortcutsManagement/ShortcutsManagement/Src/Data/ShortcutsProvider.cs b/src/AddIns/Misc/ShortcutsManagement/ShortcutsManagement/Src/Data/ShortcutsProvider.cs new file mode 100644 index 0000000000..c66c65ff1e --- /dev/null +++ b/src/AddIns/Misc/ShortcutsManagement/ShortcutsManagement/Src/Data/ShortcutsProvider.cs @@ -0,0 +1,116 @@ +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; + +namespace ICSharpCode.ShortcutsManagement +{ + internal class ShortcutsProvider + { + private readonly ObservableCollection addins = new ObservableCollection(); + + /// + /// Get list of add-ins containing shortcuts + /// + /// List of add-ins + public ObservableCollection GetAddIns() + { + return addins; + } + + /// + /// Filter addins, child categories and shortcuts where item name + /// contains filter string + /// + /// Filter string + public void Filter(string filterString) + { + foreach (var addIn in addins) + { + var addInNameContainsFilterString = addIn.Name.IndexOf(filterString, StringComparison.InvariantCultureIgnoreCase) >= 0; + + var subCategoryIsVisible = false; + foreach (var category in addIn.Categories) + { + if(Filter(category, filterString, addInNameContainsFilterString ? (bool?) true : null)) + { + subCategoryIsVisible = true; + } + } + + addIn.IsVisible = addInNameContainsFilterString || subCategoryIsVisible; + } + } + + /// + /// Filter category and child elements where item name contains + /// filter string + /// + /// Category to filter + /// Filter string + /// If set to true all sub elements are expanded + /// + private static bool Filter(ShortcutCategory category, string filterString, bool? forseMatch) + { + if(category.Name.IndexOf(filterString, StringComparison.InvariantCultureIgnoreCase) >= 0) + { + forseMatch = true; + } + + var isSubElementVisible = false; + foreach (var subCategory in category.SubCategories) + { + if(Filter(subCategory, filterString, forseMatch)) + { + isSubElementVisible = true; + } + } + + foreach (var shortcut in category.Shortcuts) + { + if ((forseMatch.HasValue && forseMatch.Value) || shortcut.Name.IndexOf(filterString, StringComparison.InvariantCultureIgnoreCase) >= 0) + { + shortcut.IsVisible = true; + isSubElementVisible = true; + } + else + { + shortcut.IsVisible = false; + } + } + + return category.IsVisible = (forseMatch.HasValue && forseMatch.Value) || isSubElementVisible; + } + + public ShortcutsProvider() + { + // Test data + addins.Add(new AddIn("SharpDevelop")); + addins[0].Categories.Add(new ShortcutCategory("Editing")); + addins[0].Categories[0].Shortcuts.Add(new Shortcut("Copy", new List { "Ctrl+C" })); + addins[0].Categories[0].Shortcuts.Add(new Shortcut("Paste", new List { "Ctrl+V", "Ctrl+Insert" })); + addins[0].Categories[0].Shortcuts.Add(new Shortcut("Cut", new List { "Ctrl+X" })); + addins[0].Categories[0].Shortcuts.Add(new Shortcut("Undo", new List { "Ctrl+Z" })); + addins[0].Categories[0].Shortcuts.Add(new Shortcut("Redo", new List { "Ctrl+Y" })); + addins[0].Categories.Add(new ShortcutCategory("Building")); + addins[0].Categories[1].Shortcuts.Add(new Shortcut("Build", new List { "Ctrl+Shift+B" })); + addins[0].Categories[1].Shortcuts.Add(new Shortcut("Run", new List { "F5" })); + addins[0].Categories[1].Shortcuts.Add(new Shortcut("Run without debuger", new List { "Ctrl+F5" })); + addins[0].Categories[1].Shortcuts.Add(new Shortcut("Attach debuger", new List { "Ctrl+F8" })); + addins[0].Categories.Add(new ShortcutCategory("Uncategorized")); + addins[0].Categories[2].Shortcuts.Add(new Shortcut("Attach debuger", new List { "Ctrl+F8" })); + + + addins.Add(new AddIn("Search & replace")); + addins[1].Categories.Add(new ShortcutCategory("Uncategorized")); + addins[1].Categories[0].Shortcuts.Add(new Shortcut("Quick find", new List { "Ctrl+F" })); + addins[1].Categories[0].Shortcuts.Add(new Shortcut("Quick replace", new List { "Ctrl+H" })); + addins[1].Categories[0].Shortcuts.Add(new Shortcut("Find in files", new List { "Ctrl+Shift+F" })); + addins[1].Categories[0].Shortcuts.Add(new Shortcut("Replace in files", new List { "Ctrl+Shift+H" })); + addins[1].Categories[0].Shortcuts.Add(new Shortcut("Find symbol", null)); + + addins.Add(new AddIn("Unspecified")); + addins[2].Categories.Add(new ShortcutCategory("Uncategorized")); + addins[2].Categories[0].Shortcuts.Add(new Shortcut("Test regex expression", null)); + } + } +} diff --git a/src/AddIns/Misc/ShortcutsManagement/ShortcutsManagement/Src/Dialogs/ShortcutsManagementOptionsPanel.xaml b/src/AddIns/Misc/ShortcutsManagement/ShortcutsManagement/Src/Dialogs/ShortcutsManagementOptionsPanel.xaml new file mode 100644 index 0000000000..a421114824 --- /dev/null +++ b/src/AddIns/Misc/ShortcutsManagement/ShortcutsManagement/Src/Dialogs/ShortcutsManagementOptionsPanel.xaml @@ -0,0 +1,171 @@ + + + + + + + + + ..\..\Resources\key_enter.png + ..\..\Resources\key_enter_pressed.png + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/AddIns/Misc/ShortcutsManagement/ShortcutsManagement/Src/Dialogs/ShortcutsManagementOptionsPanel.xaml.cs b/src/AddIns/Misc/ShortcutsManagement/ShortcutsManagement/Src/Dialogs/ShortcutsManagementOptionsPanel.xaml.cs new file mode 100644 index 0000000000..fe19e3ed2b --- /dev/null +++ b/src/AddIns/Misc/ShortcutsManagement/ShortcutsManagement/Src/Dialogs/ShortcutsManagementOptionsPanel.xaml.cs @@ -0,0 +1,84 @@ +using System.Collections.Generic; +using System.Linq; +using System.Windows; +using System.Windows.Controls; +using System.Windows.Input; +using ICSharpCode.SharpDevelop; + +namespace ICSharpCode.ShortcutsManagement +{ + /// + /// This panel is used in SharpDevelop options window to manage shortcuts + /// + public partial class ShortcutsManagementOptionsPanel : UserControl, IOptionPanel + { + public ShortcutsManagementOptionsPanel() + { + InitializeComponent(); + + } + + private void shortcutEntry_MouseDown(object sender, MouseButtonEventArgs e) + { + if (e.ChangedButton == MouseButton.Left && e.ClickCount == 2) + { + MessageBox.Show("Changing shortcut"); + } + } + + /// + /// Filter shortcuts tree view. Display only matching shortcuts + /// + /// + /// + private void searchTextBox_KeyUp(object sender, KeyEventArgs e) + { + var receiver = ((ShortcutsProvider) Resources["ShortcutsReceiver"]); + receiver.Filter(searchTextBox.Text); + + if (!string.IsNullOrEmpty(searchTextBox.Text)) + { + // Select first visible shortcut + var selectedAddIn = receiver.GetAddIns().FirstOrDefault(a => a.IsVisible); + if (selectedAddIn != null) + { + var selectedCategory = selectedAddIn.Categories.FirstOrDefault(c => c.IsVisible); + if (selectedCategory != null) + { + var selectedShortcut = selectedCategory.Shortcuts.FirstOrDefault(s => s.IsVisible); + if (selectedShortcut != null) + { + shortcutsTreeView.SelectItem(new List { selectedAddIn, selectedCategory, selectedShortcut }); + } + } + } + } + else + { + shortcutsTreeView.SetExpandAll(false); + } + } + + public void LoadOptions() + { + } + + public bool SaveOptions() + { + return true; + } + + public object Owner + { + get; set; + } + + public object Control + { + get + { + return this; + } + } + } +} diff --git a/src/AddIns/Misc/ShortcutsManagement/ShortcutsManagement/Src/Extensions/TextBlockBehavior.cs b/src/AddIns/Misc/ShortcutsManagement/ShortcutsManagement/Src/Extensions/TextBlockBehavior.cs new file mode 100644 index 0000000000..44f68e3e86 --- /dev/null +++ b/src/AddIns/Misc/ShortcutsManagement/ShortcutsManagement/Src/Extensions/TextBlockBehavior.cs @@ -0,0 +1,83 @@ +using System.Text.RegularExpressions; +using System.Windows; +using System.Windows.Controls; +using System.Windows.Documents; + +namespace ICSharpCode.ShortcutsManagement +{ + /// + /// TextBlockBehavior.SearchedText attached property + /// + public static class TextBlockBehavior + { + /// + /// Get attached property value + /// + /// Attached property host + /// Attached property value + public static string GetSearchedText(TextBlock textBlock) + { + return (string)textBlock.GetValue(SearchedTextProperty); + } + + /// + /// Set attached property value + /// + /// Attached property host + /// New attached property value + public static void SetSearchedText(TextBlock textBlock, string value) + { + textBlock.SetValue(SearchedTextProperty, value); + } + + public static readonly DependencyProperty SearchedTextProperty = + DependencyProperty.RegisterAttached( + "SearchedText", + typeof(string), + typeof(TextBlockBehavior), + new UIPropertyMetadata(null, OnSearchedTextChanged)); + + /// + /// On SearchedText changed highlight text in TextBlock which matches + /// attached property value + /// + /// + /// + private static void OnSearchedTextChanged(DependencyObject depObj, DependencyPropertyChangedEventArgs e) + { + var textBlock = (TextBlock) depObj; + + var textBlockText = textBlock.Text; + textBlock.Inlines.Clear(); + + var matches = Regex.Matches(textBlockText, @"(.*)(" + Regex.Escape((string)e.NewValue) + @")(.*)", RegexOptions.IgnoreCase); + if (matches.Count > 0) + { + foreach (Match match in matches) + { + var matchedTextPrefix = match.Groups[1].Value; + if (!string.IsNullOrEmpty(matchedTextPrefix)) + { + textBlock.Inlines.Add(new Run(matchedTextPrefix)); + } + + var matchedText = match.Groups[2].Value; + if (!string.IsNullOrEmpty(matchedText)) + { + textBlock.Inlines.Add(new Bold(new Run(matchedText))); + } + + var matchedTextSuffix = match.Groups[3].Value; + if (!string.IsNullOrEmpty(matchedTextSuffix)) + { + textBlock.Inlines.Add(new Run(matchedTextSuffix)); + } + } + } + else + { + textBlock.Inlines.Add(new Run(textBlockText)); + } + } + } +} diff --git a/src/AddIns/Misc/ShortcutsManagement/ShortcutsManagement/Src/Extensions/TreeViewExtensions.cs b/src/AddIns/Misc/ShortcutsManagement/ShortcutsManagement/Src/Extensions/TreeViewExtensions.cs new file mode 100644 index 0000000000..5b0de181a2 --- /dev/null +++ b/src/AddIns/Misc/ShortcutsManagement/ShortcutsManagement/Src/Extensions/TreeViewExtensions.cs @@ -0,0 +1,80 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Reflection; +using System.Windows.Controls; +using System.Windows.Controls.Primitives; + +namespace ICSharpCode.ShortcutsManagement +{ + /// + /// TreeView extention methods + /// + public static class TreeViewExtensions + { + /// + /// Expand TreeView items according to provided path and select element + /// on the lowest level + /// + /// TreeView or TreeViewItem + /// Path to the selected item + public static void SelectItem(this ItemsControl parentContainer, List path) + { + var head = path.First(); + var tail = path.GetRange(1, path.Count - 1); + var itemContainer = parentContainer.ItemContainerGenerator.ContainerFromItem(head) as TreeViewItem; + + if (itemContainer != null && itemContainer.Items.Count == 0) + { + itemContainer.IsSelected = true; + + var selectMethod = typeof(TreeViewItem).GetMethod("Select", BindingFlags.NonPublic | BindingFlags.Instance); + selectMethod.Invoke(itemContainer, new object[] { true }); + } + else if (itemContainer != null) + { + itemContainer.IsExpanded = true; + + if (itemContainer.ItemContainerGenerator.Status != GeneratorStatus.ContainersGenerated) + { + itemContainer.ItemContainerGenerator.StatusChanged += delegate + { + SelectItem(itemContainer, tail); + }; + } + else + { + SelectItem(itemContainer, tail); + } + } + } + + /// + /// Expand/Collapse all tree view items + /// + /// TreeView or TreeViewItem + /// True - expand, False - collapse + public static void SetExpandAll(this ItemsControl parentContainer, bool value) + { + foreach (Object item in parentContainer.Items) + { + var currentContainer = parentContainer.ItemContainerGenerator.ContainerFromItem(item) as TreeViewItem; + if (currentContainer != null && currentContainer.Items.Count > 0) + { + currentContainer.IsExpanded = value; + if (currentContainer.ItemContainerGenerator.Status != GeneratorStatus.ContainersGenerated) + { + currentContainer.ItemContainerGenerator.StatusChanged += delegate + { + SetExpandAll(currentContainer, value); + }; + } + else + { + SetExpandAll(currentContainer, value); + } + } + } + } + } +} diff --git a/src/AddIns/Misc/ShortcutsManagement/ShortcutsManagement/Themes/Generic.xaml b/src/AddIns/Misc/ShortcutsManagement/ShortcutsManagement/Themes/Generic.xaml new file mode 100644 index 0000000000..8e69621a35 --- /dev/null +++ b/src/AddIns/Misc/ShortcutsManagement/ShortcutsManagement/Themes/Generic.xaml @@ -0,0 +1,5 @@ + + + diff --git a/src/AddIns/Misc/ShortcutsManagement/ShortcutsManagement/Window1.xaml b/src/AddIns/Misc/ShortcutsManagement/ShortcutsManagement/Window1.xaml new file mode 100644 index 0000000000..2625553e4c --- /dev/null +++ b/src/AddIns/Misc/ShortcutsManagement/ShortcutsManagement/Window1.xaml @@ -0,0 +1,10 @@ + + + + + + diff --git a/src/AddIns/Misc/ShortcutsManagement/ShortcutsManagement/Window1.xaml.cs b/src/AddIns/Misc/ShortcutsManagement/ShortcutsManagement/Window1.xaml.cs new file mode 100644 index 0000000000..2a8c63544a --- /dev/null +++ b/src/AddIns/Misc/ShortcutsManagement/ShortcutsManagement/Window1.xaml.cs @@ -0,0 +1,15 @@ +using System.Windows; + +namespace ICSharpCode.ShortcutsManagement +{ + /// + /// Interaction logic for Window1.xaml + /// + public partial class Window1 : Window + { + public Window1() + { + InitializeComponent(); + } + } +} diff --git a/src/AddIns/Misc/ShortcutsManagement/ShortcutsManagementAddin.suo b/src/AddIns/Misc/ShortcutsManagement/ShortcutsManagementAddin.suo new file mode 100644 index 0000000000..00b633d582 Binary files /dev/null and b/src/AddIns/Misc/ShortcutsManagement/ShortcutsManagementAddin.suo differ