.NET

Reply
Valued Mentor
joantopo
Posts: 642
Registered: ‎04-25-2010
Message 1 of 7 (199 Views)

How can I count the number of deactivated documents ?

199 Views, 6 Replies
03-12-2013 04:01 PM

Hi.

I´m using the events "DocumentActivated" and  the event "DocumentDestroyed" .

With the "DocumentDestroyed" method I can know how many documents are closed and when is the last..

 

But, I want to know, how many documents are minimized (deactivated).

It´s to say, there aren´t any active (current) document.

 

Trank you.

 

 

Autocad Civil 3D 2014 +SP1 // Civil 3D 2015
Quad Core Intel i7 3770-cpu 3.40Ghz.
ssd samsung 840 pro 512gb+ssd samsung 840 pro 256 gb+1tb hdd
32gb RAM 1600 Mhz.
nVidia Quadro 2000.
Win 7 Pro 64bit

Valued Mentor
DiningPhilosopher
Posts: 370
Registered: ‎05-06-2012
Message 2 of 7 (171 Views)

Re: How can I count the number of deactivated documents ?

03-12-2013 09:12 PM in reply to: joantopo

The DocumentCollection's Count property tells you how many documents exist.

 

There can be only one active document so the number of 'deactivated' documents is the value of the Count property minus 1.  

 

When the DocumentToBeDestroyed event fires, if the document that's about to be destroyed is the only open document, then at that point, the DocumentCollection's Count property will be 1, and it means that AutoCAD is entering 'zero document state' (where there are no open documents).

 

 

Valued Mentor
joantopo
Posts: 642
Registered: ‎04-25-2010
Message 3 of 7 (159 Views)

Re: How can I count the number of deactivated documents ?

03-13-2013 02:17 AM in reply to: DiningPhilosopher

ok, but if I have all my documents as a(deactivated) documents. Which is the active document?  What´s the name or Id of this?

Because I can have all my documents as a deactivated document.

 

Thank you for reply.

 

 

 

 

Autocad Civil 3D 2014 +SP1 // Civil 3D 2015
Quad Core Intel i7 3770-cpu 3.40Ghz.
ssd samsung 840 pro 512gb+ssd samsung 840 pro 256 gb+1tb hdd
32gb RAM 1600 Mhz.
nVidia Quadro 2000.
Win 7 Pro 64bit

Valued Mentor
jeff
Posts: 321
Registered: ‎05-12-2009
Message 4 of 7 (140 Views)

Re: How can I count the number of deactivated documents ?

03-13-2013 04:29 AM in reply to: joantopo

joantopo wrote:

Because I can have all my documents as a deactivated document.


 How do you do that?


joantopo wrote:

but if I have all my documents as a(deactivated) documents. Which is the active document?   


If you have them all "deactivated" then how could one active?

 

I just noticed you mention minimized so when you say "deactivated" you mean minimized?

You can still enter commands and interact with active document when all them all minimized, but I think your looking for

Application.DocumentManager.MdiActiveDocument.Window.WindowState

 

You can also find your answers @ TheSwamp
Valued Mentor
joantopo
Posts: 642
Registered: ‎04-25-2010
Message 5 of 7 (136 Views)

Re: How can I count the number of deactivated documents ?

03-13-2013 04:56 AM in reply to: jeff

Yes, all right.

 

I was confusing deactivated with minimized.  I wanted to say "minimized".

 

I´m going to try this line code.

 

Thank you.

Autocad Civil 3D 2014 +SP1 // Civil 3D 2015
Quad Core Intel i7 3770-cpu 3.40Ghz.
ssd samsung 840 pro 512gb+ssd samsung 840 pro 256 gb+1tb hdd
32gb RAM 1600 Mhz.
nVidia Quadro 2000.
Win 7 Pro 64bit

Valued Mentor
joantopo
Posts: 642
Registered: ‎04-25-2010
Message 6 of 7 (126 Views)

Re: How can I count the number of deactivated documents ?

03-13-2013 05:42 AM in reply to: joantopo

I don´t understand because Autodesk interpret that the window state = normal is the same that state=minimized..:smileyfrustrated:

                 private void callback_documentActivated(object sender, DocumentCollectionEventArgs e)
                {

                  if (ComprobarTodosMinimizados()==false)
                     
                     System.Windows.Forms.MessageBox.Show("abiertoooooooo");
                  else

                      System.Windows.Forms.MessageBox.Show("todos minimizados");
                 }

                 public bool ComprobarTodosMinimizados()
                 {

                     bool TodosMinimizados = false;
                     int contador = 0;
                     DocumentCollection docs = Application.DocumentManager;

                     foreach (Document doc in docs)
                     {
                          
                        if (doc.Window.WindowState == Autodesk.AutoCAD.Windows.Window.State.Minimized);  // si se minimiza la ventana
                        {
                            contador++;
                        }
                     }
                     if (contador == Application.DocumentManager.Count)
                     {
                         TodosMinimizados = true;
                     }

                 
                 return TodosMinimizados;
                 
                 }

 

Autocad Civil 3D 2014 +SP1 // Civil 3D 2015
Quad Core Intel i7 3770-cpu 3.40Ghz.
ssd samsung 840 pro 512gb+ssd samsung 840 pro 256 gb+1tb hdd
32gb RAM 1600 Mhz.
nVidia Quadro 2000.
Win 7 Pro 64bit

Valued Mentor
joantopo
Posts: 642
Registered: ‎04-25-2010
Message 7 of 7 (121 Views)

Re: How can I count the number of deactivated documents ?

03-13-2013 05:52 AM in reply to: joantopo

is this right?

 if (doc.Window.WindowState == Autodesk.AutoCAD.Windows.Window.State.Minimized); 

 

Autocad Civil 3D 2014 +SP1 // Civil 3D 2015
Quad Core Intel i7 3770-cpu 3.40Ghz.
ssd samsung 840 pro 512gb+ssd samsung 840 pro 256 gb+1tb hdd
32gb RAM 1600 Mhz.
nVidia Quadro 2000.
Win 7 Pro 64bit

You are not logged in.

Log into access your profile, ask and answer questions, share ideas and more. Haven't signed up yet? Register

Announcements
Are you familiar with the Autodesk Expert Elites? The Expert Elite program is made up of customers that help other customers by sharing knowledge and exemplifying an engaging style of collaboration. To learn more, please visit our Expert Elite website.

Need installation help?

Start with some of our most frequented solutions to get help installing your software.

Ask the Community