public static void ExportBinary(PackedFile CurrentPackedFile, string _exportDirectory) { string extractTo = null; // TODO: Add support for ModManager //extractTo = ModManager.Instance.CurrentModSet ? ModManager.Instance.CurrentModDirectory : null; if (extractTo == null) { DirectoryDialog dialog = new DirectoryDialog { Description = "Please point to folder to extract to", SelectedPath = String.IsNullOrEmpty(_exportDirectory) ? System.IO.Path.GetDirectoryName(System.Diagnostics.Process.GetCurrentProcess().MainModule.FileName) : _exportDirectory }; extractTo = dialog.ShowDialog() == System.Windows.Forms.DialogResult.OK ? dialog.SelectedPath : null; _exportDirectory = dialog.SelectedPath; } if (!string.IsNullOrEmpty(extractTo)) { List <PackedFile> files = new List <PackedFile>(); files.Add(CurrentPackedFile); FileExtractor extractor = new FileExtractor(extractTo); extractor.ExtractFiles(files); MessageBox.Show(string.Format("File exported as binary.")); } }
private void ChooseDirectoryBTN_Click(object sender, EventArgs e) { try { if (DirectoryDialog.ShowDialog() == DialogResult.OK) { Playlist.Clear(); string[] formats = { "*.mp3", "*.wav", "*.ogg", "*.avi", "*.flv", "*.mkv", "*.mp4" }; var mediaService = new MediaService(); foreach (string format in formats) { foreach (var filePath in Directory.GetFiles(DirectoryDialog.SelectedPath, format, SearchOption.AllDirectories)) { Playlist.Add(mediaService.GetMedia(filePath)); } } DirecoryPathTB.Text = DirectoryDialog.SelectedPath; } } catch { MessageBox.Show("Нет доступа к одной из выбранных папок", "System"); } }
private void OpenFolder_Click(object sender, EventArgs e) { DirectoryDialog.SelectedPath = RConfig.Instance.LineageDirectory; if (DirectoryDialog.ShowDialog() == DialogResult.OK) { openDirectory(DirectoryDialog.SelectedPath); } }
private void BtnSelectDir_Click(object sender, EventArgs e) { DialogResult dr = DirectoryDialog.ShowDialog(); if (dr == DialogResult.OK) { TbTarget.Text = DirectoryDialog.SelectedPath; } }
/* * Query user for new mod name and its directory; then opens existing mod pack there * or lets user import initial data from a game pack. */ public string AddMod() { string result = null; InputBox box = new InputBox { Text = "Enter Mod Name:", Input = "my_mod" }; if (box.ShowDialog() == System.Windows.Forms.DialogResult.OK && box.Input.Trim() != "") { string modName = box.Input; if (modName.Contains(" ")) { if (MessageBox.Show(MOD_SPACE_MESSAGE, "Mod name warning", MessageBoxButtons.YesNo) == DialogResult.Yes) { modName = modName.Replace(" ", "_"); } } string newModDir = Settings.Default.LastPackDirectory; if (newModDir != null) { newModDir = Path.GetDirectoryName(newModDir); newModDir = Path.Combine(newModDir, modName); } DirectoryDialog dialog = new DirectoryDialog { SelectedPath = newModDir }; if (dialog.ShowDialog() == System.Windows.Forms.DialogResult.OK) { Mod mod = new Mod { Name = modName, BaseDirectory = dialog.SelectedPath }; // create directory if it doesn't already exist Directory.CreateDirectory(mod.BaseDirectory); // create new mod file to start off with result = Path.Combine(mod.BaseDirectory, string.Format("{0}.pack", modName)); if (Directory.Exists(mod.BaseDirectory) && !File.Exists(result)) { PackFile newFile = new PackFile(result, new PFHeader(GameManager.Instance.CurrentGame.DefaultPfhType)); ImportDataFromGame(newFile); new PackFileCodec().WriteToFile(result, newFile); } mod.Game = GameManager.Instance.CurrentGame; AddMod(mod); } } return(result); }
void CheckShogunInstallation() { Game g = Game.STW; string gamePathFilename = Path.Combine(ModTools.Instance.BinariesPath, "game_path.txt"); // prefer loaded from file so the user can force an installation location if (!g.IsInstalled) { string gamePath = ""; // check if the game path file is set try { // read path from file gamePath = File.ReadAllText(gamePathFilename).Trim(); if (Directory.Exists(gamePath)) { g.GameDirectory = gamePath; return; } } catch {} // ask user DirectoryDialog dlg = new DirectoryDialog() { Description = string.Format("Please enter location of {0}.", g.Id), SelectedPath = gamePath }; if (dlg.ShowDialog() == DialogResult.OK) { g.GameDirectory = dlg.SelectedPath; } else { // add empty entry to file for next time g.GameDirectory = Game.NOT_INSTALLED; } } else if (g.GameDirectory.Equals(Game.NOT_INSTALLED)) { // mark as invalid g.GameDirectory = null; } if (!g.IsInstalled) { throw new InvalidOperationException("Cannot find Shogun installation directory.\n"); } // write to gamepath file File.WriteAllText(gamePathFilename, g.GameDirectory); }
/* * Lets the user choose the mod installation directory. */ private void SetInstallDirectory(object sender = null, EventArgs e = null) { DirectoryDialog folderBrowser = new DirectoryDialog() { Description = "Please point to the location of your mod tools installation" }; if (folderBrowser.ShowDialog() == DialogResult.OK) { ModTools.Instance.InstallDirectory = folderBrowser.SelectedPath; Settings.Default.ModToolPath = folderBrowser.SelectedPath; SetInstallDirectoryLabelText(); } }
private void Source_Click(object sender, EventArgs e) { if (!DirectoryChkbx.Checked) { if (OpenDialog.ShowDialog(this) == DialogResult.OK) { SourceLbl.Text = OpenDialog.FileName; DirectoryChkbx.Enabled = false; } } else if (DirectoryDialog.ShowDialog(this) == DialogResult.OK) { SourceLbl.Text = DirectoryDialog.SelectedPath; DirectoryChkbx.Enabled = false; } }
public void ChooseFolder() { try { if (DirectoryDialog.ShowDialog() == DialogResult.OK) { DirectoryBox.Text = DirectoryDialog.SelectedPath; isSelectedFolder = true; path = DirectoryBox.Text; } } catch (Exception exc) { ErrorFrm errfrm = new ErrorFrm(exc.Message); errfrm.Show(); } }
public void Config_Load() { DirectoryDialog.Description = Localizate.getMessage(Word.PLEASE_SELECT_SYSTEM_FOLDER); // Check DatFile Directory if (!Directory.Exists(RConfig.Instance.LineageDirectory)) { new MessageBox(Localizate.getMessage(Word.SYSTEM_FOLDER_IS_EMPTY), true); DirectoryDialog.RootFolder = Environment.SpecialFolder.MyComputer; if (DirectoryDialog.ShowDialog() == DialogResult.OK) { RConfig.Instance.LineageDirectory = DirectoryDialog.SelectedPath; RConfig.Instance.save(); } } }
private void ChooseDirectoryBTN_Click(object sender, EventArgs e) { try { if (DirectoryDialog.ShowDialog() == DialogResult.OK) { Playlist.Clear(); string[] formats = { "*.aac", "*.aiff", "*.flac", "*.m4a", "*.mmf", "*.mp3", "*.opus", "*.wav", "*.wma", "*.ogg", "*.3g2", " *.3gp", " *.avi", " *.flv", " *.mkv", " *.mov", " *.mp4", " *.mpeg", " *.webm", " *.wmv" }; foreach (string format in formats) { foreach (var item in Directory.GetFiles(DirectoryDialog.SelectedPath, format, SearchOption.AllDirectories)) { var trackTags = TagLib.File.Create(item); Playlist.Add(new Track() { TrackName = trackTags.Tag.Title, Year = trackTags.Tag.Year.ToString(), Genre = trackTags.Tag.FirstGenre, Author = trackTags.Tag.FirstArtist, Album = trackTags.Tag.Album, AudioChanels = trackTags.Properties.AudioChannels.ToString(), Bits = trackTags.Properties.AudioSampleRate.ToString(), Length = trackTags.Properties.Duration.ToString(), Bitrate = trackTags.Properties.AudioBitrate.ToString(), FileSize = (int)new FileInfo(item).Length }); } } DirecoryPathTB.Text = DirectoryDialog.SelectedPath; } } catch { MessageBox.Show("Нет доступа к одной из выбранных папок", "System"); } }
public static void CheckGameDirectories() { bool writeGameDirFile = false; foreach (Game g in Game.Games) { if (g.GameDirectory == null) { // if there was an empty entry in file, don't ask again DirectoryDialog dlg = new DirectoryDialog() { Description = string.Format("Please point to Location of {0}\nCancel if not installed.", g.Id) }; dlg.Refresh(); if (dlg.ShowDialog() == DialogResult.OK) { g.GameDirectory = dlg.SelectedPath; } else { // add empty entry to file for next time g.GameDirectory = Game.NOT_INSTALLED; } writeGameDirFile = true; } else if (g.GameDirectory.Equals(Game.NOT_INSTALLED)) { // mark as invalid g.GameDirectory = null; } } // don't write the file if user wasn't queried if (writeGameDirFile) { SaveGameDirs(); } }
private void ExportData(object sender, EventArgs e) { string extractTo = ModManager.Instance.CurrentModSet ? ModManager.Instance.CurrentModDirectory : null; if (extractTo == null) { DirectoryDialog dialog = new DirectoryDialog { Description = "Please point to folder to extract to", SelectedPath = Settings.Default.LastPackDirectory }; extractTo = dialog.ShowDialog() == DialogResult.OK ? dialog.SelectedPath : null; } if (!string.IsNullOrEmpty(extractTo)) { List <PackedFile> files = new List <PackedFile>(); files.Add(CurrentPackedFile); FileExtractor extractor = new FileExtractor(null, null, extractTo) { Preprocessor = new TsvExtractionPreprocessor() }; extractor.ExtractFiles(files); MessageBox.Show(string.Format("File exported to TSV.")); } }
string SelectScanPath(string initialFolder) { string result = null; DirectoryDialog dialog = new DirectoryDialog(); dialog.BrowseFor = DirectoryDialog.BrowseForTypes.Directories; dialog.Title = "Select a folder to be scanned. Successfully scanned files will be added to the Playdar content library."; if (!string.IsNullOrEmpty(initialFolder)) dialog.InitialPath = initialFolder; _inDirectoryDialog = true; if (dialog.ShowDialog(this) == DialogResult.OK) result = dialog.Selected; _inDirectoryDialog = false; return result; }