added custom context menu for listbox/listview

This commit is contained in:
WeeXnes 2022-11-15 10:50:16 +01:00
parent 623a8acdf7
commit 277541a20c
7 changed files with 136 additions and 3 deletions

View file

@ -16,7 +16,7 @@ namespace WeeXnes.Core
public static string encryptionKey = "8zf5#RdyQ]$4x4_"; public static string encryptionKey = "8zf5#RdyQ]$4x4_";
public static string AppDataPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "WeeXnes"); public static string AppDataPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "WeeXnes");
public static string SettingsFileName = "settings.ini"; public static string SettingsFileName = "settings.ini";
public static string version = "3.7.0"; public static string version = "3.7.1";
public static bool info_isRpcRunning = false; public static bool info_isRpcRunning = false;
public static bool info_RpcAutoStart; public static bool info_RpcAutoStart;
public static string apiUrl = "https://api.github.com/repos/weexnes/weexnessuite/releases/latest"; public static string apiUrl = "https://api.github.com/repos/weexnes/weexnessuite/releases/latest";

View file

@ -41,7 +41,35 @@
Name="RpcItemList" Name="RpcItemList"
Foreground="White" Foreground="White"
SelectionChanged="RpcItemList_SelectionChanged" SelectionChanged="RpcItemList_SelectionChanged"
MouseDoubleClick="RpcItemList_MouseDoubleClick"/> MouseDoubleClick="RpcItemList_MouseDoubleClick">
<ListBox.ContextMenu>
<ContextMenu>
<ContextMenu.Template>
<ControlTemplate>
<Grid>
<Border CornerRadius="4" Padding="2">
<Border.Background>
<LinearGradientBrush StartPoint="0.5 0" EndPoint="0.5 1">
<LinearGradientBrush.GradientStops>
<GradientStop Offset="0.2" Color="#7924b3" />
<GradientStop Offset="1" Color="#247cb3" />
</LinearGradientBrush.GradientStops>
</LinearGradientBrush>
</Border.Background>
<Border CornerRadius="4" Background="#2f313b">
<StackPanel Orientation="Vertical">
<MenuItem Foreground="DarkGray" Header="Delete"
Click="MenuItem_OnClick" />
</StackPanel>
</Border>
</Border>
</Grid>
</ControlTemplate>
</ContextMenu.Template>
</ContextMenu>
</ListBox.ContextMenu>
</ListBox>
</Border> </Border>

View file

@ -228,6 +228,11 @@ namespace WeeXnes.MVVM.View
Games.Add(game); Games.Add(game);
} }
} }
else
{
Games.Clear();
}
} }
public void LoadGamesIntoListBox() public void LoadGamesIntoListBox()
{ {
@ -258,12 +263,26 @@ namespace WeeXnes.MVVM.View
} }
} }
private void clearInputs()
{
tb_FormClient.Text = "";
tb_FormDetails.Text = "";
tb_FormName.Text = "";
tb_FormState.Text = "";
tb_FormPName.Text = "";
tb_FormLargeImgKey.Text = "";
tb_FormLargeImgTxt.Text = "";
tb_FormSmallImgKey.Text = "";
tb_FormSmallImgTxt.Text = "";
}
private void RpcItemList_MouseDoubleClick(object sender, MouseButtonEventArgs e) private void RpcItemList_MouseDoubleClick(object sender, MouseButtonEventArgs e)
{ {
if (RpcItemList.SelectedItem != null) if (RpcItemList.SelectedItem != null)
{ {
deleteGameFile((Game)RpcItemList.SelectedItem); deleteGameFile((Game)RpcItemList.SelectedItem);
} }
clearInputs();
Refresh(); Refresh();
} }
@ -315,6 +334,16 @@ namespace WeeXnes.MVVM.View
{ {
} }
private void MenuItem_OnClick(object sender, RoutedEventArgs e)
{
if (RpcItemList.SelectedItem != null)
{
deleteGameFile((Game)RpcItemList.SelectedItem);
}
clearInputs();
Refresh();
}
} }
} }

View file

@ -38,6 +38,33 @@
BorderThickness="0" BorderThickness="0"
SelectionChanged="KeyListView_SelectionChanged" MouseDoubleClick="KeyListView_MouseDoubleClick" SelectionChanged="KeyListView_SelectionChanged" MouseDoubleClick="KeyListView_MouseDoubleClick"
> >
<ListView.ContextMenu>
<ContextMenu>
<ContextMenu.Template>
<ControlTemplate>
<Grid>
<Border CornerRadius="4" Padding="2">
<Border.Background>
<LinearGradientBrush StartPoint="0.5 0" EndPoint="0.5 1">
<LinearGradientBrush.GradientStops>
<GradientStop Offset="0.2" Color="#7924b3" />
<GradientStop Offset="1" Color="#247cb3" />
</LinearGradientBrush.GradientStops>
</LinearGradientBrush>
</Border.Background>
<Border CornerRadius="4" Background="#2f313b">
<StackPanel Orientation="Vertical">
<MenuItem Foreground="DarkGray" Header="Delete"
Click="MenuItem_OnClick" />
</StackPanel>
</Border>
</Border>
</Grid>
</ControlTemplate>
</ContextMenu.Template>
</ContextMenu>
</ListView.ContextMenu>
<ListView.ItemTemplate> <ListView.ItemTemplate>
<DataTemplate> <DataTemplate>
<Grid> <Grid>

View file

@ -249,6 +249,35 @@ namespace WeeXnes.MVVM.View
tb.Text = censored_string; tb.Text = censored_string;
} }
} }
private void MenuItem_OnClick(object sender, RoutedEventArgs e)
{
KeyItem selectedItem = (KeyItem)KeyListView.SelectedItem;
Console.WriteLine("Doubleclicked " + selectedItem.name);
KeyManagerLib.KeyList.Remove(selectedItem);
string[] files = SaveInterface.GetFilesInDir(Globals.settings_KeyManagerItemsPath.Value);
foreach (string file in files)
{
Console.WriteLine(file);
try
{
wxfile inifile = new wxfile(file);
string name = inifile.GetName();
string value = inifile.GetValue();
if(name == selectedItem.name)
{
File.Delete(file);
Console.WriteLine("Removed File: " + file);
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
FillList();
}
} }
public static class SaveInterface public static class SaveInterface
{ {

View file

@ -270,6 +270,26 @@
<Window.Resources> <Window.Resources>
<ContextMenu x:Key="TrayCustomMenu"
Placement="MousePoint">
<Grid>
<Border CornerRadius="4" Padding="2">
<Border.Background>
<LinearGradientBrush StartPoint="0.5 0" EndPoint="0.5 1">
<LinearGradientBrush.GradientStops>
<GradientStop Offset="0.2" Color="#7924b3" />
<GradientStop Offset="1" Color="#247cb3" />
</LinearGradientBrush.GradientStops>
</LinearGradientBrush>
</Border.Background>
<Border CornerRadius="4" Background="#2f313b">
<StackPanel Orientation="Vertical">
<MenuItem Foreground="DarkGray" Header="Exit"/>
</StackPanel>
</Border>
</Border>
</Grid>
</ContextMenu>
<Style TargetType="Image"> <Style TargetType="Image">
<Setter Property="RenderOptions.BitmapScalingMode" Value="HighQuality" /> <Setter Property="RenderOptions.BitmapScalingMode" Value="HighQuality" />
</Style> </Style>

View file

@ -4,7 +4,7 @@
<PropertyGroup> <PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<Version>3.7.0</Version> <Version>3.7.1</Version>
<ProjectGuid>{4B33CEE7-C74D-43B9-B99A-8B273D5195BC}</ProjectGuid> <ProjectGuid>{4B33CEE7-C74D-43B9-B99A-8B273D5195BC}</ProjectGuid>
<OutputType>WinExe</OutputType> <OutputType>WinExe</OutputType>
<RootNamespace>WeeXnes</RootNamespace> <RootNamespace>WeeXnes</RootNamespace>