/// <summary> /// Unpacking file /// </summary> /// <param name="Res">PackResource </param> public bool UnpackFile(PackResource Res) { Console.WriteLine("Unpack"); String InternalName = Res.GetName(); CommonSaveFileDialog dSaveAs = new CommonSaveFileDialog(); dSaveAs.DefaultFileName = Path.GetFileName(InternalName); if (dSaveAs.ShowDialog() == CommonFileDialogResult.Ok) { if (!isCLI) { this.pd.ShowDialog(ProgressDialog.PROGDLG.Normal); this.pd.Caption = Properties.Resources.Str_Unpack; } try { // loading file content. byte[] buffer = new byte[Res.GetSize()]; Res.GetData(buffer); Res.Close(); // Delete old if (File.Exists(dSaveAs.FileName)) { File.Delete(dSaveAs.FileName); } // Write to file. FileStream fs = new FileStream(dSaveAs.FileName, System.IO.FileMode.Create); fs.Write(buffer, 0, buffer.Length); fs.Close(); // Modify File time File.SetCreationTime(dSaveAs.FileName, Res.GetCreated()); File.SetLastAccessTime(dSaveAs.FileName, Res.GetAccessed()); File.SetLastWriteTime(dSaveAs.FileName, Res.GetModified()); } catch (Exception) { return(false); } finally { Res.Close(); this.pd.CloseDialog(); Console.WriteLine("Finish."); } return(true); } return(false); }
void saveCFD_FileTypeChanged(object sender, EventArgs e) { CommonSaveFileDialog cfd = sender as CommonSaveFileDialog; if (cfd.SelectedFileTypeIndex == 1) { cfd.SetCollectedPropertyKeys(true, SystemProperties.System.Title, SystemProperties.System.Author); cfd.DefaultExtension = ".docx"; } else if (cfd.SelectedFileTypeIndex == 2) { cfd.SetCollectedPropertyKeys(true, SystemProperties.System.Photo.DateTaken, SystemProperties.System.Photo.CameraModel); cfd.DefaultExtension = ".jpg"; } }
private void MenuGenerateGraph_Click(object sender, RoutedEventArgs e) { var dialog = new CommonSaveFileDialog("Save graph (.dot) file") { DefaultExtension = ".dot" }; dialog.Filters.Add(new CommonFileDialogFilter("GraphViz Graph", ".dot")); if (dialog.ShowDialog(new WindowInteropHelper(this).Handle) == CommonFileDialogResult.Ok) { ExecutionDialog.RunVcpkg("search --graph", out string graph); // TODO: the process will block here if not using shell File.WriteAllText(dialog.FileName, graph); } }
async void itmExtract_Click(object sender, EventArgs e) { using (CommonSaveFileDialog dialog = new CommonSaveFileDialog()) { dialog.DefaultExtension = ".cic"; dialog.Filters.Add(new CommonFileDialogFilter("Comicファイル", "*.cic")); dialog.Title = Properties.Resources.ExtractImages; if (dialog.ShowDialog(Handle) != CommonFileDialogResult.Ok) { return; } using (BeginAsyncWork()) await comic.ExtractAsync(dialog.FileName, imageList.SortedSelectedImages, defaultProgress); } }
/// <summary> /// Creates a RGB colour configuration file. /// </summary> public static void CreateRGBConfigurationFile() { try { if (OSHelper.IsSevenOrHigher()) { CommonSaveFileDialog csfd = new CommonSaveFileDialog(); csfd.Title = "Save Colours To:"; csfd.Filters.Add(new CommonFileDialogFilter("Colour Configuration File", ".ccf")); csfd.Filters.Add(new CommonFileDialogFilter("Normal Text File", ".txt")); csfd.DefaultFileName = $"Custom Colours Configuration File - { TranslationMethods.ReturnSafeFileNameDateTimeString() }"; csfd.AlwaysAppendDefaultExtension = true; csfd.DefaultExtension = "ccf"; if (csfd.ShowDialog() == CommonFileDialogResult.Ok) { WriteRGBColoursToFile(csfd.FileName); } } else { SaveFileDialog dialog = new SaveFileDialog(); dialog.Title = "Save Colours To:"; dialog.Filter = "Colour Configuration File | *.ccf | Normal Text Files | *.txt"; dialog.DefaultExt = "ccf"; dialog.FileName = $"All Colour Configuration File - { TranslationMethods.ReturnSafeFileNameDateTimeString() }"; if (dialog.ShowDialog() == DialogResult.OK) { WriteRGBColoursToFile(dialog.FileName); } } } catch (Exception exc) { ExtendedKryptonMessageBox.Show($"An unexpected error has occurred: '{ exc.Message }'", "Unexpected Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
/// <summary> /// Creates a RGB colour configuration file. /// </summary> public static void CreateRGBConfigurationFile() { try { if (OSHelper.IsSevenOrHigher()) { CommonSaveFileDialog csfd = new CommonSaveFileDialog(); csfd.Title = "Save Colours To:"; csfd.Filters.Add(new CommonFileDialogFilter("Colour Configuration File", ".ccf")); csfd.Filters.Add(new CommonFileDialogFilter("Normal Text File", ".txt")); csfd.DefaultFileName = $"All Colour Configuration File - { TranslationMethods.ReturnSafeFileNameDateTimeString() }"; csfd.AlwaysAppendDefaultExtension = true; csfd.DefaultExtension = "ccf"; if (csfd.ShowDialog() == CommonFileDialogResult.Ok) { WriteRGBColoursToFile(csfd.FileName); } } else { SaveFileDialog dialog = new SaveFileDialog(); dialog.Title = "Save Colours To:"; dialog.Filter = "Colour Configuration File | *.ccf | Normal Text Files | *.txt"; dialog.DefaultExt = "ccf"; dialog.FileName = $"All Colour Configuration File - { TranslationMethods.ReturnSafeFileNameDateTimeString() }"; if (dialog.ShowDialog() == DialogResult.OK) { WriteRGBColoursToFile(dialog.FileName); } } } catch (Exception exc) { ExceptionHandler.CaptureException(exc, icon: MessageBoxIcon.Error, methodSignature: MethodHelpers.GetCurrentMethod()); } }
private CommonSaveFileDialog CreateSaveFileDialog(string title = null, string defaultFileName = null) { var dialog = new CommonSaveFileDialog { Title = title ?? _saveDialogTitle, RestoreDirectory = true, DefaultFileName = defaultFileName, DefaultDirectory = _defaultDirectory, AddToMostRecentlyUsedList = false, EnsureValidNames = true, ShowPlacesList = true, DefaultExtension = null }; return(dialog); }
private void Dump() { var contents = string.Empty; switch (this.Operation) { case "Chips": contents = this.DumpChips(); break; case "AddOns": contents = this.DumpAddOns(); break; case "Upgrades": contents = this.DumpUpgrades(); break; case "Flags/Vars": contents = this.DumpFlagsVars(); break; default: return; } var saveFileDialog = new CommonSaveFileDialog { RestoreDirectory = false, InitialDirectory = Directory.GetCurrentDirectory(), DefaultExtension = "txt", NavigateToShortcut = true, OverwritePrompt = true, DefaultFileName = "dump.txt", Title = "Save dump" }; saveFileDialog.Filters.Add(new CommonFileDialogFilter("Text file", "*.txt")); saveFileDialog.Filters.Add(new CommonFileDialogFilter("All Files", "*.*")); var dialogSuccess = saveFileDialog.ShowDialog(); if (dialogSuccess == CommonFileDialogResult.Ok) { File.WriteAllText(saveFileDialog.FileName, contents); } }
/// <summary> /// Executes the browse destination execute /// </summary> private void BrowseDestinationExecute() { var dlg = new CommonSaveFileDialog(); dlg.Filters.Add(new CommonFileDialogFilter("XML file", "*.xml")); dlg.DefaultFileName = "Stringtable.xml"; if (!string.IsNullOrWhiteSpace(this.SourcePath)) { dlg.DefaultDirectory = this.SourcePath; } if (dlg.ShowDialog() == CommonFileDialogResult.Ok) { this.DestinationPath = dlg.FileName; } }
public void Save() { var fileDialog = new CommonSaveFileDialog { InitialDirectory = Model.BasePath, Filters = { new CommonFileDialogFilter("Layout File", "*.xml") } }; if (fileDialog.ShowDialog() != CommonFileDialogResult.Ok) { return; } var writer = new XmlSerializer(typeof(DeviceLayout)); var file = File.Create(fileDialog.FileName); writer.Serialize(file, DeviceLayout); file.Close(); }
private async void ExportMenu_Click(object sender, RoutedEventArgs e) { CommonSaveFileDialog dialog = new CommonSaveFileDialog() { Title = "请选择导出的位置", DefaultFileName = "文件分类" }; dialog.Filters.Add(new CommonFileDialogFilter("SQLite数据库", "db")); if (dialog.ShowDialog(this) == CommonFileDialogResult.Ok) { string path = dialog.FileName; await DoProcessAsync(Task.Run(() => ExportAll(path))); await new MessageDialog().ShowAsync("导出成功", "导出"); } }
private void J2C_Save_Click(object sender, EventArgs e) { var csfd = new CommonSaveFileDialog { DefaultFileName = "data.csv", Title = "Save File", AlwaysAppendDefaultExtension = true, DefaultExtension = ".csv" }; csfd.Filters.Add(new CommonFileDialogFilter("Comma-separated values", "*.csv")); if (csfd.ShowDialog() == CommonFileDialogResult.Ok) { SaveDataGridViewToCSV2(csfd.FileName); } }
private async void ExportProjectButton_Click(object sender, RoutedEventArgs e) { CommonSaveFileDialog dialog = new CommonSaveFileDialog() { Title = "请选择导出的位置", DefaultFileName = Project.Name }; dialog.Filters.Add(new CommonFileDialogFilter("SQLite数据库", "db")); if (dialog.ShowDialog(Window.GetWindow(this)) == CommonFileDialogResult.Ok) { string path = dialog.FileName; await MainWindow.Current.DoProcessAsync(Task.Run(() => ExportProject(path, Project))); await new MessageDialog().ShowAsync("导出成功", "导出"); } }
/// <summary> /// Handles the Click event of the buttonNew control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="System.Windows.RoutedEventArgs"/> instance containing the event data.</param> private void buttonNew_Click(object sender, RoutedEventArgs e) { CommonSaveFileDialog sfd = new CommonSaveFileDialog(); sfd.Filters.Add(new CommonFileDialogFilter(Properties.Resources.FileFilterText, Properties.Resources.FileFilterExtension)); sfd.DefaultExtension = Properties.Resources.FileFilterExtension; sfd.AlwaysAppendDefaultExtension = true; if (sfd.ShowDialog() == CommonFileDialogResult.Ok) { if (System.IO.File.Exists(sfd.FileName)) { FileSystem.DeleteFile(sfd.FileName, UIOption.OnlyErrorDialogs, RecycleOption.SendToRecycleBin); } OpenFile(sfd.FileName); } }
private void SaveItem_Click(object sender, EventArgs e) { // Pick PAC file. CommonSaveFileDialog fileDialog = new CommonSaveFileDialog() { Title = "Save .PAC File", InitialDirectory = Path.GetDirectoryName(_lastOpenFile), DefaultFileName = Path.GetFileName(_lastOpenFile) }; fileDialog.Filters.Add(new CommonFileDialogFilter("Sonic Heroes PAC Archive", ".pac")); if (fileDialog.ShowDialog() == CommonFileDialogResult.Ok) { Archive.SaveToFile(fileDialog.FileName); } }
private void BtnSaveAnnotations_Click(object sender, RoutedEventArgs e) { CommonSaveFileDialog cfd = new CommonSaveFileDialog { InitialDirectory = images.ImgFld.Folder, Title = "Images Labels file", DefaultExtension = "xml", AddToMostRecentlyUsedList = true, OverwritePrompt = true, IsExpandedMode = true }; if (cfd.ShowDialog() == CommonFileDialogResult.Ok) { images.ImgFld.SaveAnnotatedImages(cfd.FileName); } }
private void export_Click(object sender, RoutedEventArgs e) { switch (formatComboBox.SelectedIndex) { case 0: Export.ToExcel(DataContext as GuildStats); break; case 1: MainWindow.ShowTaskDialog("Sorry! This feature is not yet implemented.", TaskDialogIcon.Information); break; case 2: using (CommonSaveFileDialog dialog = new CommonSaveFileDialog()) { dialog.Filters.Add(new CommonFileDialogFilter("XML File", ".xml")); if (dialog.ShowDialog() == CommonFileDialogResult.Ok) { using (FileStream str = File.Create(dialog.FileName)) using (StreamWriter stringwriter = new StreamWriter(str)) { XmlSerializer serializer = new XmlSerializer(DataContext.GetType()); serializer.Serialize(stringwriter, DataContext); } } } break; case 3: using (CommonSaveFileDialog dialog = new CommonSaveFileDialog()) { dialog.Filters.Add(new CommonFileDialogFilter("JSON File", ".json")); if (dialog.ShowDialog() == CommonFileDialogResult.Ok) { File.WriteAllText(dialog.FileName, JsonConvert.SerializeObject(DataContext, Formatting.Indented)); } } break; case 4: break; default: break; } }
private void FileSelectorButton_Click(object sender, RoutedEventArgs e) { // Set up the file/directory picker CommonFileDialog fd; if (IsFileSaver) { fd = new CommonSaveFileDialog(); if (FileExtension != null) { CommonSaveFileDialog sfd = fd as CommonSaveFileDialog; sfd.DefaultExtension = FileExtension; sfd.AlwaysAppendDefaultExtension = true; sfd.Filters.Add(new CommonFileDialogFilter(FileExtension, "." + FileExtension)); } } else { fd = new CommonOpenFileDialog(); CommonOpenFileDialog ofd = fd as CommonOpenFileDialog; ofd.IsFolderPicker = !IsFilePicker; ofd.AllowNonFileSystemItems = false; ofd.Multiselect = false; } fd.Title = IsFilePicker ? "Choose File" : "Choose Directory"; fd.AddToMostRecentlyUsedList = false; fd.EnsureFileExists = true; fd.EnsurePathExists = true; fd.EnsureReadOnly = false; fd.EnsureValidNames = true; fd.ShowPlacesList = true; var window = Application.Current.Windows.OfType <Window>().SingleOrDefault(w => w.IsActive); if (fd.ShowDialog(window) == CommonFileDialogResult.Ok) { FileReference reference = new FileReference { FilePath = fd.FileName }; WSettingsManager.GetSettings().SetProperty(FieldName, reference); FileName = fd.FileName; } }
private void SaveVistaFileDialogClicked(object sender, RoutedEventArgs e) { CommonSaveFileDialog saveDialog = new CommonSaveFileDialog("My Save File Dialog"); saveDialog.Filters.Add(new CommonFileDialogFilter("My Test Docs", "tdc,tdcx")); saveDialog.Filters.Add(new CommonFileDialogFilter("Word Docs", "doc,docx")); saveDialog.DefaultExtension = "doc"; saveDialog.AddExtension = true; CommonFileDialogResult result = saveDialog.ShowDialog(); if (!result.Canceled) { MessageBox.Show("File chosen: " + saveDialog.FileName); } }
/// <summary> /// Download File: When the Download ToolStripButton is clicked. Displays a SaveFileDialog. /// </summary> /// <param name="FileName">Name of the File to Download</param> /// <param name="CurrentDirectory">CurrentDirectory (Directory from which to download on server)</param> private void DownloadFile(string FileName, string CurrentDirectory) { //Setup and Show CommonSaveFileDialog SaveDialog = new CommonSaveFileDialog("Save File To..."); SaveDialog.AddToMostRecentlyUsedList = true; SaveDialog.DefaultFileName = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments); SaveDialog.DefaultFileName = FileName; if (SaveDialog.ShowDialog() == CommonFileDialogResult.OK) { //Setup and Open Download Form frmDownload DownloadForm = new frmDownload(FileName, CurrentDirectory, SaveDialog.FileName, FtpClient); } else { TaskDialog.Show("Download has been cancelled."); //Notify user that Download has been cancelled. } }
/// <summary> /// Execute the save as command /// </summary> private void SaveAsCommandExecute() { if (this.Projects.Count != 1) { return; } var prjct = this.Projects[0]; var dlg = new CommonSaveFileDialog { DefaultFileName = "Stringtable.xml" }; if (dlg.ShowDialog() == CommonFileDialogResult.Ok) { XmlDeSerializer.WriteXml(prjct, dlg.FileName); } }
/// <summary> /// ファイルリストの保存 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void SaveFileList_Click(object sender, RoutedEventArgs e) { using (var dlg = new CommonSaveFileDialog("ファイルリストの保存先を選んでください。")) { dlg.Filters.Add(new CommonFileDialogFilter("HandBrakeBatchRunner File List", "hfl")); if (dlg.ShowDialog() == CommonFileDialogResult.Ok) { using (var sr = new StreamWriter(dlg.FileName)) { foreach (string item in SourceFileListBox.Items) { sr.WriteLine(item); } } LogWindow.LogMessage($"ファイルリストを保存しました。File={dlg.FileName}", LogWindow.MessageType.Information); } } }
// saving the current playlist private void SavePlaylistButton_Click(object sender, RoutedEventArgs e) { var dialog = new CommonSaveFileDialog() { Title = "Save playlist", InitialDirectory = Path.GetDirectoryName(Context.Playlist.Path), DefaultFileName = Path.GetFileName(Context.Playlist.Path), }; dialog.Filters.Add(new CommonFileDialogFilter("Music Room Playlist", "*.mrpl")); var result = dialog.ShowDialog(); if (result == CommonFileDialogResult.Ok) { Context.Playlist.Save(dialog.FileName); } }
private bool PromptForSave() { if (!CurrentFile.IsDirty) { return(true); } // ask the user to save. DialogResult dr = MessageBox.Show(this, "Current document has changed. Would you like to save?", "Save current document", MessageBoxButtons.YesNoCancel); if (dr == DialogResult.Cancel) { return(false); } if (dr == DialogResult.Yes) { // Does the current file have a name? if (string.IsNullOrEmpty(Form1.CurrentFile.Filename)) { CommonSaveFileDialog saveAsCFD = new CommonSaveFileDialog(); saveAsCFD.Filters.Add(new CommonFileDialogFilter("Text files", ".txt")); saveAsCFD.AlwaysAppendDefaultExtension = true; if (saveAsCFD.ShowDialog() == CommonFileDialogResult.Ok) { Form1.CurrentFile.Save(saveAsCFD.FileName); UpdateAppTitle(); } else { return(false); } } else { // just save it Form1.CurrentFile.Save(CurrentFile.Filename); UpdateAppTitle(); } } return(true); }
private static string SelectSaveFilePath() { CommonSaveFileDialog dialog = new CommonSaveFileDialog { AlwaysAppendDefaultExtension = true, DefaultDirectory = Environment.CurrentDirectory, DefaultExtension = ".png", Filters = { new CommonFileDialogFilter("PNG 图片", ".png") }, EnsurePathExists = true, EnsureFileExists = true, IsExpandedMode = true, Title = DialogTitle }; return(dialog.ShowDialog() == CommonFileDialogResult.Ok ? dialog.FileName : string.Empty); }
private void extractToolStripMenuItem_Click(object sender, EventArgs e) { if (selectedItem == null) { return; } CommonSaveFileDialog a = new CommonSaveFileDialog { Filters = { allFiles }, DefaultFileName = selectedItem.Text }; if (a.ShowDialog() == CommonFileDialogResult.Ok) { new Thread(() => { File.WriteAllBytes(a.FileName, file.Files[listView1.Items.IndexOf(selectedItem)].Data); }).Start(); } }
private void SaveButton_Click(object sender, RoutedEventArgs e) { if (_list != null && _list._newStore) { var sfdlg = new CommonSaveFileDialog(); sfdlg.Filters.Add(new CommonFileDialogFilter("Picture Album (*.pkg)", "*.pkg")); sfdlg.Filters.Add(new CommonFileDialogFilter("All Files (*.*)", "*.*")); sfdlg.DefaultExtension = "pkg"; sfdlg.InitialDirectory = KnownFolders.Documents.Path; if (sfdlg.ShowDialog() == CommonFileDialogResult.Ok) { _list.FilePath = sfdlg.FileName; } } _list.UpdateLibrary(); TaskDialog.Show("Note: It stores only metadata related to the Image, Renaming the original image will affect it.", "Saved Successfully to Disk", "Operation Successful"); }
public void SaveFileAs() { var dlg = new CommonSaveFileDialog(); dlg.Filters.Add(new CommonFileDialogFilter("PCC File", "pcc")); if (!FileName.IsNullOrWhiteSpace()) { dlg.InitialDirectory = Path.GetDirectoryName(FileName); dlg.DefaultFileName = Path.GetFileName(FileName); } if (dlg.ShowDialog() != CommonFileDialogResult.Ok || dlg.FileName.IsNullOrWhiteSpace()) { return; } var fileName = dlg.FileName; }
// choosing a save location for the playlist private void BrowseButton_Click(object sender, RoutedEventArgs e) { var dialog = new CommonSaveFileDialog() { Title = "Choose playlist location", InitialDirectory = Path.GetDirectoryName(Playlist.Path), DefaultFileName = Path.GetFileName(Playlist.Path), }; dialog.Filters.Add(new CommonFileDialogFilter("Music Room Playlist", "*.mrpl")); var result = dialog.ShowDialog(); if (result == CommonFileDialogResult.Ok) { Playlist.Path = dialog.FileName; } Activate(); }
/// <summary> /// Allows the user to select /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void extractToolStripMenuItem_Click(object sender, EventArgs e) { // Select path to extract to. CommonSaveFileDialog fileDialog = new CommonSaveFileDialog { Title = "Select path to extract to.", DefaultFileName = ArchiveFile.Name, InitialDirectory = _lastOpenedDirectory }; // Save the file to disk. if (fileDialog.ShowDialog() == CommonFileDialogResult.Ok) { ArchiveFile.WriteToFile(fileDialog.FileName); if (!Properties.Settings.Default.OpenAtCurrentFile) { _lastOpenedDirectory = Path.GetDirectoryName(fileDialog.FileName); } } }