예제 #1
0
파일: MainForm.cs 프로젝트: sasiit23/smah1
        private void AddButton(ButtonHelperClass btnInfo)
        {
            Button btn = new Button();

            btn.Name     = btnInfo.ButtonName;
            btn.Size     = new Size(130, 32);
            btn.TabIndex = panel.Controls.Count;
            btn.Text     = btnInfo.ButtonText;
            btn.Margin   = new Padding(5, 3, 15, 3);
            btn.UseVisualStyleBackColor = true;
            btn.Click += (btnInfo.Click != null ?
                          btnInfo.Click :
                          new System.EventHandler(this.button_Click));
            btn.Tag = btnInfo;

            panel.Controls.Add(btn);
        }
예제 #2
0
파일: MainForm.cs 프로젝트: sasiit23/smah1
        private void button_Click(object sender, EventArgs e)
        {
            try
            {//For run in mono
                Button            btn     = (Button)sender;
                ButtonHelperClass btnInfo = (ButtonHelperClass)btn.Tag;

                Type frmType = Type.GetType(btnInfo.ClassName);
                if (frmType != null)
                {
                    System.Reflection.ConstructorInfo oConstructorInfo = frmType.GetConstructor(System.Type.EmptyTypes);
                    Form frm = (Form)oConstructorInfo.Invoke(null);
                    ShowForm(frm);
                }
                else
                {
                    btnInfo.Click(sender, e);
                }
            }
            catch (Exception exc)
            {
                MessageBox.Show(exc.StackTrace + Environment.NewLine + exc.Message);
            }
        }