Showing a balloon notification using the InfoCenter API in AutoCAD 2009
This post is the latest in the series of closer looks at the new APIs in AutoCAD 2009. It dips into the InfoCenter API, a .NET API allowing you to customize and drive the InfoCenter feature inside AutoCAD.
To make use of this API you need to add Project References to two managed assemblies from the AutoCAD 2009 root folder: AcInfoCenterConn.dll and AdInfoCenter.dll.
Here's some VB.net code that will display a balloon notification to your users:
Imports Autodesk.AutoCAD.AcInfoCenterConn
Imports Autodesk.AutoCAD.Runtime
Imports Autodesk.AutoCAD.ApplicationServices
Namespace InfoCenterApp
Public Class Commands
<CommandMethod("icb")> _
Public Sub infoCenterBalloon()
Dim icm As InfoCenterManager = AcInfoCenterConn.InfoCenterManager
Dim pm As Autodesk.InfoCenter.PaletteMgr = icm.PaletteManager
' Don't provide an icon
' Show the balloon for 5 seconds
' Make it relatively slow to fade in
pm.ShowBalloon("Custom Application Notification", _
"Kean has some information for you...", Nothing, _
New System.Uri("http://blogs.autodesk.com/through-the-interface"), 5, 1)
End Sub
End Class
End Namespace
Update:
For AutoCAD 2010 things has changed a little. It seems you now need to include project references to AcWindows.dll and AdWindows.dll, as well as making some changes to your code. Some of the required types are now in the Autodesk.Internal namespace, which leads me to believe this may be subject to further change.
Here is some code that worked well for me:
Imports Autodesk.Internal.InfoCenter
Imports Autodesk.AutoCAD.AcInfoCenterConn
Imports Autodesk.AutoCAD.Runtime
Imports Autodesk.AutoCAD.ApplicationServices
Namespace InfoCenterApp
Public Class Commands
<CommandMethod("icb")> _
Public Sub infoCenterBalloon()
Dim icm As New InfoCenterManager()
Dim ri As New ResultItem()
ri.Category = "Custom Application Notification"
ri.Title = "Kean has some information for you..."
ri.Uri = New System.Uri("http://blogs.autodesk.com/through-the-interface")
ri.IsFavorite = True
ri.IsNew = True
icm.PaletteManager.ShowBalloon(ri)
End Sub
End Class
End Namespace
There's a version of the ShowBalloon() function which takes a XAML fragment as a parameter, for those of you into WPF.
Here's the notification it creates in AutoCAD 2010:
转帖自:
https://through-the-interface.typepad.com/thro ... 2008/04/showing-a-ballo.html