added custom context menu for listbox/listview
This commit is contained in:
parent
623a8acdf7
commit
277541a20c
7 changed files with 136 additions and 3 deletions
|
@ -16,7 +16,7 @@ namespace WeeXnes.Core
|
|||
public static string encryptionKey = "8zf5#RdyQ]$4x4_";
|
||||
public static string AppDataPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "WeeXnes");
|
||||
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_RpcAutoStart;
|
||||
public static string apiUrl = "https://api.github.com/repos/weexnes/weexnessuite/releases/latest";
|
||||
|
|
|
@ -41,7 +41,35 @@
|
|||
Name="RpcItemList"
|
||||
Foreground="White"
|
||||
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>
|
||||
|
||||
|
||||
|
|
|
@ -228,6 +228,11 @@ namespace WeeXnes.MVVM.View
|
|||
Games.Add(game);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Games.Clear();
|
||||
}
|
||||
|
||||
}
|
||||
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)
|
||||
{
|
||||
if (RpcItemList.SelectedItem != null)
|
||||
{
|
||||
deleteGameFile((Game)RpcItemList.SelectedItem);
|
||||
}
|
||||
clearInputs();
|
||||
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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -38,6 +38,33 @@
|
|||
BorderThickness="0"
|
||||
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>
|
||||
<DataTemplate>
|
||||
<Grid>
|
||||
|
|
|
@ -249,6 +249,35 @@ namespace WeeXnes.MVVM.View
|
|||
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
|
||||
{
|
||||
|
|
|
@ -270,6 +270,26 @@
|
|||
|
||||
|
||||
<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">
|
||||
<Setter Property="RenderOptions.BitmapScalingMode" Value="HighQuality" />
|
||||
</Style>
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
<Version>3.7.0</Version>
|
||||
<Version>3.7.1</Version>
|
||||
<ProjectGuid>{4B33CEE7-C74D-43B9-B99A-8B273D5195BC}</ProjectGuid>
|
||||
<OutputType>WinExe</OutputType>
|
||||
<RootNamespace>WeeXnes</RootNamespace>
|
||||
|
|
Loading…
Add table
Reference in a new issue