void OnUiResizeEnd(object sender, EventArgs e) { if (currentManagerConfig != null) { currentManagerConfig.LastUiSize = Size; currentManagerConfig.SaveTo(); } }
/// <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)}"; }