mirror of
https://github.com/gui-cs/Terminal.Gui.git
synced 2026-01-02 01:03:29 +01:00
Switch to EventHandler for TopLevel methods
- Loaded, - Ready - Unloaded - AllChildClosed
This commit is contained in:
@@ -48,7 +48,7 @@ namespace Terminal.Gui {
|
||||
/// A Loaded event handler is a good place to finalize initialization before calling
|
||||
/// <see cref="Application.RunLoop(Application.RunState, bool)"/>.
|
||||
/// </summary>
|
||||
public event Action Loaded;
|
||||
public event EventHandler Loaded;
|
||||
|
||||
/// <summary>
|
||||
/// Invoked when the Toplevel <see cref="MainLoop"/> has started it's first iteration.
|
||||
@@ -57,13 +57,13 @@ namespace Terminal.Gui {
|
||||
/// <para>A Ready event handler is a good place to finalize initialization after calling
|
||||
/// <see cref="Application.Run(Func{Exception, bool})"/> on this Toplevel.</para>
|
||||
/// </summary>
|
||||
public event Action Ready;
|
||||
public event EventHandler Ready;
|
||||
|
||||
/// <summary>
|
||||
/// Invoked when the Toplevel <see cref="Application.RunState"/> has been unloaded.
|
||||
/// A Unloaded event handler is a good place to dispose objects after calling <see cref="Application.End(Application.RunState)"/>.
|
||||
/// </summary>
|
||||
public event Action Unloaded;
|
||||
public event EventHandler Unloaded;
|
||||
|
||||
/// <summary>
|
||||
/// Invoked when the Toplevel <see cref="Application.RunState"/> becomes the <see cref="Application.Current"/> Toplevel.
|
||||
@@ -85,7 +85,7 @@ namespace Terminal.Gui {
|
||||
/// Invoked when the last child of the Toplevel <see cref="Application.RunState"/> is closed from
|
||||
/// by <see cref="Application.End(Application.RunState)"/>.
|
||||
/// </summary>
|
||||
public event Action AllChildClosed;
|
||||
public event EventHandler AllChildClosed;
|
||||
|
||||
/// <summary>
|
||||
/// Invoked when the Toplevel's <see cref="Application.RunState"/> is being closed by
|
||||
@@ -141,7 +141,7 @@ namespace Terminal.Gui {
|
||||
|
||||
internal virtual void OnAllChildClosed ()
|
||||
{
|
||||
AllChildClosed?.Invoke ();
|
||||
AllChildClosed?.Invoke (this, EventArgs.Empty);
|
||||
}
|
||||
|
||||
internal virtual void OnChildClosed (Toplevel top)
|
||||
@@ -171,7 +171,7 @@ namespace Terminal.Gui {
|
||||
foreach (Toplevel tl in Subviews.Where (v => v is Toplevel)) {
|
||||
tl.OnLoaded ();
|
||||
}
|
||||
Loaded?.Invoke ();
|
||||
Loaded?.Invoke (this, EventArgs.Empty);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -183,7 +183,7 @@ namespace Terminal.Gui {
|
||||
foreach (Toplevel tl in Subviews.Where (v => v is Toplevel)) {
|
||||
tl.OnReady ();
|
||||
}
|
||||
Ready?.Invoke ();
|
||||
Ready?.Invoke (this, EventArgs.Empty);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -194,7 +194,7 @@ namespace Terminal.Gui {
|
||||
foreach (Toplevel tl in Subviews.Where (v => v is Toplevel)) {
|
||||
tl.OnUnloaded ();
|
||||
}
|
||||
Unloaded?.Invoke ();
|
||||
Unloaded?.Invoke (this, EventArgs.Empty);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -385,7 +385,7 @@ namespace Terminal.Gui {
|
||||
|
||||
}
|
||||
|
||||
private void Wizard_Loaded ()
|
||||
private void Wizard_Loaded (object sender, EventArgs args)
|
||||
{
|
||||
CurrentStep = GetFirstStep (); // gets the first step if CurrentStep == null
|
||||
}
|
||||
|
||||
@@ -272,7 +272,7 @@ namespace UICatalog.Scenarios {
|
||||
}
|
||||
};
|
||||
|
||||
Application.Top.Ready += () => radioGroup.Refresh ();
|
||||
Application.Top.Ready += (s,e) => radioGroup.Refresh ();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -112,7 +112,7 @@ namespace UICatalog.Scenarios {
|
||||
};
|
||||
frame.Add (styleRadioGroup);
|
||||
|
||||
void Top_Loaded ()
|
||||
void Top_Loaded (object sender, EventArgs args)
|
||||
{
|
||||
frame.Height = Dim.Height (widthEdit) + Dim.Height (heightEdit) + Dim.Height (titleEdit)
|
||||
+ Dim.Height (numButtonsEdit) + Dim.Height (styleRadioGroup) + Dim.Height (glyphsNotWords) + 2;
|
||||
|
||||
@@ -73,7 +73,7 @@ namespace UICatalog.Scenarios {
|
||||
Win.Add (colorLabel);
|
||||
x += colorLabel.Text.Length + 2;
|
||||
}
|
||||
Application.Top.Ready += () => Application.Top.Redraw (Application.Top.Bounds);
|
||||
Application.Top.Ready += (s,e) => Application.Top.Redraw (Application.Top.Bounds);
|
||||
|
||||
Label Label;
|
||||
Win.Add (Label = new Label ("A super long _Label that will probably expose a bug in clipping or wrapping of text. Will it?") {
|
||||
@@ -306,7 +306,7 @@ namespace UICatalog.Scenarios {
|
||||
}
|
||||
};
|
||||
|
||||
Application.Top.Ready += () => radioGroup.Refresh ();
|
||||
Application.Top.Ready += (s,e) => radioGroup.Refresh ();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -152,7 +152,7 @@ namespace UICatalog.Scenarios {
|
||||
};
|
||||
frame.Add (ckbEffect3D);
|
||||
|
||||
void Top_Loaded ()
|
||||
void Top_Loaded (object sender, EventArgs args)
|
||||
{
|
||||
frame.Height = Dim.Height (widthEdit) + Dim.Height (heightEdit) + Dim.Height (titleEdit) + Dim.Height (messageEdit)
|
||||
+ Dim.Height (numButtonsEdit) + Dim.Height (defaultButtonEdit) + Dim.Height (styleRadioGroup) + 2 + Dim.Height (ckbEffect3D);
|
||||
|
||||
@@ -133,7 +133,7 @@ namespace UICatalog.Scenarios {
|
||||
|
||||
Application.Top.Unloaded += Top_Unloaded;
|
||||
|
||||
void Top_Unloaded ()
|
||||
void Top_Unloaded (object sender, EventArgs args)
|
||||
{
|
||||
if (_fractionTimer != null) {
|
||||
_fractionTimer.Dispose ();
|
||||
|
||||
@@ -151,7 +151,7 @@ namespace UICatalog.Scenarios {
|
||||
};
|
||||
scrollView.Add (verticalRuler);
|
||||
|
||||
void Top_Loaded ()
|
||||
void Top_Loaded (object sender, EventArgs args)
|
||||
{
|
||||
horizontalRuler.Text = rule.Repeat ((int)Math.Ceiling ((double)(horizontalRuler.Bounds.Width) / (double)rule.Length)) [0..(horizontalRuler.Bounds.Width)] +
|
||||
"\n" + "| ".Repeat ((int)Math.Ceiling ((double)(horizontalRuler.Bounds.Width) / (double)rule.Length)) [0..(horizontalRuler.Bounds.Width)];
|
||||
@@ -310,7 +310,7 @@ namespace UICatalog.Scenarios {
|
||||
}
|
||||
Application.MainLoop.AddTimeout (TimeSpan.FromMilliseconds (300), timer);
|
||||
|
||||
void Top_Unloaded ()
|
||||
void Top_Unloaded (object sender, EventArgs args)
|
||||
{
|
||||
pulsing = false;
|
||||
Application.Top.Unloaded -= Top_Unloaded;
|
||||
|
||||
@@ -93,7 +93,7 @@ namespace UICatalog.Scenarios {
|
||||
|
||||
Win.Add (_itemsList, _btnActionCancel, _logJob, text, _btnAction, _btnLambda, _btnHandler, _btnSync, _btnMethod, _btnClearData, _btnQuit);
|
||||
|
||||
void Top_Loaded ()
|
||||
void Top_Loaded (object sender, EventArgs args)
|
||||
{
|
||||
_btnActionCancel.SetFocus ();
|
||||
Application.Top.Loaded -= Top_Loaded;
|
||||
|
||||
@@ -83,7 +83,7 @@ namespace UICatalog.Scenarios {
|
||||
|
||||
Application.Top.Add (menu);
|
||||
|
||||
Win.Loaded += () => loaded = true;
|
||||
Win.Loaded += (s,e) => loaded = true;
|
||||
}
|
||||
|
||||
private void SetupTileView ()
|
||||
|
||||
@@ -70,7 +70,7 @@ namespace UICatalog.Scenarios {
|
||||
};
|
||||
frame.Add (titleEdit);
|
||||
|
||||
void Top_Loaded ()
|
||||
void Top_Loaded (object sender, EventArgs args)
|
||||
{
|
||||
frame.Height = Dim.Height (widthEdit) + Dim.Height (heightEdit) + Dim.Height (titleEdit) + 2;
|
||||
Application.Top.Loaded -= Top_Loaded;
|
||||
|
||||
@@ -352,7 +352,7 @@ namespace UICatalog {
|
||||
ConfigurationManager.Applied += ConfigAppliedHandler;
|
||||
}
|
||||
|
||||
void LoadedHandler ()
|
||||
void LoadedHandler (object sender, EventArgs args)
|
||||
{
|
||||
ConfigChanged ();
|
||||
|
||||
@@ -381,7 +381,7 @@ namespace UICatalog {
|
||||
Loaded -= LoadedHandler;
|
||||
}
|
||||
|
||||
private void UnloadedHandler ()
|
||||
private void UnloadedHandler (object sender, EventArgs args)
|
||||
{
|
||||
ConfigurationManager.Applied -= ConfigAppliedHandler;
|
||||
Unloaded -= UnloadedHandler;
|
||||
|
||||
@@ -420,9 +420,9 @@ namespace Terminal.Gui.ApplicationTests {
|
||||
Init ();
|
||||
var top = Application.Top;
|
||||
var count = 0;
|
||||
top.Loaded += () => count++;
|
||||
top.Ready += () => count++;
|
||||
top.Unloaded += () => count++;
|
||||
top.Loaded += (s,e) => count++;
|
||||
top.Ready += (s,e) => count++;
|
||||
top.Unloaded += (s,e) => count++;
|
||||
Application.Iteration = () => Application.RequestStop ();
|
||||
Application.Run ();
|
||||
Application.Shutdown ();
|
||||
@@ -473,23 +473,23 @@ namespace Terminal.Gui.ApplicationTests {
|
||||
// t1, t2, t3, d, t4
|
||||
var iterations = 5;
|
||||
|
||||
t1.Ready += () => {
|
||||
t1.Ready += (s,e) => {
|
||||
Assert.Equal (t1, Application.Top);
|
||||
Application.Run (t2);
|
||||
};
|
||||
t2.Ready += () => {
|
||||
t2.Ready += (s,e) => {
|
||||
Assert.Equal (t2, Application.Top);
|
||||
Application.Run (t3);
|
||||
};
|
||||
t3.Ready += () => {
|
||||
t3.Ready += (s,e) => {
|
||||
Assert.Equal (t3, Application.Top);
|
||||
Application.Run (d);
|
||||
};
|
||||
d.Ready += () => {
|
||||
d.Ready += (s, e) => {
|
||||
Assert.Equal (t3, Application.Top);
|
||||
Application.Run (t4);
|
||||
};
|
||||
t4.Ready += () => {
|
||||
t4.Ready += (s, e) => {
|
||||
Assert.Equal (t4, Application.Top);
|
||||
t4.RequestStop ();
|
||||
d.RequestStop ();
|
||||
|
||||
@@ -899,7 +899,7 @@ namespace Terminal.Gui.CoreTests {
|
||||
w.Add (f);
|
||||
t.Add (w);
|
||||
|
||||
t.Ready += () => {
|
||||
t.Ready += (s, e) => {
|
||||
Assert.True (t.CanFocus);
|
||||
Assert.True (w.CanFocus);
|
||||
Assert.True (f.CanFocus);
|
||||
@@ -943,7 +943,7 @@ namespace Terminal.Gui.CoreTests {
|
||||
w.Add (f);
|
||||
t.Add (w);
|
||||
|
||||
t.Ready += () => {
|
||||
t.Ready += (s, e) => {
|
||||
Assert.True (t.CanFocus);
|
||||
Assert.True (w.CanFocus);
|
||||
Assert.True (f.CanFocus);
|
||||
@@ -978,7 +978,7 @@ namespace Terminal.Gui.CoreTests {
|
||||
w.Add (f);
|
||||
t.Add (w);
|
||||
|
||||
t.Ready += () => {
|
||||
t.Ready += (s, e) => {
|
||||
Assert.True (t.CanFocus);
|
||||
Assert.True (w.CanFocus);
|
||||
Assert.True (f.CanFocus);
|
||||
@@ -1012,7 +1012,7 @@ namespace Terminal.Gui.CoreTests {
|
||||
|
||||
Application.Init (new FakeDriver ());
|
||||
|
||||
Application.Top.Ready += () => {
|
||||
Application.Top.Ready += (s, e) => {
|
||||
Assert.Null (Application.Top.Focused);
|
||||
};
|
||||
|
||||
@@ -1072,10 +1072,10 @@ namespace Terminal.Gui.CoreTests {
|
||||
|
||||
t.Ready += FirstDialogToplevel;
|
||||
|
||||
void FirstDialogToplevel ()
|
||||
void FirstDialogToplevel (object sender, EventArgs args)
|
||||
{
|
||||
var od = new OpenDialog ();
|
||||
od.Ready += SecoundDialogToplevel;
|
||||
od.Ready += SecondDialogToplevel;
|
||||
|
||||
Application.MainLoop.AddTimeout (TimeSpan.FromMilliseconds (100), (_) => {
|
||||
count1++;
|
||||
@@ -1096,7 +1096,7 @@ namespace Terminal.Gui.CoreTests {
|
||||
Application.Run (od);
|
||||
}
|
||||
|
||||
void SecoundDialogToplevel ()
|
||||
void SecondDialogToplevel (object sender, EventArgs args)
|
||||
{
|
||||
var d = new Dialog ();
|
||||
|
||||
|
||||
@@ -582,7 +582,7 @@ namespace Terminal.Gui.TopLevelTests {
|
||||
{
|
||||
for (int i = 0; i < 8; i++) {
|
||||
var fd = new FileDialog ();
|
||||
fd.Ready += () => Application.RequestStop ();
|
||||
fd.Ready += (s,e) => Application.RequestStop ();
|
||||
Application.Run (fd);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -67,24 +67,24 @@ namespace Terminal.Gui.TopLevelTests {
|
||||
// top1, top2, top3, d1 = 4
|
||||
var iterations = 4;
|
||||
|
||||
top1.Ready += () => {
|
||||
top1.Ready += (s, e) => {
|
||||
Assert.Null (Application.MdiChildes);
|
||||
Application.Run (top2);
|
||||
};
|
||||
top2.Ready += () => {
|
||||
top2.Ready += (s, e) => {
|
||||
Assert.Null (Application.MdiChildes);
|
||||
Application.Run (top3);
|
||||
};
|
||||
top3.Ready += () => {
|
||||
top3.Ready += (s, e) => {
|
||||
Assert.Null (Application.MdiChildes);
|
||||
Application.Run (top4);
|
||||
};
|
||||
top4.Ready += () => {
|
||||
top4.Ready += (s, e) => {
|
||||
Assert.Null (Application.MdiChildes);
|
||||
Application.Run (d);
|
||||
};
|
||||
|
||||
d.Ready += () => {
|
||||
d.Ready += (s, e) => {
|
||||
Assert.Null (Application.MdiChildes);
|
||||
// This will close the d because on a not MdiContainer the Application.Current it always used.
|
||||
Application.RequestStop (top1);
|
||||
@@ -130,25 +130,25 @@ else Assert.True (Application.Current == top1);
|
||||
// d1 = 1
|
||||
var iterations = 4;
|
||||
|
||||
mdi.Ready += () => {
|
||||
mdi.Ready += (s, e) => {
|
||||
Assert.Empty (Application.MdiChildes);
|
||||
Application.Run (c1);
|
||||
};
|
||||
c1.Ready += () => {
|
||||
c1.Ready += (s, e) => {
|
||||
Assert.Single (Application.MdiChildes);
|
||||
Application.Run (c2);
|
||||
};
|
||||
c2.Ready += () => {
|
||||
c2.Ready += (s, e) => {
|
||||
Assert.Equal (2, Application.MdiChildes.Count);
|
||||
Application.Run (c3);
|
||||
};
|
||||
c3.Ready += () => {
|
||||
c3.Ready += (s, e) => {
|
||||
Assert.Equal (3, Application.MdiChildes.Count);
|
||||
Application.Run (d);
|
||||
};
|
||||
|
||||
// More easy because the Mdi Container handles all at once
|
||||
d.Ready += () => {
|
||||
d.Ready += (s, e) => {
|
||||
Assert.Equal (3, Application.MdiChildes.Count);
|
||||
// This will not close the MdiContainer because d is a modal toplevel and will be closed.
|
||||
mdi.RequestStop ();
|
||||
@@ -190,25 +190,25 @@ else Assert.True (Application.Current == top1);
|
||||
// d1 = 1
|
||||
var iterations = 4;
|
||||
|
||||
mdi.Ready += () => {
|
||||
mdi.Ready += (s, e) => {
|
||||
Assert.Empty (Application.MdiChildes);
|
||||
Application.Run (c1);
|
||||
};
|
||||
c1.Ready += () => {
|
||||
c1.Ready += (s, e) => {
|
||||
Assert.Single (Application.MdiChildes);
|
||||
Application.Run (c2);
|
||||
};
|
||||
c2.Ready += () => {
|
||||
c2.Ready += (s, e) => {
|
||||
Assert.Equal (2, Application.MdiChildes.Count);
|
||||
Application.Run (c3);
|
||||
};
|
||||
c3.Ready += () => {
|
||||
c3.Ready += (s, e) => {
|
||||
Assert.Equal (3, Application.MdiChildes.Count);
|
||||
Application.Run (d);
|
||||
};
|
||||
|
||||
// Also easy because the Mdi Container handles all at once
|
||||
d.Ready += () => {
|
||||
d.Ready += (s, e) => {
|
||||
Assert.Equal (3, Application.MdiChildes.Count);
|
||||
// This will not close the MdiContainer because d is a modal toplevel
|
||||
Application.RequestStop (mdi);
|
||||
@@ -248,25 +248,25 @@ else Assert.True (Application.Current == top1);
|
||||
// d1 = 1
|
||||
var iterations = 4;
|
||||
|
||||
mdi.Ready += () => {
|
||||
mdi.Ready += (s, e) => {
|
||||
Assert.Empty (Application.MdiChildes);
|
||||
Application.Run (c1);
|
||||
};
|
||||
c1.Ready += () => {
|
||||
c1.Ready += (s, e) => {
|
||||
Assert.Single (Application.MdiChildes);
|
||||
Application.Run (c2);
|
||||
};
|
||||
c2.Ready += () => {
|
||||
c2.Ready += (s, e) => {
|
||||
Assert.Equal (2, Application.MdiChildes.Count);
|
||||
Application.Run (c3);
|
||||
};
|
||||
c3.Ready += () => {
|
||||
c3.Ready += (s, e) => {
|
||||
Assert.Equal (3, Application.MdiChildes.Count);
|
||||
Application.Run (d);
|
||||
};
|
||||
|
||||
//More harder because it's sequential.
|
||||
d.Ready += () => {
|
||||
d.Ready += (s, e) => {
|
||||
Assert.Equal (3, Application.MdiChildes.Count);
|
||||
// Close the Dialog
|
||||
Application.RequestStop ();
|
||||
@@ -331,28 +331,28 @@ else Assert.True (Application.Current == top1);
|
||||
// d1, d2 = 2
|
||||
var iterations = 5;
|
||||
|
||||
mdi.Ready += () => {
|
||||
mdi.Ready += (s, e) => {
|
||||
Assert.Empty (Application.MdiChildes);
|
||||
Application.Run (c1);
|
||||
};
|
||||
c1.Ready += () => {
|
||||
c1.Ready += (s, e) => {
|
||||
Assert.Single (Application.MdiChildes);
|
||||
Application.Run (c2);
|
||||
};
|
||||
c2.Ready += () => {
|
||||
c2.Ready += (s, e) => {
|
||||
Assert.Equal (2, Application.MdiChildes.Count);
|
||||
Application.Run (c3);
|
||||
};
|
||||
c3.Ready += () => {
|
||||
c3.Ready += (s, e) => {
|
||||
Assert.Equal (3, Application.MdiChildes.Count);
|
||||
Application.Run (d1);
|
||||
};
|
||||
d1.Ready += () => {
|
||||
d1.Ready += (s, e) => {
|
||||
Assert.Equal (3, Application.MdiChildes.Count);
|
||||
Application.Run (d2);
|
||||
};
|
||||
|
||||
d2.Ready += () => {
|
||||
d2.Ready += (s, e) => {
|
||||
Assert.Equal (3, Application.MdiChildes.Count);
|
||||
Assert.True (Application.Current == d2);
|
||||
Assert.True (Application.Current.Running);
|
||||
@@ -406,28 +406,28 @@ else Assert.True (Application.Current == top1);
|
||||
// d1 = 1
|
||||
var iterations = 5;
|
||||
|
||||
mdi.Ready += () => {
|
||||
mdi.Ready += (s, e) => {
|
||||
Assert.Empty (Application.MdiChildes);
|
||||
Application.Run (c1);
|
||||
};
|
||||
c1.Ready += () => {
|
||||
c1.Ready += (s, e) => {
|
||||
Assert.Single (Application.MdiChildes);
|
||||
Application.Run (c2);
|
||||
};
|
||||
c2.Ready += () => {
|
||||
c2.Ready += (s, e) => {
|
||||
Assert.Equal (2, Application.MdiChildes.Count);
|
||||
Application.Run (c3);
|
||||
};
|
||||
c3.Ready += () => {
|
||||
c3.Ready += (s, e) => {
|
||||
Assert.Equal (3, Application.MdiChildes.Count);
|
||||
Application.Run (d1);
|
||||
};
|
||||
d1.Ready += () => {
|
||||
d1.Ready += (s, e) => {
|
||||
Assert.Equal (3, Application.MdiChildes.Count);
|
||||
Application.Run (c4);
|
||||
};
|
||||
|
||||
c4.Ready += () => {
|
||||
c4.Ready += (s, e) => {
|
||||
Assert.Equal (4, Application.MdiChildes.Count);
|
||||
// Trying to close the Dialog1
|
||||
d1.RequestStop ();
|
||||
@@ -471,19 +471,19 @@ else Assert.True (Application.Current == top1);
|
||||
// MdiChild = c1, c2, c3
|
||||
var iterations = 3;
|
||||
|
||||
mdi.Ready += () => {
|
||||
mdi.Ready += (s, e) => {
|
||||
Assert.Empty (Application.MdiChildes);
|
||||
Application.Run (c1);
|
||||
};
|
||||
c1.Ready += () => {
|
||||
c1.Ready += (s, e) => {
|
||||
Assert.Single (Application.MdiChildes);
|
||||
Application.Run (c2);
|
||||
};
|
||||
c2.Ready += () => {
|
||||
c2.Ready += (s, e) => {
|
||||
Assert.Equal (2, Application.MdiChildes.Count);
|
||||
Application.Run (c3);
|
||||
};
|
||||
c3.Ready += () => {
|
||||
c3.Ready += (s, e) => {
|
||||
Assert.Equal (3, Application.MdiChildes.Count);
|
||||
c3.RequestStop ();
|
||||
c1.RequestStop ();
|
||||
@@ -532,7 +532,7 @@ else Assert.True (Application.Current == top1);
|
||||
var mdi = new Mdi ();
|
||||
var mdi2 = new Mdi ();
|
||||
|
||||
mdi.Ready += () => {
|
||||
mdi.Ready += (s, e) => {
|
||||
Assert.Throws<InvalidOperationException> (() => Application.Run (mdi2));
|
||||
mdi.RequestStop ();
|
||||
};
|
||||
@@ -553,19 +553,19 @@ else Assert.True (Application.Current == top1);
|
||||
var allStageClosed = false;
|
||||
var mdiRequestStop = false;
|
||||
|
||||
mdi.Ready += () => {
|
||||
mdi.Ready += (s, e) => {
|
||||
Assert.Empty (Application.MdiChildes);
|
||||
Application.Run (logger);
|
||||
};
|
||||
|
||||
logger.Ready += () => Assert.Single (Application.MdiChildes);
|
||||
logger.Ready += (s, e) => Assert.Single (Application.MdiChildes);
|
||||
|
||||
Application.Iteration += () => {
|
||||
if (stageCompleted && running) {
|
||||
stageCompleted = false;
|
||||
var stage = new Window () { Modal = true };
|
||||
|
||||
stage.Ready += () => {
|
||||
stage.Ready += (s, e) => {
|
||||
Assert.Equal (iterations, Application.MdiChildes.Count);
|
||||
stage.RequestStop ();
|
||||
};
|
||||
@@ -578,7 +578,7 @@ else Assert.True (Application.Current == top1);
|
||||
|
||||
var rpt = new Window ();
|
||||
|
||||
rpt.Ready += () => {
|
||||
rpt.Ready += (s, e) => {
|
||||
iterations++;
|
||||
Assert.Equal (iterations, Application.MdiChildes.Count);
|
||||
};
|
||||
@@ -618,26 +618,26 @@ else if (!mdiRequestStop && !running && allStageClosed) {
|
||||
// MdiChild = c1, c2, c3
|
||||
var iterations = 3;
|
||||
|
||||
mdi.Ready += () => {
|
||||
mdi.Ready += (s, e) => {
|
||||
Assert.Empty (Application.MdiChildes);
|
||||
Application.Run (c1);
|
||||
};
|
||||
c1.Ready += () => {
|
||||
c1.Ready += (s, e) => {
|
||||
Assert.Single (Application.MdiChildes);
|
||||
Application.Run (c2);
|
||||
};
|
||||
c2.Ready += () => {
|
||||
c2.Ready += (s, e) => {
|
||||
Assert.Equal (2, Application.MdiChildes.Count);
|
||||
Application.Run (c3);
|
||||
};
|
||||
c3.Ready += () => {
|
||||
c3.Ready += (s, e) => {
|
||||
Assert.Equal (3, Application.MdiChildes.Count);
|
||||
c3.RequestStop ();
|
||||
c2.RequestStop ();
|
||||
c1.RequestStop ();
|
||||
};
|
||||
// Now this will close the MdiContainer when all MdiChildes was closed
|
||||
mdi.AllChildClosed += () => {
|
||||
mdi.AllChildClosed += (s, e) => {
|
||||
mdi.RequestStop ();
|
||||
};
|
||||
Application.Iteration += () => {
|
||||
|
||||
@@ -166,7 +166,7 @@ namespace Terminal.Gui.TopLevelTests {
|
||||
top.Closing += (e) => eventInvoked = "Closing";
|
||||
top.OnClosing (new ToplevelClosingEventArgs (top));
|
||||
Assert.Equal ("Closing", eventInvoked);
|
||||
top.AllChildClosed += () => eventInvoked = "AllChildClosed";
|
||||
top.AllChildClosed += (s, e) => eventInvoked = "AllChildClosed";
|
||||
top.OnAllChildClosed ();
|
||||
Assert.Equal ("AllChildClosed", eventInvoked);
|
||||
top.ChildClosed += (e) => eventInvoked = "ChildClosed";
|
||||
@@ -178,13 +178,13 @@ namespace Terminal.Gui.TopLevelTests {
|
||||
top.Activate += (e) => eventInvoked = "Activate";
|
||||
top.OnActivate (top);
|
||||
Assert.Equal ("Activate", eventInvoked);
|
||||
top.Loaded += () => eventInvoked = "Loaded";
|
||||
top.Loaded += (s, e) => eventInvoked = "Loaded";
|
||||
top.OnLoaded ();
|
||||
Assert.Equal ("Loaded", eventInvoked);
|
||||
top.Ready += () => eventInvoked = "Ready";
|
||||
top.Ready += (s, e) => eventInvoked = "Ready";
|
||||
top.OnReady ();
|
||||
Assert.Equal ("Ready", eventInvoked);
|
||||
top.Unloaded += () => eventInvoked = "Unloaded";
|
||||
top.Unloaded += (s, e) => eventInvoked = "Unloaded";
|
||||
top.OnUnloaded ();
|
||||
Assert.Equal ("Unloaded", eventInvoked);
|
||||
|
||||
@@ -355,7 +355,7 @@ namespace Terminal.Gui.TopLevelTests {
|
||||
|
||||
var top = Application.Top;
|
||||
top.Add (win1, win2);
|
||||
top.Loaded += () => isRunning = true;
|
||||
top.Loaded += (s, e) => isRunning = true;
|
||||
top.Closing += (_) => isRunning = false;
|
||||
Application.Begin (top);
|
||||
top.Running = true;
|
||||
@@ -668,7 +668,7 @@ namespace Terminal.Gui.TopLevelTests {
|
||||
{
|
||||
for (int i = 0; i < 8; i++) {
|
||||
var fd = new FileDialog ();
|
||||
fd.Ready += () => Application.RequestStop ();
|
||||
fd.Ready += (s, e) => Application.RequestStop ();
|
||||
Application.Run (fd);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -268,7 +268,7 @@ namespace Terminal.Gui.TypeTests {
|
||||
w.Add (v);
|
||||
t.Add (w);
|
||||
|
||||
t.Ready += () => {
|
||||
t.Ready += (s, e) => {
|
||||
Assert.Equal (2, w.Width = 2);
|
||||
Assert.Equal (2, w.Height = 2);
|
||||
Assert.Throws<ArgumentException> (() => v.Width = 2);
|
||||
@@ -298,7 +298,7 @@ namespace Terminal.Gui.TypeTests {
|
||||
var w = new Window (new Rect (1, 2, 4, 5), "w");
|
||||
t.Add (w);
|
||||
|
||||
t.Ready += () => {
|
||||
t.Ready += (s, e) => {
|
||||
Assert.Equal (3, w.Width = 3);
|
||||
Assert.Equal (4, w.Height = 4);
|
||||
};
|
||||
@@ -328,7 +328,7 @@ namespace Terminal.Gui.TypeTests {
|
||||
w.Add (v);
|
||||
t.Add (w);
|
||||
|
||||
t.Ready += () => {
|
||||
t.Ready += (s, e) => {
|
||||
v.LayoutStyle = LayoutStyle.Absolute;
|
||||
Assert.Equal (2, v.Width = 2);
|
||||
Assert.Equal (2, v.Height = 2);
|
||||
@@ -419,7 +419,7 @@ namespace Terminal.Gui.TypeTests {
|
||||
w.Add (f1, f2, v1, v2, v3, v4, v5, v6);
|
||||
t.Add (w);
|
||||
|
||||
t.Ready += () => {
|
||||
t.Ready += (s, e) => {
|
||||
Assert.Equal ("Absolute(100)", w.Width.ToString ());
|
||||
Assert.Equal ("Absolute(100)", w.Height.ToString ());
|
||||
Assert.Equal (100, w.Frame.Width);
|
||||
@@ -565,7 +565,7 @@ namespace Terminal.Gui.TypeTests {
|
||||
f.Width = Dim.Width (t) - Dim.Width (v2);
|
||||
f.Height = Dim.Height (t) - Dim.Height (v2);
|
||||
|
||||
t.Ready += () => {
|
||||
t.Ready += (s, e) => {
|
||||
Assert.Equal (80, t.Frame.Width);
|
||||
Assert.Equal (25, t.Frame.Height);
|
||||
Assert.Equal (78, w.Frame.Width);
|
||||
|
||||
@@ -716,7 +716,7 @@ namespace Terminal.Gui.TypeTests {
|
||||
w.Add (v);
|
||||
t.Add (w);
|
||||
|
||||
t.Ready += () => {
|
||||
t.Ready += (s, e) => {
|
||||
Assert.Equal (2, w.X = 2);
|
||||
Assert.Equal (2, w.Y = 2);
|
||||
Assert.Throws<ArgumentException> (() => v.X = 2);
|
||||
@@ -739,7 +739,7 @@ namespace Terminal.Gui.TypeTests {
|
||||
var w = new Window (new Rect (1, 2, 4, 5), "w");
|
||||
t.Add (w);
|
||||
|
||||
t.Ready += () => {
|
||||
t.Ready += (s, e) => {
|
||||
Assert.Equal (2, w.X = 2);
|
||||
Assert.Equal (2, w.Y = 2);
|
||||
};
|
||||
@@ -770,7 +770,7 @@ namespace Terminal.Gui.TypeTests {
|
||||
w.Add (v);
|
||||
t.Add (w);
|
||||
|
||||
t.Ready += () => {
|
||||
t.Ready += (s, e) => {
|
||||
v.LayoutStyle = LayoutStyle.Absolute;
|
||||
Assert.Equal (2, v.X = 2);
|
||||
Assert.Equal (2, v.Y = 2);
|
||||
@@ -812,7 +812,7 @@ namespace Terminal.Gui.TypeTests {
|
||||
f.X = Pos.X (t) + Pos.X (v2) - Pos.X (v1);
|
||||
f.Y = Pos.Y (t) + Pos.Y (v2) - Pos.Y (v1);
|
||||
|
||||
t.Ready += () => {
|
||||
t.Ready += (s, e) => {
|
||||
Assert.Equal (0, t.Frame.X);
|
||||
Assert.Equal (0, t.Frame.Y);
|
||||
Assert.Equal (2, w.Frame.X);
|
||||
|
||||
@@ -495,7 +495,7 @@ namespace Terminal.Gui.ViewTests {
|
||||
newScrollBarView.Refresh ();
|
||||
};
|
||||
|
||||
top.Ready += () => {
|
||||
top.Ready += (s, e) => {
|
||||
newScrollBarView.Position = 45;
|
||||
Assert.Equal (newScrollBarView.Position, newScrollBarView.Size - listView.TopItem + (listView.TopItem - listView.Bounds.Height));
|
||||
Assert.Equal (newScrollBarView.Position, listView.TopItem);
|
||||
@@ -570,7 +570,7 @@ namespace Terminal.Gui.ViewTests {
|
||||
newScrollBarView.Refresh ();
|
||||
};
|
||||
|
||||
top.Ready += () => {
|
||||
top.Ready += (s, e) => {
|
||||
newScrollBarView.Position = 100;
|
||||
Assert.Equal (newScrollBarView.Position, newScrollBarView.Size - listView.LeftItem + (listView.LeftItem - listView.Bounds.Width));
|
||||
Assert.Equal (newScrollBarView.Position, listView.LeftItem);
|
||||
|
||||
Reference in New Issue
Block a user