public string OpenSaveDialog(FileType fileType = FileType.Xml, string initialPath = null) { string filters; string ext; switch (fileType) { case FileType.Word: ext = "doc"; filters = "Документы Microsoft Word|*.doc;*.docx"; break; case FileType.Xml: ext = Constants.ExtName; filters = $"Файлы проекта|*.{ext}"; break; default: ext = string.Empty; filters = "Все файлы| *.*"; break; } var dialog = new Ookii.Dialogs.Wpf.VistaSaveFileDialog { CheckFileExists = true, RestoreDirectory = true, DereferenceLinks = true, Filter = filters }; if (!string.IsNullOrEmpty(initialPath)) { dialog.InitialDirectory = initialPath; } if (!dialog.ShowDialog().GetValueOrDefault()) { return(null); } var fileName = dialog.FileName; var fileExt = Path.GetExtension(fileName); if (string.IsNullOrEmpty(fileExt)) { fileName += $".{ext}"; } return(fileName); }
private void Button_ExportAFSClick(object sender, RoutedEventArgs e) { if (currentAfs == null) { return; } var dialog = new Ookii.Dialogs.Wpf.VistaSaveFileDialog(); if (dialog.ShowDialog() == false) { return; } if (dialog.FileName != "") { File.WriteAllBytes(dialog.FileName, currentAfs.ToBytes()); } }
private async void SaveDictionaryAsCommandExecuted(object sender, ExecutedRoutedEventArgs e) { if (_canSave == false) { return; } var dialog = new Ookii.Dialogs.Wpf.VistaSaveFileDialog(); dialog.Filter = "Text File (*.txt)|*.txt|All Files (*.*)|*.*"; var result = dialog.ShowDialog(); if (result == true) { await Save(dialog.FileName); } }
private void Button_ExtractADXClick(object sender, RoutedEventArgs e) { if (currentAfs == null) { return; } var dialog = new Ookii.Dialogs.Wpf.VistaSaveFileDialog(); dialog.FileName = TextBlock_AfsAudioIDName.Text; if (dialog.ShowDialog() == false) { return; } if (dialog.FileName != "") { File.WriteAllBytes(dialog.FileName, currentAfs.Files[int.Parse(TextBox_AudioID.Text)].Data); } }
private void SaveItemsToDisk() { var saveFileDialog = new Ookii.Dialogs.Wpf.VistaSaveFileDialog(); saveFileDialog.AddExtension = true; saveFileDialog.Filter = "Easy Backup Files | *.ebf"; saveFileDialog.DefaultExt = "ebf"; saveFileDialog.OverwritePrompt = true; saveFileDialog.Title = "Choose Save Location"; if (File.Exists(_lastSaveFilePath)) { saveFileDialog.FileName = _lastSaveFilePath; } if (saveFileDialog.ShowDialog(Application.Current.MainWindow).GetValueOrDefault()) { var backupTemplate = new BackupTemplate() { Paths = Items.ToList(), BackupLocation = BackupLocation }; var json = Newtonsoft.Json.JsonConvert.SerializeObject(backupTemplate); File.WriteAllText(saveFileDialog.FileName, json); UpdateLastUsedBackupPath(saveFileDialog.FileName); } }
internal static void SaveAsset(Scene scene) { string path = ""; Dispatcher.CurrentDispatcher.Invoke(() => { var dlg = new Ookii.Dialogs.Wpf.VistaSaveFileDialog(); dlg.Filter = "xml|*.xml"; if (dlg.ShowDialog() == true) { path = dlg.FileName; if (path.Contains("}") || path.Contains("{")) { DefaultScene.Actions.Add(() => { new MessageBox(DefaultScene.scene.Context, "File name must not contain { or }.", "File Name Mismatch"); }); path = ""; return; } } }); if (string.IsNullOrEmpty(path)) { return; } #if false Urho3DNet.File file = new Urho3DNet.File(scene.Context, path, Urho3DNet.FileMode.FileWrite); file.sa if (!scene.Save(file)) { new MessageBox(scene.Context, "Couldn't Save File", "Save Error"); return; } #endif #if false var jsonFile = new JSONFile(scene.Context); var rootElem = jsonFile.GetRoot(); if (!scene.SaveJSON(rootElem)) { new MessageBox(scene.Context, "Couldn't Save File", "Save Error"); return; } jsonFile.SaveFile(path); #endif #if true var xmlFile = new XMLFile(scene.Context); XMLElement rootElem = xmlFile.CreateRoot("Root"); if (!scene.SaveXML(rootElem)) { new MessageBox(scene.Context, "Couldn't Save File", "Save Error"); return; } xmlFile.SaveFile(path); #endif //Task.Run(async () => await cam.MoveToSelected(max, modelnode.Position, 50)); }
private void ConvertMultiToSingleBin_OnClick(object sender, RoutedEventArgs e) { var openFileDialog = new Ookii.Dialogs.Wpf.VistaOpenFileDialog(); openFileDialog.Filter = "Supported files|*.bin;*.cue|All files|*.*"; openFileDialog.Multiselect = true; var openResult = openFileDialog.ShowDialog(); if (!openResult.GetValueOrDefault(false)) { return; } var saveFileDialog = new Ookii.Dialogs.Wpf.VistaSaveFileDialog(); saveFileDialog.Filter = "Supported files|*.bin;"; saveFileDialog.DefaultExt = ".bin"; saveFileDialog.AddExtension = true; var saveResult = saveFileDialog.ShowDialog(); if (!saveResult.GetValueOrDefault(false)) { return; } bool generatedCue = false; string tempFile = ""; var trackRegex = new Regex("Track (\\d+)"); if (openFileDialog.FileNames.Length > 1) { if (!openFileDialog.FileNames.All(f => { var match = trackRegex.Match(f); return(Path.GetExtension(f).ToLower() == ".bin" && match.Success && int.TryParse(match.Groups[1].Value, out var dummy)); })) { MessageBox.Show(Window, "Please multi-select only .bins ending in (Track #)", "PSXPackager", MessageBoxButton.OK, MessageBoxImage.Information); return; } var cueFile = new CueFile(); var index = 1; foreach (var fileName in openFileDialog.FileNames.OrderBy(f => int.Parse(trackRegex.Match(f).Groups[1].Value))) { cueFile.FileEntries.Add(new CueFileEntry() { FileName = fileName, FileType = "BINARY", Tracks = index == 1 ? new List <CueTrack>() { new CueTrack() { DataType = CueTrackType.Data, Number = index, Indexes = new List <CueIndex>() { new CueIndex() { Number = 1, Position = new IndexPosition(0, 0, 0) } } } } : new List <CueTrack>() { new CueTrack() { DataType = CueTrackType.Audio, Number = index, Indexes = new List <CueIndex>() { new CueIndex() { Number = 0, Position = new IndexPosition(0, 0, 0) }, new CueIndex() { Number = 1, Position = new IndexPosition(0, 2, 0) } } } } }); index++; } tempFile = Path.GetTempFileName() + ".cue"; CueFileWriter.Write(cueFile, tempFile); generatedCue = true; } else if (Path.GetExtension(openFileDialog.FileName).ToLower() == ".cue") { tempFile = openFileDialog.FileName; } else { MessageBox.Show(Window, "Please select the CUE file, or if you do not have a CUE file, multi-select all the .bins ending in (Track #)", "PSXPackager", MessageBoxButton.OK, MessageBoxImage.Information); } var folder = Path.GetDirectoryName(Path.GetFullPath(saveFileDialog.FileName)); var filename = Path.GetFileName(saveFileDialog.FileName); var processing = new Popstation.Processing(null, null, null); var(binfile, cuefile) = processing.ProcessCue(tempFile, Path.GetTempPath()); var cueFileName = Path.GetFileNameWithoutExtension(filename) + ".cue"; var outputPath = Path.Combine(folder, saveFileDialog.FileName); if (File.Exists(outputPath)) { File.Delete(outputPath); } File.Move(binfile, outputPath); if (generatedCue) { var updatedCueFile = CueFileReader.Read(cuefile); var fileEntry = updatedCueFile.FileEntries.First(); fileEntry.FileName = filename; CueFileWriter.Write(updatedCueFile, Path.Combine(folder, cueFileName)); } MessageBox.Show(Window, $"Merged .bins to {outputPath}", "PSXPackager", MessageBoxButton.OK, MessageBoxImage.Information); }
private void start_Click(object sender, RoutedEventArgs e) { if (locationtext.Text == "..." || locationtext.Text == "") { MessageBox.Show("Can't found the selected location."); } else { if (radrename.IsChecked == true) { string tempqua = ""; string filesfound = "Old File Name || New File Name\n"; int r = 0, re = 0; var location = new DirectoryInfo(locationtext.Text); FileInfo[] files = location.GetFiles("*", SearchOption.TopDirectoryOnly); FileInfo[] fileextrac = new FileInfo[files.Length]; if (selecextension.Text == "" || selecextension.Text == null) { MessageBox.Show("File extension can't be empty."); } else if (selecfilenameout.Text == "" || selecfilenameout.Text == null) { MessageBox.Show("Output filename can't be empty."); } else if (!selecfilenameout.Text.Contains("*")) { MessageBox.Show("Output File Name must include * tag before running the rename action."); } else { while (r < files.Length) { if (files[r].Extension.ToString().Contains(selecextension.Text)) { fileextrac[re] = files[r]; tempqua = selecfilenameout.Text.Replace("*", re.ToString()); filesfound = $"{filesfound} {files[r].Name.ToString()} || {tempqua}\n"; re++; } r++; } System.Windows.Forms.MessageBoxManager.Yes = "Confirm"; System.Windows.Forms.MessageBoxManager.No = "No"; System.Windows.Forms.MessageBoxManager.Register(); MessageBoxResult extractconfirm = MessageBox.Show(filesfound, "Files Found", MessageBoxButton.YesNo); System.Windows.Forms.MessageBoxManager.Unregister(); if (extractconfirm == MessageBoxResult.Yes) { r = 0; while (r < re) { File.Move(fileextrac[r].FullName, fileextrac[r].FullName.Replace(fileextrac[r].Name, selecfilenameout.Text.Replace("*", (r + 1).ToString()) + fileextrac[r].Extension)); r++; } MessageBoxResult endconfirmation = MessageBox.Show("Would you like to open location?", "Action is completed", MessageBoxButton.YesNo); if (extractconfirm == MessageBoxResult.Yes) { Process.Start($@"{fileextrac[r - 1].Directory}"); } } } } else if (radretag.IsChecked == true) { string filesfound = "Old File Name || New File Name\n"; int r = 0, re = 0; var location = new DirectoryInfo(locationtext.Text); FileInfo[] files = location.GetFiles("*", SearchOption.TopDirectoryOnly); FileInfo[] fileextrac = new FileInfo[files.Length]; if (selecextension.Text == "" || selecextension.Text == null) { MessageBox.Show("File extension can't be empty."); } else if (selecfilenametag.Text == "" || selecfilenametag.Text == null) { MessageBox.Show("Tag type can't be empty."); } else { while (r < files.Length) { if ((files[r].Name.ToString().Contains(selecextension.Text))) { if (selecfilenametag.Text == "[TAG]") { if (files[r].Name.Contains("[") && files[r].Name.Contains("]")) { fileextrac[re] = files[r]; filesfound = $"{filesfound} {files[r].Name.ToString()} || {Regex.Replace(files[r].Name, "\\((.*?)\\)", "")}\n"; re++; } } else if (selecfilenametag.Text == "(TAG)") { if (files[r].Name.Contains("(") && files[r].Name.Contains(")")) { fileextrac[re] = files[r]; filesfound = $"{filesfound} {files[r].Name.ToString()} || {Regex.Replace(files[r].Name, "\\((.*?)\\)", "")}\n"; re++; } } } r++; } System.Windows.Forms.MessageBoxManager.Yes = "Confirm"; System.Windows.Forms.MessageBoxManager.No = "No"; System.Windows.Forms.MessageBoxManager.Register(); MessageBoxResult extractconfirm = MessageBox.Show(filesfound, "Files Found", MessageBoxButton.YesNo); System.Windows.Forms.MessageBoxManager.Unregister(); if (extractconfirm == MessageBoxResult.Yes) { r = 0; if (selecfilenametag.Text == "[TAG]") { while (r < re) { if (!File.Exists(fileextrac[r].FullName.Replace(fileextrac[r].Name, Regex.Replace(fileextrac[r].Name, "\\[(.*?)\\]", "")))) { File.Move(fileextrac[r].FullName, (fileextrac[r].FullName.Replace(fileextrac[r].Name, Regex.Replace(fileextrac[r].Name, "\\[(.*?)\\]", "")))); } else { System.Windows.Forms.MessageBoxManager.Yes = "Manually Naming"; System.Windows.Forms.MessageBoxManager.No = "Skip"; System.Windows.Forms.MessageBoxManager.Register(); MessageBoxResult alreadyhave = MessageBox.Show($"There is a file({fileextrac[r].Name}) with the same name on the directory would you like to chose a name for this file manually or skip", "Duplicate Detected", MessageBoxButton.YesNo); System.Windows.Forms.MessageBoxManager.Unregister(); if (alreadyhave == MessageBoxResult.Yes) { var alreadyloc = new Ookii.Dialogs.Wpf.VistaSaveFileDialog(); if (alreadyloc.ShowDialog(this).GetValueOrDefault()) { File.Move(fileextrac[r].FullName, alreadyloc.FileName + fileextrac[r].Extension); } } } r++; } MessageBoxResult endconfirmation = MessageBox.Show("Would you like to open location.", "Action is completed", MessageBoxButton.YesNo); if (extractconfirm == MessageBoxResult.Yes) { Process.Start(@"" + fileextrac[r - 1].Directory); } } else if (selecfilenametag.Text == "(TAG)") { while (r < re) { if (!File.Exists(fileextrac[r].FullName.Replace(fileextrac[r].Name, Regex.Replace(fileextrac[r].Name, "\\((.*?)\\)", "")))) { File.Move(fileextrac[r].FullName, (fileextrac[r].FullName.Replace(fileextrac[r].Name, Regex.Replace(fileextrac[r].Name, "\\((.*?)\\)", "")))); } else { System.Windows.Forms.MessageBoxManager.Yes = "Manually Naming"; System.Windows.Forms.MessageBoxManager.No = "Skip"; System.Windows.Forms.MessageBoxManager.Register(); MessageBoxResult alreadyhave = MessageBox.Show($"There is a file({fileextrac[r].Name}) with the same name on the directory would you like to chose a name for this file manually or skip", "Duplicate Detected", MessageBoxButton.YesNo); System.Windows.Forms.MessageBoxManager.Unregister(); if (alreadyhave == MessageBoxResult.Yes) { var alreadyloc = new Ookii.Dialogs.Wpf.VistaSaveFileDialog(); if (alreadyloc.ShowDialog(this).GetValueOrDefault()) { File.Move(fileextrac[r].FullName, alreadyloc.FileName + fileextrac[r].Extension); } } } r++; } MessageBoxResult endconfirmation = MessageBox.Show("Would you like to open location?", "Action is completed", MessageBoxButton.YesNo); if (extractconfirm == MessageBoxResult.Yes) { Process.Start($@"{fileextrac[r - 1].Directory}"); } } } } } } }