private Button GetButtonFromMethod(MethodCallInfo method, int width, int height) { var btn = new Button(); //btn.Text = method.DisplayName; btn.Text = string.Format("{0} : {1}", method.MethodSignatureShort, method.ReturnType.Name); btn.Left = 0; btn.Height = height; btn.Width = width; btn.Anchor = AnchorStyles.Left | AnchorStyles.Top | AnchorStyles.Right; btn.Click += (s, e) => { object returnObject = null; List<object> parameters = null; if (method.HasParameters) { using (var form = new MethodParamForm(method)) { if (form.ShowDialog() == DialogResult.OK) { try { method.Invoke(form.Parameters, out returnObject); } catch (Exception ex) { Dump(ex); tbMethodLog.AppendText(string.Format("{0} ⇒ Exception: {1}\r\n", method.Name, ex.Message)); return; } } else { return; } } } else { try { method.Invoke(null, out returnObject); } catch (Exception ex) { Dump(ex); tbMethodLog.AppendText(string.Format("{0} ⇒ Exception: {1}\r\n", method.Name, ex.Message)); return; } } Dump(returnObject); tbMethodLog.AppendText(string.Format("{0} ⇒ {1}\r\n", method.Name, returnObject ?? "null")); // Update board control gameBoardViewer1.Invalidate(); }; return btn; }