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(); } }
internal void Remove(ToolBox toolbox) { // Write out our change string currentIniFilename = toolbox.GetCurrentIniFilenameFromLocation(Location); MOG_Ini pIni = new MOG_Ini(); OpenConfigIni: if (pIni.Open(currentIniFilename, FileShare.Write)) { // Remove this control from the siblings mSiblings.Remove(VisibleIndex); // Go thru all of this controls siblings and move their visual index up one so that there is not a break in the chain foreach (KeyValuePair <int, ControlDefinition> sibling in mSiblings) { // Is this guy visually after the one we are deleting? if (sibling.Value.VisibleIndex > VisibleIndex) { // Then move it up one sibling.Value.VisibleIndex = sibling.Value.VisibleIndex - 1; // Make sure this section actually exists if (pIni.SectionExist(sibling.Value.ControlGuid)) { pIni.PutString(sibling.Value.ControlGuid, VisisbleIndex_Key, sibling.Value.VisibleIndex.ToString()); } } } pIni.RemoveSection(ControlGuid); // Scan all the sections looking for any related subsections ArrayList relatedSubSections = new ArrayList(); string subControlGuid = ControlGuid + SubSectionIndicator_Text; foreach (string section in pIni.GetSections(null)) { if (section.StartsWith(subControlGuid, StringComparison.CurrentCultureIgnoreCase)) { // Schedule this subsection for removal relatedSubSections.Add(section); } } // Remove any subsections related to this control foreach (string section in relatedSubSections) { pIni.RemoveSection(section); } pIni.Save(); pIni.Close(); } else { if ( MOG_Prompt.PromptResponse("Configuration locked!", "Configuration file for this control is currently in use by another user", MOGPromptButtons.RetryCancel) == MOGPromptResult.Retry) { goto OpenConfigIni; } } }
public void UpdateControl(ToolBox toolBox) { UpdateControl(null, toolBox); }
/// <summary> /// Initialize a ControlDefinition (always NOT visible and NOT enabled) /// </summary> /// <param name="controlType">Indicates the type of the control we are representing.</param> public ControlDefinition(ToolBoxControlType controlType, ToolBox parent, string openingStackTrace) : this(parent, openingStackTrace) { this.mControlType = controlType; }