void ModConfigBox.ApplyValue(List <KeyValuePair <string, ConfigFile> > configFiles, ApplyType type) { //Text = configFiles.Find((p) => { return p.Key == configFilePath; }).Value.getOption(configOption); switch (type) { case ApplyType.inGoose: Text = modFilePath; return; case ApplyType.inLauncher: string exePath = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); string forDefaultPath = ModConfigForm.getInGooseFilePath(modFilePath); string defaultPath = Path.Combine(exePath, "ModsFiles", MainForm.modName, "Default", forDefaultPath); Text = defaultPath; return; } /*ModsFilesPath = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "ModsFiles", MainForm.modName, "Used Before"); * if (configFiles.First().Value.fileLocationPath.StartsWith(ModsFilesPath)) { * string exePath = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); * string forDefaultPath = ModConfigForm.getInGooseFilePath(modFilePath); * string defaultPath = Path.Combine(exePath, "ModsFiles", MainForm.modName, "Used Before", forDefaultPath); * * Text = defaultPath; * }*/ }
public FileBox(string showedName, OpenFileDialog FileDialog, Action <string> howToUsePath, string toFilePath) { fileDialogButton.Size = new Size(23, 23); fileDialogButton.Text = "..."; fileDialogButton.FontWeight = MetroButtonWeight.Regular; ReadOnly = true; BoxName.Text = showedName + ':'; BoxName.AutoSize = true; Size = new Size(365, 23); applyAction = howToUsePath; fileDialog = FileDialog; fileDialogButton.Click += FileDialogButtonClick; modFilePath = toFilePath; string exePath = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); string forDefaultPath = ModConfigForm.getInGooseFilePath(modFilePath); string defaultPath = Path.Combine(exePath, "ModsFiles", MainForm.modName, "Default", forDefaultPath); if (!Directory.Exists(Path.GetDirectoryName(defaultPath))) { Directory.CreateDirectory(Path.GetDirectoryName(defaultPath)); } try { File.Copy(toFilePath, defaultPath, false); } catch (IOException) { } }
void ModConfigBox.Apply(List <KeyValuePair <string, ConfigFile> > configFiles) { if (Text != modFilePath) { if (File.Exists(Text)) { applyAction(Text); string exePath = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); string forDefaultPath = ModConfigForm.getInGooseFilePath(modFilePath); string defaultPath = Path.Combine(exePath, "ModsFiles", MainForm.modName, "Used Before", forDefaultPath); try { File.Copy(modFilePath, defaultPath, true); } catch (IOException) { } } } }