Browse Source

Fixed profiles bugs and bug in new gesture window when first chord had to be full even it's function key

git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/branches/shortcuts@4423 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61
shortcuts^2
Sergej Andrejev 16 years ago
parent
commit
dcb940d77d
  1. 2
      AddIns/ICSharpCode.SharpDevelop.addin
  2. 9
      SharpDevelop.Tests.sln
  3. 2
      src/AddIns/Misc/ShortcutsManagement/ShortcutsManagement/Src/Dialogs/MultiKeyGestureTextBox.xaml.cs
  4. 4
      src/AddIns/Misc/ShortcutsManagement/ShortcutsManagement/Src/Dialogs/ShortcutManagementWindow.xaml.cs
  5. 76
      src/AddIns/Misc/ShortcutsManagement/ShortcutsManagement/Src/Dialogs/ShortcutsManagementOptionsPanel.xaml.cs
  6. 9
      src/Main/ICSharpCode.Core.Presentation/CommandsService/UserDefinedGesturesManager.cs
  7. 31
      src/Main/ICSharpCode.Core.Presentation/Input/PartialKeyGesture.cs
  8. 36
      src/Main/ICSharpCode.Core.Presentation/Test/ICSharpCode.Core.Presentation.Tests.csproj
  9. 23
      src/Main/ICSharpCode.Core.Presentation/Test/InputGestureTests.cs
  10. 85
      src/Main/ICSharpCode.Core.Presentation/Test/UserDefinedGestureProfileTests.cs

2
AddIns/ICSharpCode.SharpDevelop.addin

@ -152,7 +152,7 @@ @@ -152,7 +152,7 @@
<CommandBinding
command="SDBuildCommands.BuildSolution"
class="ICSharpCode.SharpDevelop.Project.Commands.Build"
gestures="Ctrl+Alt+R,R;Ctrl+B,B"
gestures="F8"
categories="/Building"
/>
<CommandBinding

9
SharpDevelop.Tests.sln

@ -1,7 +1,7 @@ @@ -1,7 +1,7 @@

Microsoft Visual Studio Solution File, Format Version 11.00
# Visual Studio 10
# SharpDevelop 4.0.0.4289
# SharpDevelop 4.0.0.4395
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Main", "Main", "{256F5C28-532C-44C0-8AB8-D8EC5E492E01}"
ProjectSection(SolutionItems) = postProject
EndProjectSection
@ -58,6 +58,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "StartUp", "src\Main\StartUp @@ -58,6 +58,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "StartUp", "src\Main\StartUp
{35CEF10F-2D4C-45F2-9DD1-161E0FEC583C} = {35CEF10F-2D4C-45F2-9DD1-161E0FEC583C}
EndProjectSection
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ICSharpCode.Core.Presentation.Tests", "src\Main\ICSharpCode.Core.Presentation\Test\ICSharpCode.Core.Presentation.Tests.csproj", "{FFA7988E-7348-4669-9E9D-27E629C873A2}"
EndProject
Project("{00000000-0000-0000-0000-000000000000}") = "Tools", "src\Tools\Tools.build", "{3DF4060F-5EE0-41CF-8096-F27355FD5511}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Libraries", "Libraries", "{2A232EF1-EB95-41C6-B63A-C106E0C95D3C}"
@ -751,11 +753,16 @@ Global @@ -751,11 +753,16 @@ Global
{DDE2A481-8271-4EAC-A330-8FA6A38D13D1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{DDE2A481-8271-4EAC-A330-8FA6A38D13D1}.Release|Any CPU.Build.0 = Release|Any CPU
{DDE2A481-8271-4EAC-A330-8FA6A38D13D1}.Release|Any CPU.ActiveCfg = Release|Any CPU
{FFA7988E-7348-4669-9E9D-27E629C873A2}.Debug|Any CPU.Build.0 = Debug|Any CPU
{FFA7988E-7348-4669-9E9D-27E629C873A2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{FFA7988E-7348-4669-9E9D-27E629C873A2}.Release|Any CPU.Build.0 = Release|Any CPU
{FFA7988E-7348-4669-9E9D-27E629C873A2}.Release|Any CPU.ActiveCfg = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(NestedProjects) = preSolution
{FFA7988E-7348-4669-9E9D-27E629C873A2} = {256F5C28-532C-44C0-8AB8-D8EC5E492E01}
{1152B71B-3C05-4598-B20D-823B5D40559E} = {256F5C28-532C-44C0-8AB8-D8EC5E492E01}
{8035765F-D51F-4A0C-A746-2FD100E19419} = {256F5C28-532C-44C0-8AB8-D8EC5E492E01}
{2748AD25-9C63-4E12-877B-4DCE96FBED54} = {256F5C28-532C-44C0-8AB8-D8EC5E492E01}

2
src/AddIns/Misc/ShortcutsManagement/ShortcutsManagement/Src/Dialogs/MultiKeyGestureTextBox.xaml.cs

@ -291,7 +291,7 @@ namespace ICSharpCode.ShortcutsManagement.Dialogs @@ -291,7 +291,7 @@ namespace ICSharpCode.ShortcutsManagement.Dialogs
Clear();
}
if (enteredKeyGestureSequence[0].Modifiers == ModifierKeys.None)
if (!enteredKeyGestureSequence[0].IsFull)
{
DisplayNotification(StringParser.Parse("${res:ShortcutsManagement.GestureTextBox.FirstChordIsIncomplete}"), NotificationType.Invalid);
}

4
src/AddIns/Misc/ShortcutsManagement/ShortcutsManagement/Src/Dialogs/ShortcutManagementWindow.xaml.cs

@ -116,9 +116,9 @@ namespace ICSharpCode.ShortcutsManagement.Dialogs @@ -116,9 +116,9 @@ namespace ICSharpCode.ShortcutsManagement.Dialogs
return;
}
// Check whether first chord is finished
// Check whether first chord is unfinished
var partialKeyGesture = gestureTextBox.Gesture as PartialKeyGesture;
if (partialKeyGesture != null && partialKeyGesture.Modifiers == ModifierKeys.None) {
if (partialKeyGesture != null && !partialKeyGesture.IsFull) {
DisplayNotification(StringParser.Parse("${res:ShortcutsManagement.ModificationWindow.AdditionFailedFirstChordIsIncomplete}"), NotificationType.Failed);
return;
}

76
src/AddIns/Misc/ShortcutsManagement/ShortcutsManagement/Src/Dialogs/ShortcutsManagementOptionsPanel.xaml.cs

@ -85,12 +85,13 @@ namespace ICSharpCode.ShortcutsManagement.Dialogs @@ -85,12 +85,13 @@ namespace ICSharpCode.ShortcutsManagement.Dialogs
if (UserDefinedGesturesManager.CurrentProfile != null && profile.Name == UserDefinedGesturesManager.CurrentProfile.Name)
{
profilesTextBox.SelectedItem = profile;
SelectedProfile = profile;
}
}
}
BindProfiles();
BindShortcuts();
}
private void BindProfiles()
@ -125,6 +126,20 @@ namespace ICSharpCode.ShortcutsManagement.Dialogs @@ -125,6 +126,20 @@ namespace ICSharpCode.ShortcutsManagement.Dialogs
profilesTextBoxItemsSource.Add(resetItem);
profilesTextBox.DataContext = profilesTextBoxItemsSource;
if (SelectedProfile != null)
{
if(profilesTextBox.SelectedItem != SelectedProfile) {
profilesTextBox.Text = SelectedProfile.Text;
profilesTextBox.SelectedItem = SelectedProfile;
}
}
else
{
profilesTextBox.SelectedIndex = -1;
profilesTextBox.Text = "";
}
}
private void BindShortcuts()
@ -195,7 +210,12 @@ namespace ICSharpCode.ShortcutsManagement.Dialogs @@ -195,7 +210,12 @@ namespace ICSharpCode.ShortcutsManagement.Dialogs
// Strip this sign from shortcut entry text
shortcutText = Regex.Replace(shortcutText, @"&([^\s])", @"$1");
var shortcut = new Shortcut(shortcutText, new InputGestureCollection(inputBindingInfo.ActiveGestures));
var shortcutGestures = new InputGestureCollection(inputBindingInfo.DefaultGestures);
if(SelectedProfile != null && SelectedProfile[inputBindingInfo.Identifier] != null) {
shortcutGestures = new InputGestureCollection(SelectedProfile[inputBindingInfo.Identifier]);
}
var shortcut = new Shortcut(shortcutText, shortcutGestures);
shortcutsMap.Add(shortcut, inputBindingInfo);
// Assign shortcut to all categories it is registered in
@ -266,23 +286,10 @@ namespace ICSharpCode.ShortcutsManagement.Dialogs @@ -266,23 +286,10 @@ namespace ICSharpCode.ShortcutsManagement.Dialogs
return;
}
if (!(e.AddedItems[0] is UserGesturesProfile))
{
if (e.RemovedItems != null && e.RemovedItems.Count > 0)
{
profilesTextBox.SelectedItem = e.RemovedItems[0];
}
else if (profilesTextBox.SelectedIndex >= 0)
{
profilesTextBox.SelectedIndex = -1;
profilesTextBox.Text = "";
}
}
var userGestureProfileAction = e.AddedItems[0] as UserGestureProfileAction;
if (userGestureProfileAction != null)
{
if (userGestureProfileAction.Name == "Delete" && e.RemovedItems != null && e.RemovedItems.Count > 0)
if (userGestureProfileAction.Name == "Delete" && SelectedProfile != null)
{
var result = MessageBox.Show(
StringParser.Parse("${res:ShortcutsManagement.ShortcutsManagementOptionsPanel.ConfirmDeleteProfileMessage}"),
@ -291,26 +298,20 @@ namespace ICSharpCode.ShortcutsManagement.Dialogs @@ -291,26 +298,20 @@ namespace ICSharpCode.ShortcutsManagement.Dialogs
if(MessageBoxResult.Yes == result)
{
var removedProfile = (UserGesturesProfile)e.RemovedItems[0];
profiles.Remove(removedProfile);
removedProfiles.Add(removedProfile);
profiles.Remove(SelectedProfile);
removedProfiles.Add(SelectedProfile);
SelectedProfile = null;
}
}
if (userGestureProfileAction.Name == "Rename" && e.RemovedItems != null && e.RemovedItems.Count > 0)
if (userGestureProfileAction.Name == "Rename" && SelectedProfile != null)
{
var renamedProfile = e.RemovedItems[0] as UserGesturesProfile;
if (renamedProfile != null)
{
var promptWindow = new CreateNewProfilePrompt();
promptWindow.BaseProfilesVisibility = Visibility.Collapsed;
promptWindow.Text = renamedProfile.Text;
promptWindow.ShowDialog();
var promptWindow = new CreateNewProfilePrompt();
promptWindow.BaseProfilesVisibility = Visibility.Collapsed;
promptWindow.Text = SelectedProfile.Text;
promptWindow.ShowDialog();
renamedProfile.Text = promptWindow.Text;
}
SelectedProfile.Text = promptWindow.Text;
}
if(userGestureProfileAction.Name == "Load")
@ -370,24 +371,13 @@ namespace ICSharpCode.ShortcutsManagement.Dialogs @@ -370,24 +371,13 @@ namespace ICSharpCode.ShortcutsManagement.Dialogs
}
var userGestureProfile = e.AddedItems[0] as UserGesturesProfile;
if (userGestureProfile != null)
if (userGestureProfile != null && userGestureProfile != SelectedProfile)
{
SelectedProfile = userGestureProfile;
}
if (SelectedProfile != null)
{
profilesTextBox.Text = SelectedProfile.Text;
profilesTextBox.SelectedItem = SelectedProfile;
}
else
{
profilesTextBox.SelectedIndex = -1;
profilesTextBox.Text = "";
}
BindShortcuts();
BindProfiles();
BindShortcuts();
}
private void shortcutsManagementOptionsPanel_ShortcutModified(object sender, EventArgs e)

9
src/Main/ICSharpCode.Core.Presentation/CommandsService/UserDefinedGesturesManager.cs

@ -15,9 +15,11 @@ namespace ICSharpCode.Core.Presentation @@ -15,9 +15,11 @@ namespace ICSharpCode.Core.Presentation
static UserDefinedGesturesManager()
{
_userGestureProfilesDirectory = Path.Combine(PropertyService.ConfigDirectory, "UserGestureProfiles");
if(!Directory.Exists(_userGestureProfilesDirectory)) {
Directory.CreateDirectory(_userGestureProfilesDirectory);
if(PropertyService.ConfigDirectory != null) {
_userGestureProfilesDirectory = Path.Combine(PropertyService.ConfigDirectory, "UserGestureProfiles");
if(!Directory.Exists(_userGestureProfilesDirectory)) {
Directory.CreateDirectory(_userGestureProfilesDirectory);
}
}
}
@ -56,6 +58,7 @@ namespace ICSharpCode.Core.Presentation @@ -56,6 +58,7 @@ namespace ICSharpCode.Core.Presentation
set {
_currentProfile = value;
PropertyService.Set("ICSharpCode.Core.Presentation.UserDefinedGesturesManager.UserGestureProfilesDirectory", CurrentProfile != null ? CurrentProfile.Path : null);
_isCurrentProfileLoaded = true;
}
}
}

31
src/Main/ICSharpCode.Core.Presentation/Input/PartialKeyGesture.cs

@ -107,7 +107,6 @@ namespace ICSharpCode.Core.Presentation @@ -107,7 +107,6 @@ namespace ICSharpCode.Core.Presentation
_modifiers = ModifierKeys.None;
}
/// <summary>
/// Create new instance of<see cref="PartialKeyGesture"/> having only key and no modifiers
/// </summary>
@ -192,6 +191,36 @@ namespace ICSharpCode.Core.Presentation @@ -192,6 +191,36 @@ namespace ICSharpCode.Core.Presentation
return modifierMatches && keyMatches;
}
public bool IsFull
{
get {
if(Key == Key.None) {
return false;
}
// and function keys are valid without modifier
if (Key >= Key.F1 && Key <= Key.F24) {
return true;
}
// Modifiers alone are not valid
if (Array.IndexOf(new[] { Key.LeftAlt, Key.RightAlt,
Key.LeftShift, Key.RightShift,
Key.LeftCtrl, Key.RightCtrl,
Key.LWin, Key.RWin,
Key.System}, Key) > -1) {
return false;
}
// All other gestures must have modifier (except shift alone because it would mean uppercase)
if((Modifiers & (ModifierKeys.Windows | ModifierKeys.Control | ModifierKeys.Alt)) != ModifierKeys.None) {
return true;
}
return false;
}
}
/// <summary>
/// Returns string that represents <see cref="PartialKeyGesture"/>

36
src/Main/ICSharpCode.Core.Presentation/Test/ICSharpCode.Core.Presentation.Tests.csproj

@ -1,22 +1,26 @@ @@ -1,22 +1,26 @@
<Project ToolsVersion="3.5" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" DefaultTargets="Build">
<PropertyGroup>
<ProjectGuid>{18FD5FC0-C57D-4A8F-8972-AC467B4FE83E}</ProjectGuid>
<ProjectGuid>{FFA7988E-7348-4669-9E9D-27E629C873A2}</ProjectGuid>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<OutputType>Library</OutputType>
<RootNamespace>ICSharpCode.Core.Presentation.Tests</RootNamespace>
<AssemblyName>ICSharpCode.Core.Presentation.Tests</AssemblyName>
<TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
<AppDesignerFolder>Properties</AppDesignerFolder>
<SourceAnalysisOverrideSettingsFile>C:\Documents and Settings\Administrator\Application Data\ICSharpCode/SharpDevelop3.0\Settings.SourceAnalysis</SourceAnalysisOverrideSettingsFile>
<AllowUnsafeBlocks>False</AllowUnsafeBlocks>
<NoStdLib>False</NoStdLib>
<WarningLevel>4</WarningLevel>
<TreatWarningsAsErrors>false</TreatWarningsAsErrors>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">
<OutputPath>bin\Debug\</OutputPath>
<DebugSymbols>True</DebugSymbols>
<DebugSymbols>true</DebugSymbols>
<DebugType>Full</DebugType>
<Optimize>False</Optimize>
<CheckForOverflowUnderflow>True</CheckForOverflowUnderflow>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<OutputPath>bin\</OutputPath>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)' == 'Release' ">
<OutputPath>bin\Release\</OutputPath>
@ -26,7 +30,13 @@ @@ -26,7 +30,13 @@
<CheckForOverflowUnderflow>False</CheckForOverflowUnderflow>
<DefineConstants>TRACE</DefineConstants>
</PropertyGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.Targets" />
<PropertyGroup Condition=" '$(Platform)' == 'AnyCPU' ">
<RegisterForComInterop>False</RegisterForComInterop>
<GenerateSerializationAssemblies>Auto</GenerateSerializationAssemblies>
<BaseAddress>4194304</BaseAddress>
<PlatformTarget>AnyCPU</PlatformTarget>
<FileAlignment>4096</FileAlignment>
</PropertyGroup>
<ItemGroup>
<Reference Include="nunit.framework">
<HintPath>..\..\..\Tools\NUnit\nunit.framework.dll</HintPath>
@ -34,23 +44,29 @@ @@ -34,23 +44,29 @@
<Reference Include="PresentationCore">
<RequiredTargetFramework>3.0</RequiredTargetFramework>
</Reference>
<Reference Include="PresentationFramework">
<RequiredTargetFramework>3.0</RequiredTargetFramework>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core">
<RequiredTargetFramework>3.5</RequiredTargetFramework>
</Reference>
<Reference Include="System.Xml" />
<Reference Include="System.Xml.Linq">
<RequiredTargetFramework>3.5</RequiredTargetFramework>
</Reference>
</ItemGroup>
<ItemGroup>
<Compile Include="InputGestureTests.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="UserDefinedGestureProfileTests.cs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\Core\Project\ICSharpCode.Core.csproj">
<Project>{35CEF10F-2D4C-45F2-9DD1-161E0FEC583C}</Project>
<Name>ICSharpCode.Core</Name>
</ProjectReference>
<ProjectReference Include="..\ICSharpCode.Core.Presentation.csproj">
<Project>{7E4A7172-7FF5-48D0-B719-7CD959DD1AC9}</Project>
<Name>ICSharpCode.Core.Presentation</Name>
</ProjectReference>
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.Targets" />
</Project>

23
src/Main/ICSharpCode.Core.Presentation/Test/InputGestureTests.cs

@ -125,7 +125,6 @@ namespace ICSharpCode.Core.Presentation.Tests @@ -125,7 +125,6 @@ namespace ICSharpCode.Core.Presentation.Tests
var template1 = (MultiKeyGesture)multiKeyGestureConverter.ConvertFromInvariantString("Ctrl+");
var original1 = (MultiKeyGesture)multiKeyGestureConverter.ConvertFromInvariantString("Ctrl+D");
Assert.IsTrue(template1.IsTemplateFor(original1, GestureCompareMode.StartsWith));
Assert.IsTrue(original1.IsTemplateFor(template1, GestureCompareMode.StartsWith));
var template2 = (MultiKeyGesture)multiKeyGestureConverter.ConvertFromInvariantString("Ctrl+C");
var original2 = (MultiKeyGesture)multiKeyGestureConverter.ConvertFromInvariantString("Ctrl+C,Ctrl+D");
@ -363,5 +362,27 @@ namespace ICSharpCode.Core.Presentation.Tests @@ -363,5 +362,27 @@ namespace ICSharpCode.Core.Presentation.Tests
Assert.IsFalse(template5.IsTemplateFor(original5, GestureCompareMode.Conflicting));
Assert.IsFalse(original5.IsTemplateFor(template5, GestureCompareMode.Conflicting));
}
[Test]
public void PartialGestureIsFullTest()
{
Assert.IsTrue(((PartialKeyGesture)new PartialKeyGestureConverter().ConvertFromInvariantString("Ctrl+A")).IsFull);
Assert.IsTrue(((PartialKeyGesture)new PartialKeyGestureConverter().ConvertFromInvariantString("Ctrl+Shift+A")).IsFull);
Assert.IsTrue(((PartialKeyGesture)new PartialKeyGestureConverter().ConvertFromInvariantString("F8")).IsFull);
Assert.IsFalse(((PartialKeyGesture)new PartialKeyGestureConverter().ConvertFromInvariantString("A")).IsFull);
Assert.IsFalse(((PartialKeyGesture)new PartialKeyGestureConverter().ConvertFromInvariantString("Ctrl+")).IsFull);
Assert.IsFalse(((PartialKeyGesture)new PartialKeyGestureConverter().ConvertFromInvariantString("Shift+A")).IsFull);
}
[Test]
public void IdentifierTest()
{
var sameBinding1 = new InputBindingInfo { OwnerTypeName="Binding", RoutedCommandName="Binding" };
var sameBinding2 = new InputBindingInfo { OwnerTypeName="Binding", RoutedCommandName="Binding" };
var sameBinding3 = new InputBindingInfo { OwnerTypeName="Binding3", RoutedCommandName="Binding" };
Assert.AreEqual(sameBinding1.Identifier, sameBinding2.Identifier);
Assert.AreNotEqual(sameBinding1.Identifier, sameBinding3.Identifier);
}
}
}

85
src/Main/ICSharpCode.Core.Presentation/Test/UserDefinedGestureProfileTests.cs

@ -0,0 +1,85 @@ @@ -0,0 +1,85 @@
/*
* Created by SharpDevelop.
* User: Administrator
* Date: 7/10/2009
* Time: 11:19 AM
*
* To change this template use Tools | Options | Coding | Edit Standard Headers.
*/
using System;
using System.Windows.Input;
using ICSharpCode.Core;
using ICSharpCode.Core.Presentation;
using NUnit.Framework;
namespace ICSharpCode.Core.Presentation.Tests
{
[TestFixture]
public class UserDefinedGestureProfileTests
{
UserGesturesProfile profile = null;
InputBindingInfo binding = null;
KeyGesture gesture = null;
[TestFixtureSetUp]
public void SetUpFixture()
{
PropertyService.InitializeServiceForUnitTests();
}
[SetUp]
public void SetuUp()
{
UserDefinedGesturesManager.CurrentProfile = null;
profile = new UserGesturesProfile();
gesture = (KeyGesture)new KeyGestureConverter().ConvertFromInvariantString("Ctrl+A");
binding = new InputBindingInfo { OwnerTypeName="Binding", RoutedCommandName="Binding" };
}
[Test]
public void NoProfileTest()
{
binding.DefaultGestures.Add(gesture);
Assert.AreEqual(1, binding.DefaultGestures.Count);
Assert.AreEqual(gesture, binding.DefaultGestures[0]);
Assert.AreEqual(1, binding.ActiveGestures.Count);
Assert.AreEqual(gesture, binding.ActiveGestures[0]);
}
[Test]
public void ActiveProfileTest()
{
binding.DefaultGestures.Add(gesture);
var userDefinedGestures = (InputGestureCollection)new InputGestureCollectionConverter().ConvertFromInvariantString("Ctrl+B;Ctrl+C");
profile[binding.Identifier] = userDefinedGestures;
UserDefinedGesturesManager.CurrentProfile = profile;
// Default gestures stay the same
Assert.AreEqual(1, binding.DefaultGestures.Count);
Assert.AreEqual(gesture, binding.DefaultGestures[0]);
// Only active gestures are modified
Assert.AreEqual(2, binding.ActiveGestures.Count);
Assert.AreEqual(userDefinedGestures[0], binding.ActiveGestures[0]);
Assert.AreEqual(userDefinedGestures[1], binding.ActiveGestures[1]);
}
[Test]
public void NoGestureInActiveProfileTest()
{
var binding2 = new InputBindingInfo { OwnerTypeName="Binding2", RoutedCommandName="Binding2" };
binding2.DefaultGestures.Add(gesture);
var userDefinedGestures = (InputGestureCollection)new InputGestureCollectionConverter().ConvertFromInvariantString("Ctrl+B;Ctrl+C");
profile[binding.Identifier] = userDefinedGestures;
UserDefinedGesturesManager.CurrentProfile = profile;
// Default gestures are used because current profile doesn't contain modifications to this gesture
Assert.AreEqual(1, binding2.ActiveGestures.Count);
Assert.AreEqual(binding2.DefaultGestures[0], binding2.ActiveGestures[0]);
}
}
}
Loading…
Cancel
Save