Albert,
Excellent example, thanks. Having played with this for a few minutes,
I'm really intrigued by the Popup pane style. It looks as though it's
meant to attach a menu item to. Any chance you could make a simple
example showing a menu popup and a click handler on a menu item? (or
would the menu events handle the click?)
Something like a menu with "Say Hello" and an event handler of MsgBox
("Hello world")? I can run with it from there.
Thanks in advance for your help, and thanks for everything you do here
for us,
-Danny Polkinhorn
WATG
Honolulu
PS: Here's the VB port (as well as I can do it, watch for wrapping)...
Imports Autodesk.AutoCAD.Runtime
Imports Autodesk.AutoCAD.ApplicationServices
Imports Autodesk.AutoCAD.DatabaseServices
Imports Autodesk.AutoCAD.Windows
Public Class TestStatusBarPane
_
Public Sub DoIt()
Application.DocumentManager.MdiActiveDocument.Editor.WriteMessage("Application
Statusbar " + ControlChars.Lf)
Dim sb As StatusBar =
Autodesk.AutoCAD.ApplicationServices.Application.StatusBar
' add a new pane
Dim newPane As New Pane
newPane.Text = "Scale: 1/8'' = 1'-0''"
newPane.ToolTipText = "Default Scale"
newPane.Visible = True
newPane.MinimumWidth = 40
newPane.Style = PaneStyles.PopUp
AddHandler newPane.MouseDown, AddressOf paneMouseDown
sb.Panes.Add(newPane)
Dim panes As PaneCollection = sb.Panes
Dim p As Pane
For Each p In panes
Application.DocumentManager.MdiActiveDocument.Editor.WriteMessage("Pane
-- {0}" + ControlChars.Lf, p.Text)
Next p
Application.DocumentManager.MdiActiveDocument.Editor.WriteMessage("Document
Statusbar " + ControlChars.Lf)
sb = Application.DocumentManager.MdiActiveDocument.StatusBar
panes = sb.Panes
For Each p In panes
Application.DocumentManager.MdiActiveDocument.Editor.WriteMessage("Pane
-- {0}" + ControlChars.Lf, p.Text)
Next p
End Sub 'DoIt
Shared Sub paneMouseDown(ByVal o As Object, ByVal e As
StatusBarMouseDownEventArgs)
Dim p As Pane = CType(o, Pane)
Application.DocumentManager.MdiActiveDocument.Editor.WriteMessage("Pane
-- {0} {1}, Style: " + ControlChars.Lf, p.Text, e.Button, p.Style.ToString)
End Sub 'paneMouseDown
Shared Sub trayMouseDown(ByVal o As Object, ByVal e As
StatusBarMouseDownEventArgs)
Dim ti As TrayItem = CType(o, TrayItem)
Application.DocumentManager.MdiActiveDocument.Editor.WriteMessage("Tray
on Click {0} {1}" + ControlChars.Lf, ti.ToolTipText, e.Button)
ti.CloseBubbleWindows()
End Sub 'trayMouseDown
Shared Sub bubbleClosed(ByVal o As Object, ByVal e As
TrayItemBubbleWindowClosedEventArgs)
Dim bubble As TrayItemBubbleWindow = CType(o, TrayItemBubbleWindow)
Application.DocumentManager.MdiActiveDocument.Editor.WriteMessage("Bubble
'{0}' closed on Click -- {1}" + ControlChars.Lf, bubble.Title,
e.CloseReason)
End Sub 'bubbleClosed
Public Class TestStatusBarTray
Private Shared oneNewTi As TrayItem = Nothing
_
Public Sub DoIt()
Application.DocumentManager.MdiActiveDocument.Editor.WriteMessage("Status
Bar Tray Item test " + ControlChars.Lf)
Dim sb As StatusBar = Application.StatusBar
Dim tis As TrayItemCollection = sb.TrayItems
Dim oneTi As TrayItem = Nothing
Dim ti As TrayItem
For Each ti In tis
Application.DocumentManager.MdiActiveDocument.Editor.WriteMessage("Tray
-- {0}" + ControlChars.Lf, ti.ToolTipText)
oneTi = ti
Next ti
If Not (oneTi Is Nothing) And oneNewTi Is Nothing Then
oneNewTi = New TrayItem
oneNewTi.Visible = True
oneNewTi.Icon = oneTi.Icon
oneNewTi.ToolTipText = "copy of " + oneTi.ToolTipText
tis.Add(oneNewTi)
AddHandler oneNewTi.MouseDown, AddressOf trayMouseDown
End If
Dim bubble As New TrayItemBubbleWindow
bubble.Text = "Bubble Text"
bubble.Title = "Bubble Title"
bubble.HyperLink = "http://google.com"
bubble.HyperText = "Cool site"
oneNewTi.ShowBubbleWindow(bubble)
AddHandler bubble.Closed, AddressOf bubbleClosed
End Sub 'DoIt
End Class 'TestStatusBarTray
End Class 'TestStatusBarPane