Skip to content

Commit 30e951c

Browse files
committed
Restart related improvements:
- Added new button flag: IsOnlyInstance - Added new method to get the amount of instances running - Restart button is now enabled when only one instance is running - Improved restart button visibility
1 parent 5cba601 commit 30e951c

File tree

4 files changed

+29
-4
lines changed

4 files changed

+29
-4
lines changed

FlashDevelop/Bin/Debug/Settings/MainMenu.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@
5959
<button label="Label.Print" click="Print" shortcut="Control|P" image="343" flags="Enable:IsEditable" />
6060
<button label="Label.PrintPreview" click="PrintPreview" shortcut="Control|Shift|P" flags="Enable:IsEditable" />
6161
<separator />
62-
<button label="Label.Restart" click="Restart" flags="Enable:!MultiInstanceMode" />
62+
<button label="Label.Restart" click="Restart" flags="Enable:IsOnlyInstance" />
6363
<button label="Label.Exit" click="Exit" />
6464
</menu>
6565
<menu label="Label.Edit" name="EditMenu">

FlashDevelop/MainForm.cs

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -754,8 +754,9 @@ private void AppManUpdate(Object sender, FileSystemEventArgs e)
754754
private void InitializeRestartButton()
755755
{
756756
this.restartButton = new ToolStripButton();
757-
this.restartButton.Image = this.FindImage("69");
757+
this.restartButton.Image = this.FindImage("73|6|3|3");
758758
this.restartButton.Alignment = ToolStripItemAlignment.Right;
759+
this.restartButton.Text = TextHelper.GetString("Label.Restart");
759760
this.restartButton.ToolTipText = TextHelper.GetString("Info.RequiresRestart");
760761
this.restartButton.Click += delegate { this.Restart(null, null); };
761762
this.restartButton.Visible = false;
@@ -2202,6 +2203,15 @@ public String GetWorkingDirectory()
22022203

22032204
}
22042205

2206+
/// <summary>
2207+
/// Gets the amount instances running
2208+
/// </summary>
2209+
public Int32 GetInstanceCount()
2210+
{
2211+
Process current = Process.GetCurrentProcess();
2212+
return Process.GetProcessesByName(current.ProcessName).Length;
2213+
}
2214+
22052215
/// <summary>
22062216
/// Sets the text to find globally
22072217
/// </summary>
@@ -4232,8 +4242,11 @@ public void Debug(Object sender, EventArgs e)
42324242
/// </summary>
42334243
public void Restart(Object sender, EventArgs e)
42344244
{
4235-
this.restartRequested = true;
4236-
this.Close();
4245+
if (this.GetInstanceCount() == 1)
4246+
{
4247+
this.restartRequested = true;
4248+
this.Close();
4249+
}
42374250
}
42384251

42394252
#endregion

FlashDevelop/Managers/ButtonManager.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,14 @@ public static Boolean ValidateFlagAction(ToolStripItem item, String action)
134134
{
135135
if (!mainForm.IsFullScreen) return false;
136136
}
137+
if (action.Contains("!IsOnlyInstance"))
138+
{
139+
if (mainForm.GetInstanceCount() == 1) return false;
140+
}
141+
else if (action.Contains("IsOnlyInstance"))
142+
{
143+
if (mainForm.GetInstanceCount() > 1) return false;
144+
}
137145
if (action.Contains("TracksBoolean"))
138146
{
139147
Boolean value = (Boolean)Globals.Settings.GetValue(((ItemData)item.Tag).Tag);

PluginCore/PluginCore/Interfaces.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -272,6 +272,10 @@ public interface IMainForm : IContainerControl, IWin32Window
272272
/// Equivalent to calling <code>ImageSetAdjust(FindImage(data, false))</code>.
273273
/// </summary>
274274
Image FindImageAndSetAdjust(String data);
275+
/// <summary>
276+
/// Gets the amount of FD instances running
277+
/// </summary>
278+
Int32 GetInstanceCount();
275279

276280
#endregion
277281

0 commit comments

Comments
 (0)