Inheritance: Common.Controls.BaseForm
示例#1
0
        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();
        }
示例#2
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();
        }
示例#3
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);
                if (!string.IsNullOrEmpty(directory) && Directory.Exists(directory))
                {
                    _rootDataDirectory = directory;
                }
                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;
                        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)
                    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();
        }
示例#4
0
 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();
 }
示例#5
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);
                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();
        }
示例#6
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();
        }