Example #1
0
        private static bool CheckConfigurationForOutOfDate(string currentIniFilename)
        {
            MOG_Ini pIni = new MOG_Ini();

            if (pIni.Open(currentIniFilename, FileShare.Read))
            {
                foreach (string upgradeSection in pIni.GetSections(null))
                {
                    if (pIni.KeyExist(upgradeSection, VisisbleIndex_Key) == false ||
                        upgradeSection.StartsWith(CustomSectionIndicator_Text, StringComparison.CurrentCultureIgnoreCase))
                    {
                        // Only add the visisble key to ini's with a controlName defined
                        if (pIni.KeyExist(upgradeSection, ControlName_Key) && pIni.KeyExist(upgradeSection, VisisbleIndex_Key) == false)
                        {
                            return(true);
                        }

                        // Check for depricated section names
                        if (upgradeSection.StartsWith("CustomControl", StringComparison.CurrentCultureIgnoreCase))
                        {
                            return(true);
                        }
                    }
                }
                pIni.Close();
            }

            return(false);
        }
Example #2
0
        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;
                }
            }
        }