private void PopulateProfileList() { XMLProfileSettings profile = new XMLProfileSettings(); int profileCount = profile.GetSetting(XMLProfileSettings.SettingType.Profiles, "ProfileCount", 0); if (profileCount == 0) { ProfileItem item = new ProfileItem { Name = "Default", DataFolder = _defaultFolder }; comboBoxProfiles.Items.Add(item); } else { for (int i = 0; i < profileCount; i++) { ProfileItem item = new ProfileItem { Name = profile.GetSetting(XMLProfileSettings.SettingType.Profiles, "Profile" + i + "/Name", "New Profile"), DataFolder = profile.GetSetting(XMLProfileSettings.SettingType.Profiles, "Profile" + i + "/DataFolder", _defaultFolder) }; comboBoxProfiles.Items.Add(item); } } comboBoxProfiles.SelectedIndex = 0; }
private void PopulateProfileList() { XMLProfileSettings profile = new XMLProfileSettings(); int profileCount = profile.GetSetting("Profiles/ProfileCount", 0); if (profileCount == 0) { ProfileItem item = new ProfileItem(); item.Name = "Default"; item.DataFolder = defaultFolder; comboBoxProfiles.Items.Add(item); } else { for (int i = 0; i < profileCount; i++) { ProfileItem item = new ProfileItem(); item.Name = profile.GetSetting("Profiles/" + "Profile" + i.ToString() + "/Name", "New Profile"); item.DataFolder = profile.GetSetting("Profiles/" + "Profile" + i.ToString() + "/DataFolder", defaultFolder); comboBoxProfiles.Items.Add(item); } } comboBoxProfiles.SelectedIndex = 0; }
private void PopulateProfileList() { var profile = new XMLProfileSettings(); int profileCount = profile.GetSetting(XMLProfileSettings.SettingType.Profiles, "ProfileCount", 0); if (profileCount == 0) { var item = new ProfileItem { Name = "Default", DataFolder = DataProfileForm.DefaultFolder }; comboBoxProfiles.Items.Add(item); } else { for (int i = 0; i < profileCount; i++) { var item = new ProfileItem { Name = profile.GetSetting(XMLProfileSettings.SettingType.Profiles, "Profile" + i.ToString() + "/Name", ""), DataFolder = profile.GetSetting(XMLProfileSettings.SettingType.Profiles, "Profile" + i.ToString() + "/DataFolder", "") }; comboBoxProfiles.Items.Add(item); } } comboBoxProfiles.SelectedIndex = 0; textBoxFileName.Text = @"VixenProfile"; textBoxSaveFolder.Text = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments); }
private void PopulateProfileList() { var profile = new XMLProfileSettings(); int profileCount = profile.GetSetting(XMLProfileSettings.SettingType.Profiles, "ProfileCount", 0); if (profileCount == 0) { MessageBox.Show(@"Unable to locate any profiles."); return; } for (int i = 0; i < profileCount; i++) { var item = new ProfileItem { Name = profile.GetSetting(XMLProfileSettings.SettingType.Profiles, "Profile" + i.ToString() + "/Name", ""), DataFolder = profile.GetSetting(XMLProfileSettings.SettingType.Profiles, "Profile" + i.ToString() + "/DataFolder", "") }; comboBoxProfiles.Items.Add(item); } comboBoxProfiles.SelectedIndex = 0; textBoxFileName.Text = @"VixenProfile"; textBoxSaveFolder.Text = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments); }
private void PopulateProfileList() { XMLProfileSettings profile = new XMLProfileSettings(); listBoxProfiles.BeginUpdate(); //Make sure we start with an empty listbox since we may repopulate after editing profiles listBoxProfiles.Items.Clear(); int profileCount = profile.GetSetting(XMLProfileSettings.SettingType.Profiles, "ProfileCount", 0); for (int i = 0; i < profileCount; i++) { var dataFolder = profile.GetSetting(XMLProfileSettings.SettingType.Profiles, "Profile" + i.ToString() + "/DataFolder", string.Empty); // if (!VixenApplication.IsProfileLocked(dataFolder)) //Only add the profile if it is not locked. //{ ProfileItem item = new ProfileItem(); item.Name = profile.GetSetting(XMLProfileSettings.SettingType.Profiles, "Profile" + i.ToString() + "/Name", "New Profile"); item.DataFolder = dataFolder; item.IsLocked = VixenApplication.IsProfileLocked(dataFolder); listBoxProfiles.Items.Add(item); //} } listBoxProfiles.EndUpdate(); }
private void PopulateProfileList() { XMLProfileSettings profile = new XMLProfileSettings(); List <ProfileItem> profiles = new List <ProfileItem>(); listBoxProfiles.BeginUpdate(); //Make sure we start with an empty listbox since we may repopulate after editing profiles listBoxProfiles.Items.Clear(); int profileCount = profile.GetSetting(XMLProfileSettings.SettingType.Profiles, "ProfileCount", 0); for (int i = 0; i < profileCount; i++) { var dataFolder = profile.GetSetting(XMLProfileSettings.SettingType.Profiles, "Profile" + i.ToString() + "/DataFolder", string.Empty); // if (!VixenApplication.IsProfileLocked(dataFolder)) //Only add the profile if it is not locked. //{ ProfileItem item = new ProfileItem { Name = profile.GetSetting(XMLProfileSettings.SettingType.Profiles, "Profile" + i.ToString() + "/Name", "New Profile"), DataFolder = dataFolder, IsLocked = VixenApplication.IsProfileLocked(dataFolder), DateLastLoaded = profile.GetSetting(XMLProfileSettings.SettingType.Profiles, "Profile" + i.ToString() + "/DateLastLoaded", DateTime.MinValue), ProfileNumber = i }; profiles.Add(item); //} } profiles.Sort((x, y) => y.DateLastLoaded.CompareTo(x.DateLastLoaded)); listBoxProfiles.DataSource = profiles; listBoxProfiles.EndUpdate(); }
private void SelectProfile_Load(object sender, EventArgs e) { XMLProfileSettings profile = new XMLProfileSettings(); int profileCount = profile.GetSetting("Profiles/ProfileCount", 0); for (int i = 0; i < profileCount; i++) { ProfileItem item = new ProfileItem(); item.Name = profile.GetSetting("Profiles/" + "Profile" + i.ToString() + "/Name", "New Profile"); item.DataFolder = profile.GetSetting("Profiles/" + "Profile" + i.ToString() + "/DataFolder", ""); listBoxProfiles.Items.Add(item); } }
private void PopulateProfileList() { XMLProfileSettings profile = new XMLProfileSettings(); //Make sure we start with an empty listbox since we may repopulate after editing profiles listBoxProfiles.Items.Clear(); int profileCount = profile.GetSetting(XMLProfileSettings.SettingType.Profiles, "ProfileCount", 0); for (int i = 0; i < profileCount; i++) { ProfileItem item = new ProfileItem(); item.Name = profile.GetSetting(XMLProfileSettings.SettingType.Profiles, "Profile" + i.ToString() + "/Name", "New Profile"); item.DataFolder = profile.GetSetting(XMLProfileSettings.SettingType.Profiles, "Profile" + i.ToString() + "/DataFolder", string.Empty); listBoxProfiles.Items.Add(item); } }
private void ProcessProfiles() { XMLProfileSettings profile = new XMLProfileSettings(); string loadAction = profile.GetSetting("Profiles/LoadAction", "LoadSelected"); int profileCount = profile.GetSetting("Profiles/ProfileCount", 0); int profileToLoad = profile.GetSetting("Profiles/ProfileToLoad", -1); // why ask if there is 0 or 1 profile? if (loadAction == "Ask" && profileCount > 1) { SelectProfile f = new SelectProfile(); if (f.ShowDialog() == System.Windows.Forms.DialogResult.OK) { _rootDataDirectory = f.DataFolder; } } else // So we're to use the "selected" one... { // If we don't have any profiles, get outta here if (profileCount == 0 || profileToLoad < 0) { return; } else { if (profileToLoad < profileCount) { _rootDataDirectory = profile.GetSetting("Profiles/Profile" + profileToLoad.ToString() + "/DataFolder", string.Empty); if (_rootDataDirectory != string.Empty) { if (!System.IO.Directory.Exists(_rootDataDirectory)) { System.IO.Directory.CreateDirectory(_rootDataDirectory); } } else { _rootDataDirectory = null; } } } } SetLogFilePaths(); }
private void PopulateLoadProfileSection(bool firstTime) { XMLProfileSettings profile = new XMLProfileSettings(); radioButtonAskMe.Checked = (profile.GetSetting(XMLProfileSettings.SettingType.Profiles, "LoadAction", "LoadSelected") == "Ask"); radioButtonLoadThisProfile.Checked = (!radioButtonAskMe.Checked); ProfileItem selectedItem = comboBoxLoadThisProfile.SelectedItem as ProfileItem; comboBoxLoadThisProfile.Items.Clear(); if (comboBoxProfiles.Items.Count == 0) { return; } foreach (ProfileItem item in comboBoxProfiles.Items) { comboBoxLoadThisProfile.Items.Add(item); } if (firstTime) { if (radioButtonLoadThisProfile.Checked) { int loadItemNum = profile.GetSetting(XMLProfileSettings.SettingType.Profiles, "ProfileToLoad", 0); if (loadItemNum < comboBoxLoadThisProfile.Items.Count) { comboBoxLoadThisProfile.SelectedIndex = loadItemNum; } } } else // If the combo box was already populated, we want to select the same item. if (selectedItem != null && comboBoxLoadThisProfile.Items.Contains(selectedItem)) { comboBoxLoadThisProfile.SelectedItem = selectedItem; } }
private void PopulateProfileList() { XMLProfileSettings profile = new XMLProfileSettings(); int profileCount = profile.GetSetting("Profiles/ProfileCount", 0); if (profileCount == 0) { MessageBox.Show("Unable to locate any profiles."); return; } else { for (int i = 0; i < profileCount; i++) { ProfileItem item = new ProfileItem(); item.Name = profile.GetSetting("Profiles/" + "Profile" + i.ToString() + "/Name", ""); item.DataFolder = profile.GetSetting("Profiles/" + "Profile" + i.ToString() + "/DataFolder", ""); comboBoxProfiles.Items.Add(item); } } comboBoxProfiles.SelectedIndex = 0; }
private void ProcessProfiles() { XMLProfileSettings profile = new XMLProfileSettings(); // if we don't have any profiles yet, fall through so the "Default" profile will be created int profileCount = profile.GetSetting(XMLProfileSettings.SettingType.Profiles, "ProfileCount", 0); if (profileCount == 0) { return; } // now that we know we have profiles, get the rest of the settings string loadAction = profile.GetSetting(XMLProfileSettings.SettingType.Profiles, "LoadAction", "LoadSelected"); int profileToLoad = profile.GetSetting(XMLProfileSettings.SettingType.Profiles, "ProfileToLoad", -1); // try to load the selected profile if (loadAction != "Ask" && profileToLoad > -1 && profileToLoad < profileCount) { string directory = profile.GetSetting(XMLProfileSettings.SettingType.Profiles, "Profile" + profileToLoad + "/DataFolder", string.Empty); var isLocked = IsProfileLocked(directory); if (!string.IsNullOrEmpty(directory) && Directory.Exists(directory) && !isLocked) { _rootDataDirectory = directory; string profileName = profile.GetSetting(XMLProfileSettings.SettingType.Profiles, "Profile" + profileToLoad + "/Name", string.Empty); UpdateTitleWithProfileName(profileName); } else { string name = profile.GetSetting(XMLProfileSettings.SettingType.Profiles, "Profile" + profileToLoad + "/Name", string.Empty); ShowLoadProfileErrorMessage(name, isLocked); } } // if _rootDataDirectory is still empty at this point either we're configured to always ask or loading the selected profile failed // keep asking until we get a good profile directory while (string.IsNullOrEmpty(_rootDataDirectory)) { SelectProfile selectProfile = new SelectProfile(); DialogResult result = selectProfile.ShowDialog(); if (result == DialogResult.OK) { string directory = selectProfile.DataFolder; var isLocked = IsProfileLocked(directory); if (!string.IsNullOrEmpty(directory) && Directory.Exists(directory) && !isLocked) { _rootDataDirectory = directory; UpdateTitleWithProfileName(selectProfile.ProfileName); break; } ShowLoadProfileErrorMessage(selectProfile.ProfileName, isLocked); } else if (result == DialogResult.Cancel) { var messageBox = new MessageBoxForm(Application.ProductName + " cannot continue without a vaild profile." + Environment.NewLine + Environment.NewLine + "Are you sure you want to exit " + Application.ProductName + "?", Application.ProductName, MessageBoxButtons.YesNo, SystemIcons.Warning); messageBox.ShowDialog(); if (messageBox.DialogResult == DialogResult.OK) { Environment.Exit(0); } } else { // SelectProfile.ShowDialog() should only return DialogResult.OK or Cancel, how did we get here? throw new NotImplementedException("SelectProfile.ShowDialog() returned " + result.ToString()); } } SetLogFilePaths(); }
private void ProcessProfiles() { XMLProfileSettings profile = new XMLProfileSettings(); // if we don't have any profiles yet, fall through so the "Default" profile will be created int profileCount = profile.GetSetting(XMLProfileSettings.SettingType.Profiles, "ProfileCount", 0); if (profileCount == 0) { return; } // now that we know we have profiles, get the rest of the settings string loadAction = profile.GetSetting(XMLProfileSettings.SettingType.Profiles, "LoadAction", "LoadSelected"); int profileToLoad = profile.GetSetting(XMLProfileSettings.SettingType.Profiles, "ProfileToLoad", -1); // try to load the selected profile if (loadAction != "Ask" && profileToLoad > -1 && profileToLoad < profileCount) { string directory = profile.GetSetting(XMLProfileSettings.SettingType.Profiles, "Profile" + profileToLoad + "/DataFolder", string.Empty); if (!string.IsNullOrEmpty(directory) && Directory.Exists(directory)) { _rootDataDirectory = directory; string profileName = profile.GetSetting(XMLProfileSettings.SettingType.Profiles, "Profile" + profileToLoad + "/Name", string.Empty); UpdateTitleWithProfileName(profileName); } else { string name = profile.GetSetting(XMLProfileSettings.SettingType.Profiles, "Profile" + profileToLoad + "/Name", string.Empty); //messageBox Arguments are (Text, Title, No Button Visible, Cancel Button Visible) MessageBoxForm.msgIcon = SystemIcons.Error; //this is used if you want to add a system icon to the message form. var messageBox = new MessageBoxForm("Selected profile '" + name + "' data directory does not exist!" + Environment.NewLine + Environment.NewLine + directory + Environment.NewLine + Environment.NewLine + "Select a different profile to load or use the Profile Editor to create a new profile.", "Error", false, false); messageBox.ShowDialog(); } } // if _rootDataDirectory is still empty at this point either we're configured to always ask or loading the selected profile failed // keep asking until we get a good profile directory while (string.IsNullOrEmpty(_rootDataDirectory)) { SelectProfile selectProfile = new SelectProfile(); DialogResult result = selectProfile.ShowDialog(); if (result == DialogResult.OK) { string directory = selectProfile.DataFolder; if (!string.IsNullOrEmpty(directory) && Directory.Exists(directory)) { _rootDataDirectory = directory; UpdateTitleWithProfileName(selectProfile.ProfileName); break; } //messageBox Arguments are (Text, Title, No Button Visible, Cancel Button Visible) MessageBoxForm.msgIcon = SystemIcons.Error; //this is used if you want to add a system icon to the message form. var messageBox = new MessageBoxForm("The data directory for the selected profile does not exist!" + Environment.NewLine + Environment.NewLine + directory + Environment.NewLine + Environment.NewLine + "Select a different profile to load or use the Profile Editor to create a new profile.", "Error", false, false); messageBox.ShowDialog(); } else if (result == DialogResult.Cancel) { //messageBox Arguments are (Text, Title, No Button Visible, Cancel Button Visible) MessageBoxForm.msgIcon = SystemIcons.Warning; var messageBox = new MessageBoxForm(Application.ProductName + " cannot continue without a vaild profile." + Environment.NewLine + Environment.NewLine + "Are you sure you want to exit " + Application.ProductName + "?", Application.ProductName, true, false); messageBox.ShowDialog(); if (messageBox.DialogResult == DialogResult.OK) { Environment.Exit(0); } } else { // SelectProfile.ShowDialog() should only return DialogResult.OK or Cancel, how did we get here? throw new NotImplementedException("SelectProfile.ShowDialog() returned " + result.ToString()); } } SetLogFilePaths(); }