/// <summary> /// 导出 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void BtnExport_Click(object sender, RoutedEventArgs e) { if (watchElements == null || watchElements.Count == 0) { MessageBox.Show("没有要导出的表盘元素"); return; } System.Windows.Forms.FolderBrowserDialog folderBrowserDialog = new System.Windows.Forms.FolderBrowserDialog(); if (folderBrowserDialog.ShowDialog() == System.Windows.Forms.DialogResult.OK) { string folder = folderBrowserDialog.SelectedPath; ExportWindow export = new ExportWindow(); export.WatchDescription = new WatchDescription { Screen = resolution == 0 ? "HWHD02" : "HWHD01", Version = resolution == 0 ? "2.1.1" : "3.1.1" }; if (export.ShowDialog() ?? false) { ConfigWriter writer = new ConfigWriter(folder, watchElements, export.WatchDescription); writer.Write(); string res = folder + "/watchface/res/"; SaveToImage(res + "A100_001.png"); SaveToPreviewImage(folder + "/preview/"); Process.Start(folder); } } }
internal static void SaveSettings() { if (Program.settings != null) { ConfigWriter.Write(Program.settings, Program.GetSettingsFilename(), true); } }
/// <summary> /// Click event handler for saving the new config file. Validates prior to saving. Displays the error/save message box. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void SaveFile_Click(object sender, EventArgs e) { try { var formProcessor = new FormProcessor(ContentFlow); var cv = new ConfigValidator(ConfigPath, SchemaPath); if (cv.Validate(true) != 0) { throw new InvalidDataException("XSD-based Validation Failed. Check for errors."); } var cf = new ConfigWriter(ConfigPath); cf.Write(); Saved.Text = "Saved newrelic.config successfully"; Saved.BackColor = Color.FromArgb(244, 144, 0); Saved.Visible = true; _savedTimer.Start(); } catch (Exception ex) { log.Error("01 - " + ex.Message); Saved.Text = ex.Message; Saved.BackColor = Color.DarkRed; Saved.Visible = true; _savedTimer.Start(); } }
private void button_save_Click(object sender, EventArgs e) { if (saveFileDialog1.ShowDialog() == System.Windows.Forms.DialogResult.OK) { ConfigWriter writer = new ConfigWriter(saveFileDialog1.FileName); Config config = BuildConfigFromDataGridView(); writer.Write(config); Geo.Utils.FormUtil.ShowOkAndOpenDirectory(Path.GetDirectoryName(saveFileDialog1.FileName)); } }
public void AssertNewFileIsSameAsOldFile() { var p = new Parser("ConfigFilesForTest/telldus.conf"); var config = p.Parse(); var w = new ConfigWriter("ConfigFilesForTest/test.conf"); w.Write(config); var p2 = new Parser("ConfigFilesForTest/test.conf"); var config2 = p2.Parse(); Assert.Equal(config.Devices.Count, config2.Devices.Count); }
/// <summary> /// Click event handler for saving the new config file to a new location. Validates prior to saving. Displays the error/save message box. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void SaveFileAs_Click(object sender, EventArgs e) { try { var formProcessor = new FormProcessor(ContentFlow); var cv = new ConfigValidator(ConfigPath, SchemaPath); if (cv.Validate(true) != 0) { throw new InvalidDataException("XSD-based Validation Failed. Check for errors."); } var cf = new ConfigWriter(); var safeFile = new SaveFileDialog(); safeFile.Title = "Select the new location for the newrelic.config file"; safeFile.FileName = "newrelic.config"; safeFile.Filter = "config files (*.config)|*.config|All files (*.*)|*.*"; safeFile.FilterIndex = 0; safeFile.RestoreDirectory = true; if (safeFile.ShowDialog() == DialogResult.OK) { cf.Write(safeFile.FileName); } Saved.Text = "Saved newrelic.config successfully"; Saved.BackColor = Color.FromArgb(244, 144, 0); Saved.Visible = true; _savedTimer.Start(); } catch (Exception ex) { log.Error(ex); Saved.Text = ex.Message; Saved.BackColor = Color.DarkRed; Saved.Visible = true; _savedTimer.Start(); } }
private static void StoreConfig(ConfigFile c) { var p = new ConfigWriter("./telldus.conf"); p.Write(c); }