[BUG] Default do a restart if any other instance is running (#320), version 1.2.6.0

This commit is contained in:
Markus Hofknecht 2022-02-07 16:41:30 +01:00
parent b32f8aaffd
commit 021d1b2d85
24 changed files with 112 additions and 45 deletions

View file

@ -18,21 +18,13 @@ namespace SystemTrayMenu
{
try
{
bool killOtherInstances = true;
bool isArgumentSetToRestart = args != null && args.Length > 0 && args[0] == "-r";
if (!isArgumentSetToRestart)
{
args = null;
killOtherInstances = false;
}
Log.Initialize();
Translator.Initialize();
Config.SetFolderByWindowsContextMenu(args);
Config.LoadOrSetByUser();
Config.Initialize();
if (SingleAppInstance.Initialize(killOtherInstances))
if (SingleAppInstance.Initialize())
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);

View file

@ -10,7 +10,7 @@
<Identity
Name="49543SystemTrayMenu.SystemTrayMenu"
Publisher="CN=5884501C-92ED-45DE-9508-9D987C314243"
Version="1.2.5.0" />
Version="1.2.6.0" />
<Properties>
<DisplayName>SystemTrayMenu</DisplayName>

View file

@ -39,5 +39,5 @@ using System.Runtime.InteropServices;
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.2.5.0")]
[assembly: AssemblyFileVersion("1.2.5.0")]
[assembly: AssemblyVersion("1.2.6.0")]
[assembly: AssemblyFileVersion("1.2.6.0")]

View file

@ -155,6 +155,22 @@ namespace SystemTrayMenu.Properties
}
}
[global::System.Configuration.UserScopedSettingAttribute()]
[global::System.Configuration.SettingsProviderAttribute(typeof(CustomSettingsProvider))]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Configuration.DefaultSettingValueAttribute("False")]
public bool SendHotkeyInsteadKillOtherInstances
{
get
{
return ((bool)(this["SendHotkeyInsteadKillOtherInstances"]));
}
set
{
this["SendHotkeyInsteadKillOtherInstances"] = value;
}
}
[global::System.Configuration.UserScopedSettingAttribute()]
[global::System.Configuration.SettingsProviderAttribute(typeof(CustomSettingsProvider))]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]

View file

@ -862,6 +862,15 @@ namespace SystemTrayMenu.Resources {
}
}
/// <summary>
/// Looks up a localized string similar to Send hotkey to other instance.
/// </summary>
internal static string Send_hotkey_to_other_instance {
get {
return ResourceManager.GetString("Send hotkey to other instance", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Set as SystemTrayMenu folder.
/// </summary>

View file

@ -465,4 +465,7 @@
<data name="Fading" xml:space="preserve">
<value>Blednutí</value>
</data>
<data name="Send hotkey to other instance" xml:space="preserve">
<value>Odeslat klávesovou zkratku do jiné instance</value>
</data>
</root>

View file

@ -465,4 +465,7 @@
<data name="Fading" xml:space="preserve">
<value>Fading</value>
</data>
<data name="Send hotkey to other instance" xml:space="preserve">
<value>Hotkey an andere Instanz senden</value>
</data>
</root>

View file

@ -465,4 +465,7 @@
<data name="Fading" xml:space="preserve">
<value>Desvanecimiento</value>
</data>
<data name="Send hotkey to other instance" xml:space="preserve">
<value>Enviar tecla de acceso directo a otra instancia</value>
</data>
</root>

View file

@ -465,4 +465,7 @@
<data name="Fading" xml:space="preserve">
<value>محو شدن</value>
</data>
<data name="Send hotkey to other instance" xml:space="preserve">
<value>کلید میانبر را به نمونه دیگر ارسال کنید</value>
</data>
</root>

View file

@ -465,4 +465,7 @@
<data name="Fading" xml:space="preserve">
<value>Décoloration</value>
</data>
<data name="Send hotkey to other instance" xml:space="preserve">
<value>Envoyer le raccourci vers une autre instance</value>
</data>
</root>

View file

@ -465,4 +465,7 @@
<data name="Fading" xml:space="preserve">
<value>Dissolvenza</value>
</data>
<data name="Send hotkey to other instance" xml:space="preserve">
<value>Invia tasto di scelta rapida ad un'altra istanza</value>
</data>
</root>

View file

@ -465,4 +465,7 @@
<data name="Fading" xml:space="preserve">
<value>フェージング</value>
</data>
<data name="Send hotkey to other instance" xml:space="preserve">
<value>ホットキーを他のインスタンスに送信する</value>
</data>
</root>

View file

@ -465,4 +465,7 @@
<data name="Fading" xml:space="preserve">
<value>페이딩</value>
</data>
<data name="Send hotkey to other instance" xml:space="preserve">
<value>다른 인스턴스로 단축키 보내기</value>
</data>
</root>

View file

@ -465,4 +465,7 @@
<data name="Fading" xml:space="preserve">
<value>Vervagen</value>
</data>
<data name="Send hotkey to other instance" xml:space="preserve">
<value>Sneltoets naar andere instantie verzenden</value>
</data>
</root>

View file

@ -465,4 +465,7 @@
<data name="Fading" xml:space="preserve">
<value>Desbotando</value>
</data>
<data name="Send hotkey to other instance" xml:space="preserve">
<value>Enviar tecla de atalho para outra instância</value>
</data>
</root>

View file

@ -465,4 +465,7 @@
<data name="Fading" xml:space="preserve">
<value>Fading</value>
</data>
<data name="Send hotkey to other instance" xml:space="preserve">
<value>Send hotkey to other instance</value>
</data>
</root>

View file

@ -465,4 +465,7 @@
<data name="Fading" xml:space="preserve">
<value>исчезновение</value>
</data>
<data name="Send hotkey to other instance" xml:space="preserve">
<value>Отправить горячую клавишу в другой экземпляр</value>
</data>
</root>

View file

@ -465,4 +465,7 @@
<data name="Fading" xml:space="preserve">
<value>Solma</value>
</data>
<data name="Send hotkey to other instance" xml:space="preserve">
<value>Başka bir örneğe kısayol tuşu gönder</value>
</data>
</root>

View file

@ -465,4 +465,7 @@
<data name="Fading" xml:space="preserve">
<value>Mờ dần</value>
</data>
<data name="Send hotkey to other instance" xml:space="preserve">
<value>Gửi phím nóng đến phiên bản khác</value>
</data>
</root>

View file

@ -465,4 +465,7 @@
<data name="Fading" xml:space="preserve">
<value>衰退</value>
</data>
<data name="Send hotkey to other instance" xml:space="preserve">
<value>向其他實例發送熱鍵</value>
</data>
</root>

View file

@ -102,6 +102,7 @@ namespace SystemTrayMenu.UserInterface
this.radioButtonSystemSettingsShowHiddenFiles = new System.Windows.Forms.RadioButton();
this.groupBoxClick = new System.Windows.Forms.GroupBox();
this.tableLayoutPanelClick = new System.Windows.Forms.TableLayoutPanel();
this.checkBoxSendHotkeyInsteadKillOtherInstances = new System.Windows.Forms.CheckBox();
this.checkBoxOpenDirectoryWithOneClick = new System.Windows.Forms.CheckBox();
this.checkBoxOpenItemWithOneClick = new System.Windows.Forms.CheckBox();
this.checkBoxShowInTaskbar = new System.Windows.Forms.CheckBox();
@ -1385,7 +1386,7 @@ namespace SystemTrayMenu.UserInterface
this.groupBoxHiddenFilesAndFolders.AutoSize = true;
this.groupBoxHiddenFilesAndFolders.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink;
this.groupBoxHiddenFilesAndFolders.Controls.Add(this.tableLayoutPanel1);
this.groupBoxHiddenFilesAndFolders.Location = new System.Drawing.Point(3, 106);
this.groupBoxHiddenFilesAndFolders.Location = new System.Drawing.Point(3, 131);
this.groupBoxHiddenFilesAndFolders.MaximumSize = new System.Drawing.Size(400, 0);
this.groupBoxHiddenFilesAndFolders.MinimumSize = new System.Drawing.Size(400, 0);
this.groupBoxHiddenFilesAndFolders.Name = "groupBoxHiddenFilesAndFolders";
@ -1458,7 +1459,7 @@ namespace SystemTrayMenu.UserInterface
this.groupBoxClick.MaximumSize = new System.Drawing.Size(400, 0);
this.groupBoxClick.MinimumSize = new System.Drawing.Size(400, 0);
this.groupBoxClick.Name = "groupBoxClick";
this.groupBoxClick.Size = new System.Drawing.Size(400, 97);
this.groupBoxClick.Size = new System.Drawing.Size(400, 122);
this.groupBoxClick.TabIndex = 0;
this.groupBoxClick.TabStop = false;
this.groupBoxClick.Text = "groupBoxClick";
@ -1469,24 +1470,38 @@ namespace SystemTrayMenu.UserInterface
this.tableLayoutPanelClick.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink;
this.tableLayoutPanelClick.ColumnCount = 1;
this.tableLayoutPanelClick.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 100F));
this.tableLayoutPanelClick.Controls.Add(this.checkBoxOpenDirectoryWithOneClick, 0, 2);
this.tableLayoutPanelClick.Controls.Add(this.checkBoxOpenItemWithOneClick, 0, 1);
this.tableLayoutPanelClick.Controls.Add(this.checkBoxSendHotkeyInsteadKillOtherInstances, 0, 1);
this.tableLayoutPanelClick.Controls.Add(this.checkBoxOpenDirectoryWithOneClick, 0, 3);
this.tableLayoutPanelClick.Controls.Add(this.checkBoxOpenItemWithOneClick, 0, 2);
this.tableLayoutPanelClick.Controls.Add(this.checkBoxShowInTaskbar, 0, 0);
this.tableLayoutPanelClick.Dock = System.Windows.Forms.DockStyle.Fill;
this.tableLayoutPanelClick.Location = new System.Drawing.Point(3, 19);
this.tableLayoutPanelClick.Name = "tableLayoutPanelClick";
this.tableLayoutPanelClick.RowCount = 3;
this.tableLayoutPanelClick.RowCount = 4;
this.tableLayoutPanelClick.RowStyles.Add(new System.Windows.Forms.RowStyle());
this.tableLayoutPanelClick.RowStyles.Add(new System.Windows.Forms.RowStyle());
this.tableLayoutPanelClick.RowStyles.Add(new System.Windows.Forms.RowStyle());
this.tableLayoutPanelClick.Size = new System.Drawing.Size(394, 75);
this.tableLayoutPanelClick.RowStyles.Add(new System.Windows.Forms.RowStyle());
this.tableLayoutPanelClick.Size = new System.Drawing.Size(394, 100);
this.tableLayoutPanelClick.TabIndex = 0;
//
// checkBoxSendHotkeyInsteadKillOtherInstances
//
this.checkBoxSendHotkeyInsteadKillOtherInstances.AutoSize = true;
this.checkBoxSendHotkeyInsteadKillOtherInstances.Dock = System.Windows.Forms.DockStyle.Fill;
this.checkBoxSendHotkeyInsteadKillOtherInstances.Location = new System.Drawing.Point(3, 28);
this.checkBoxSendHotkeyInsteadKillOtherInstances.MaximumSize = new System.Drawing.Size(330, 0);
this.checkBoxSendHotkeyInsteadKillOtherInstances.Name = "checkBoxSendHotkeyInsteadKillOtherInstances";
this.checkBoxSendHotkeyInsteadKillOtherInstances.Size = new System.Drawing.Size(330, 19);
this.checkBoxSendHotkeyInsteadKillOtherInstances.TabIndex = 3;
this.checkBoxSendHotkeyInsteadKillOtherInstances.Text = "checkBoxSendHotkeyInsteadKillOtherInstances";
this.checkBoxSendHotkeyInsteadKillOtherInstances.UseVisualStyleBackColor = true;
//
// checkBoxOpenDirectoryWithOneClick
//
this.checkBoxOpenDirectoryWithOneClick.AutoSize = true;
this.checkBoxOpenDirectoryWithOneClick.Dock = System.Windows.Forms.DockStyle.Fill;
this.checkBoxOpenDirectoryWithOneClick.Location = new System.Drawing.Point(3, 53);
this.checkBoxOpenDirectoryWithOneClick.Location = new System.Drawing.Point(3, 78);
this.checkBoxOpenDirectoryWithOneClick.Name = "checkBoxOpenDirectoryWithOneClick";
this.checkBoxOpenDirectoryWithOneClick.Size = new System.Drawing.Size(388, 19);
this.checkBoxOpenDirectoryWithOneClick.TabIndex = 2;
@ -1497,7 +1512,7 @@ namespace SystemTrayMenu.UserInterface
//
this.checkBoxOpenItemWithOneClick.AutoSize = true;
this.checkBoxOpenItemWithOneClick.Dock = System.Windows.Forms.DockStyle.Fill;
this.checkBoxOpenItemWithOneClick.Location = new System.Drawing.Point(3, 28);
this.checkBoxOpenItemWithOneClick.Location = new System.Drawing.Point(3, 53);
this.checkBoxOpenItemWithOneClick.Name = "checkBoxOpenItemWithOneClick";
this.checkBoxOpenItemWithOneClick.Size = new System.Drawing.Size(388, 19);
this.checkBoxOpenItemWithOneClick.TabIndex = 0;
@ -1519,7 +1534,7 @@ namespace SystemTrayMenu.UserInterface
//
this.buttonAdvancedDefault.AutoSize = true;
this.buttonAdvancedDefault.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink;
this.buttonAdvancedDefault.Location = new System.Drawing.Point(9, 215);
this.buttonAdvancedDefault.Location = new System.Drawing.Point(9, 240);
this.buttonAdvancedDefault.Margin = new System.Windows.Forms.Padding(9, 9, 3, 9);
this.buttonAdvancedDefault.MinimumSize = new System.Drawing.Size(75, 25);
this.buttonAdvancedDefault.Name = "buttonAdvancedDefault";
@ -4958,5 +4973,6 @@ namespace SystemTrayMenu.UserInterface
private System.Windows.Forms.Label labelIconSizeInPercent;
private System.Windows.Forms.CheckBox checkBoxUseFading;
private System.Windows.Forms.Button buttonAppearanceDefault;
private System.Windows.Forms.CheckBox checkBoxSendHotkeyInsteadKillOtherInstances;
}
}

View file

@ -146,6 +146,7 @@ namespace SystemTrayMenu.UserInterface
tabPageAdvanced.Text = Translator.GetText("Advanced");
groupBoxClick.Text = Translator.GetText("Click");
checkBoxShowInTaskbar.Text = Translator.GetText("Show in Taskbar");
checkBoxSendHotkeyInsteadKillOtherInstances.Text = Translator.GetText("Send hotkey to other instance");
checkBoxOpenItemWithOneClick.Text = Translator.GetText("Single click to open an item instead of double click");
checkBoxOpenDirectoryWithOneClick.Text = Translator.GetText("Single click to open a directory instead of double click");
groupBoxHiddenFilesAndFolders.Text = Translator.GetText("Hidden files and folders");
@ -391,6 +392,7 @@ namespace SystemTrayMenu.UserInterface
}
checkBoxShowInTaskbar.Checked = Settings.Default.ShowInTaskbar;
checkBoxSendHotkeyInsteadKillOtherInstances.Checked = Settings.Default.SendHotkeyInsteadKillOtherInstances;
checkBoxOpenItemWithOneClick.Checked = Settings.Default.OpenItemWithOneClick;
checkBoxOpenDirectoryWithOneClick.Checked = Settings.Default.OpenDirectoryWithOneClick;
@ -825,6 +827,7 @@ namespace SystemTrayMenu.UserInterface
}
Settings.Default.ShowInTaskbar = checkBoxShowInTaskbar.Checked;
Settings.Default.SendHotkeyInsteadKillOtherInstances = checkBoxSendHotkeyInsteadKillOtherInstances.Checked;
Settings.Default.OpenItemWithOneClick = checkBoxOpenItemWithOneClick.Checked;
Settings.Default.OpenDirectoryWithOneClick = checkBoxOpenDirectoryWithOneClick.Checked;
Settings.Default.SystemSettingsShowHiddenFiles = radioButtonSystemSettingsShowHiddenFiles.Checked;
@ -1109,6 +1112,7 @@ namespace SystemTrayMenu.UserInterface
private void ButtonAdvancedDefault_Click(object sender, EventArgs e)
{
checkBoxShowInTaskbar.Checked = true;
checkBoxSendHotkeyInsteadKillOtherInstances.Checked = false;
checkBoxOpenItemWithOneClick.Checked = true;
checkBoxOpenDirectoryWithOneClick.Checked = true;

View file

@ -66,15 +66,6 @@
<metadata name="ColumnOnlyFiles.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="ColumnFolder.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="ColumnRecursiveLevel.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="ColumnOnlyFiles.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="colorDialog.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>17, 17</value>
</metadata>

View file

@ -15,7 +15,7 @@ namespace SystemTrayMenu.Utilities
internal static class SingleAppInstance
{
internal static bool Initialize(bool killOtherInstances)
internal static bool Initialize()
{
bool success = true;
@ -23,9 +23,9 @@ namespace SystemTrayMenu.Utilities
{
foreach (Process p in Process.GetProcessesByName(
Process.GetCurrentProcess().ProcessName).
Where(s => s.Id != Process.GetCurrentProcess().Id))
Where(s => s.Id != Environment.ProcessId))
{
if (!killOtherInstances)
if (Properties.Settings.Default.SendHotkeyInsteadKillOtherInstances)
{
Keys modifiers = HotkeyControl.HotkeyModifiersFromString(Properties.Settings.Default.HotKey);
Keys hotkey = HotkeyControl.HotkeyFromString(Properties.Settings.Default.HotKey);
@ -41,17 +41,12 @@ namespace SystemTrayMenu.Utilities
}
VirtualKeyCode virtualKeyCode = VirtualKeyCode.LWIN;
switch (key)
virtualKeyCode = key switch
{
case "ALT":
virtualKeyCode = VirtualKeyCode.MENU;
break;
default:
virtualKeyCode = (VirtualKeyCode)Enum.Parse(
typeof(VirtualKeyCode), key.ToUpperInvariant());
break;
}
"ALT" => VirtualKeyCode.MENU,
_ => (VirtualKeyCode)Enum.Parse(
typeof(VirtualKeyCode), key.ToUpperInvariant()),
};
virtualKeyCodesModifiers.Add(virtualKeyCode);
}
@ -68,11 +63,10 @@ namespace SystemTrayMenu.Utilities
catch (Exception ex)
{
Log.Warn($"Send hoktey {Properties.Settings.Default.HotKey} to other instance failed", ex);
killOtherInstances = true;
}
}
if (killOtherInstances)
if (!Properties.Settings.Default.SendHotkeyInsteadKillOtherInstances)
{
try
{