// Constructor public MainPage() { InitializeComponent(); LogsModel = new Logs(); MainPageModel = new MainPageModel(); _notifServerApi = App.NotifServerApi; SetNotificationEnabled(false); UiStateToStopped(true); // DataContexts this.ActivitySlider.DataContext = CameraViewfinder.CameraData; this.ActivitySlider.Style = Application.Current.Resources["CustomSliderStyle_Yellow"] as Style; this.CameraTresholdSlider.DataContext = CameraViewfinder.CameraData; // Custom screensaver _screensaverControl = new ScreenSaver(this.LayoutRoot, this.ApplicationBar); // Read Ovi accout id from isolated storage string usernameFromStore; if (ReadUsername(out usernameFromStore)) MainPageModel.OviAccountId = usernameFromStore; // Load sounds StreamResourceInfo alarmStream = Application.GetResourceStream( new Uri("SoundFiles/26173__wim__sirene-06080401.wav", UriKind.RelativeOrAbsolute)); _alarmSound = SoundEffect.FromStream(alarmStream.Stream); StreamResourceInfo waitAlarmSound = Application.GetResourceStream( new Uri("SoundFiles/31841__hardpcm__chip001.wav", UriKind.RelativeOrAbsolute)); _waitAlarmSound = SoundEffect.FromStream(waitAlarmSound.Stream); StreamResourceInfo radioStream = Application.GetResourceStream( new Uri("SoundFiles/30335__erh__radio-noise-2.wav", UriKind.RelativeOrAbsolute)); _radioSound = SoundEffect.FromStream(radioStream.Stream); StreamResourceInfo radioStream2 = Application.GetResourceStream( new Uri("SoundFiles/30623__erh__do-it-now-2.wav", UriKind.RelativeOrAbsolute)); _radioSound2 = SoundEffect.FromStream(radioStream2.Stream); StreamResourceInfo radioStream3 = Application.GetResourceStream( new Uri("SoundFiles/27878__inequation__walkietalkie-eot.wav", UriKind.RelativeOrAbsolute)); _radioSound3 = SoundEffect.FromStream(radioStream3.Stream); StreamResourceInfo radioStream4 = Application.GetResourceStream( new Uri("SoundFiles/34383__erh__walk-away.wav", UriKind.RelativeOrAbsolute)); _radioSound4 = SoundEffect.FromStream(radioStream4.Stream); }
/* * Restore page state * */ private void RestorePageState() { if (State.ContainsKey("MainPageModel")) { MainPageModel = (MainPageModel)State["MainPageModel"]; CameraViewfinder.CameraData.Treshold = MainPageModel.CameraThreshold; this.CameraTresholdSlider.Value = MainPageModel.CameraThreshold; SetNotificationEnabled(MainPageModel.NotificationEnabled); UiStateToStopped(!MainPageModel.NotificationEnabled); State.Remove("MainPageModel"); } }