using DeviceRepairAndOptimization.Common;
using System;

namespace DeviceRepairAndOptimization.Pages
{
    public partial class DialogWindow : DevExpress.XtraEditors.XtraForm
    {
        public DialogWindow(string Caption, Type T, bool isHideOperationPanel = false)
        {
            InitializeComponent();
            this.DialogResult = System.Windows.Forms.DialogResult.Cancel;
            this.Text = Caption;
            this.pnl_Content.ShowInPanel((FormBase)Activator.CreateInstance(T, new Action(() => { DialogResult = System.Windows.Forms.DialogResult.OK; this.Close(); })));
            if (isHideOperationPanel)
                stackPanel1.Hide();
        }

        public DialogWindow(string Caption, Type T, System.Data.DataRow Datas)
        {
            InitializeComponent();
            this.Text = Caption;
            this.pnl_Content.ShowInPanel((FormBase)Activator.CreateInstance(T, Datas));
        }

        private void simpleButton2_Click(object sender, EventArgs e)
        {
            this.DialogResult = System.Windows.Forms.DialogResult.OK;
            this.Close();
        }

        private void simpleButton1_Click(object sender, EventArgs e)
        {
            this.Close();
        }
    }
}