private async void Page_LoadedAsync(object sender, RoutedEventArgs e) { _viewModel.appLog.Info(this.GetType().ToString(), "MainPage Loaded."); CoreApplicationViewTitleBar titleBar = CoreApplication.GetCurrentView().TitleBar; titleBar.LayoutMetricsChanged += TitleBar_LayoutMetricsChanged; BackToEmpty(); navigationViewItemForegroundDefault = navigationViewItemDatasets.Foreground; string lastDataset = AppSettingsService.RetrieveFromSettings <string>("WorkingDataset", ""); if (lastDataset != "") { List <Site> siteList = await LocalMetadataService.LoadSitesAsync(); List <Dataset> datasetList = await LocalMetadataService.LoadDatasetsAsync(siteList); Dataset dataset = datasetList.Find(x => x.Name == lastDataset); if (dataset == null) { return; } MessageDialog dlg = new MessageDialog("Do you want to load dataset " + lastDataset + " ?", "Load Dataset"); dlg.Commands.Add(new UICommand("Yes")); dlg.Commands.Add(new UICommand("No")); IUICommand selectedCmd = await dlg.ShowAsync(); if (selectedCmd.Label == "Yes") { MainFrameNavigate(typeof(DatasetViewPage), dataset); } } }
public DatasetEventsPage() { this.InitializeComponent(); sensorIconWidth = AppSettingsService.RetrieveFromSettings <double>("sensorIconWidth", 10); sensorIconHeight = AppSettingsService.RetrieveFromSettings <double>("sensorIconHeight", 10); sensorTextWidth = AppSettingsService.RetrieveFromSettings <double>("sensorTextWidth", 60); sensorTextHeight = AppSettingsService.RetrieveFromSettings <double>("sensorTextHeight", 20); }
private async void Page_LoadedAsync(object sender, RoutedEventArgs e) { PageBusy("Loading events from dataset " + _viewModel.Dataset.Name + " ..."); await _viewModel.LoadDataAsync(); PopulateSensors(); DrawSensors(); PopulateAnnotateFlyout(); // Check Application Settings for last saved states. If the state exists and is valid, load the state ApplicationDataCompositeValue datasetLastSavedStates = AppSettingsService.RetrieveFromSettings <ApplicationDataCompositeValue>( "DatasetLastSavedStates", new ApplicationDataCompositeValue() ); if (datasetLastSavedStates.TryGetValue(_viewModel.Dataset.Name, out object jsonDatasetSavedState)) { DatasetViewSavedState datasetState = JsonConvert.DeserializeObject <DatasetViewSavedState>((string)jsonDatasetSavedState); if (datasetState.Day <= _viewModel.LastEventDate && datasetState.Day >= _viewModel.FirstEventDate) { await _viewModel.LoadEventsAsync(datasetState.Day); } _viewModel.EventViewFilter = datasetState.Filter; _viewModel.RefreshEventsInView(); if (datasetState.EventTimeTag != null) { int i = 0; for (i = 0; i < _viewModel.EventsInView.Count; i++) { SensorEventViewModel sensorEvent = (SensorEventViewModel)_viewModel.EventsInView[i]; if (sensorEvent.TimeTag >= datasetState.EventTimeTag) { _viewModel.SelectedSensorEvent = sensorEvent; break; } } if (i == _viewModel.EventsInView.Count && i != 0) { _viewModel.SelectedSensorEvent = (SensorEventViewModel)_viewModel.EventsInView.Last(); } } else { if (datasetState.EventInView >= 0 && datasetState.EventInView < _viewModel.EventsInView.Count) { _viewModel.SelectedSensorEvent = (SensorEventViewModel)dataListView.Items[datasetState.EventInView]; } } if (_viewModel.SelectedSensorEvent != null) { dataListView.ScrollIntoView(_viewModel.SelectedSensorEvent); } } PageReady(); }
private void App_Suspending(object sender, SuspendingEventArgs e) { AppSettingsService.AddToSettings <string>("WorkingDataset", _viewModel.Dataset.Name); ApplicationDataCompositeValue datasetLastSavedStates = AppSettingsService.RetrieveFromSettings <ApplicationDataCompositeValue>( "DatasetLastSavedStates", new ApplicationDataCompositeValue() ); datasetLastSavedStates[_viewModel.Dataset.Name] = JsonConvert.SerializeObject(new DatasetViewSavedState { Day = _viewModel.CurrentDate, EventInView = dataListView.SelectedIndex, EventTimeTag = (_viewModel.SelectedSensorEvent != null) ? _viewModel.SelectedSensorEvent.TimeTag : _viewModel.CurrentDate, Filter = _viewModel.EventViewFilter }); AppSettingsService.AddToSettings <ApplicationDataCompositeValue>("DatasetLastSavedStates", datasetLastSavedStates); }