Exemplo n.º 1
0
        // 从配置文件中读取信息,设置form尺寸位置状态
        // parameters:
        //		form	Form对象
        //		strCfgTitle	配置信息路径。本函数将用此值作为GetString()或GetInt()的strPath参数使用
        public static void LoadFormStates(this ConfigSetting config,
                                          Form form,
                                          string strCfgTitle,
                                          FormWindowState default_state)
        {
            // 为了优化视觉效果
            bool bVisible = form.Visible;

            if (bVisible == true)
            {
                form.Visible = false;
            }

            form.Width = config.GetInt(
                strCfgTitle, "width", form.Width);
            form.Height = config.GetInt(
                strCfgTitle, "height", form.Height);

            form.Location = new Point(
                config.GetInt(strCfgTitle, "x", form.Location.X),
                config.GetInt(strCfgTitle, "y", form.Location.Y));

            string strState = config.Get(
                strCfgTitle,
                "window_state",
                "");

            if (String.IsNullOrEmpty(strState) == true)
            {
                form.WindowState = default_state;
            }
            else
            {
                form.WindowState = (FormWindowState)Enum.Parse(typeof(FormWindowState),
                                                               strState);
            }

            if (bVisible == true)
            {
                form.Visible = true;
            }

            /// form.Update();  // 2007/4/8
        }