Exemplo n.º 1
0
 public static BaseForm GetMainFormInstance(ConfigFormEntity FormConfig, List <ConfigControlsEntity> ControlConfigs)
 {
     if (mainform == null)
     {
         object _form = null;
         if (FormConfig.AssembleFile == null && FormConfig.AssembleFile.Equals(string.Empty))
         {
             string[] _t = FormConfig.AssembleString.Split('.');
             _form = System.Reflection.Assembly.Load(_t[0]).CreateInstance(FormConfig.AssembleString);
         }
         else
         {
             _form = System.Reflection.Assembly.LoadFrom(FormConfig.AssembleFile).CreateInstance(FormConfig.AssembleString);
         }
         mainform = _form as BaseForm;
         if (mainform == null)
         {
             throw new Exception("Init MainForm failed, please check your config;");
         }
         else
         {
             mainform.LoadConfig(FormConfig);
         }
         loadControls(ControlConfigs);
     }
     return(mainform);
 }
Exemplo n.º 2
0
        public static BaseForm ReLoad(ConfigFormEntity FormConfig, List <ConfigControlsEntity> ControlConfigs)
        {
            _controls.Clear();
            object _form = null;

            if (FormConfig.AssembleFile == null && FormConfig.AssembleFile.Equals(string.Empty))
            {
                string[] _t = FormConfig.AssembleString.Split('.');
                _form = System.Reflection.Assembly.Load(_t[0]).CreateInstance(FormConfig.AssembleString);
            }
            else
            {
                _form = System.Reflection.Assembly.LoadFrom(FormConfig.AssembleFile).CreateInstance(FormConfig.AssembleString);
            }
            mainform = _form as BaseForm;
            if (mainform == null)
            {
                throw new Exception("Init MainForm failed, please check your config;");
            }
            else
            {
                mainform.LoadConfig(FormConfig);
            }
            loadControls(ControlConfigs);

            mainform.FormClosing += new System.Windows.Forms.FormClosingEventHandler(mainform_FormClosing);
            mainform.FormClosed  += new System.Windows.Forms.FormClosedEventHandler(mainform_FormClosed);
            return(mainform);
        }
Exemplo n.º 3
0
        public void LoadConfig(ConfigFormEntity FormConfig)
        {
            if (FormConfig != null)
            {
                this.MaximizeBox = false;
                this.MinimizeBox = false;

                if (FormConfig.FullScreen)
                {
                    this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;
                    this.WindowState     = FormWindowState.Maximized;
                    this.Bounds          = Screen.PrimaryScreen.Bounds;
                }
                else
                {
                    this.StartPosition = FormStartPosition.Manual;
                    this.Top           = FormConfig.Top;
                    this.Left          = FormConfig.Left;
                    this.Width         = FormConfig.Width;
                    this.Height        = FormConfig.Height;



                    if (FormConfig.Resizable)
                    {
                        this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.Sizable;
                        this.MaximizeBox     = true;
                        this.MinimizeBox     = true;
                    }
                    else
                    {
                        this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle;
                        this.MinimizeBox     = true;
                    }
                }
            }
            else
            {
                throw new Exception("Form Config is Null");
            }
        }