Esempio n. 1
0
        /// <summary>Edits the config.  Document should be the document being edited, not the config container document</summary>
        public static DialogResult EditConfig(Config.Levels level, Document document, Config config = null, bool userOnly = false, Sections initialSection = (Sections)(-1))
        {
            // returns DialogResult = Yes if OK, but has stored doc settings transaction which will have triggered refresh of main screen settings already
            Config.UserCurrent.StorePalettePositions();
            if (config == null)
            {
                config = Globals.Root.GetCurrentConfig(level, document);
            }
            frmEditConfig frm = new frmEditConfig(config, level, document);

            if (initialSection >= 0)
            {
                frm.pnlSections.SelectedIndex = (int)initialSection;
            }
            DialogResult result = frm.ShowDialog();

            if (result == DialogResult.OK)
            {
                bool usersChanged    = false;
                bool documentChanged = false;
                bool activityChanged = false;
                foreach (Config changed in frm.m_Changed.Values)
                {
                    if (changed == Config.UserUser)
                    {
                        usersChanged = true;
                    }
                    else if (changed == Config.SystemConfig)
                    {
                        Globals.Root.SaveSystemConfig();
                    }
                    else if (changed == document.UserSettings || changed == document.BothSettings)
                    {
                        documentChanged = true;
                    }
                    else
                    {
                        // must be from current activity; could be either part
                        activityChanged = true;
                    }
                }
                if (documentChanged)
                {
                    Globals.Root.StoreNewTransaction(frm.m_Transaction);
                }
                if (usersChanged)
                {
                    Globals.Root.SaveUserConfigs();
                }
                if (activityChanged)
                {
                    Globals.Root.SaveActivityConfig();
                }
                if (frm.m_PalettePurposeChanged)
                {
                    // One or more user-defined palettes have had their purpose changed
                    foreach (Palette palette in Palette.List.Values)
                    {
                        if (palette.UserDefined)
                        {
                            palette.PalettePurpose = palette.CustomDocument.PalettePurpose;
                        }
                    }
                }
                if (frm.m_OpenPaletteOnExit != null)
                {
                    if (Globals.Root.User == Users.User)
                    {
                        Globals.Root.User = Users.Editor;
                    }
                    Globals.Root.SelectDocument(frm.m_OpenPaletteOnExit);
                }
                Globals.OnSettingsChanged();
            }
            else
            {
                frm.m_Transaction.Cancel();
            }
            return(result);
        }
Esempio n. 2
0
 protected override void Dispose(bool disposing)
 {
     base.Dispose(disposing);
     Form = null;
 }