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;
        }
예제 #4
0
        private void SaveAndClose()
        {
            TelemetrySettingsDto newTelemetrySettingsDto = _settingsWindowViewModel.SaveToNewModel();

            _settingsController.SetTelemetrySettings(newTelemetrySettingsDto, RequestedAction.RefreshCharts);
            CloseWindow();
        }
예제 #5
0
        private void OpenWindow()
        {
            TelemetrySettingsDto telemetrySettingsDto = _settingsController.TelemetrySettings;

            _settingsWindowViewModel.FromModel(telemetrySettingsDto);
            _settingsWindowViewModel.IsWindowOpened = true;
        }
예제 #6
0
 public Task StartControllerAsync()
 {
     Subscribe();
     _telemetrySettingsDto = _telemetrySettings.TelemetrySettings;
     ReloadGraphCollection();
     Graphs.ForEach(InitializeViewModel);
     return(Task.CompletedTask);
 }
예제 #7
0
 private void TelemetrySettingsRepositoryOnSettingsChanged(object sender, SettingChangedArgs e)
 {
     if (e.RequestedAction != RequestedAction.RefreshCharts)
     {
         return;
     }
     _telemetrySettingsDto = _telemetrySettings.TelemetrySettings;
     ReloadGraphCollection();
     Graphs.ForEach(InitializeViewModel);
 }
예제 #8
0
        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());
        }
예제 #10
0
 private void TelemetrySettingsRepositoryOnSettingsChanged(object sender, EventArgs e)
 {
     _telemetrySettingsDto = _telemetrySettingsRepository.LoadOrCreateNew();
     ReloadGraphCollection();
     Graphs.ForEach(InitializeViewModel);
 }
예제 #11
0
 public void SetTelemetrySettings(TelemetrySettingsDto telemetrySettings, RequestedAction action)
 {
     TelemetrySettings = telemetrySettings;
     SettingsChanged?.Invoke(this, new SettingChangedArgs(action));
 }