public bool TryLoadTelemetrySettings(out TelemetrySettingsDto telemetrySettings) { if (_cachedSettings != null) { telemetrySettings = _cachedSettings; return(true); } string fullPathName = Path.Combine(_repositoryDirectory, SettingsFileName); try { using (TextReader file = File.OpenText(fullPathName)) { XmlReader reader = XmlReader.Create(file, new XmlReaderSettings() { CheckCharacters = false }); telemetrySettings = (TelemetrySettingsDto)_xmlSerializer.Deserialize(reader); _cachedSettings = telemetrySettings; } return(true); } catch (Exception ex) { Logger.Error(ex, "Unable to load telemetry settings"); if (File.Exists(fullPathName)) { File.Delete(fullPathName); } telemetrySettings = null; return(false); } }
private void SaveAndClose() { TelemetrySettingsDto newTelemetrySettingsDto = _settingsWindowViewModel.SaveToNewModel(); _telemetrySettingsRepository.SaveTelemetrySettings(newTelemetrySettingsDto); CloseWindow(); }
private void OpenWindow() { TelemetrySettingsDto telemetrySettingsDto = _telemetrySettingsRepository.LoadOrCreateNew(); _settingsWindowViewModel.FromModel(telemetrySettingsDto); _settingsWindowViewModel.IsWindowOpened = true; }
private void SaveAndClose() { TelemetrySettingsDto newTelemetrySettingsDto = _settingsWindowViewModel.SaveToNewModel(); _settingsController.SetTelemetrySettings(newTelemetrySettingsDto, RequestedAction.RefreshCharts); CloseWindow(); }
private void OpenWindow() { TelemetrySettingsDto telemetrySettingsDto = _settingsController.TelemetrySettings; _settingsWindowViewModel.FromModel(telemetrySettingsDto); _settingsWindowViewModel.IsWindowOpened = true; }
public Task StartControllerAsync() { Subscribe(); _telemetrySettingsDto = _telemetrySettings.TelemetrySettings; ReloadGraphCollection(); Graphs.ForEach(InitializeViewModel); return(Task.CompletedTask); }
private void TelemetrySettingsRepositoryOnSettingsChanged(object sender, SettingChangedArgs e) { if (e.RequestedAction != RequestedAction.RefreshCharts) { return; } _telemetrySettingsDto = _telemetrySettings.TelemetrySettings; ReloadGraphCollection(); Graphs.ForEach(InitializeViewModel); }
public Task StartControllerAsync() { _telemetryViewsSynchronization.NewSessionLoaded += TelemetryViewsSynchronizationOnNewSessionLoaded; TelemetrySettings = _telemetrySettingsRepository.LoadOrCreateNew(); if (TelemetrySettings.CarsProperties == null) { TelemetrySettings.CarsProperties = new CarsProperties(); } return(Task.CompletedTask); }
public void SaveTelemetrySettings(TelemetrySettingsDto telemetrySettings) { string fullPathName = Path.Combine(_repositoryDirectory, SettingsFileName); Directory.CreateDirectory(_repositoryDirectory); using (FileStream file = File.Exists(fullPathName) ? File.Open(fullPathName, FileMode.Truncate) : File.Create(fullPathName)) { _xmlSerializer.Serialize(file, telemetrySettings); } _cachedSettings = telemetrySettings; SettingsChanged?.Invoke(this, new EventArgs()); }
private void TelemetrySettingsRepositoryOnSettingsChanged(object sender, EventArgs e) { _telemetrySettingsDto = _telemetrySettingsRepository.LoadOrCreateNew(); ReloadGraphCollection(); Graphs.ForEach(InitializeViewModel); }
public void SetTelemetrySettings(TelemetrySettingsDto telemetrySettings, RequestedAction action) { TelemetrySettings = telemetrySettings; SettingsChanged?.Invoke(this, new SettingChangedArgs(action)); }