Invisable App

Invisable App

SRSDS
Advisor Advisor
741 Views
3 Replies
Message 1 of 4

Invisable App

SRSDS
Advisor
Advisor

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

 

742 Views
3 Replies
Replies (3)
Message 2 of 4

SRSDS
Advisor
Advisor

Can people ignore this? 

I think I've worked it out.

Just needed to give it a good bit of thought.

0 Likes
Message 3 of 4

lena.talkhina
Alumni
Alumni

Hello @SRSDS !

Don't hesitate to share how you work it out.  I am sure community members are appreciate your contribution.

 

Находите сообщения полезными? Поставьте "НРАВИТСЯ" этим сообщениям! | Do you find the posts helpful? "LIKE" these posts!
На ваш вопрос успешно ответили? Нажмите кнопку "УТВЕРДИТЬ РЕШЕНИЕ" | Have your question been answered successfully? Click "ACCEPT SOLUTION" button.



Лена Талхина/Lena Talkhina
Менеджер Сообщества - Русский/Community Manager - Russian

0 Likes
Message 4 of 4

SRSDS
Advisor
Advisor

I ended up with the below if it helps anyone or if anyone can comment on possible problems.

A command triggers the AppName NOD dictionary into existance

And InitializeActiveDocument only does it's thing if the NOD dictionary exists. 

I think it's working but Visual Studio is crashing but hopefully a problem with Visual Studio and not the code. 

 

    Public Sub Initialize() Implements IExtensionApplication.Initialize
        docMan = Application.DocumentManager
        AddHandler Application.Idle, AddressOf OnIdle
        AddHandler Application.SystemVariableChanged, AddressOf Application_SystemVariableChanged
        DemandLoading.RegistryUpdate.RegisterForDemandLoading()
    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)
        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()
                If NODDictionaryExists(trans, db) Then
                    'LoadSettings
                End If
                trcnt -= 1 : If trcnt > 0 Then : MsgBox("TRCNT>0" & vbCr & "Last opened transaction in " & LastOpenedTransaction) : LastOpenedTransaction = "" : End If
            End Using
        End Using
     End Sub

 

 

0 Likes