TheSwamp

Code Red => .NET => Topic started by: Bobby C. Jones on December 28, 2005, 02:22:37 PM

Title: AU 2005 code - Part 1 "Adding tabs to the Options Dialog"
Post by: Bobby C. Jones on December 28, 2005, 02:22:37 PM
As promised, I am going to post the code from my AU class this year.  This was meant as a high level overview, so most of the code isn't real in depth.


This first example shows how to add tabs to the Options dialog box.  You will need to create a user control in order for this to work.  This code uses a control named "Au2005UserControl".

The drafting settings and customization dialogs can also host user defined controls.

Code: [Select]
using System;

using Autodesk.AutoCAD.Runtime;
using Autodesk.AutoCAD.ApplicationServices;
using acadApp = Autodesk.AutoCAD.ApplicationServices.Application;
using AU2005.AcadApi;

namespace AU2005.AcadApi
{
//Pages 5 & 6 in the handout
public class OptionsDialogTabExample
{
//This method tells Autocad to run the OnDisplayingOptionsDialog method
//when the DisplayingOptionsDialog event is fired
[CommandMethod("CreateNewOptionsTab")]
public void AddNewOptionsTab()
{
acadApp.DisplayingOptionDialog += new TabbedDialogEventHandler(OnDisplayingOptionDialog);

//The Drafting Settings and Customization dialogs can also be captured
}

//This is the method that adds the tab and places the user control on it
private void OnDisplayingOptionDialog(object sender, TabbedDialogEventArgs e)
{
//Create an instance of the user control
Au2005UserControl AuOptionsTab = new Au2005UserControl();

//Add actions for the Ok button
//Actions can also be added for Cancel and Help
TabbedDialogAction onOkPress = new TabbedDialogAction(OnOk);

//Add the tab, the user control, and Ok/Cancel/Help handlers.
e.AddTab("AutoDesk University 2005", new TabbedDialogExtension(AuOptionsTab, onOkPress));
}

//This method runs when the Ok button on the Options dialog is pressed.
//It will run even if they never open the custom tab.
public void OnOk()
{
acadApp.ShowAlertDialog ("Ok Pressed.\nSee you at AU 2006!");
}
}
}

Title: Re: AU 2005 code - Part 1 "Adding tabs to the Options Dialog"
Post by: Birdy on December 28, 2005, 02:32:58 PM
Hey! I remember this!
Bobby, I enjoyed your class at AU.  Good stuff, although still a tad over my head.
Title: Re: AU 2005 code - Part 1 "Adding tabs to the Options Dialog"
Post by: Bobby C. Jones on December 28, 2005, 03:44:26 PM
Hey! I remember this!
Bobby, I enjoyed your class at AU.  Good stuff, although still a tad over my head.

Hi Birdy,  I'm glad that you enjoyed it.  I did too!

When I feel that I'm in over my head with this stuff I just pick a project and dive in head first.  I'm currently working on my project list for the upcoming year and I expect to be totally immersed in this for quite some time, like it or not.  Fortunately, I do :-)
Title: Re: AU 2005 code - Part 1 "Adding tabs to the Options Dialog"
Post by: Kerry on December 28, 2005, 06:19:42 PM
Thanks for posting these Bobby. These will be very handy for a lot of the people who weren't able to visit AU and who don't have Subscriptions. The ADN will not make the lessons available either, which I found dissapointing in regard their supporting an emerging technology.

I hope that some of our visitors are encouraged by these lessons to participate in helping to build our knowledgebase. Every little bit counts.
Title: Re: AU 2005 code - Part 1 "Adding tabs to the Options Dialog"
Post by: LE on December 28, 2005, 09:21:14 PM
I hope that some of our visitors are encouraged by these lessons to participate in helping to build our knowledgebase. Every little bit counts.

Hi Kerry;

What is the compiler you have?
Title: Re: AU 2005 code - Part 1 "Adding tabs to the Options Dialog"
Post by: Kerry on December 28, 2005, 09:27:28 PM
Hi Luis

VB6

VS2003 C# only

VS2005 Express ALL

VS2005 Pro
Title: Re: AU 2005 code - Part 1 "Adding tabs to the Options Dialog"
Post by: TR on December 29, 2005, 09:45:02 AM
Luis:

All .NET compilers are free in the SDK.
Title: Re: AU 2005 code - Part 1 "Adding tabs to the Options Dialog"
Post by: LE on December 29, 2005, 10:54:29 AM
Luis:

All .NET compilers are free in the SDK.

Thank you Tim, I think is time to try C#... [any issues of having VS.NET 7.0 with new compiler versions ? or recomendations ?]
Title: Re: AU 2005 code - Part 1 "Adding tabs to the Options Dialog"
Post by: TR on December 29, 2005, 10:58:59 AM
Luis:

All .NET compilers are free in the SDK.

Thank you Tim, I think is time to try C#... [any issues of having VS.NET 7.0 with new compiler versions ? or recomendations ?]

I can't really answer that as I don't use Visual Studio. I've tried the express editions but didn't really like them. However, I'm a big fan of Sharpdevelop (http://www.icsharpcode.net/OpenSource/SD/Default.aspx).
Title: Re: AU 2005 code - Part 1 "Adding tabs to the Options Dialog"
Post by: Bobby C. Jones on December 29, 2005, 11:04:16 AM
Thank you Tim, I think is time to try C#... [any issues of having VS.NET 7.0 with new compiler versions ? or recomendations ?]

Hey Luis,
I have VS2003 & VS2005 installed and running side by side w/o any problems.
Title: Re: AU 2005 code - Part 1 "Adding tabs to the Options Dialog"
Post by: LE on December 29, 2005, 11:21:32 AM
Hey Luis,
I have VS2003 & VS2005 installed and running side by side w/o any problems.

Thank you Bobby;

I use the VSC++ .NET 2002 Standard version for what I write on C++ and ObjectARX, I have never had tried to do anything on C#, for what I have seen and reading it is very similar the code.... will see.

Again thanks.
Title: Re: AU 2005 code - Part 1 "Adding tabs to the Options Dialog"
Post by: LE on January 17, 2006, 11:58:05 AM
VS2005 express... I cannot installed on my PC here at my office, it has XP Home Edition... so does not qualify for the service pack 2 required....  :cry:
Title: Re: AU 2005 code - Part 1 "Adding tabs to the Options Dialog"
Post by: TR on January 17, 2006, 01:10:06 PM
VS2005 express... I cannot installed on my PC here at my office, it has XP Home Edition... so does not qualify for the service pack 2 required....  :cry:
Try SharpDevelop (http://www.icsharpcode.net/OpenSource/SD/Default.aspx).
Title: Re: AU 2005 code - Part 1 "Adding tabs to the Options Dialog"
Post by: LE on January 17, 2006, 01:17:54 PM
Try SharpDevelop (http://www.icsharpcode.net/OpenSource/SD/Default.aspx).

Yes, I have that one Tim... I just want to use the SLN projects, from samples I have...


Thanks.
Title: Re: AU 2005 code - Part 1 "Adding tabs to the Options Dialog"
Post by: TR on January 17, 2006, 01:27:26 PM
I'm using SharpDevelop 2 with .NET 2 and I can open VS2003 sln files.
Title: Re: AU 2005 code - Part 1 "Adding tabs to the Options Dialog"
Post by: LE on January 17, 2006, 01:30:09 PM
I'm using SharpDevelop 2 with .NET 2 and I can open VS2003 sln files.
Strange... the version I downloaded the other day... on the same link you gave me... is 1.1.... ok, I know why...
Title: Re: AU 2005 code - Part 1 "Adding tabs to the Options Dialog"
Post by: LE on January 17, 2006, 02:52:06 PM
Now, that I see this new IDE for SharpDevelop, man is seems that MFC is much simpler.... all just for the dialog boxes... hmmmm..... OK, I need to read a lot... I am now out of scope here... I open one SLN and cannot even being able to view the forms.... no no no....  :lol:

On the mean time, has anyone here have been able to run a unmanaged ARX code, with C#... or better a sample of using both?
Title: Re: AU 2005 code - Part 1 "Adding tabs to the Options Dialog"
Post by: TR on January 17, 2006, 02:54:28 PM
If you open a sln that has a control referenced from an unavailable assembly you will not be able to view the form.
Title: Re: AU 2005 code - Part 1 "Adding tabs to the Options Dialog"
Post by: LE on January 17, 2006, 02:56:34 PM
If you open a sln that has a control referenced from an unavailable assembly you will not be able to view the form.

Now in Spanish please....  :roll:
Title: Re: AU 2005 code - Part 1 "Adding tabs to the Options Dialog"
Post by: TR on January 17, 2006, 03:00:52 PM
Si usted se abre un sln que tiene un control referido de una asamblea inasequible usted no podrá visión la forma.

- note: Babelfish doesn't work well.