summaryrefslogtreecommitdiff
path: root/Xamarin.Forms.Controls/MainPageLifeCycleTests.cs
diff options
context:
space:
mode:
authorE.Z. Hart <hartez@gmail.com>2016-03-29 20:08:26 (GMT)
committerE.Z. Hart <hartez@gmail.com>2016-03-29 20:08:26 (GMT)
commit81cb1d36479ec7d889fade1d53bef34357a73fb9 (patch)
tree061db1acff6446c4a7fce242c4231bb6e19e5a8a /Xamarin.Forms.Controls/MainPageLifeCycleTests.cs
parent57b0f3ab3080928d2ddd2da58fc84ef7023c3651 (diff)
downloadxamarin-forms-81cb1d36479ec7d889fade1d53bef34357a73fb9.zip
xamarin-forms-81cb1d36479ec7d889fade1d53bef34357a73fb9.tar.gz
xamarin-forms-81cb1d36479ec7d889fade1d53bef34357a73fb9.tar.bz2
Make ControlGallery App.cs conform to code style
Diffstat (limited to 'Xamarin.Forms.Controls/MainPageLifeCycleTests.cs')
-rw-r--r--Xamarin.Forms.Controls/MainPageLifeCycleTests.cs75
1 files changed, 75 insertions, 0 deletions
diff --git a/Xamarin.Forms.Controls/MainPageLifeCycleTests.cs b/Xamarin.Forms.Controls/MainPageLifeCycleTests.cs
new file mode 100644
index 0000000..5d14fca
--- /dev/null
+++ b/Xamarin.Forms.Controls/MainPageLifeCycleTests.cs
@@ -0,0 +1,75 @@
+namespace Xamarin.Forms.Controls
+{
+ public class MainPageLifeCycleTests : ContentPage
+ {
+ int _numTimesStarted;
+ int _numTimesSlept;
+ int _numTimesResumed;
+
+ readonly StackLayout _numTimesStartedLayout;
+ readonly StackLayout _numTimesSleptLayout;
+ readonly StackLayout _numTimesResumedLayout;
+
+ public MainPageLifeCycleTests ()
+ {
+ object timesStarted;
+ if (!Application.Current.Properties.TryGetValue ("TimesStarted", out timesStarted)) {
+ Application.Current.Properties["TimesStarted"] = 0;
+ }
+ var numTimesStarted = (int)Application.Current.Properties["TimesStarted"];
+
+
+ object timesSlept;
+ if (!Application.Current.Properties.TryGetValue ("TimesSlept", out timesSlept)) {
+ Application.Current.Properties["TimesSlept"] = 0;
+ }
+ var numTimesSlept = (int)Application.Current.Properties["TimesSlept"];
+
+
+ object timesResumed;
+ if (!Application.Current.Properties.TryGetValue ("TimesResumed", out timesResumed)) {
+ Application.Current.Properties["TimesResumed"] = 0;
+ }
+ var numTimesResumed = (int)Application.Current.Properties["TimesResumed"];
+
+ _numTimesStartedLayout = BuildLabelLayout ("TimesStarted", numTimesStarted);
+ _numTimesSleptLayout = BuildLabelLayout ("TimesSlept", numTimesSlept);
+ _numTimesResumedLayout = BuildLabelLayout ("TimesResumed", numTimesResumed);
+
+ var layout = new StackLayout {
+ Children = {
+ _numTimesStartedLayout,
+ _numTimesSleptLayout,
+ _numTimesResumedLayout
+ }
+ };
+
+ Content = layout;
+ }
+
+ StackLayout BuildLabelLayout (string title, int property)
+ {
+ var labelTitle = new Label {
+ Text = title
+ };
+
+ var valueLabel = new Label {
+ Text = property.ToString ()
+ };
+
+ return new StackLayout {
+ Children = {
+ labelTitle,
+ valueLabel
+ }
+ };
+ }
+
+ public void UpdateLabels ()
+ {
+ ((Label)_numTimesStartedLayout.Children[1]).Text = ((int)Application.Current.Properties["TimesStarted"]).ToString ();
+ ((Label)_numTimesSleptLayout.Children[1]).Text = ((int)Application.Current.Properties["TimesSlept"]).ToString ();
+ ((Label)_numTimesResumedLayout.Children[1]).Text = ((int)Application.Current.Properties["TimesResumed"]).ToString ();
+ }
+ }
+} \ No newline at end of file