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.

This commit is contained in:
mika-n 2020-01-11 23:27:33 +02:00
parent 2b25e55611
commit 3a482eca13
5 changed files with 76 additions and 3 deletions

View File

@ -152,10 +152,16 @@
</GridViewColumn.CellTemplate> </GridViewColumn.CellTemplate>
</GridViewColumn> </GridViewColumn>
<GridViewColumn Header="{lex:Loc Path}" Width="600" DisplayMemberBinding="{Binding Path}"/> <GridViewColumn Header="{lex:Loc Path}" Width="600" DisplayMemberBinding="{Binding Path}"/>
<GridViewColumn Header="Window Title" Width="Auto" DisplayMemberBinding="{Binding Title}"/> <GridViewColumn Header="{lex:Loc WindowTitle}" Width="Auto" DisplayMemberBinding="{Binding Title}"/>
</GridView> </GridView>
</ListView.View> </ListView.View>
</ListView> <ListView.ContextMenu>
<ContextMenu>
<MenuItem Header="{lex:Loc MoveUp}" Name="MoveUp" Click="MoveUpDownAutoBtn_Click"/>
<MenuItem Header="{lex:Loc MoveDown}" Name="MoveDown" Click="MoveUpDownAutoBtn_Click"/>
</ContextMenu>
</ListView.ContextMenu>
</ListView>
</DockPanel> </DockPanel>
</DockPanel> </DockPanel>
</UserControl> </UserControl>

View File

@ -277,5 +277,14 @@ namespace DS4WinWPF.DS4Forms
this.IsEnabled = true; 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");
}
}
} }
} }

View File

@ -326,6 +326,28 @@ namespace DS4WinWPF.DS4Forms.ViewModels
return result; 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 public class ProgramItem

View File

@ -375,6 +375,24 @@ namespace DS4WinWPF.Translations {
} }
} }
/// <summary>
/// Looks up a localized string similar to Move Down.
/// </summary>
public static string MoveDown {
get {
return ResourceManager.GetString("MoveDown", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Move Up.
/// </summary>
public static string MoveUp {
get {
return ResourceManager.GetString("MoveUp", resourceCulture);
}
}
/// <summary> /// <summary>
/// Looks up a localized string similar to Name. /// Looks up a localized string similar to Name.
/// </summary> /// </summary>
@ -644,5 +662,14 @@ namespace DS4WinWPF.Translations {
return ResourceManager.GetString("WarningsOnly", resourceCulture); return ResourceManager.GetString("WarningsOnly", resourceCulture);
} }
} }
/// <summary>
/// Looks up a localized string similar to Window Title.
/// </summary>
public static string WindowTitle {
get {
return ResourceManager.GetString("WindowTitle", resourceCulture);
}
}
} }
} }

View File

@ -312,4 +312,13 @@
<data name="RumbleMaxSecsTip" xml:space="preserve"> <data name="RumbleMaxSecsTip" xml:space="preserve">
<value>Auto stop rumble in secs (0=auto stop disabled)</value> <value>Auto stop rumble in secs (0=auto stop disabled)</value>
</data> </data>
<data name="WindowTitle" xml:space="preserve">
<value>Window Title</value>
</data>
<data name="MoveUp" xml:space="preserve">
<value>Move Up</value>
</data>
<data name="MoveDown" xml:space="preserve">
<value>Move Down</value>
</data>
</root> </root>