.NET
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Cancel change active document

8 REPLIES 8
SOLVED
Reply
Message 1 of 9
Fredrik.Larsen
1367 Views, 8 Replies

Cancel change active document

Hi

How can I stop changing active document?

 

I was thinking I could use this, but I don't know how to cancel it in the event handler:

 

AcadApp.DocumentManager.DocumentToBeActivated += new DocumentCollectionEventHandler(DocumentManager_DocumentToBeActivated);

static void DocumentManager_DocumentToBeActivated(object sender, DocumentCollectionEventArgs e)
{
    // Messagebox to ask if user are sure
    bool AreYouSureYouWantToChangeActiveFile = MessageBox....

    if(!AreYouSureYouWantToChangeActiveFile)
        //cancel change active file somehow...???
}

 

8 REPLIES 8
Message 2 of 9

DocumentCollection.DocumentActivationEnabled property can help you

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


Alexander Rivilis / Александр Ривилис / Олександр Рівіліс
Programmer & Teacher & Helper / Программист - Учитель - Помощник / Програміст - вчитель - помічник
Facebook | Twitter | LinkedIn
Expert Elite Member

Message 3 of 9

Hi

I could not get it to work. When I set the property you mentioned the active document has already changed. And if I set the property to false at a earlier stage I will never come to the listener. Any ideas?

static void DocumentManager_DocumentToBeActivated(object sender, DocumentCollectionEventArgs e)
{
            DialogResult dialogResult = MessageBox.Show("You are changing the active drawing. Continue?", "Active drawing change", MessageBoxButtons.YesNo);
            if (dialogResult == DialogResult.Yes)
            {
                AcadApp.DocumentManager.DocumentActivationEnabled = true;
                RemoveDocumentToBeActivatedListener();
            }
            else if (dialogResult == DialogResult.No)
            {
                AcadApp.DocumentManager.DocumentActivationEnabled = false;
            }
}

 

Message 4 of 9

1. You can disable switching of Document's at all if you call:

AcadApp.DocumentManager.DocumentActivationEnabled = false;

 but not in handler of event of DocumentToBeActivated.

2. If you have to prevent switching in a handler of event of DocumentToBeActivated you have to:

a) save previous Document and set flag of switching in this handler.

b) in command reactor switch Document back to previous Document and clear flag of switching.

 

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


Alexander Rivilis / Александр Ривилис / Олександр Рівіліс
Programmer & Teacher & Helper / Программист - Учитель - Помощник / Програміст - вчитель - помічник
Facebook | Twitter | LinkedIn
Expert Elite Member

Message 5 of 9

Perhaps you can explain why you want to prevent a document from being activated?

Message 6 of 9

I have created an application that scans and does something with the active document and I haven't implemented support for what happens when active document is changed. So for my demo version I thought I could just prevent the user from changing the document.

Message 7 of 9

While command with CommandFlags.Modal is active user can not switch active document. More precisely when switching to another document, the command will paused and wait for switch back.

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


Alexander Rivilis / Александр Ривилис / Олександр Рівіліс
Programmer & Teacher & Helper / Программист - Учитель - Помощник / Програміст - вчитель - помічник
Facebook | Twitter | LinkedIn
Expert Elite Member

Message 8 of 9

Hi Alex,

Which is command reactor switch Document back to previous Document ?

Will this solution run correct when new drawing is created ?

Thank for your suggest.

 

 

 

Message 9 of 9

I have tried almost everything to accomplish that, but I couldn't cancel the document opening at DocumentToBeActivated event. Has anyone resolved it?

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk DevCon in Munich May 28-29th


Autodesk Design & Make Report

”Boost