private async void buttonExport_Click(object sender, RoutedEventArgs e) { var model = getModel(); if ((model != null) && (model.Count > 1)) { try { Microsoft.Win32.SaveFileDialog dlg = new Microsoft.Win32.SaveFileDialog(); dlg.DefaultExt = ".tsv"; dlg.Filter = "Tab Separated values (*.tsv)|*.tsv"; Nullable<bool> result = dlg.ShowDialog(); String filename = null; if ((result != null) && result.HasValue && (result.Value == true)) { filename = dlg.FileName; } if (!String.IsNullOrEmpty(filename)){ this.buttonExport.IsEnabled = false; await performExport(model, filename); } } catch (Exception/* ex */) { } this.buttonExport.IsEnabled = true; }//model }
void SetConfigurationMenu(MainWindowViewModel viewModel) { ConfigurationContextMenu.Items.Clear(); foreach (var item in viewModel.Configrations) { ConfigurationContextMenu.Items.Add(new MenuItem { FontSize = 12, Header = item.Item1, Command = item.Item2 }); } ConfigurationContextMenu.Items.Add(new Separator()); var saveCommand = new ReactiveCommand(); saveCommand.Subscribe(_ => { var dialog = new Microsoft.Win32.SaveFileDialog(); dialog.FilterIndex = 1; dialog.Filter = "JSON Configuration|*.json"; dialog.InitialDirectory = System.IO.Path.Combine(System.IO.Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "configuration"); if (dialog.ShowDialog() == true) { var fName = dialog.FileName; if (!fName.EndsWith(".json")) fName = fName + ".json"; viewModel.SaveCurrentConfiguration(fName); viewModel.LoadConfigurations(); SetConfigurationMenu(viewModel); // reset } }); ConfigurationContextMenu.Items.Add(new MenuItem { FontSize = 12, Header = "Save...", Command = saveCommand }); }
public string GetSaveFilePath(string exporttype) { Dictionary<string, string> type = new Dictionary<string, string>() { {"HTML", "HTML|*.html"}, {"TXT", "TXT|*.txt"} }; Microsoft.Win32.SaveFileDialog dlg = new Microsoft.Win32.SaveFileDialog(); dlg.FileName = "accounts"; // Default file name dlg.DefaultExt = type[exporttype].Split('*')[1]; // Default file extension dlg.Filter = type[exporttype]; // Filter files by extension // Show save file dialog box Nullable<bool> result = dlg.ShowDialog(); // Process save file dialog box results if (result == true) { // Save document return dlg.FileName; } else { return null; } }
public override bool Save() { /* * If the file is still undefined, open a save file dialog */ if (IsUnboundNonExistingFile) { var sf = new Microsoft.Win32.SaveFileDialog(); sf.Filter = "All files (*.*)|*.*"; sf.FileName = AbsoluteFilePath; if (!sf.ShowDialog().Value) return false; else { AbsoluteFilePath = sf.FileName; Modified = true; } } try { if (Modified) { Editor.Save(AbsoluteFilePath); lastWriteTime = File.GetLastWriteTimeUtc(AbsoluteFilePath); } } catch (Exception ex) { ErrorLogger.Log(ex); return false; } Modified = false; return true; }
private void btnExport_Click(object sender, RoutedEventArgs e) { var dlg = new Microsoft.Win32.SaveFileDialog(); dlg.DefaultExt = "xlsx"; dlg.Filter = "Excel Workbook (*.xlsx)|*.xlsx|" + "HTML File (*.htm;*.html)|*.htm;*.html|" + "Comma Separated Values (*.csv)|*.csv|" + "Text File (*.txt)|*.txt"; if (dlg.ShowDialog() == true) { var ext = System.IO.Path.GetExtension(dlg.SafeFileName).ToLower(); ext = ext == ".htm" ? "ehtm" : ext == ".html" ? "ehtm" : ext; switch (ext) { case "ehtm": { C1FlexGrid1.Save(dlg.FileName, C1.WPF.FlexGrid.FileFormat.Html, SaveOptions.Formatted); break; } case ".csv": { C1FlexGrid1.Save(dlg.FileName, C1.WPF.FlexGrid.FileFormat.Csv, SaveOptions.Formatted); break; } case ".txt": { C1FlexGrid1.Save(dlg.FileName, C1.WPF.FlexGrid.FileFormat.Text, SaveOptions.Formatted); break; } default: { Save(dlg.FileName,C1FlexGrid1); break; } } } }
private void MenuItem_Click_2(object sender, RoutedEventArgs e) { Microsoft.Win32.SaveFileDialog dlg = new Microsoft.Win32.SaveFileDialog(); dlg.FileName = "NewFile"; dlg.DefaultExt = ".txt"; dlg.Filter = "Text document (.txt)|*.txt"; Nullable<bool> result = dlg.ShowDialog(); if (result == true) { filename = dlg.FileName; } try { FileStream fs = new FileStream(filename, FileMode.Create); StreamWriter outstr = new StreamWriter(fs); outstr.Write(textBox1.Text); outstr.Close(); fs.Close(); } catch (Exception error) { MessageBox.Show(error.ToString()); } }
public static void SaveAsImage(FrameworkElement visual) { Microsoft.Win32.SaveFileDialog dlg = new Microsoft.Win32.SaveFileDialog(); dlg.DefaultExt = ".png"; dlg.Filter = "PNG Image (.png)|*.png|JPEG Image (.jpg)|*.jpg"; if (dlg.ShowDialog().Value) { BitmapSource img = (BitmapSource)ToImageSource(visual); FileStream stream = new FileStream(dlg.FileName, FileMode.Create); BitmapEncoder encoder = null; // new BitmapEncoder(); if (dlg.SafeFileName.ToLower().EndsWith(".png")) { encoder = new PngBitmapEncoder(); } else { encoder = new JpegBitmapEncoder(); } encoder.Frames.Add(BitmapFrame.Create(img)); encoder.Save(stream); stream.Close(); } }
/// <summary> /// ドロップ情報をCSVに出力する /// </summary> /// <param name="dropList"></param> public static void OutputCsv(List<DatDropData> dropList) { if (dropList.Count == 0) { MessageBox.Show("ドロップ情報が0件のため、処理を中止します。"); return; } Microsoft.Win32.SaveFileDialog dlg = new Microsoft.Win32.SaveFileDialog(); //保存先の初期値(マイドキュメント) dlg.InitialDirectory = System.Environment.GetFolderPath(Environment.SpecialFolder.Personal); dlg.Title = "保存先のファイルを選択してください"; dlg.FileName = "ドロップ情報"; dlg.Filter = "CSVファイル(*.csv)|*.csv"; if (dlg.ShowDialog() == true) { try { using (var sw = new System.IO.StreamWriter(dlg.FileName, false, System.Text.Encoding.GetEncoding("Shift_JIS"))) { //ダブルクォーテーションで囲む Func<string, string> dqot = (str) => { return "\"" + str.Replace("\"", "\"\"") + "\""; }; foreach (DatDropData d in dropList) sw.WriteLine(dqot(d.DropWinDecision) + "," + dqot(d.DropKanmusuName)); } MessageBox.Show("保存しました。"); } catch (SystemException ex) { MessageBox.Show(ClsConst.ErrorMessage); ClsLogWrite.LogWrite("CSV出力中にエラーが起きました。",ex); } } }
private void OnCommand() { // Configure open file dialog box Microsoft.Win32.SaveFileDialog dlg = new Microsoft.Win32.SaveFileDialog(); dlg.FileName = _viewModel.Workspace.Path; // Default file name dlg.DefaultExt = ".jws"; // Default file extension dlg.Filter = "Jade Workspace files (.jws)|*.jws"; // Filter files by extension dlg.CheckFileExists = true; dlg.CheckPathExists = true; // Show open file dialog box Nullable<bool> result = dlg.ShowDialog(); // Process open file dialog box results if (result == true) { // Open document string filename = dlg.FileName; try { JadeData.Workspace.IWorkspace workspace = JadeData.Persistence.Workspace.Reader.Read(filename); _viewModel.Workspace = new JadeControls.Workspace.ViewModel.Workspace(workspace); } catch (System.Exception e) { } } }
private void NewRAWRItem_Click(object sender, RoutedEventArgs e) { // Open a file chooser to choose where to put the RAWR system Microsoft.Win32.SaveFileDialog dlg = new Microsoft.Win32.SaveFileDialog(); dlg.FileName = "RAWR"; dlg.DefaultExt = ".img"; dlg.Filter = "Virtual Image Files (.img)|*.img"; dlg.Title = "Create New RAWR Virtual Disc"; // Show file chooser Nullable<bool> result = dlg.ShowDialog(); // Format the RAWR system on selected filename if selected if (result == true) { // Show my progress window of formatting my RAWR filesystem pgFormatRAWR.Show(); // Create a BackgroundWorker that will create my RAWR file system BackgroundWorker rawrWriter = new BackgroundWorker(); rawrWriter.DoWork += new DoWorkEventHandler(rawrWriter_DoWork); rawrWriter.ProgressChanged += new ProgressChangedEventHandler(rawrWriter_ProgressChanged); rawrWriter.RunWorkerCompleted += new RunWorkerCompletedEventHandler(rawrWriter_RunWorkerCompleted); rawrWriter.WorkerReportsProgress = true; rawrWriter.RunWorkerAsync(dlg.FileName); // Passing in my file name to the worker } }
private void _btnSave_Click(object sender, RoutedEventArgs e) { var dlg = new Microsoft.Win32.SaveFileDialog(); dlg.DefaultExt = ".csv"; dlg.Filter = "Comma Separated Values (*.csv)|*.csv|" + "Plain text (*.txt)|*.txt|" + "HTML (*.html)|*.html"; if (dlg.ShowDialog() == true) { // select format based on file extension var fileFormat = FileFormat.Csv; switch (System.IO.Path.GetExtension(dlg.SafeFileName).ToLower()) { case ".htm": case ".html": fileFormat = FileFormat.Html; break; case ".txt": fileFormat = FileFormat.Text; break; } // save the file using (var stream = dlg.OpenFile()) { _flex.Save(stream, fileFormat); } } }
// Save the program using a configurable location public void SaveUserInput(string subfolder) { // create folder if it don't exist like string store = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) + "\\WooFractal\\Scripts" + "\\" + subfolder; if (!System.IO.Directory.Exists(store)) { System.IO.Directory.CreateDirectory(store); } // Configure save file dialog box Microsoft.Win32.SaveFileDialog dlg = new Microsoft.Win32.SaveFileDialog(); dlg.FileName = subfolder + "script"; // Default file name dlg.DefaultExt = ".woo"; // Default file extension dlg.Filter = "WooScript|*.woo"; // Filter files by extension dlg.InitialDirectory = store; // Show save file dialog box Nullable<bool> result = dlg.ShowDialog(); // Process save file dialog box results if (result == true) { string filename = dlg.FileName; StreamWriter sw = new StreamWriter(filename); sw.Write(_Program); sw.Close(); } }
public bool Execute() { SaveFileDialog dialog = new SaveFileDialog(); dialog.FileName = "export.csv"; dialog.Filter = "*.csv|*.csv|All files|*.*"; if (dialog.ShowDialog() == true) { try { using (TextWriter writer = File.CreateText(dialog.FileName)) { writer.WriteLine("File,Time,TimeDif"); for (int i = 0; i < ServiceProvider.Settings.DefaultSession.Files.Count; i++) { var file = ServiceProvider.Settings.DefaultSession.Files[i]; writer.WriteLine("{0},{1},{2}", file.FileName, file.FileDate.ToString("O"), (i > 0 ? Math.Round( (file.FileDate - ServiceProvider.Settings.DefaultSession.Files[i - 1].FileDate) .TotalMilliseconds, 0) : 0)); } PhotoUtils.Run(dialog.FileName); } } catch (Exception ex) { MessageBox.Show("Error to export " + ex.Message); Log.Error("Error to export ", ex); } } return true; }
private void button2_Click(object sender, RoutedEventArgs e) { if (listBox1.SelectedItem != null) { Microsoft.Win32.SaveFileDialog dialog = new Microsoft.Win32.SaveFileDialog(); dialog.FileName = "Блок " + block_index + " запись " + (listBox1.SelectedIndex + 1); //dialog.DefaultExt = "."; dialog.Filter = "Все файлы (*.*)|*.*"; dialog.Title = "Выберите файл для сохранения данных"; Nullable<bool> result = dialog.ShowDialog(); if (result == true) { selected_record = links[listBox1.SelectedIndex]; file2save = dialog.FileName; Thread saving = new Thread(save_thread); saving.Start(); } else { addText("\n" + get_time() + " Не выбран файл для сохранения."); } } else addText("\n" + get_time() + " Не выбрана запись для сохранения."); }
public static void saveSlides(Microsoft.Office.Interop.PowerPoint.Presentation presentation) { string desktopPath = Environment.GetFolderPath(Environment.SpecialFolder.Desktop); //string path = Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location); string filePath = desktopPath + "\\Slides.pptx"; // Microsoft.Office.Interop.PowerPoint.FileConverter fc = new Microsoft.Office.Interop.PowerPoint.FileConverter(); // if (fc.CanSave) { } //https://msdn.microsoft.com/en-us/library/system.windows.forms.savefiledialog(v=vs.110).aspx //Browse Files Microsoft.Win32.SaveFileDialog dlg = new Microsoft.Win32.SaveFileDialog(); dlg.InitialDirectory = desktopPath+"\\Scano"; dlg.DefaultExt = ".pptx"; dlg.Filter = "PPTX Files (*.pptx)|*.pptx"; Nullable<bool> result = dlg.ShowDialog(); // Get the selected file name and display in a TextBox if (result == true) { // Open document filePath = dlg.FileName; //textBox1.Text = filename; } else { System.Console.WriteLine("Couldn't show the dialog."); } presentation.SaveAs(filePath, Microsoft.Office.Interop.PowerPoint.PpSaveAsFileType.ppSaveAsOpenXMLPresentation, Microsoft.Office.Core.MsoTriState.msoTriStateMixed); System.Console.WriteLine("PowerPoint application saved in {0}.", filePath); }
private void btnAddNew_Click(object sender, RoutedEventArgs e) { // Create OpenFileDialog var dlg = new Microsoft.Win32.SaveFileDialog(); // Set filter for file extension and default file extension dlg.DefaultExt = ".mdb"; dlg.Filter = "TestFrame Databases (.mdb)|*.mdb"; // Display OpenFileDialog by calling ShowDialog method Nullable<bool> result = dlg.ShowDialog(); // Get the selected file name and display in a TextBox if (result == true) { // Open document string filename = dlg.FileName; string shortname = Globals.InputBox("Enter shortname for database:"); Parallel.Invoke( () => { TFDBManager.NewDatabase(shortname, filename); }); FillList(); listDatabases.SelectedValue = shortname; } }
private async void ExportEventLogButton_Click(object sender, RoutedEventArgs e) { XDocument doc = new XDocument( new XDeclaration("1.0", "UTF-8", "true"), new XElement("LogEntries", from entry in (this.DataContext as MainViewModel).LogEntries select new XElement("LogEntry", new XElement("Date", entry.EventDateTimeUTC), new XElement("Type", entry.Level), new XElement("DeploymentId", entry.DeploymentId), new XElement("Role", entry.Role), new XElement("Instance", entry.RoleInstance), new XElement("Message", entry.Message) ) ) ); // Configure save file dialog box Microsoft.Win32.SaveFileDialog dlg = new Microsoft.Win32.SaveFileDialog(); dlg.FileName = "Export.xml"; // Show save file dialog box if (dlg.ShowDialog() == true) { doc.Save(dlg.FileName); } }
public string GetFileSavePath(string title, string defaultExt, string filter) { if (VistaSaveFileDialog.IsVistaFileDialogSupported) { VistaSaveFileDialog saveFileDialog = new VistaSaveFileDialog(); saveFileDialog.Title = title; saveFileDialog.DefaultExt = defaultExt; saveFileDialog.CheckFileExists = false; saveFileDialog.RestoreDirectory = true; saveFileDialog.Filter = filter; if (saveFileDialog.ShowDialog() == true) return saveFileDialog.FileName; } else { Microsoft.Win32.SaveFileDialog ofd = new Microsoft.Win32.SaveFileDialog(); ofd.Title = title; ofd.DefaultExt = defaultExt; ofd.CheckFileExists = false; ofd.RestoreDirectory = true; ofd.Filter = filter; if (ofd.ShowDialog() == true) return ofd.FileName; } return ""; }
private void btnExportToPdf_Click(object sender, System.Windows.RoutedEventArgs e) { Model.Patient selectedPatient = GetSelectedPatient(); if (selectedPatient != null) { try { // Configure save file dialog box Microsoft.Win32.SaveFileDialog dlg = new Microsoft.Win32.SaveFileDialog(); dlg.FileName = selectedPatient.FullName + "_" + DateTime.Now.ToString("dd-MMMM-yyyy"); // Default file name dlg.DefaultExt = ".pdf"; // Default file extension dlg.Filter = "Text documents (.pdf)|*.pdf"; // Filter files by extension if (dlg.ShowDialog() == true) { ExportToPdf(dlg.FileName, selectedPatient); MessageBox.Show("PDF generado", "Información", MessageBoxButton.OK, MessageBoxImage.Information); } } catch (Exception ex) { MessageBox.Show("No se pudo generar el PDF.\n\n Detalle del error:\n" + ex.Message, "Error", MessageBoxButton.OK, MessageBoxImage.Error); } } }
bool zapis_zawartosci(byte[] zawartosc) { var dlg = new Microsoft.Win32.SaveFileDialog(); // Set filter for file extension and default file extension // Display OpenFileDialog by calling ShowDialog method Nullable<bool> result = dlg.ShowDialog(); // Get the selected file name and display in a TextBox if (result == true) { // Open document filename = dlg.FileName; var file = File.Open(filename, FileMode.OpenOrCreate); var plik = new BinaryWriter(file); plik.Write(zawartosc); plik.Close(); return true; } else { MessageBox.Show("Problem z zapisaniem pliku"); return false; } }
private void ExportCards() { var dlg = new Microsoft.Win32.SaveFileDialog(); dlg.FileName = "Scrum Cards.xps"; dlg.DefaultExt = ".xps"; dlg.Filter = "XPS Documents (.xps)|*.xps"; dlg.OverwritePrompt = true; var result = dlg.ShowDialog(); if (result == false) return; var document = GenerateDocument(); var filename = dlg.FileName; if (File.Exists(filename)) File.Delete(filename); using (var xpsd = new XpsDocument(filename, FileAccess.ReadWrite)) { var xw = XpsDocument.CreateXpsDocumentWriter(xpsd); xw.Write(document); xpsd.Close(); } }
private void btnDestination_Click(object sender, RoutedEventArgs e) { var saveFileDialog = new Microsoft.Win32.SaveFileDialog(); saveFileDialog.FileName = "Select File to Convert"; Nullable<bool> result = saveFileDialog.ShowDialog(); if (result == true) { entDestination.Text = saveFileDialog.FileName.ToLower(); if (!(entDestination.Text.EndsWith(".shp") || entDestination.Text.EndsWith(".kml"))) { entDestination.Text = "Extension Must be SHP or KML"; btnConvert.IsEnabled = false; } else { if (entSource.Text.EndsWith(".shp") || entSource.Text.EndsWith(".kml")) { btnConvert.IsEnabled = true; } } } }
public string GetFileSavePath(string title, string defaultExt, string filter) { if (VistaFileDialog.IsVistaFileDialogSupported) { var saveFileDialog = new VistaSaveFileDialog { Title = title, DefaultExt = defaultExt, CheckFileExists = false, RestoreDirectory = true, Filter = filter }; if (saveFileDialog.ShowDialog() == true) return saveFileDialog.FileName; } else { var ofd = new Microsoft.Win32.SaveFileDialog { Title = title, DefaultExt = defaultExt, CheckFileExists = false, RestoreDirectory = true, Filter = filter }; if (ofd.ShowDialog() == true) return ofd.FileName; } return ""; }
public static Boolean DumpDataToFile(object data) { if (data != null) { // Configure save file dialog box Microsoft.Win32.SaveFileDialog dlg = new Microsoft.Win32.SaveFileDialog(); dlg.FileName = "calibrate_rawdatadump"; // Default file name dlg.DefaultExt = ".csv"; // Default file extension dlg.Filter = "CSV documents (.csv)|*.csv|XML documents (.xml)|*.xml"; // Filter files by extension // Show save file dialog box Nullable<bool> result = dlg.ShowDialog(); // Process save file dialog box results if (result == true) { if (Path.GetExtension(dlg.FileName).ToLower() == ".csv") { return DataDumper.ToCsv(dlg.FileName, data); } else { return DataDumper.ToXml(dlg.FileName, data); } } } return false; }
public static void SaveImageCapture(BitmapSource bitmap) { var encoder = new JpegBitmapEncoder(); encoder.Frames.Add(BitmapFrame.Create(bitmap)); encoder.QualityLevel = 100; // Configure save file dialog box var dlg = new Microsoft.Win32.SaveFileDialog { FileName = "Image", DefaultExt = ".Jpg", Filter = "Image (.jpg)|*.jpg" }; // Show save file dialog box var result = dlg.ShowDialog(); // Process save file dialog box results if (result == true) { // Save Image string filename = dlg.FileName; var fstream = new FileStream(filename, FileMode.Create); encoder.Save(fstream); fstream.Close(); } }
/// <summary> /// Presents the user with a folder browser dialog. /// </summary> /// <param name="filter">Filename filter for if the OS doesn't support a folder browser.</param> /// <returns>Full path the user selected.</returns> private static string ShowFolderBrowser(string filter) { bool cancelled = false; string path = null; if (VistaFolderBrowserDialog.IsVistaFolderDialogSupported) { var dlg = new VistaFolderBrowserDialog(); cancelled = !(dlg.ShowDialog() ?? false); if (!cancelled) { path = Path.GetFullPath(dlg.SelectedPath); } } else { var dlg = new Microsoft.Win32.SaveFileDialog(); dlg.Filter = filter; dlg.FilterIndex = 1; cancelled = !(dlg.ShowDialog() ?? false); if (!cancelled) { path = Path.GetFullPath(Path.GetDirectoryName(dlg.FileName)); // Discard whatever filename they chose } } return path; }
/// <summary> /// Initializes a new instance of the <see cref="ScratchpadControl"/> class. /// </summary> public ScratchpadControl() { this.InitializeComponent(); mDlgOpen = new Microsoft.Win32.OpenFileDialog {Filter = "Text files (*.txt)|*.txt"}; mDlgSave = new Microsoft.Win32.SaveFileDialog { Filter = "Text file (*.txt)|*.txt", //REMOVE IN RELEASE InitialDirectory = @"D:\Applications\Workspace\Cpp\" }; contentPath = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "\\ScratchPadExtension"; Directory.CreateDirectory(contentPath); contentPath += "\\currContent.txt"; //Make config file if doesn't exist if (!File.Exists(contentPath)) { File.WriteAllText(contentPath, ""); } // Set timer to save file contents no more often than once every 30 seconds and only after modification dispatcherTimer = new System.Windows.Threading.DispatcherTimer(); dispatcherTimer.Tick += dispatcherTimer_Tick; dispatcherTimer.Interval = new TimeSpan(0, 0, 30); //Read file path of last content ScratchBox.Text = File.ReadAllText(contentPath); }
public void Execute(CommandContext ctx) { Microsoft.Win32.SaveFileDialog dlg = new Microsoft.Win32.SaveFileDialog(); string defaultFileName = string.Format("RegexTester_{0}", DateTime.Now.ToString("yyyy_MM_dd__HH_mm_ss")); dlg.FileName = defaultFileName; dlg.DefaultExt = ".txt"; dlg.Filter = "Text documents (.txt)|*.txt"; Nullable<bool> result = dlg.ShowDialog(); if (result == true) { string fileName = dlg.FileName; StringBuilder sb = new StringBuilder(); sb.Append("Regex Tester: version=").AppendLine(GetVersion()) .AppendLine(new String('-', 40)) .Append("REGEX MODE: ").AppendLine(ctx.RegexMode.ToString()) .Append("REGEX OPTIONS: ").AppendLine(ctx.RegexOptions.ToString()) .Append("INPUT REGEX: ").AppendLine(ctx.InputRegex) .Append("INPUT FORMAT: ").AppendLine(ctx.InputFormat) .AppendLine(string.Format("{0}INPUT TEXT{1}", PREFIX, POSTFIX)) .AppendLine(ctx.InputText) .AppendLine(string.Format("{0}OUTPUT TEXT{1}", PREFIX, POSTFIX)) .Append(ctx.OutputText); File.WriteAllText(fileName, sb.ToString(), Encoding.UTF8); } }
/// <summary> /// Scripter: YONGTOK KIM /// Description : Save the image to the file. /// </summary> public static string SaveImageCapture(BitmapSource bitmap) { JpegBitmapEncoder encoder = new JpegBitmapEncoder(); encoder.Frames.Add(BitmapFrame.Create(bitmap)); encoder.QualityLevel = 100; // Configure save file dialog box Microsoft.Win32.SaveFileDialog dlg = new Microsoft.Win32.SaveFileDialog(); dlg.FileName = "Image"; // Default file name dlg.DefaultExt = ".Jpg"; // Default file extension dlg.Filter = "Image (.jpg)|*.jpg"; // Filter files by extension // Show save file dialog box Nullable<bool> result = dlg.ShowDialog(); // Process save file dialog box results if (result == true) { // Save Image string filename = dlg.FileName; FileStream fstream = new FileStream(filename, FileMode.Create); encoder.Save(fstream); fstream.Close(); return filename; } return null; }
public void SaveCurrentDocument() { // Configure save file dialog box var dlg = new Microsoft.Win32.SaveFileDialog { FileName = "Faktura", DefaultExt = ".xps", Filter = "XPS Documents (.xps)|*.xps" }; // Show save file dialog box Nullable<bool> result = dlg.ShowDialog(); // Process save file dialog box results if (result == true) { // Save document string filename = dlg.FileName; FixedDocument doc = CreateMyWPFControlReport(); File.Delete(filename); var xpsd = new XpsDocument(filename, FileAccess.ReadWrite); XpsDocumentWriter xw = XpsDocument.CreateXpsDocumentWriter(xpsd); xw.Write(doc); xpsd.Close(); } }
private void MoonPhases(object sender, RoutedEventArgs e) { // WriteAllText creates a file, writes the specified string to the file, // and then closes the file. You do NOT need to call Flush() or Close(). // System.IO.File.WriteAllText(@"C:\Works\MoonSun\MoonSunText.txt", result.Text); TheMoonAndSun.MainWindow w = new TheMoonAndSun.MainWindow(); Microsoft.Win32.SaveFileDialog saveFileDialog1 = new Microsoft.Win32.SaveFileDialog(); saveFileDialog1.FileName = w.Location.Text + "Moon Phases"; // Default file name saveFileDialog1.DefaultExt = ".text"; // Default file extension saveFileDialog1.Filter = "Text documents (.txt)|*.txt"; // Filter files by extension // Show save file dialog box Nullable <bool> resultBox = saveFileDialog1.ShowDialog(); // Process save file dialog box results if (resultBox == true) { // Save document string filename = saveFileDialog1.FileName; System.IO.File.WriteAllText(saveFileDialog1.FileName, moonPhaseResult.Text); } }
private void SaveFile(object sender, RoutedEventArgs e) { if (filepath == null) { Microsoft.Win32.SaveFileDialog dlg = new Microsoft.Win32.SaveFileDialog(); dlg.FileName = "Document"; // Default file name dlg.DefaultExt = ".text"; // Default file extension dlg.Filter = "Text documents (.txt)|*.txt"; // Filter files by extension // Show save file dialog box Nullable <bool> result = dlg.ShowDialog(); // Process save file dialog box results if (result == true) { // Save document string filename = dlg.FileName; System.IO.File.WriteAllText(filename, editorFile.Text); } } else { System.IO.File.WriteAllText(filepath, editorFile.Text); } }
private void mnuExport_Click(object sender, RoutedEventArgs e) { if (listView.SelectedIndex == -1) { return; } Microsoft.Win32.SaveFileDialog ofd = new Microsoft.Win32.SaveFileDialog { DefaultExt = ".reg", Filter = "Importing Registration Entries|*.reg" }; if (ofd.ShowDialog() != true) { return; } if (ofd.FileName == "") { return; } var Items = listView.SelectedItems.Cast <IFEOItem>(); IFEO.Export(Items, ofd.FileName); }
/// <summary> /// 另存为 /// </summary> private void SaveAs(Object para) { string fullName = $"{ this._targeModel.Content}"; if (File.Exists(fullName)) { Microsoft.Win32.SaveFileDialog dlg = new Microsoft.Win32.SaveFileDialog(); dlg.FileName = System.IO.Path.GetFileName(fullName); // Default file name dlg.DefaultExt = System.IO.Path.GetExtension(fullName); // fileName.Split('.').LastOrDefault(); // Default file extension dlg.Filter = string.Format("文件 (.{0})|*.{0}", dlg.DefaultExt); // // Filter files by extension dlg.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory); if (dlg.ShowDialog() == true) { File.Copy(fullName, dlg.FileName, true); } } else { AppData.MainMV.TipMessage = "文件不存在!"; } }
public void GenerateDocument() { Microsoft.Win32.SaveFileDialog dlg = new Microsoft.Win32.SaveFileDialog(); dlg.DefaultExt = ".docx"; dlg.Filter = "Word documents (.docx)|*.docx"; Nullable <bool> result = dlg.ShowDialog(); if (result == true) { //try //{ string filename = dlg.FileName; DocManp d = new DocManp(); d.CreateDoc(_inputs, FileName.Text, filename); System.Diagnostics.Process.Start(filename); //} //catch (Exception ex) //{ // Logger.Log(ex); //} } DownloadButton.Visibility = Visibility.Hidden; }
/// <summary> /// Open the Save File Browser Dialog with the given settings /// </summary> /// <param name="fileName">Default filename</param> /// <param name="defaultExt">Default extension</param> /// <param name="filter">Files to filter</param> /// <param name="initialDirectory">Intitial directory</param> /// <returns>Return the path of the file to save, null if none</returns> public static string SaveFileDialog(string fileName, string defaultExt, string filter, string initialDirectory) { if (initialDirectory == null) { initialDirectory = string.Empty; } Microsoft.Win32.FileDialog saveDialog = new Microsoft.Win32.SaveFileDialog { InitialDirectory = initialDirectory, Filter = filter, FileName = fileName, DefaultExt = defaultExt, }; bool?result = saveDialog.ShowDialog(); if (result == true) { return(saveDialog.FileName); } return(null); }
private void Dump_Click(object sender, RoutedEventArgs e) { if (string.IsNullOrEmpty(m_selectedTable)) { return; } var dialog = new Microsoft.Win32.SaveFileDialog(); dialog.FileName = "db.xml"; dialog.DefaultExt = "xml"; dialog.Filter = "XML (*.xml)|*.xml|All Files (*.*)|*.*"; dialog.OverwritePrompt = false; bool?result = dialog.ShowDialog(); if (result.HasValue && result.Value) { using (var output = new System.IO.FileStream(dialog.FileName, System.IO.FileMode.OpenOrCreate)) { m_viewModel.DumpTable(m_selectedTable, output); } } }
private void BtnExport2007_OnClick(object sender, RoutedEventArgs e) { try { var dlg = new Microsoft.Win32.SaveFileDialog() { FileName = "工作簿1", DefaultExt = ".xlsx", Filter = "Excel 工作簿(*.xlsx)|*.xlsx", }; if (dlg.ShowDialog() == true) { var dt = DataContext as DataTable; ExcelService.ExportDataTableToExcel2007(dt, dlg.FileName, "Sheet"); ShowSubViewNotification(new NotificationMessage("导出成功")); } } catch (Exception ex) { Log.Error(ex); ShowSubViewNotification(new NotificationMessage("导出失败")); } }
private void Save_to_txt_Click(object sender, RoutedEventArgs e) { var SaveJSONFileDialog = new Microsoft.Win32.SaveFileDialog() { Filter = "文本文件|*.txt" }; var result = SaveJSONFileDialog.ShowDialog(); if (result == true) { string File_path = SaveJSONFileDialog.FileName; file_info[0] = "txt"; file_info[1] = File_path.Substring(0, File_path.LastIndexOf('.')); MenuItem file_path_object = new MenuItem { Header = File_path, Height = 30, Name = "file_history" }; file_path_object.Click += new RoutedEventHandler(Open_history_path_text_Click); open_whitelist_text.Items.Add(file_path_object); Title = file_info[0] + ">" + File_path; TextRange textRange = new TextRange(inputName.Document.ContentStart, inputName.Document.ContentEnd); File.WriteAllText(file_info[1] + ".txt", textRange.Text); MessageBox.Show($"已保存到{file_info[1]}.txt"); } }
private void SaveMapBtn_Click(object sender, RoutedEventArgs e) { Microsoft.Win32.SaveFileDialog saveFileDlg = new Microsoft.Win32.SaveFileDialog(); saveFileDlg.Title = "Save Map"; saveFileDlg.Filter = "Map Documents|*.mxd|All Files|*.*"; saveFileDlg.RestoreDirectory = true; saveFileDlg.OverwritePrompt = true; saveFileDlg.AddExtension = true; //get the layer name from the user Nullable <bool> result = saveFileDlg.ShowDialog(); string sFilePath = saveFileDlg.FileName; if (sFilePath != "" && result == true) { if (System.IO.File.Exists(sFilePath)) { System.IO.File.Delete(sFilePath); } this.mapMgr.SaveMap(sFilePath); } }
private void BtnExportPDF_OnClick(object sender, RoutedEventArgs e) { try { var dlg = new Microsoft.Win32.SaveFileDialog() { FileName = "工作簿1", DefaultExt = ".pdf", Filter = "PDF (*.pdf)|*.pdf", }; if (dlg.ShowDialog() == true) { var dt = DataContext as DataTable; PdfService.ExportDataTable(dt, dlg.FileName); ShowSubViewNotification(new NotificationMessage("导出成功")); } } catch (Exception ex) { Log.Error(ex); ShowSubViewNotification(new NotificationMessage("导出失败")); } }
private void Button_Click_5(object sender, RoutedEventArgs e) { Microsoft.Win32.SaveFileDialog dlg = new Microsoft.Win32.SaveFileDialog(); dlg.FileName = ""; // Default file name dlg.DefaultExt = ".gwf"; // Default file extension dlg.Filter = "GSAKWrapper Flows (.gwf)|*.gwf"; // Filter files by extension // Show open file dialog box Nullable <bool> result = dlg.ShowDialog(); // Process open file dialog box results if (result == true) { try { System.IO.File.WriteAllText(dlg.FileName, Settings.Settings.Default.ActionBuilderFlowsXml ?? ""); } catch { System.Windows.MessageBox.Show("Unable to save the file.", "Error"); } } }
private void saveasxml(object sender, RoutedEventArgs e) { Microsoft.Win32.SaveFileDialog dlg = new Microsoft.Win32.SaveFileDialog(); dlg.FileName = ""; dlg.DefaultExt = ".xml"; dlg.Filter = "Xml Files (.xml)|*.xml"; Nullable <bool> result = dlg.ShowDialog(); if (result == false) { return; } // For Serializing Node Data List <NodeClass> NodeData = new List <NodeClass>(); for (int i = 0; i < createdNode.Count; i++) { NodeData.Add(MakeNodeData(createdNode[i])); } SerializeObject <List <NodeClass> >(NodeData, dlg.FileName); }
private void ExportSettings(object sender, RoutedEventArgs e) { // Save the current thresholds on the first available pad as a preset. foreach (Tuple <int, SMX.SMXConfig> activePad in ActivePad.ActivePads()) { int pad = activePad.Item1; SMX.SMXConfig config = activePad.Item2; string json = SMXHelpers.ExportSettingsToJSON(config); Microsoft.Win32.SaveFileDialog dialog = new Microsoft.Win32.SaveFileDialog(); dialog.FileName = "StepManiaX settings"; dialog.DefaultExt = ".smxcfg"; dialog.Filter = "StepManiaX settings (.smxcfg)|*.smxcfg"; bool?result = dialog.ShowDialog(); if (result == null || !(bool)result) { return; } System.IO.File.WriteAllText(dialog.FileName, json); return; } }
private void Save_Click_2(object sender, RoutedEventArgs e) { //假設儲存路徑空白 if (File_Path == "") { //則另存新檔 Microsoft.Win32.SaveFileDialog dig = new Microsoft.Win32.SaveFileDialog(); Nullable <bool> result = dig.ShowDialog(); if (result == true) { File_Path = dig.FileName; System.IO.File.WriteAllText(File_Path, TextArea.Text); } Title = dig.SafeFileName; } else { //不然直接儲存 System.IO.File.WriteAllText(File_Path, TextArea.Text); } }
private void ButtonSave_Click(object sender, RoutedEventArgs e) { var selectfile = new Microsoft.Win32.SaveFileDialog() { Filter = "Bin Files (.bin)|*.bin|All Files (*.*)|*.*", FilterIndex = 1 }; selectfile.ShowDialog(); string _filesave = null; if (!string.IsNullOrEmpty(selectfile.FileName)) { _filesave = selectfile.FileName; } if (string.IsNullOrEmpty(_filesave)) { return; } MainWindow.SDK.Save(_filesave); DataRefresh(); }
private void SerializeBoW_Click(object sender, RoutedEventArgs e) { Microsoft.Win32.SaveFileDialog dlg = new Microsoft.Win32.SaveFileDialog(); dlg.Filter = "XML Files (.xml)|*.xml"; Nullable <bool> result = dlg.ShowDialog(); if (result == true) { string fileName = dlg.FileName; try { SerializationClass.ConSerializer(bow, fileName); } catch (Exception ex) { MessageBox.Show(ex.Message); } } else { MessageBox.Show("Failed to save File"); } }
private void Save(object sender, RoutedEventArgs e) { if (SaveFolder == "") { try { var path = new Microsoft.Win32.SaveFileDialog(); path.Filter = ".test||.test"; path.ShowDialog(); if (string.IsNullOrEmpty(path.FileName)) { return; } SaveFolder = path.FileName; SaveFile(path.FileName); } catch { } } else { SaveFile(SaveFolder); } }
public void Save(MemoryStream data, string FileName) { // the actionscript API will show the dialog after the user event // has returned, so we must mimic it here 1.AtDelay( delegate { var s = new Microsoft.Win32.SaveFileDialog(); s.FileName = FileName; if (s.ShowDialog() ?? false) { using (var w = s.OpenFile()) { var a = data.ToArray(); w.Write(a, 0, a.Length); } } } ); }
private void OnExportCsv(object sender, RoutedEventArgs e) { Microsoft.Win32.SaveFileDialog fo = new Microsoft.Win32.SaveFileDialog(); fo.Filter = "CSV Files (*.csv)|*.csv"; fo.CheckPathExists = true; if (fo.ShowDialog() == true) { using (var stream = fo.OpenFile()) { using (System.IO.StreamWriter writer = new System.IO.StreamWriter(stream)) { if (this.series != null) { writer.WriteLine("ticks\t" + this.series.Name); foreach (var d in this.GetVisibleDataValues()) { writer.WriteLine(d.X + "\t" + d.Y); } } } } } }
private void tbSelectOut_Click(object sender, RoutedEventArgs e) { // Configure open file dialog box string path = tbZipFile.Text.ToLower(); string filename = tbZipFile.Text.Split('\\').Last(); path = path.Remove(path.Length - filename.Length); Microsoft.Win32.SaveFileDialog dlg = new Microsoft.Win32.SaveFileDialog(); dlg.InitialDirectory = path; dlg.FileName = filename.ToLower().Replace(".zip", "_contents.csv"); dlg.DefaultExt = ".csv"; // Default file extension dlg.Filter = "CSV File|*.csv"; // Filter files by extension // Show open file dialog box bool?result = dlg.ShowDialog(); // Process open file dialog box results if (result == true) { // Open document tbOutputCSV.Text = dlg.FileName; } }
private void SaveB_Click(object sender, RoutedEventArgs e) { var saveDialog = new Microsoft.Win32.SaveFileDialog { Filter = "Файл изображения (.jpg)|*.jpg" }; bool?result = saveDialog.ShowDialog(); if (result == true) { var fileStream = File.Create(saveDialog.FileName); Combine combine = new Combine(); var filterItem = FilterList.SelectedItem as FilterItem; if (filterItem == null) { return; } Bitmap resultImage = combine.ApplyFilter(filterItem.Filter.ApplyFilter(OriginalImage), OriginalImage, filterItem.SliderValue); resultImage.Save(fileStream, ImageFormat.Jpeg); fileStream.Close(); } }
private void SaveButton_Click(object sender, RoutedEventArgs e) { if (grantTrees.filteredTree == null) { Console.WriteLine("Der Baum muss vor dem Speichern gefiltert werden."); return; } // Configure save file dialog box Microsoft.Win32.SaveFileDialog dlg = new Microsoft.Win32.SaveFileDialog(); dlg.FileName = GuiFunctions.cleanInput("filteredTree_" + strategyMgr.getSpecifiedTree().GetData(strategyMgr.getSpecifiedTree().Child(grantTrees.filteredTree)).properties.nameFiltered); // Default file name dlg.DefaultExt = ".grant"; // Default file extension dlg.Filter = "GRANT documents (.grant)|*.grant"; // Filter files by extension dlg.OverwritePrompt = true; // Hinweis wird gezeigt, wenn die Datei schon existiert dlg.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments); // Show save file dialog box Nullable <bool> result = dlg.ShowDialog(); // Process save file dialog box results if (result == true) { // Save document guiFunctions.saveProject(dlg.FileName); } }
private void SaveEasyImageToFile(object sender, RoutedEventArgs e) { var filePath = _userConfigution.WindowState.InitEasyImagePath; if (filePath == null || !File.Exists(filePath)) { var dialog = new SaveFileDialog { CheckPathExists = true, AddExtension = true, FileName = "EasyImage1", Filter = "EasyImage 元文件 (*.ei)|*.ei", ValidateNames = true, }; var showDialog = dialog.ShowDialog().GetValueOrDefault(); if (!showDialog) { return; } filePath = dialog.FileName; } SaveEasyImageToFile(filePath); }
/// <summary> /// Closes current Xps Document /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void SaveCommandHandler(object sender, RoutedEventArgs e) { if (dest.Items.Count < 1) { MessageBox.Show("Please add document to list before saving", "No document to be combined", MessageBoxButton.OK, MessageBoxImage.Exclamation); return; } Microsoft.Win32.SaveFileDialog saveFileDialog = new Microsoft.Win32.SaveFileDialog(); saveFileDialog.Filter = "Xps Documents (*.xps)|*.xps"; saveFileDialog.FilterIndex = 1; if (saveFileDialog.ShowDialog() == true) { string destFile = saveFileDialog.FileName; if (File.Exists(destFile)) { File.Delete(destFile); } _documentRollUp.Uri = new Uri(destFile); _documentRollUp.Save(); } }
private void SaveBTN_Click(object sender, RoutedEventArgs e) { Microsoft.Win32.SaveFileDialog dlgSave = new Microsoft.Win32.SaveFileDialog(); dlgSave.FileName = "select file..."; dlgSave.DefaultExt = ".txt"; dlgSave.Filter = "Text documents (.txt)|*.txt"; bool?result = dlgSave.ShowDialog(); if (result == true) { string filename = dlgSave.FileName; if (!(File.Exists(filename))) { File.CreateText(filename); } //if (File.Exists(Directory.GetCurrentDirectory()+'/' + filename)) // PoleTekstowe.Text = "Niczem"; //string pathOfFilename = System.IO.Path.GetDirectoryName(filename); StreamWriter sr = new StreamWriter(filename); sr.Write(PoleTekstowe.Text); //zapisanie do bufora pamięci nie do pliku sr.Close(); //czyszczenie bufora zpais do pliku } }
private void script_save_Click(object sender, RoutedEventArgs e) { Microsoft.Win32.SaveFileDialog saveFile = new Microsoft.Win32.SaveFileDialog(); saveFile.Filter = "Arquivo json|*.json"; saveFile.AddExtension = true; saveFile.DefaultExt = "json"; if (Directory.Exists(utils.constants.script_default_address)) { saveFile.InitialDirectory = utils.constants.script_default_address; } if (saveFile.ShowDialog() == true) { try { utils.saveScript(saveFile.FileName, script); }catch (Exception ex) { MessageBox.Show(ex.Message, "Error", MessageBoxButton.OK, MessageBoxImage.Error); } } }
private string GetSaveAsLocation() { string exportFilename = string.Format("{0}-{1}-{2}.csv", "times", System.Environment.UserName, System.DateTime.Now.ToString("yyyyMMddHHmm")); Microsoft.Win32.SaveFileDialog dlg = new Microsoft.Win32.SaveFileDialog(); dlg.FileName = exportFilename; dlg.InitialDirectory = GlobalConfig.DatabaseFolder; dlg.DefaultExt = ".csv"; dlg.Filter = "CSV (Comma Delimited) (*.csv)|*.csv"; bool?result = dlg.ShowDialog(); if (result == true) { return(dlg.FileName); } else { return(string.Empty); } }
private void OpenFolderPickerClick(object sender, RoutedEventArgs e) { var dialog = new Microsoft.Win32.SaveFileDialog(); dialog.InitialDirectory = settings.Databases.FolderPickerDefaltPath; // Use current value for initial dir dialog.Title = "Select a Directory"; // instead of default "Save As" dialog.Filter = "Directory|*.this.directory"; // Prevents displaying files dialog.FileName = "select"; // Filename will then be "select.this.directory" if (dialog.ShowDialog() == true) { string path = dialog.FileName; // Remove fake filename from resulting path path = path.Replace("\\select.this.directory", ""); path = path.Replace(".this.directory", ""); // If user has changed the filename, create the new directory if (!System.IO.Directory.Exists(path)) { System.IO.Directory.CreateDirectory(path); } // Our final value is in path ResultText.Text = path; } }
/// <summary> /// Закрытие окна. Если есть несохраненные изменения, то сохраняем /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void Window_Closing(object sender, CancelEventArgs e) { if (_isChanged) { MessageBoxResult result = MessageBox.Show("Структура дерева изменена. Сохранить дерево в Xml файл?", "Внимание!!!", MessageBoxButton.OKCancel); if (result == MessageBoxResult.OK) { Microsoft.Win32.SaveFileDialog sfd = new Microsoft.Win32.SaveFileDialog(); sfd.FileName = "Document"; sfd.DefaultExt = ".xml"; sfd.Filter = "XML documents (.xml)|*.xml"; Nullable <bool> resultSfd = sfd.ShowDialog(); if (resultSfd == true) { this.tagStorage.fileName = sfd.FileName; this.tagStorage.SaveXmlDocument(); } } } Application.Current.Shutdown(); }