Exemplo n.º 1
0
        public void UpdateControl(MOG_Ini pIni, ToolBox toolBox)
        {
            try
            {
                // Do we need to load this file?
                if (pIni == null)
                {
                    string currentIniFilename = toolBox.GetCurrentIniFilenameFromLocation(Location);
                    pIni = new MOG_Ini(currentIniFilename);
                }

                string type = "";
                // If we can, get the ToolBoxControlType of this control...
                if (pIni.KeyExist(ControlGuid, Type_Key))
                {
                    type = pIni.GetString(ControlGuid, Type_Key);
                }
                // Get the ToolBoxControlType from the ini
                ControlType = (ToolBoxControlType)Enum.Parse(ToolBoxControlType.Button.GetType(), type, true);

                // If we can, get our ToolBoxControlLocation for this control...
                if (pIni.KeyExist(ControlGuid, Location_Key))
                {
                    // Get the location from the ini
                    Location = (ToolBoxControlLocation)Enum.Parse(ToolBoxControlLocation.Project.GetType(), pIni.GetString(ControlGuid, Location_Key), true);
                }

                // If we can, get the HideWindow value...
                if (pIni.KeyExist(ControlGuid, HideWindow_Key))
                {
                    HideOutput = pIni.GetBool(ControlGuid, HideWindow_Key);
                }

                // Get all of our default values: (see ControlDefinition for what these identifiers mean)
                // If we can, get the ControlName...
                if (pIni.KeyExist(ControlGuid, ControlName_Key))
                {
                    ControlName = pIni.GetString(ControlGuid, ControlName_Key);

                    // Should this control have it's text updated?
                    bool bUpdateControlText = false;
                    switch (this.ControlType)
                    {
                    case ToolBoxControlType.Button:                         bUpdateControlText = true;                      break;

                    case ToolBoxControlType.ParameterButton:        bUpdateControlText = true;                      break;

                    case ToolBoxControlType.Label:                          bUpdateControlText = true;                      break;

                    case ToolBoxControlType.LinkLabel:                      bUpdateControlText = true;                      break;

                    case ToolBoxControlType.IniCombo:                       bUpdateControlText = false;                     break;

                    case ToolBoxControlType.FileCombo:                      bUpdateControlText = false;                     break;

                    case ToolBoxControlType.CheckBox:                       bUpdateControlText = true;                      break;

                    case ToolBoxControlType.RadioButton:            bUpdateControlText = true;                      break;
                    }

                    if (bUpdateControlText)
                    {
                        DefButton.Text = ControlName;
                    }
                }
                // If we can, get the Command...
                if (pIni.KeyExist(ControlGuid, Command_Key))
                {
                    Command = pIni.GetString(ControlGuid, Command_Key);
                }
                // If we can, get the Arguments...
                if (pIni.KeyExist(ControlGuid, Arguments_Key))
                {
                    Arguments = pIni.GetString(ControlGuid, Arguments_Key);
                }
                // If we can, get the ArgumentTrue...
                if (pIni.KeyExist(ControlGuid, ArgumentsTrue_Key))
                {
                    ArgumentTrue = pIni.GetString(ControlGuid, ArgumentsTrue_Key);
                }
                // If we can, get the ArgumentFalse...
                if (pIni.KeyExist(ControlGuid, ArgumentsFalse_Key))
                {
                    ArgumentFalse = pIni.GetString(ControlGuid, ArgumentsFalse_Key);
                }

                // If we can, get the TagName...
                if (pIni.KeyExist(ControlGuid, TagName_Key))
                {
                    TagName = pIni.GetString(ControlGuid, TagName_Key);
                }
                // If we can, get the ToolTipString...
                if (pIni.KeyExist(ControlGuid, ToolTip_Key))
                {
                    ToolTipString = pIni.GetString(ControlGuid, ToolTip_Key);
                }
                // If we can, get the FolderName...
                if (pIni.KeyExist(ControlGuid, FolderName_Key))
                {
                    FolderName = pIni.GetString(ControlGuid, FolderName_Key);
                }
                // If we can, get the ComboBoxDepth...
                if (pIni.KeyExist(ControlGuid, ComboBoxDepth_Key))
                {
                    ComboBoxDepth = int.Parse(pIni.GetString(ControlGuid, ComboBoxDepth_Key));
                }
                // If we can, get our Pattern
                if (pIni.KeyExist(ControlGuid, Pattern_Key))
                {
                    Pattern = pIni.GetString(ControlGuid, Pattern_Key);
                }
                // If we can, get our ini filename path
                if (pIni.KeyExist(ControlGuid, IniFilename_Key))
                {
                    IniFilename = pIni.GetString(ControlGuid, IniFilename_Key);
                }
                // If we can, get our ini section name
                if (pIni.KeyExist(ControlGuid, IniSection_Key))
                {
                    IniSectionName = pIni.GetString(ControlGuid, IniSection_Key);
                }
                // If we can, get our DialogStartPath
                if (pIni.KeyExist(ControlGuid, DialogStartPath_Key))
                {
                    DialogStartPath = pIni.GetString(ControlGuid, DialogStartPath_Key);
                }
                // If we can, set our LastSelectedIndex
                // By adding the scope of the user's name to the section key we can retain a user's own settings seperatly from the rest of the team
                string usersLastIndex_Key = MOG_ControllerProject.IsUser() ? LastIndex_Key + SubSectionIndicator_Text + MOG_ControllerProject.GetUserName(): LastIndex_Key;
                if (pIni.KeyExist(ControlGuid, usersLastIndex_Key))
                {
                    LastSelectedIndex = int.Parse(pIni.GetString(ControlGuid, usersLastIndex_Key));
                }

                if (pIni.KeyExist(ControlGuid, ShowFullPaths_Key))
                {
                    ShowFullPaths = Convert.ToBoolean(pIni.GetString(ControlGuid, ShowFullPaths_Key));
                }
                if (pIni.KeyExist(ControlGuid, ShowWorkspaceRelativePaths_Key))
                {
                    ShowWorkspaceRelativePaths = Convert.ToBoolean(pIni.GetString(ControlGuid, ShowWorkspaceRelativePaths_Key));
                }
                if (pIni.KeyExist(ControlGuid, ShowFolderRelativePaths_Key))
                {
                    ShowFolderRelativePaths = Convert.ToBoolean(pIni.GetString(ControlGuid, ShowFolderRelativePaths_Key));
                }
                if (pIni.KeyExist(ControlGuid, ShowBasePaths_Key))
                {
                    ShowBasePaths = Convert.ToBoolean(pIni.GetString(ControlGuid, ShowBasePaths_Key));
                }

                if (pIni.KeyExist(ControlGuid, VisisbleIndex_Key))
                {
                    VisibleIndex = Convert.ToInt32(pIni.GetString(ControlGuid, VisisbleIndex_Key));
                }

                if (pIni.KeyExist(ControlGuid, FullPaths_Key))
                {
                    TagFullPaths = Convert.ToBoolean(pIni.GetString(ControlGuid, FullPaths_Key));
                }

                if (pIni.KeyExist(ControlGuid, WorkspaceRelativePaths_Key))
                {
                    TagWorkspaceRelativePaths = Convert.ToBoolean(pIni.GetString(ControlGuid, WorkspaceRelativePaths_Key));
                }

                if (pIni.KeyExist(ControlGuid, FolderRelativePaths_Key))
                {
                    TagFolderRelativePaths = Convert.ToBoolean(pIni.GetString(ControlGuid, FolderRelativePaths_Key));
                }

                if (pIni.KeyExist(ControlGuid, BasePaths_Key))
                {
                    TagBasePaths = Convert.ToBoolean(pIni.GetString(ControlGuid, BasePaths_Key));
                }

                if (pIni.KeyExist(ControlGuid, RecurseFolders_Key))
                {
                    RecurseFolders = Convert.ToBoolean(pIni.GetString(ControlGuid, RecurseFolders_Key));
                }

                // If we can, get the ComboBoxItems
                // By adding the scope of the user's name to the section key we can retain a user's own settings seperatly from the rest of the team
                string usersSection = MOG_ControllerProject.IsUser() ? ControlGuid + ComboItems_Section + SubSectionIndicator_Text + MOG_ControllerProject.GetUserName(): ControlGuid + ComboItems_Section;
                if (pIni.SectionExist(usersSection))
                {
                    ComboBoxItems = LoadComboBoxItems(usersSection, pIni);
                }

                // If we can, get our RadioButtons
                if (pIni.SectionExist(ControlGuid + RadioButton_Section))
                {
                    RadioButtons = LoadRadioButtons(ControlGuid + RadioButton_Section, pIni);
                }
            }
            catch (Exception e)
            {
                e.ToString();
            }
        }
Exemplo n.º 2
0
        public void Save(MOG_Ini pIni, string section)
        {
            // Write the type out to the INI
            pIni.PutString(section, Type_Key, ControlType.ToString());

            // Write our location out to the INI
            pIni.PutString(section, Location_Key, Location.ToString());

            // Write the name of the control out to our INI
            pIni.PutString(section, ControlName_Key, ControlName);
            // Write our TagName
            pIni.PutString(section, TagName_Key, TagName);

            // Write our Command
            pIni.PutString(section, Command_Key, Command);
            // Write whether or not we will be hiding output window
            pIni.PutBool(section, HideWindow_Key, HideOutput);

            // (ADD_HERE):  Any new Controls must be added here...

            pIni.PutString(section, VisisbleIndex_Key, VisibleIndex.ToString());

            // Write our arguments
            pIni.PutString(section, Arguments_Key, Arguments);
            pIni.PutString(section, ArgumentsTrue_Key, ArgumentTrue);
            pIni.PutString(section, ArgumentsFalse_Key, ArgumentFalse);

            // Write our ToolTipString
            pIni.PutString(section, ToolTip_Key, ToolTipString);

            // Write the folder path we will start at for dialogs
            pIni.PutString(section, FolderName_Key, FolderName);

            // Write out the depth we will support for this def's ComboBox
            pIni.PutString(section, ComboBoxDepth_Key, ComboBoxDepth.ToString());

            // Write out the show full paths bool
            pIni.PutString(section, ShowFullPaths_Key, ShowFullPaths.ToString());
            pIni.PutString(section, ShowWorkspaceRelativePaths_Key, ShowWorkspaceRelativePaths.ToString());
            pIni.PutString(section, ShowFolderRelativePaths_Key, ShowFolderRelativePaths.ToString());
            pIni.PutString(section, ShowBasePaths_Key, ShowBasePaths.ToString());

            // Write out the relative paths bool
            pIni.PutString(section, FullPaths_Key, TagFullPaths.ToString());
            pIni.PutString(section, WorkspaceRelativePaths_Key, TagWorkspaceRelativePaths.ToString());
            pIni.PutString(section, FolderRelativePaths_Key, TagFolderRelativePaths.ToString());
            pIni.PutString(section, BasePaths_Key, TagBasePaths.ToString());

            pIni.PutString(section, RecurseFolders_Key, RecurseFolders.ToString());

            // Write our IniSectionName
            pIni.PutString(section, IniSection_Key, IniSectionName);
            // Write out our IniFilename
            pIni.PutString(section, IniFilename_Key, IniFilename);
            // Write out our GUID
            pIni.PutString(section, GUID_Key, section);

            // Write out our ComboBoxDepth
            pIni.PutString(section, ComboBoxDepth_Key, ComboBoxDepth.ToString());

            // By adding the scope of the user's name to the section key we can retain a user's own settings seperatly from the rest of the team
            string usersLastIndex_Key = MOG_ControllerProject.IsUser() ? LastIndex_Key + SubSectionIndicator_Text + MOG_ControllerProject.GetUserName(): LastIndex_Key;

            pIni.PutString(section, usersLastIndex_Key, LastSelectedIndex.ToString());

            // If we are a fileComboBox write out our items
            if (ControlType == ToolBoxControlType.FileCombo)
            {
                // By adding the scope of the user's name to the section key we can retain a user's own settings seperatly from the rest of the team
                string usersSection = MOG_ControllerProject.IsUser() ? section + ComboItems_Section + SubSectionIndicator_Text + MOG_ControllerProject.GetUserName(): section + ComboItems_Section;

                int count = 0;
                foreach (MogTaggedString item in DefComboBox.Items)
                {
                    pIni.PutString(usersSection, ComboItems_Key + count++, (string)item.AttachedItem);
                }
            }

            // Write out the fileComboBox patterns
            pIni.PutString(section, Pattern_Key, Pattern);

            // If we are a ToolBoxGroupBox, write out our radio buttons
            if (ControlType == ToolBoxControlType.RadioButton)
            {
                foreach (DictionaryEntry button in RadioButtons)
                {
                    pIni.PutString(section + RadioButton_Section, (string)button.Key, (string)button.Value);
                }
            }
        }