/// <summary> /// Load the collection represented by the given file /// also sets collection variable. /// </summary> /// <param name="path">the path of the collection to open</param> void LoadCollection(string path) { //check that path is valid if (string.IsNullOrWhiteSpace(path)) { return; } //check if collection file already exists if (File.Exists(path)) { currentCollection = PadoruCollection.FromFile(path); } else { //collection file does not exist, create it? if (MessageBox.Show(this, $"The Collection at \"{path}\" does not exist!\nDo you want to create a new Collection?", "Create Collection", MessageBoxButtons.YesNo) != DialogResult.Yes) { return; } //create empty collection currentCollection = PadoruCollection.CreateEmpty(); currentCollection.LoadedFrom = path; } //check if collection config file already exists string collectionConfig = Path.Combine(Path.GetDirectoryName(path), COLLECTION_MANAGER_CONFIG_NAME); if (File.Exists(collectionConfig)) { //exists, load it currentManagerConfig = CollectionManagerConfig.LoadFrom(collectionConfig); } else { //does not exists, open setup wizard ManagerConfigSetupWizard wizard = new ManagerConfigSetupWizard(); //have to enter a config to continue while (wizard.ShowDialog() != DialogResult.OK) { ; } //get configuration from wizard currentManagerConfig = wizard.ResultingConfig; //save config currentManagerConfig.LoadedFrom = collectionConfig; currentManagerConfig.SaveTo(); } //set window title Text = $"Collection Manager - {Path.GetFileName(currentCollection.LoadedFrom)}"; }
void OnSaveClick(object sender, EventArgs e) { //check if both repo urls are ok OnCommonRepoTextChange(sender, e); if (!repoUrlsValid) { MessageBox.Show(this, "The Repo URLs are not valid! Re- Check your github username and repo name.", "Repo URLs invalid", MessageBoxButtons.OK); return; } //check if table of contents path is filled if (string.IsNullOrWhiteSpace(txtToCRoot.Text)) { MessageBox.Show(this, "You have to fill in a Table Of Contents root directory name!", "ToC Root missing", MessageBoxButtons.OK); return; } //ask user if settings are correct if (MessageBox.Show(this, "Are the settings correct?", "Check Settings", MessageBoxButtons.YesNo) != DialogResult.Yes) { return; } //create CollectionManagerConfig ResultingConfig = new CollectionManagerConfig() { RepoRootUrl = txtRepoRoot.Text, RawRepoRootUrl = txtRepoRootRaw.Text, TableOfContentsDirectoryName = txtToCRoot.Text, LastUiSize = Size.Empty }; //exit with result ok DialogResult = DialogResult.OK; Close(); }
/// <summary> /// initialize the toc creator /// </summary> /// <param name="managerConfig">the colleciton manager config</param> public TableOfContentCreator(CollectionManagerConfig managerConfig) { CurrentManagerConfig = managerConfig; }