Skip to content

Commit 7c56dd1

Browse files
committed
Merge pull request #967 from Neverbirth/dialogs_ux
Minor UX improvement
2 parents 2ca18af + 97a758c commit 7c56dd1

File tree

1 file changed

+30
-18
lines changed

1 file changed

+30
-18
lines changed

FlashDevelop/MainForm.cs

Lines changed: 30 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,13 @@
55
using System.IO;
66
using System.Text;
77
using System.Drawing;
8-
using System.Threading;
98
using System.Reflection;
109
using System.Collections;
1110
using System.Diagnostics;
1211
using System.Windows.Forms;
1312
using System.ComponentModel;
1413
using System.Collections.Generic;
1514
using System.Text.RegularExpressions;
16-
using System.Runtime.InteropServices;
1715
using ScintillaNet.Configuration;
1816
using PluginCore.Localization;
1917
using FlashDevelop.Controls;
@@ -23,7 +21,6 @@
2321
using FlashDevelop.Helpers;
2422
using FlashDevelop.Dialogs;
2523
using FlashDevelop.Settings;
26-
using WeifenLuo.WinFormsUI;
2724
using WeifenLuo.WinFormsUI.Docking;
2825
using ICSharpCode.SharpZipLib.Zip;
2926
using PluginCore.Utilities;
@@ -291,7 +288,7 @@ public Boolean ClosingEntirely
291288
/// </summary>
292289
public Boolean IsFirstInstance
293290
{
294-
get { return MainForm.IsFirst; }
291+
get { return IsFirst; }
295292
}
296293

297294
/// <summary>
@@ -322,7 +319,7 @@ public ITabbedDocument[] Documents
322319
get
323320
{
324321
List<ITabbedDocument> documents = new List<ITabbedDocument>();
325-
foreach (DockPane pane in Globals.MainForm.DockPanel.Panes)
322+
foreach (DockPane pane in DockPanel.Panes)
326323
{
327324
if (pane.DockState == DockState.Document)
328325
{
@@ -462,7 +459,7 @@ public Boolean RefreshConfig
462459
/// </summary>
463460
public String[] StartArguments
464461
{
465-
get { return MainForm.Arguments; }
462+
get { return Arguments; }
466463
}
467464

468465
/// <summary>
@@ -758,7 +755,7 @@ public void InitializeSmartDialogs()
758755
/// </summary>
759756
private DialogResult InitializeFirstRun()
760757
{
761-
if (!this.StandaloneMode && MainForm.IsFirst && FirstRunDialog.ShouldProcessCommands())
758+
if (!this.StandaloneMode && IsFirst && FirstRunDialog.ShouldProcessCommands())
762759
{
763760
return FirstRunDialog.Show();
764761
}
@@ -1180,7 +1177,7 @@ public void OnMainFormClosing(Object sender, System.ComponentModel.CancelEventAr
11801177
{
11811178
String title = TextHelper.GetString("Title.ConfirmDialog");
11821179
String message = TextHelper.GetString("Info.AreYouSureToExit");
1183-
DialogResult result = MessageBox.Show(Globals.MainForm, message, " " + title, MessageBoxButtons.YesNo, MessageBoxIcon.Question);
1180+
DialogResult result = MessageBox.Show(this, message, " " + title, MessageBoxButtons.YesNo, MessageBoxIcon.Question);
11841181
if (result == DialogResult.No) e.Cancel = true;
11851182
}
11861183
if (!e.Cancel) this.CloseAllDocuments(false);
@@ -1335,7 +1332,7 @@ public void OnDocumentClosing(Object sender, System.ComponentModel.CancelEventAr
13351332
{
13361333
String saveChanges = TextHelper.GetString("Info.SaveChanges");
13371334
String saveChangesTitle = TextHelper.GetString("Title.SaveChanges");
1338-
DialogResult result = MessageBox.Show(Globals.MainForm, saveChanges, saveChangesTitle + " " + document.Text, MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question);
1335+
DialogResult result = MessageBox.Show(this, saveChanges, saveChangesTitle + " " + document.Text, MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question);
13391336
if (result == DialogResult.Yes)
13401337
{
13411338
if (document.IsUntitled)
@@ -1467,7 +1464,7 @@ public void OnScintillaControlModifyRO(ScintillaControl sci)
14671464
if (te.Handled) return; // Let plugin handle this...
14681465
String dlgTitle = TextHelper.GetString("Title.ConfirmDialog");
14691466
String message = TextHelper.GetString("Info.MakeReadOnlyWritable");
1470-
if (MessageBox.Show(Globals.MainForm, message, dlgTitle, MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
1467+
if (MessageBox.Show(this, message, dlgTitle, MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
14711468
{
14721469
ScintillaManager.MakeFileWritable(sci);
14731470
}
@@ -2683,7 +2680,10 @@ public void PrintPreview(Object sender, System.EventArgs e)
26832680
/// </summary>
26842681
public void GoTo(Object sender, System.EventArgs e)
26852682
{
2686-
this.gotoDialog.Show();
2683+
if (!this.gotoDialog.Visible)
2684+
this.gotoDialog.Show();
2685+
else
2686+
this.gotoDialog.Activate();
26872687
}
26882688

26892689
/// <summary>
@@ -2711,7 +2711,10 @@ public void FindPrevious(Object sender, System.EventArgs e)
27112711
/// </summary>
27122712
public void FindAndReplace(Object sender, System.EventArgs e)
27132713
{
2714-
this.frInDocDialog.Show();
2714+
if (!this.frInDocDialog.Visible)
2715+
this.frInDocDialog.Show();
2716+
else
2717+
this.frInDocDialog.Activate();
27152718
}
27162719

27172720
/// <summary>
@@ -2721,19 +2724,25 @@ public void FindAndReplaceFrom(Object sender, System.EventArgs e)
27212724
{
27222725
ToolStripItem button = (ToolStripItem)sender;
27232726
String file = ((ItemData)button.Tag).Tag;
2724-
((Form)PluginBase.MainForm).BeginInvoke((MethodInvoker)delegate
2727+
this.BeginInvoke((MethodInvoker)delegate
27252728
{
27262729
OpenEditableDocument(file);
27272730
});
2728-
this.frInDocDialog.Show();
2731+
if (!this.frInDocDialog.Visible)
2732+
this.frInDocDialog.Show();
2733+
else
2734+
this.frInDocDialog.Activate();
27292735
}
27302736

27312737
/// <summary>
27322738
/// Opens a find and replace in files dialog
27332739
/// </summary>
27342740
public void FindAndReplaceInFiles(Object sender, System.EventArgs e)
27352741
{
2736-
this.frInFilesDialog.Show();
2742+
if (!this.frInFilesDialog.Visible)
2743+
this.frInFilesDialog.Show();
2744+
else
2745+
this.frInFilesDialog.Activate();
27372746
}
27382747

27392748
/// <summary>
@@ -2743,7 +2752,10 @@ public void FindAndReplaceInFilesFrom(Object sender, System.EventArgs e)
27432752
{
27442753
ToolStripItem button = (ToolStripItem)sender;
27452754
String path = ((ItemData)button.Tag).Tag;
2746-
this.frInFilesDialog.Show(); // Show first..
2755+
if (!this.frInFilesDialog.Visible)
2756+
this.frInFilesDialog.Show(); // Show first..
2757+
else
2758+
this.frInFilesDialog.Activate();
27472759
this.frInFilesDialog.SetFindPath(path);
27482760
}
27492761

@@ -2852,7 +2864,7 @@ public void ExtractZip(Object sender, System.EventArgs e)
28522864
String zipLog = String.Empty;
28532865
String zipFile = String.Empty;
28542866
Boolean requiresRestart = false;
2855-
Boolean silentInstall = MainForm.Silent;
2867+
Boolean silentInstall = Silent;
28562868
ToolStripItem button = (ToolStripItem)sender;
28572869
String[] chunks = (((ItemData)button.Tag).Tag).Split(';');
28582870
if (chunks.Length > 1)
@@ -2934,7 +2946,7 @@ public void RemoveZip(Object sender, System.EventArgs e)
29342946
String zipLog = String.Empty;
29352947
String zipFile = String.Empty;
29362948
Boolean requiresRestart = false;
2937-
Boolean silentRemove = MainForm.Silent;
2949+
Boolean silentRemove = Silent;
29382950
List<String> removeDirs = new List<String>();
29392951
ToolStripItem button = (ToolStripItem)sender;
29402952
String[] chunks = (((ItemData)button.Tag).Tag).Split(';');

0 commit comments

Comments
 (0)