Ejemplo n.º 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);
        }
Ejemplo n.º 2
0
 private void ClientForm_FormClosed(object sender, FormClosedEventArgs e)
 {
     FormState.SaveFormState(this, "ClientForm", null);
 }