示例#1
0
        public AppearancePanelForm(AppearanceClass app)
        {
            this.Icon = LayoutDetails.Instance.MainFormIcon;
            FormUtils.SizeFormsForAccessibility(this, LayoutDetails.Instance.MainFormFontSize);

            Panel bottom = new Panel();

            bottom.Dock   = DockStyle.Bottom;
            bottom.Height = LayoutDetails.ButtonHeight;
            ok            = new Button();



            ok.Text         = Loc.Instance.GetString("OK");
            ok.DialogResult = DialogResult.OK;
            ok.Dock         = DockStyle.Left;


            Button Cancel = new Button();

            Cancel.Text         = Loc.Instance.GetString("Cancel");
            Cancel.Dock         = DockStyle.Right;
            Cancel.DialogResult = System.Windows.Forms.DialogResult.Cancel;

            bottom.Controls.Add(ok);
            bottom.Controls.Add(Cancel);


            if (app == null)
            {
                // we are in build mode. So we create a classic note
                app = AppearanceClass.SetAsClassic();

                app.Name   = "Choose A Unique Name For Your New Appearance";
                ok.Enabled = false;
            }



            appearancePanel = new AppearancePanel(false, app, null, ValidData, true);

            appearancePanel.Dock = DockStyle.Fill;
            this.Controls.Add(bottom);
            this.Controls.Add(appearancePanel);
            appearancePanel.BringToFront();
        }
        //	System.Collections.SortedList  AppearanceCache = new SortedList();
        //List<Appearance> AppearanceCache = new List<Appearance>();
        public AppearanceClass GetAppearanceByName(string classic)
        {
            if (null == GetAppearanceFromStorage)
            {
                throw new Exception("A callback to GetAppearanceFromStorage needs to be defined when application initalizes");
            }


            //Hashtable attempt 6.7 seconds to 6.4 on second attempt

            AppearanceClass app = (AppearanceClass)AppearanceCache [classic];

            if (app != null)
            {
            }
            else
            {
                app = GetAppearanceFromStorage(classic);

                if (app == null)
                {
                    NewMessage.Show(Loc.Instance.GetStringFmt("The appearance {0} no longer exists, reverting to default.", classic));
                    // somehow we have lost an appearance then we just use clasic
                    app = AppearanceClass.SetAsClassic();
                }
                //app = new Appearance();
                //app.SetAsClassic();

                AppearanceCache.Add(classic, app);
            }

            //6.4 seconds to 6.9
//			Appearance app = (Appearance)AppearanceCache [classic];
//			if (app != null) {
//			} else {
//				NewMessage.Show ("Hack : 'grabbing app from database. Should see this only once a session");
//							app = new Appearance();
//							app.SetAsClassic();
//
//								AppearanceCache.Add (classic, app);
//			}
//



            // 1. Look to see if it already exist. If so, retrieve it. about 6.6 seconds on zombie
            //    IF NOT, load from database

            /* This seemed faster than Sorted list
             *
             * Appearance app = AppearanceCache.Find (Appearance => Appearance.Name == classic);
             * if (app != null) {
             *
             * }
             * else
             * {
             *      NewMessage.Show ("Hack : 'grabbing app from database. Should see this only once a session");
             * app = new Appearance();
             * app.SetAsClassic();
             *
             *      AppearanceCache.Add (app);
             * }
             */
            return(app);
        }