DocIface: The Diagram Document Interface

Warning: Microsoft Research reserves the right to alter, enhance or rescind any of these interfaces and capabilities at any time. Neither it nor Microsoft Corporation is liable for any loss or damages attendant to using the current interfaces nor any changes to such interfaces. All such usage is entirely unsupported.

Description

An add-in's view of a MSBNx document. Every open diagram document window in MSBNx is represented by a DocIface object. Remember that multiple diagram windows can reference the same model.

This interface is the key means by which an addin (implementing the IDocAddIn interface) can monitor and control the diagram document with which it is associated.

Remarks

MSBNx initializes the add-in giving it a DocIface object.

MSBNx tells an add-in that it is about to be killed by either:

  1. Setting the DocIface property to Nothing

  2. Having DocIface raise the Remove event.

An add-in can access its underlying model either indirectly through the Model property or by listening for the Model event, which is raised whenever the model associated with a document changes.

An add-in will typically monitor events from the DocIface that it is given.

Other automation data types mentioned here are defined in the documentation for the MSBN3 automation object.

Properties

Document

Public Property Get Document() As Variant
Public Property Set Document(ByVal vNewValue As Variant)

This property returns a reference to the actual Visual Basic form containing the document.

DocumentName

Public Property Get DocumentName() As String

Each document in MSBNX has a unique internal document name, represented as a string. This property returns that string.

InternalDocName

Public Property Get InternalDocName() As String

Each document in MSBNX has a unique internal document name, represented as a string. This property returns that string.

Left

Public Property Get Left() As Double
Public Property Let Left(ByVal dbl As Double)

References a standard Visual Basic property of the document form.

Top

Public Property Get Top() As Double
Public Property Let Top(ByVal dbl As Double)

References a standard Visual Basic property of the document form.

Width

Public Property Get Width() As Double
Public Property Let Width(ByVal dbl As Double)

References a standard Visual Basic property of the document form.

Height

Public Property Get Height() As Double
Public Property Let Height(ByVal dbl As Double)

References a standard Visual Basic property of the document form.

Zoom

Public Property Get Zoom() As Integer
Public Property Let Zoom(ByVal iNewVal As Integer)

References a standard Visual Basic property of the document form.

Model

Public Property Get Model() As MSBN3Lib.Model
Public Property Set Model(ipModel As MSBN3Lib.Model)

References the underlying model for the diagram document.

WindowState

Public Property Get WindowState() As Integer
Public Property Let WindowState(ByVal iState As Integer)

Returns the Visual Basic window state of the document window (minimized, maximized or normal).

NodeSelectedCount

Public Property Get NodeSelectedCount() As Integer

Returns the number of nodes currently selected on the diagram window.

ShowStatusBar

Public Property Get ShowStatusBar() As Boolean
Public Property Let ShowStatusBar(ByVal bNewValue As Boolean)

Determines whether the status bar is visible on the diagram window.

ShowToolBar

Public Property Get ShowToolBar() As Boolean
Public Property Let ShowToolBar(ByVal bNewValue As Boolean)

Determines whether the tool button bar is visible on the diagram window.

Dirty

Public Property Get Dirty() As Boolean
Public Property Let Dirty(bDirty As Boolean)

Indicates when the model underlying the diagram document has not been saved to disk since its last change.

SetProperties

Public Sub SetProperties()

Invokes the diagram's properties window as a modal dialog.

ColorEnumPropType

Public Property Get ColorEnumPropType() As String
Public Property Let ColorEnumPropType(ByVal sNewValue As String)

Returns or sets the name of the color scheme used to color the nodes in a diagram.

UseColorScheme

Public Property Get UseColorScheme() As Boolean
Public Property Let UseColorScheme(ByVal bNewValue As Boolean)

Indicates whether a diagram is currently coloring nodes using a color scheme.

TwipsXPopup

Public Property Get TwipsXPopup() As Long

Returns the horizontal mouse point location (in twips) when the last popup menu was invoked.

TwipsYPopup

Public Property Get TwipsYPopup() As Long

Returns the vertical mouse point location (in twips) when the last popup menu was invoked.

HimetricXPopup

Public Property Get HimetricXPopup() As Long

Returns the horizontal mouse point location (in HIMETRIC corrdinates) when the last popup menu was invoked.

HimetricYPopup

Public Property Get HimetricYPopup() As Long

Returns the vertical mouse point location (in HIMETRIC corrdinates) when the last popup menu was invoked.

CurrentNode

Public Property Get CurrentNode() As MSBN3Lib.Node

Returns the last selected node on the diagram or Nothing.

Methods

SetFocus

Public Sub SetFocus()

Causes the diagram window to become the focused document (top MDI child).

ReleaseModel

Public Sub ReleaseModel()

Release or unbinds the MSBN3 model from the diagram window document.

NodeLastSelected

Public Function NodeLastSelected(szNodeName As String) As Boolean

Returns the name of the last selected node or False if there are no selections.

Events

Remove

Public Event Remove()

Raised when the document is being discarded.

Model

Public Event Model(Model As MSBN3Lib.Model)

Raised when the model of a document is assigned or changed.

PopUpBefore

Public Event PopUpBefore(aPopUp As Object, aPopUpPlace As PopUpPlace)

The first parameter, aPopUp, is actually a DTAS Popup Menu object.

This event is raised just before the menu appears allows the add-in to alter (add, modify or delete) the contents of the popup menu.

PopUpAfter

Public Event PopUpAfter(aPopUp As Object, aPopUpPlace As PopUpPlace, ItemIndex As Long, Handled As Boolean)

The first parameter, aPopUp, is actually a DTAS Popup Menu object.

This event is raised after before the menu has appeared. The ItemIndex parameter informs the add-in which of the menu items, if any, the user has chosen. The Handled parameter indicates whether any other add-in has dealt with the impliations of this menu selection. An add-in may set the Handled parameter, in which case MSBNX and all other add-ins will take no further action.

Timer

Public Event Timer()

This key event occurs periodically and allows the add-in to update the model based upon its list of pending operations.

Evaluate

Public Event Evaluate(ByRef Cancel As Boolean)

This event occurs just before MSBNx would normally create an evaluation document for this diagram. If it should not do so, this provides an opportunity for the add-in to suppress this behavior by setting Cancel to False. The add-in can then bring up its own evaluation form the next time it gets the timer event. Here are excerpts of Visual Basic code showing this.

Option Explicit

' All MsbnX addins support this interface
Implements MSBNx.IDocAddIn

' My view of the MsbnX document to which I am attached and the Model to which
' it is attached.
Private WithEvents m_DocIface As MSBNx.DocIface

[...]

Private bToDoEvaluate As Boolean

 

[...]

Public Sub Evaluate()
    bToDoEvaluate = False

[...]

End Sub

[...]

Private Sub m_DocIface_Timer()
    If bToDoEvaluate Then
        Evaluate
    End If
End Sub

[...]

Private Sub m_DocIface_Evaluate(Cancel As Boolean)
    bToDoEvaluate = True
    Cancel = True
End Sub


Private Sub m_DocIface_AutoCompile(Cancel As Boolean)
    Cancel = True
End Sub

AutoCompile

Public Event AutoCompile(ByRef Cancel As Boolean)

This event occurs just before MSBNx would normally begin inference against the model associated with this diagram. If it should not do so, this provides an opportunity for the add-in to suppress this behavior by setting Cancel to False. An add-in might want to cancel AutoCompile if it want to provide the only user interface to compiling a model.