Skip to content

Commit 11f1caa

Browse files
committed
Addes IsLoaded property to MapWindowForm so plug-ins don't need to do it anymore.
1 parent 824c6cf commit 11f1caa

1 file changed

Lines changed: 19 additions & 10 deletions

File tree

src/MW5.UI/Forms/MapWindowForm.cs

Lines changed: 19 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
using System;
88
using System.Drawing;
9+
using System.Windows.Forms;
910
using MW5.Plugins.Interfaces;
1011
using MW5.UI.Properties;
1112
using Syncfusion.Windows.Forms;
@@ -19,6 +20,7 @@ public class MapWindowForm : MetroForm
1920
#endif
2021
{
2122
protected readonly IAppContext _context;
23+
public static bool IsLoaded;
2224

2325
public MapWindowForm()
2426
{
@@ -33,31 +35,38 @@ public MapWindowForm(IAppContext context)
3335
: this()
3436
{
3537
_context = context;
38+
InitializeComponent();
3639
}
3740

38-
public IAppContext AppContext
39-
{
40-
get { return _context; }
41-
}
41+
public IAppContext AppContext => _context;
4242

4343
private void InitializeComponent()
4444
{
45-
this.SuspendLayout();
45+
SuspendLayout();
4646
//
4747
// MapWindowForm
4848
//
49-
this.CaptionFont = new System.Drawing.Font("Microsoft Sans Serif", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
50-
this.ClientSize = new System.Drawing.Size(284, 261);
51-
this.Name = "MapWindowForm";
52-
this.Load += new System.EventHandler(this.MapWindowForm_Load);
53-
this.ResumeLayout(false);
49+
CaptionFont = new Font("Microsoft Sans Serif", 9.75F, FontStyle.Regular, GraphicsUnit.Point, 0);
50+
ClientSize = new Size(284, 261);
51+
Name = "MapWindowForm";
52+
FormClosed += MapWindowForm_FormClosed;
53+
Load += MapWindowForm_Load;
54+
ResumeLayout(false);
5455

5556
}
5657

5758
private void MapWindowForm_Load(object sender, EventArgs e)
5859
{
5960
// Fixing CORE-160
6061
CaptionFont = new Font("Microsoft Sans Serif", 10F, FontStyle.Regular, GraphicsUnit.Point, 0);
62+
63+
// To prevent loading multiple instances:
64+
IsLoaded = true;
65+
}
66+
67+
private void MapWindowForm_FormClosed(object sender, FormClosedEventArgs e)
68+
{
69+
IsLoaded = false;
6170
}
6271
}
6372
}

0 commit comments

Comments
 (0)