|
@@ -1,4 +1,8 @@
|
|
|
-namespace UICatalog.Scenarios;
|
|
|
|
|
|
|
+#nullable enable
|
|
|
|
|
+
|
|
|
|
|
+using System.Diagnostics;
|
|
|
|
|
+
|
|
|
|
|
+namespace UICatalog.Scenarios;
|
|
|
|
|
|
|
|
[ScenarioMetadata ("Scrolling", "Content scrolling, IScrollBars, etc...")]
|
|
[ScenarioMetadata ("Scrolling", "Content scrolling, IScrollBars, etc...")]
|
|
|
[ScenarioCategory ("Controls")]
|
|
[ScenarioCategory ("Controls")]
|
|
@@ -6,6 +10,8 @@
|
|
|
[ScenarioCategory ("Tests")]
|
|
[ScenarioCategory ("Tests")]
|
|
|
public class Scrolling : Scenario
|
|
public class Scrolling : Scenario
|
|
|
{
|
|
{
|
|
|
|
|
+ private object? _progressTimer = null;
|
|
|
|
|
+
|
|
|
public override void Main ()
|
|
public override void Main ()
|
|
|
{
|
|
{
|
|
|
Application.Init ();
|
|
Application.Init ();
|
|
@@ -38,10 +44,6 @@ public class Scrolling : Scenario
|
|
|
|
|
|
|
|
app.Add (demoView);
|
|
app.Add (demoView);
|
|
|
|
|
|
|
|
- //// NOTE: This call to EnableScrollBar is technically not needed because the reference
|
|
|
|
|
- //// NOTE: to demoView.HorizontalScrollBar below will cause it to be lazy created.
|
|
|
|
|
- //// NOTE: The call included in this sample to for illustration purposes.
|
|
|
|
|
- //demoView.EnableScrollBar (Orientation.Horizontal);
|
|
|
|
|
var hCheckBox = new CheckBox
|
|
var hCheckBox = new CheckBox
|
|
|
{
|
|
{
|
|
|
X = Pos.X (demoView),
|
|
X = Pos.X (demoView),
|
|
@@ -52,10 +54,6 @@ public class Scrolling : Scenario
|
|
|
app.Add (hCheckBox);
|
|
app.Add (hCheckBox);
|
|
|
hCheckBox.CheckedStateChanged += (sender, args) => { demoView.HorizontalScrollBar.Visible = args.Value == CheckState.Checked; };
|
|
hCheckBox.CheckedStateChanged += (sender, args) => { demoView.HorizontalScrollBar.Visible = args.Value == CheckState.Checked; };
|
|
|
|
|
|
|
|
- //// NOTE: This call to EnableScrollBar is technically not needed because the reference
|
|
|
|
|
- //// NOTE: to demoView.HorizontalScrollBar below will cause it to be lazy created.
|
|
|
|
|
- //// NOTE: The call included in this sample to for illustration purposes.
|
|
|
|
|
- //demoView.EnableScrollBar (Orientation.Vertical);
|
|
|
|
|
var vCheckBox = new CheckBox
|
|
var vCheckBox = new CheckBox
|
|
|
{
|
|
{
|
|
|
X = Pos.Right (hCheckBox) + 3,
|
|
X = Pos.Right (hCheckBox) + 3,
|
|
@@ -96,8 +94,6 @@ public class Scrolling : Scenario
|
|
|
|
|
|
|
|
app.Add (progress);
|
|
app.Add (progress);
|
|
|
|
|
|
|
|
- var pulsing = true;
|
|
|
|
|
-
|
|
|
|
|
app.Initialized += AppOnInitialized;
|
|
app.Initialized += AppOnInitialized;
|
|
|
app.Unloaded += AppUnloaded;
|
|
app.Unloaded += AppUnloaded;
|
|
|
|
|
|
|
@@ -108,17 +104,25 @@ public class Scrolling : Scenario
|
|
|
|
|
|
|
|
return;
|
|
return;
|
|
|
|
|
|
|
|
- void AppOnInitialized (object sender, EventArgs e)
|
|
|
|
|
|
|
+ void AppOnInitialized (object? sender, EventArgs e)
|
|
|
{
|
|
{
|
|
|
bool TimerFn ()
|
|
bool TimerFn ()
|
|
|
{
|
|
{
|
|
|
progress.Pulse ();
|
|
progress.Pulse ();
|
|
|
|
|
|
|
|
- return pulsing;
|
|
|
|
|
|
|
+ return _progressTimer is { };
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- Application.AddTimeout (TimeSpan.FromMilliseconds (200), TimerFn);
|
|
|
|
|
|
|
+ _progressTimer = Application.AddTimeout (TimeSpan.FromMilliseconds (200), TimerFn);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ void AppUnloaded (object? sender, EventArgs args)
|
|
|
|
|
+ {
|
|
|
|
|
+ if (_progressTimer is { })
|
|
|
|
|
+ {
|
|
|
|
|
+ Application.RemoveTimeout (_progressTimer);
|
|
|
|
|
+ _progressTimer = null;
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
- void AppUnloaded (object sender, EventArgs args) { pulsing = false; }
|
|
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|