Message 1 of 4
Invisable App
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I want my app to be virtually invisible unless it’s triggered into existence.
I'd like it to be triggered into existence if a NOD dictionary exists.
Here is the code that loads the project. Can someone critique it and tell me what I am doing wrong?
Public Sub Initialize() Implements IExtensionApplication.Initialize
docMan = Application.DocumentManager
AddHandler Application.Idle, AddressOf OnIdle
AddHandler Application.SystemVariableChanged, AddressOf Application_SystemVariableChanged
DemandLoading.RegistryUpdate.RegisterForDemandLoading()
LoadDefaultDictionaries() 'If there's a problem here it might be that a duplicate key is being added to a dictionary
LoadDefaultLists()
LoadDefaultSettings()
CheckMinSettingsInRegistry()
Using docLock As DocumentLock = Application.DocumentManager.MdiActiveDocument.LockDocument()
Using trans As Transaction = Application.DocumentManager.MdiActiveDocument.TransactionManager.StartOpenCloseTransaction : trcnt += 1 : LastOpenedTransaction = Reflection.MethodBase.GetCurrentMethod.Name()
LoadSettings(trans)
trcnt -= 1 : If trcnt > 0 Then : MsgBox("TRCNT>0" & vbCr & "Last opened transaction in " & LastOpenedTransaction) : LastOpenedTransaction = "" : End If 'DISPOSE - ONLY USED FOR GATHERING DATA
End Using
End Using
Dim pal = New PaletteClass()
pal.LoadPalette()
End Sub
Public Sub Terminate() Implements IExtensionApplication.Terminate
End Sub
Private Sub OnIdle(ByVal sender As Object, ByVal e As EventArgs)
Dim doc As Document = docMan.MdiActiveDocument
If doc IsNot Nothing Then
RemoveHandler Application.Idle, AddressOf OnIdle
AddHandler docMan.DocumentActivated, AddressOf DocMan_documentActivated ' To get document settings
AddHandler docMan.DocumentToBeDeactivated, AddressOf docMan_DocumentToBeDeactivated 'To save settings before moving docs. There is also a problem if the user doesn't exit the cell after editing members.
AddHandler docMan.DocumentDestroyed, AddressOf DocMan_DocumentDestroyed ' Disables pallet so that it can't be used when no drawings open. Will reenable when a new drawing open
DBlockClassLibrary.Commands.RemoveGripPointsOverrule() 'Add Overrule to hide Dynamic Block Insertion Points / Basepoints
InitializeActiveDocument(doc)
End If
End Sub
Public Sub InitializeActiveDocument(ByVal doc As Document)
Dim db As Database = doc.Database
If trcnt > 0 Then MsgBox("TRCNT>0" & vbCr & "Last opened transaction in " & LastOpenedTransaction)
trcnt = 0
ClearVariables()
AddHandler doc.CommandWillStart, AddressOf doc_CommandWillStart : CommandWillStart_HandlerRunning = True
AddHandler doc.ImpliedSelectionChanged, AddressOf doc_ImpliedSelectionChanged : ImpliedSeletionChange_HandlerRunning = True
AddHandler db.BeginSave, AddressOf db_BeginSave : BeginSave_HandlerRunning = True
Using docLock As DocumentLock = Application.DocumentManager.MdiActiveDocument.LockDocument()
Using trans As Transaction = Application.DocumentManager.MdiActiveDocument.TransactionManager.StartOpenCloseTransaction : trcnt += 1 : LastOpenedTransaction = Reflection.MethodBase.GetCurrentMethod.Name()
LoadSettings(trans)
ScheduleContainer.UpdateForm(trans)
OptionsContainer.UpdateForm(trans)
LoadCode()
UpdateSelectionCboBoxes(trans) 'Entity selection cbo boxes (ie BarViews (5))
UpdatePalette(trans) 'Do this last to prevent black flash of panel
'Don't commit the transaction as we don't want the drawing to feel the need to save when unaltered
trcnt -= 1 : If trcnt > 0 Then : MsgBox("TRCNT>0" & vbCr & "Last opened transaction in " & LastOpenedTransaction) : LastOpenedTransaction = "" : End If
End Using
End Using
If CShort(Application.GetSystemVariable("BLOCKEDITOR")) = 1 Then ps.Visible = False 'Hide
End Sub