Example #1
0
        public static void Display(Config config, int index)
        {
            using (frmUserButtonStyle frm = new frmUserButtonStyle())
            {
                ButtonStyle.EnsureConfigUserDefaultsSet(config);                 // (theoretically reachable without having created the default if they started in teacher mode?)
                frm.ctrStyle.DisplayStyle(config.ButtonStyle[index]);
                Transaction objTransaction = new Transaction();
                objTransaction.Edit(config.ButtonStyle[index]);

                string typeName;
                switch (index)
                {
                case 0:
                    typeName = Strings.Item("Config_ButtonStyle_Action");
                    break;

                case 1:
                    typeName = Strings.Item("Config_ButtonStyle_Selection");
                    break;

                default:
                    SAW.Item.ItemDisplayTypes displayType = (SAW.Item.ItemDisplayTypes)(index - 2);
                    typeName = Strings.Item("SAW_Style_" + displayType.ToString().Replace("IDT_", ""));
                    break;
                }
                frm.Text = Strings.Item("Button_UserStyle_Title") + ": " + typeName;

                frm.lblHeader.Text = Strings.Item("Button_UserStyle_Header").Replace("%0", typeName);

                if (frm.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                {
                    ButtonStyle.SetDefaultOnUserChange();                     // This is often redundant as we are in teacher mode and editing the user mode, but it is harmless and IS occasionally needed
                    Globals.Root.StoreNewTransaction(objTransaction);
                }
                else
                {
                    objTransaction.Cancel();
                }
            }
            //frm.Dispose(); // Must be disposed immediately because the style panel registers itself with Engine
        }