using System;
using Autodesk.AutoCAD.Runtime;
using Autodesk.AutoCAD.ApplicationServices;
using acadApp = Autodesk.AutoCAD.ApplicationServices.Application;
using Autodesk.AutoCAD.Windows;
namespace AU2005.AcadApi
{
//Pages 7 & 8
public class PaneButtonsExample
{
#region Application Pane
[CommandMethod("CreateAppPane")]
public static void AddApplicationPane()
{
Pane au2005AppPaneButton = new Pane();
//Set the buttons properties
au2005AppPaneButton.Enabled = true;
au2005AppPaneButton.Visible = true;
au2005AppPaneButton.Style = PaneStyles.Normal;
au2005AppPaneButton.Text = "AU2005 App. Pane";
au2005AppPaneButton.ToolTipText = "Welcome to Autodesk University 2005!";
//Hook into the MouseDown event to run code when the button is pressed.
au2005AppPaneButton.MouseDown += new StatusBarMouseDownEventHandler(OnAppMouseDown);
//Add the button to the applications status bar
//Items can also be added to the tray area
acadApp.StatusBar.Panes.Add(au2005AppPaneButton);
}
private static void OnAppMouseDown(object sender, StatusBarMouseDownEventArgs e)
{
Pane paneButton = (Pane) sender;
string alertMessage;
if (paneButton.Style == PaneStyles.PopOut)
{
paneButton.Style = PaneStyles.Normal;
alertMessage = "The application button is activated.";
}
else
{
paneButton.Style = PaneStyles.PopOut;
alertMessage = "The application button is de-activated.";
}
acadApp.StatusBar.Update();
acadApp.ShowAlertDialog(alertMessage);
}
#endregion
//Document pane code not shown in the handout
#region Document Pane
[CommandMethod("CreateDocPane")]
public static void AddDocumentPane()
{
Pane au2005DocPaneButton = new Pane();
//Set the buttons properties
au2005DocPaneButton.Enabled = true;
au2005DocPaneButton.Visible = true;
au2005DocPaneButton.Style = PaneStyles.Normal;
au2005DocPaneButton.Text = "AU2005 Doc. Pane";
au2005DocPaneButton.ToolTipText = "Welcome to Autodesk University 2005!";
//Hook into the MouseDown event to run code when the button is pressed.
au2005DocPaneButton.MouseDown += new StatusBarMouseDownEventHandler(OnDocMouseDown);
//Add the button to the documents status bar
acadApp.DocumentManager.MdiActiveDocument.StatusBar.Panes.Add(au2005DocPaneButton);
}
private static void OnDocMouseDown(object sender, StatusBarMouseDownEventArgs e)
{
Pane paneButton = (Pane) sender;
string alertMessage;
if (paneButton.Style == PaneStyles.PopOut)
{
paneButton.Style = PaneStyles.Normal;
alertMessage = "The document button is activated.";
}
else
{
paneButton.Style = PaneStyles.PopOut;
alertMessage = "The document button is de-activated.";
}
acadApp.DocumentManager.MdiActiveDocument.StatusBar.Update();
acadApp.ShowAlertDialog(alertMessage);
}
#endregion
}
}