From 3a482eca1309411305b1631bebede0b95e6f1aba Mon Sep 17 00:00:00 2001 From: mika-n Date: Sat, 11 Jan 2020 23:27:33 +0200 Subject: [PATCH 1/2] MoveUp and MoveDown context menu (right mouse button) in AutoProfiler list view to move items up or down. If there are wildchars in path or wndTitle search keywords then the order of auto-profile rules is significant. Now it is possible to modify the order of rules through the GUI and not just by editing AutoProfiles.xml file via text editor. --- DS4Windows/DS4Forms/AutoProfiles.xaml | 10 +++++-- DS4Windows/DS4Forms/AutoProfiles.xaml.cs | 11 +++++++- .../ViewModels/AutoProfilesViewModel.cs | 22 +++++++++++++++ DS4Windows/Translations/Strings.Designer.cs | 27 +++++++++++++++++++ DS4Windows/Translations/Strings.resx | 9 +++++++ 5 files changed, 76 insertions(+), 3 deletions(-) diff --git a/DS4Windows/DS4Forms/AutoProfiles.xaml b/DS4Windows/DS4Forms/AutoProfiles.xaml index 6fc2e90..e53996f 100644 --- a/DS4Windows/DS4Forms/AutoProfiles.xaml +++ b/DS4Windows/DS4Forms/AutoProfiles.xaml @@ -152,10 +152,16 @@ - + - + + + + + + + diff --git a/DS4Windows/DS4Forms/AutoProfiles.xaml.cs b/DS4Windows/DS4Forms/AutoProfiles.xaml.cs index bd99a40..6aa8134 100644 --- a/DS4Windows/DS4Forms/AutoProfiles.xaml.cs +++ b/DS4Windows/DS4Forms/AutoProfiles.xaml.cs @@ -66,7 +66,7 @@ namespace DS4WinWPF.DS4Forms autoProfVM = new AutoProfilesViewModel(autoProfileHolder, profileList); programListLV.DataContext = autoProfVM; programListLV.ItemsSource = autoProfVM.ProgramColl; - + revertDefaultProfileOnUnknownCk.DataContext = autoProfVM; autoProfVM.SearchFinished += AutoProfVM_SearchFinished; @@ -277,5 +277,14 @@ namespace DS4WinWPF.DS4Forms this.IsEnabled = true; } } + + private void MoveUpDownAutoBtn_Click(object sender, RoutedEventArgs e) + { + if (autoProfVM.SelectedItem != null && sender != null) + { + if(autoProfVM.MoveItemUpDown(autoProfVM.SelectedItem, ((sender as MenuItem).Name == "MoveUp") ? -1 : 1)) + autoProfVM.AutoProfileHolder.Save(DS4Windows.Global.appdatapath + @"\Auto Profiles.xml"); + } + } } } diff --git a/DS4Windows/DS4Forms/ViewModels/AutoProfilesViewModel.cs b/DS4Windows/DS4Forms/ViewModels/AutoProfilesViewModel.cs index c9107c4..b64376b 100644 --- a/DS4Windows/DS4Forms/ViewModels/AutoProfilesViewModel.cs +++ b/DS4Windows/DS4Forms/ViewModels/AutoProfilesViewModel.cs @@ -326,6 +326,28 @@ namespace DS4WinWPF.DS4Forms.ViewModels return result; } + + public bool MoveItemUpDown(ProgramItem item, int moveDirection) + { + // Move autoprofile item up (-1) or down (1) both in listView (programColl) and in autoProfileHolder data structure (will be written into AutoProfiles.xml file) + bool itemMoved = true; + int oldIdx = programColl.IndexOf(item); + + if (moveDirection == -1 && oldIdx > 0 && oldIdx < autoProfileHolder.AutoProfileColl.Count) + { + programColl.Move(oldIdx, oldIdx - 1); + autoProfileHolder.AutoProfileColl.Move(oldIdx, oldIdx - 1); + } + else if (moveDirection == 1 && oldIdx >= 0 && oldIdx < programColl.Count - 1 && oldIdx < autoProfileHolder.AutoProfileColl.Count - 1) + { + programColl.Move(oldIdx, oldIdx + 1); + autoProfileHolder.AutoProfileColl.Move(oldIdx, oldIdx + 1); + } + else + itemMoved = false; + + return itemMoved; + } } public class ProgramItem diff --git a/DS4Windows/Translations/Strings.Designer.cs b/DS4Windows/Translations/Strings.Designer.cs index ab4fc7e..986a1f8 100644 --- a/DS4Windows/Translations/Strings.Designer.cs +++ b/DS4Windows/Translations/Strings.Designer.cs @@ -375,6 +375,24 @@ namespace DS4WinWPF.Translations { } } + /// + /// Looks up a localized string similar to Move Down. + /// + public static string MoveDown { + get { + return ResourceManager.GetString("MoveDown", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Move Up. + /// + public static string MoveUp { + get { + return ResourceManager.GetString("MoveUp", resourceCulture); + } + } + /// /// Looks up a localized string similar to Name. /// @@ -644,5 +662,14 @@ namespace DS4WinWPF.Translations { return ResourceManager.GetString("WarningsOnly", resourceCulture); } } + + /// + /// Looks up a localized string similar to Window Title. + /// + public static string WindowTitle { + get { + return ResourceManager.GetString("WindowTitle", resourceCulture); + } + } } } diff --git a/DS4Windows/Translations/Strings.resx b/DS4Windows/Translations/Strings.resx index 907d910..b14a989 100644 --- a/DS4Windows/Translations/Strings.resx +++ b/DS4Windows/Translations/Strings.resx @@ -312,4 +312,13 @@ Auto stop rumble in secs (0=auto stop disabled) + + Window Title + + + Move Up + + + Move Down + \ No newline at end of file From 208687e3951589210d8b0a1fe49c9deeca8cd42c Mon Sep 17 00:00:00 2001 From: mika-n Date: Mon, 13 Jan 2020 13:29:46 +0200 Subject: [PATCH 2/2] Added tooltip to auto-profile path and title editbox fields --- DS4Windows/DS4Forms/AutoProfiles.xaml | 4 ++-- DS4Windows/Translations/Strings.Designer.cs | 18 ++++++++++++++++++ DS4Windows/Translations/Strings.resx | 6 ++++++ 3 files changed, 26 insertions(+), 2 deletions(-) diff --git a/DS4Windows/DS4Forms/AutoProfiles.xaml b/DS4Windows/DS4Forms/AutoProfiles.xaml index e53996f..6ca166c 100644 --- a/DS4Windows/DS4Forms/AutoProfiles.xaml +++ b/DS4Windows/DS4Forms/AutoProfiles.xaml @@ -116,8 +116,8 @@ - - + + diff --git a/DS4Windows/Translations/Strings.Designer.cs b/DS4Windows/Translations/Strings.Designer.cs index 986a1f8..37be829 100644 --- a/DS4Windows/Translations/Strings.Designer.cs +++ b/DS4Windows/Translations/Strings.Designer.cs @@ -132,6 +132,24 @@ namespace DS4WinWPF.Translations { } } + /// + /// Looks up a localized string similar to Process path. ^ABC = Match at the beginning of string (^) | ABC$ = Match at the end of string ($) | *ABC =Contains a string (*). + /// + public static string AutoProfPathTip { + get { + return ResourceManager.GetString("AutoProfPathTip", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Window title. ^ABC = Match at the beginning of string (^) | ABC$ = Match at the end of string ($) | *ABC =Contains a string (*). + /// + public static string AutoProfTitleTip { + get { + return ResourceManager.GetString("AutoProfTitleTip", resourceCulture); + } + } + /// /// Looks up a localized string similar to Battery. /// diff --git a/DS4Windows/Translations/Strings.resx b/DS4Windows/Translations/Strings.resx index b14a989..6186cb8 100644 --- a/DS4Windows/Translations/Strings.resx +++ b/DS4Windows/Translations/Strings.resx @@ -321,4 +321,10 @@ Move Down + + Process path. ^ABC = Match at the beginning of string (^) | ABC$ = Match at the end of string ($) | *ABC =Contains a string (*) + + + Window title. ^ABC = Match at the beginning of string (^) | ABC$ = Match at the end of string ($) | *ABC =Contains a string (*) + \ No newline at end of file