/// <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); } } }
// Обработка нажатия кнопки в Док. private void btnToDoc_Click(object sender, RoutedEventArgs e) { ExportWindow exportWindow = new ExportWindow(); exportWindow.ShowDialog(); }
private void exportPC(object sender, RoutedEventArgs e) { ExportWindow window = new ExportWindow(); window.ShowDialog(); }
// Save, SaveAs, or Export private void SaveAsButton_Click(object sender, RoutedEventArgs e) { // we should be checking the Loadfile object if (Loadfile == null) { // Get the table name from the command in SQL Console #region Select Ad-Hoc string pattern = @".*\s*FROM\s*(?<tblname>\w*)\s*"; Regex rgx = new Regex(pattern, RegexOptions.IgnoreCase); Match match = rgx.Match(SelectCommandString); CurrentView.TableName = match.Groups["tblname"].Value.ToString(); #endregion string NewLoadfileFilepath = System.IO.Path.Combine( Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments), CurrentView.TableName + "_" + Log.ErrorLog.TimeStamp() + ".dat" ); this.tbFilepath.Text = NewLoadfileFilepath; ConcordanceDat Dat = new ConcordanceDat(NewLoadfileFilepath); Dat.SetFieldNames(this.CurrentView.FieldNamesAsDisplayed); Dat.Save(NewLoadfileFilepath); Dat.Close(); this.Loadfile = Dat; } ExportWindow Ew = null; try { Ew = new ExportWindow(this.Loadfile); Ew.ShowDialog(); } catch (Exception Ex) { Status("Error opening Save dialog with loadfile: " + this.Loadfile.FileInformation.Name + Environment.NewLine + Ex.Message ); } if (Ew.DialogResult == true) { Log.Timer.Start(); // try to make a backup try { // make a backup of the loadfile if (this.Loadfile.FileInformation.FullName.ToUpper() == Ew.OutputFilepath.ToUpper()) { Status("Creating backup of the original loadfile...."); string backupfilename = System.IO.Path.Combine( System.IO.Path.GetDirectoryName(this.Loadfile.FileInformation.FullName), System.IO.Path.GetFileNameWithoutExtension(this.Loadfile.FileInformation.FullName) + "_LFUBACKUP_" + Log.ErrorLog.TimeStamp() + System.IO.Path.GetExtension(this.Loadfile.FileInformation.FullName) ); Log.ErrorLog.AddMessage("Creating backup of " + this.Loadfile.FileInformation.FullName + " as " + backupfilename); // make the copy! File.Copy(this.Loadfile.FileInformation.FullName, backupfilename); Status("Created backup " + backupfilename); } } catch (Exception Ex) { Log.ErrorLog.AddMessage("Error during backup of file: " + this.Loadfile.FileInformation.FullName + Environment.NewLine + Ex.Message + Environment.NewLine + Ex.StackTrace); Status("Error during save of file: " + this.Loadfile.FileInformation.FullName); } // try to save the loadfile try { // we need to save against a select statement and NOT a tablename -ds 09-23-2015 Export.Save(Loadfile, Ew.OutputFilepath, CurrentView.TableName, CurrentView.FieldNamesAsDisplayed, SelectCommandString); Status("Save is complete: " + Ew.OutputFilepath + " (" + Log.Timer.ElapsedTime().ToString() + ")" ); // let's not rename table // -ds 2015-07-17 /*if (Db.Connect.RenameTable(TableName, Db.Connect.GetTableName(Ew.OutputFilepath)) == 1) * { * // change visible path only if we successfully renamed that backing table * this.tbFilepath.Text = Ew.OutputFilepath; * TableName = Db.Connect.GetTableName(this.tbFilepath.Text); * }*/ } catch (Exception Ex) { Log.ErrorLog.AddMessage("Error during save of file: " + this.Loadfile.FileInformation.FullName + Environment.NewLine + Ex.Message + Environment.NewLine + Ex.StackTrace); Status("Error during save of file: " + this.Loadfile.FileInformation.FullName); } } else { Status("Export or Save was cancelled."); } }