/// <summary> /// Opens a given file /// </summary> /// <param name="filename">path of file to open. if successful, this path will be cached for saving and opening</param> /// <returns>returns true if the operation was successful, false if it failed.</returns> private bool OpenFile(string filename) { try { ProfileGroup temp = ProfileGroup.LoadFromFile(filename); try { ProfileGroup = temp; saveFileDialog.FileName = openFileDialog.FileName = filename; return(true); } catch (Exception loadEx) { MessageBox.Show(this, "An error occurred while loading the file! A blank Profile Group will be loaded instead." + Environment.NewLine + Environment.NewLine + loadEx.Message, "Error loading file!", MessageBoxButtons.OK, MessageBoxIcon.Error); saveFileDialog.FileName = ""; ProfileGroup = null; } } catch (Exception ex) { MessageBox.Show(this, "An error occurred while reading the file!" + Environment.NewLine + Environment.NewLine + ex.ToString(), "Error reading file!", MessageBoxButtons.OK, MessageBoxIcon.Error); } return(false); }
/// <summary> /// Takes care of loading the profile groups from disk. /// </summary> protected virtual void LoadProfileGroups() { if (SourceConfig.ProfileGroupNames != null) { ProfileGroups = new ProfileGroups(); foreach (string profileGroupName in SourceConfig.ProfileGroupNames) { ProfileGroup profileGroup = ProfileGroup.LoadFromFile(profileGroupName); ProfileGroups.Items.Add(profileGroup); foreach (Profile profile in profileGroup.Items) { profile.Name = profileGroup.Name + ":" + profile.Name; } } } }