Ok, so lets say you have a form (2 textboxes and a "Start" button) and a command class. When I hit the Start button, how does the form go back to the command class to execute the functions there? I've set it up like you describe, but I'm not sure how to make it jump from the form to the command class. Maybe a silly question, but I'm kinda new to .Net and appreciate the help.
Mark
Here is some pseudo code:
public class MyCommandClass { ... [CommandMethod("DoSomething")] public static void DoWork() { string txt1=null; string txt2=null; //Show form to get user input using (Form1 frm=new Form1()) { //The form is shown and the command is held until //the form is dismissed DialogResult res=Autodesk.AutoCAD.ApplicationServices. Application.ShowModalDialog(frm); //Only if the user clicks "OK/Start" //The user input is obtained if (res=DialogResult.OK) { txt1=frm.TextValue1; txt2=frm.TextValue2; } } if (txt1!=null && txt2!=null) { //Do your work with the user input acquired with the form } } ... } public class Form1:System.Windows.Forms.Form { //Assume the form has 2 text boxes and //a button "Start" and a button "Cancel" //You add 2 public read-only properties to the form public string TextValue1 { get { return TextBox1.Text; } } public string TextValue2 { get { return TextBox2.Text; } } //You set "Start" button's DialogResult property to "OK" //Set "Cancel" button's DialogResult property to "Cancel" //So, when clicking on the buttons, the form will closed (Hidden), //No code is needed }
Well, you of course would do some inout validation beofre the form turns hidden.
You might wan to learn more on .NET basics on windows forms, modelss form and modal form.
Norman Yuan