Skip to content

Commit 3b57356

Browse files
author
xujinkai
committed
添加Debug按钮
1 parent e59415e commit 3b57356

3 files changed

Lines changed: 23 additions & 2 deletions

File tree

ShellCommand/MainWindow.xaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,9 @@
4141

4242
<Grid Grid.Row="1" Margin="20">
4343
<StackPanel>
44+
<StackPanel Orientation="Horizontal" Visibility="{Binding DEBUG}">
45+
<Button Click="TestGlobalMenu">Test GlobalMenu</Button>
46+
</StackPanel>
4447
<wpf:Link Content="Open App Setting Folder" Click="OpenAppSettingFolder"></wpf:Link>
4548
<wpf:Link Content="Edit Global Setting File" Click="EditGlobalSettingFile"></wpf:Link>
4649
<Label></Label>

ShellCommand/MainWindow.xaml.cs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
using ShellCommand.DataModel;
2+
using ShellCommand.MenuDefinition;
23
using System;
34
using System.Collections.Generic;
45
using System.IO;
@@ -26,9 +27,16 @@ public partial class MainWindow : Window
2627
const string ARG_INSTALL = "--install";
2728
const string ARG_UNINSTALL = "--uninstall";
2829

30+
#if DEBUG
31+
public Visibility DEBUG => Visibility.Visible;
32+
#else
33+
public Visibility DEBUG => Visibility.Collapsed;
34+
#endif
35+
2936
public MainWindow()
3037
{
3138
InitializeComponent();
39+
this.DataContext = this;
3240
if(Environment.Is64BitOperatingSystem != Environment.Is64BitProcess)
3341
{
3442
MessageBox.Show($"Please run x64 version instead.");
@@ -110,5 +118,10 @@ private void EditGlobalSettingFile(object sender, RoutedEventArgs e)
110118
var configpath = System.IO.Path.Combine(XJK.ENV.BaseDirectory, Env.GlobalSettingFileName);
111119
Cmd.RunAsInvoker(configpath, "");
112120
}
121+
122+
private void TestGlobalMenu(object sender, RoutedEventArgs e)
123+
{
124+
DirectoryBackgroundContextMenu.CreateMenu(Env.GetAppFolder(), "").Show(XJK.SysX.Device.Mouse.GetPosition());
125+
}
113126
}
114127
}

ShellCommand/MenuDefinition/DirectoryBackgroundContextMenu.cs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,19 +28,24 @@ protected override bool CanShowMenu()
2828
}
2929

3030
protected override ContextMenuStrip CreateMenu()
31+
{
32+
return CreateMenu(FolderPath, CommandFilePath);
33+
}
34+
35+
internal static ContextMenuStrip CreateMenu(string workingDir, string CommandFilePath)
3136
{
3237
var menu = new ContextMenuStrip();
3338
var container = new ToolStripMenuItem(Env.MenuDisplay);
3439

3540
var list = new List<ToolStripItem>();
3641

37-
MenuItemsBuilder.ParseDirectoryCommandInto(list, CommandFilePath, FolderPath);
42+
MenuItemsBuilder.ParseDirectoryCommandInto(list, CommandFilePath, workingDir);
3843
MenuItemsBuilder.AddSeparator(list);
3944

4045
var globalSettingPath = Path.Combine(Env.GetAppFolder(), Env.GlobalSettingFileName);
4146
if (File.Exists(globalSettingPath))
4247
{
43-
MenuItemsBuilder.ParseGlobalCommandInto(list, globalSettingPath, FolderPath);
48+
MenuItemsBuilder.ParseGlobalCommandInto(list, globalSettingPath, workingDir);
4449
}
4550

4651
list.Add(BuildinMenuItems.OpenApp());

0 commit comments

Comments
 (0)