refactor disable_webpage_commander

This commit is contained in:
Kang Yu 2024-08-17 12:49:39 -07:00
parent 697e79b1ba
commit 0a6c00c3a7
2 changed files with 7 additions and 8 deletions

View file

@ -21,6 +21,7 @@ namespace PersistentWindows.SystrayShell
public static System.Drawing.Icon BusyIcon = null;
public static System.Drawing.Icon UpdateIcon = null;
public static string AppdataFolder = null;
public static string DisableWebpageCommander = null;
public static string CmdArgs;
public static bool Gui = true;
public static bool hotkey_window = true;
@ -283,6 +284,8 @@ namespace PersistentWindows.SystrayShell
if (!Directory.Exists(appDataFolder))
Directory.CreateDirectory(appDataFolder);
DisableWebpageCommander = Path.Combine(AppdataFolder, "disable_webpage_commander");
// default icons
var iconHandle = (legacy_icon ? Properties.Resources.pwIcon2: Properties.Resources.pwIcon).GetHicon();
IdleIcon = System.Drawing.Icon.FromHandle(iconHandle);
@ -380,8 +383,7 @@ namespace PersistentWindows.SystrayShell
if (ignore_process.Length > 0)
pwp.SetIgnoreProcess(ignore_process);
string disable_webpage_commander= Path.Combine(Program.AppdataFolder, "disable_webpage_commander");
if (!File.Exists(disable_webpage_commander) && hotkey_window)
if (!File.Exists(DisableWebpageCommander) && hotkey_window)
HotKeyForm.Start(hotkey);
if (!pwp.Start(auto_restore_from_db_at_startup))

View file

@ -53,8 +53,7 @@ namespace PersistentWindows.SystrayShell
else
upgradeNoticeMenuItem.Text = "Enable upgrade notice";
string disable_webpage_commander= Path.Combine(Program.AppdataFolder, "disable_webpage_commander");
if (File.Exists(disable_webpage_commander))
if (File.Exists(Program.DisableWebpageCommander))
{
invokeWebCommander.Text = "Enable webpage commander";
}
@ -357,13 +356,11 @@ namespace PersistentWindows.SystrayShell
private void WebCommander(object sender, EventArgs e)
{
string disable_webpage_commander= Path.Combine(Program.AppdataFolder, "disable_webpage_commander");
if ((User32.GetKeyState(0x11) & 0x8000) != 0)
HotKeyForm.InvokeFromMenu();
else if (this.invokeWebCommander.Text.Contains("Disable"))
{
File.Create(disable_webpage_commander);
File.Create(Program.DisableWebpageCommander);
this.invokeWebCommander.Text = "Enable webpage commander";
HotKeyForm.Stop();
}
@ -371,7 +368,7 @@ namespace PersistentWindows.SystrayShell
{
try
{
File.Delete(disable_webpage_commander);
File.Delete(Program.DisableWebpageCommander);
}
catch (Exception ex)
{