private void OnConfigFileClick(object sender, RoutedEventArgs e) { OpenFileDialog fileDialog = new OpenFileDialog { Filter = "YAML Config files (.yaml)|*.yaml", FileName = "config", DefaultExt = ".yaml" }; bool?result = fileDialog.ShowDialog(); if (result.HasValue && result.Value) { try { OctoConfig config = OctoConfig.FromFile(fileDialog.FileName); this.SaveConfig(config); this.TBAddress.Text = config.Address; this.TBPort.Text = config.Port.ToString(); this.TBProcessName.Text = config.ProcessName; this.TBTimeout.Text = config.Timeout.ToString(); this.TBToken.Password = config.Token; this.TBBufferSize.Text = config.BufferSize.ToString(); this.TBCompressionTreshold.Text = config.CompressionThreshold.ToString(); } catch (Exception ex) { ExceptionPopup.ShowException(ex); } } }
private void LoadLastConfig() { if (!File.Exists("last_config.yaml")) { return; } try { OctoConfig config = OctoConfig.FromFile("last_config.yaml"); this.TBAddress.Text = config.Address; this.TBPort.Text = config.Port.ToString(); this.TBProcessName.Text = config.ProcessName; this.TBTimeout.Text = config.Timeout.ToString(); this.TBToken.Password = config.Token; this.TBBufferSize.Text = config.BufferSize.ToString(); this.TBCompressionTreshold.Text = config.CompressionThreshold.ToString(); } catch { File.Delete("last_config.yaml"); } }