public Form1(Inventor.Application oApp) { // This call is required by the Windows Form Designer. InitializeComponent(); // Add any initialization after the InitializeComponent() call. _macros = new Macros(oApp); MemberInfo[] methods = _macros.GetType().GetMembers(); foreach (MemberInfo member in methods) { if (member.DeclaringType.Name == "Macros" && member.MemberType == MemberTypes.Method) { ComboBoxMacros.Items.Add(member.Name); } } if (ComboBoxMacros.Items.Count > 0) { ComboBoxMacros.SelectedIndex = 0; Button1.Enabled = true; } }
public void Button1_Click(System.Object sender, System.EventArgs e) { try { string memberName = ComboBoxMacros.SelectedItem.ToString(); object[] @params = null; _macros.GetType().InvokeMember(memberName, BindingFlags.InvokeMethod, null, _macros, @params, null, null, null); } catch (Exception ex) { string Caption = ex.Message; MessageBoxButtons Buttons = MessageBoxButtons.OK; DialogResult Result = MessageBox.Show(ex.StackTrace, Caption, Buttons, MessageBoxIcon.Exclamation); } }
private void Form1_Load(object sender, EventArgs e) { try { _InvApplication = (Inventor.Application)Marshal.GetActiveObject("Inventor.Application"); } catch(Exception ex) { MessageBox.Show("make sure an Inventor instance is launched!"); return; } // Add any initialization after the InitializeComponent() call. _macros = new Macros(_InvApplication); MemberInfo[] methods = _macros.GetType().GetMembers(); foreach (MemberInfo member in methods) { if ((member.DeclaringType.Name == "Macros" & member.MemberType == MemberTypes.Method)) { ComboBoxMacros.Items.Add(member.Name); } } if (ComboBoxMacros.Items.Count > 0) { ComboBoxMacros.SelectedIndex = 0; button1.Enabled = true; } //======================================================= //Service provided by Telerik (www.telerik.com) //Conversion powered by NRefactory. //Built and maintained by Todd Anglin and Telerik //======================================================= }
private void Form1_Load(object sender, EventArgs e) { try { _InvApplication = (Inventor.Application)Marshal.GetActiveObject("Inventor.Application"); } catch (Exception ex) { MessageBox.Show("make sure an Inventor instance is launched!"); return; } // Add any initialization after the InitializeComponent() call. _macros = new Macros(_InvApplication); MemberInfo[] methods = _macros.GetType().GetMembers(); foreach (MemberInfo member in methods) { if ((member.DeclaringType.Name == "Macros" & member.MemberType == MemberTypes.Method)) { ComboBoxMacros.Items.Add(member.Name); } } if (ComboBoxMacros.Items.Count > 0) { ComboBoxMacros.SelectedIndex = 0; button1.Enabled = true; } //======================================================= //Service provided by Telerik (www.telerik.com) //Conversion powered by NRefactory. //Built and maintained by Todd Anglin and Telerik //======================================================= }
public Form1(Inventor.Application oApp) { // This call is required by the Windows Form Designer. InitializeComponent(); // Add any initialization after the InitializeComponent() call. _macros = new Macros(oApp); MemberInfo[] methods = _macros.GetType().GetMembers(); foreach (MemberInfo member in methods) { if (member.DeclaringType.Name == "Macros" && member.MemberType == MemberTypes.Method) { ComboBoxMacros.Items.Add(member.Name); } } if (ComboBoxMacros.Items.Count > 0) { ComboBoxMacros.SelectedIndex = 0; Button1.Enabled = true; } }