Author Topic: AU 2005 code - Part 1 "Adding tabs to the Options Dialog"  (Read 16735 times)

0 Members and 1 Guest are viewing this topic.

Bobby C. Jones

  • Swamp Rat
  • Posts: 516
  • Cry havoc and let loose the dogs of war.
AU 2005 code - Part 1 "Adding tabs to the Options Dialog"
« 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!");
}
}
}

Bobby C. Jones

Birdy

  • Guest
Re: AU 2005 code - Part 1 "Adding tabs to the Options Dialog"
« Reply #1 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.

Bobby C. Jones

  • Swamp Rat
  • Posts: 516
  • Cry havoc and let loose the dogs of war.
Re: AU 2005 code - Part 1 "Adding tabs to the Options Dialog"
« Reply #2 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 :-)
Bobby C. Jones

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: AU 2005 code - Part 1 "Adding tabs to the Options Dialog"
« Reply #3 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.
kdub, kdub_nz in other timelines.
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.

LE

  • Guest
Re: AU 2005 code - Part 1 "Adding tabs to the Options Dialog"
« Reply #4 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?

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: AU 2005 code - Part 1 "Adding tabs to the Options Dialog"
« Reply #5 on: December 28, 2005, 09:27:28 PM »
Hi Luis

VB6

VS2003 C# only

VS2005 Express ALL

VS2005 Pro
« Last Edit: December 29, 2005, 09:03:29 AM by Kerry Brown »
kdub, kdub_nz in other timelines.
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.

TR

  • Guest
Re: AU 2005 code - Part 1 "Adding tabs to the Options Dialog"
« Reply #6 on: December 29, 2005, 09:45:02 AM »
Luis:

All .NET compilers are free in the SDK.

LE

  • Guest
Re: AU 2005 code - Part 1 "Adding tabs to the Options Dialog"
« Reply #7 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 ?]

TR

  • Guest
Re: AU 2005 code - Part 1 "Adding tabs to the Options Dialog"
« Reply #8 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.

Bobby C. Jones

  • Swamp Rat
  • Posts: 516
  • Cry havoc and let loose the dogs of war.
Re: AU 2005 code - Part 1 "Adding tabs to the Options Dialog"
« Reply #9 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.
Bobby C. Jones

LE

  • Guest
Re: AU 2005 code - Part 1 "Adding tabs to the Options Dialog"
« Reply #10 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.

LE

  • Guest
Re: AU 2005 code - Part 1 "Adding tabs to the Options Dialog"
« Reply #11 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:

TR

  • Guest
Re: AU 2005 code - Part 1 "Adding tabs to the Options Dialog"
« Reply #12 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.

LE

  • Guest
Re: AU 2005 code - Part 1 "Adding tabs to the Options Dialog"
« Reply #13 on: January 17, 2006, 01:17:54 PM »
Try SharpDevelop.

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


Thanks.
« Last Edit: January 17, 2006, 01:22:09 PM by LE »

TR

  • Guest
Re: AU 2005 code - Part 1 "Adding tabs to the Options Dialog"
« Reply #14 on: January 17, 2006, 01:27:26 PM »
I'm using SharpDevelop 2 with .NET 2 and I can open VS2003 sln files.