Exemple #1
0
        public DialogResult OpenDialogForm(Type formType, string title, ViewModelBase viewModel = null)
        {
            Form frm;

            if (viewModel == null)
            {
                frm = Activator.CreateInstance(formType, title) as Form;
            }
            else
            {
                frm = Activator.CreateInstance(formType, viewModel, title) as Form;
            }
            if (frm != null)
            {
                //加载布局
                FormState.LoadFormState(frm, title, viewModel);
                //添加保存布局事件
                frm.ShowIcon      = false;
                frm.ShowInTaskbar = false;
                MinimumSize       = new Size(820, 200);
                frm.Closed       += (object sender, EventArgs e) => { FormState.SaveFormState(frm, title, viewModel); };
                return(frm.ShowDialog(this));
            }

            return(DialogResult.None);
        }
Exemple #2
0
 public ClientForm()
 {
     if (new LoginForm().ShowDialog() != DialogResult.OK)
     {
         System.Diagnostics.Process.GetCurrentProcess().Kill();
     }
     LastInstance = this;
     InitializeComponent();
     Text = AppConfig.Instance.AppName;
     LoadIcon();
     FormState.LoadFormState(this, "ClientForm", null);
 }