Page 2 of 2

Re: Treeview - Node - Property (Plus/Minus)

Posted: Fri Mar 08, 2019 1:50 pm
by angelofstealth
Understand, appreciate explaining/attaching the link.

I like this method of loading the nodes as it is fast and doesn't hang the GUI. Reading/referencing the following link below with Dan potter example the GUI will hang if the OU has a lot of objects (organization units / containers ). I like the clean look of the GUI/object select so forth.

viewtopic.php?t=10784

Thanks jvierra

Re: Treeview - Node - Property (Plus/Minus)

Posted: Fri Mar 08, 2019 2:15 pm
by jvierra
The ADSI load does not take advantage of mechanism to load very large children. This can be managed by controlling what is in view. ADSI can be written to retrieve some of the objects and continue incrementally. These methods can be use to keep the tree alive.

We can also load nodes as jobs and return the loaded node and just attach it to the tree when available.

Re: Treeview - Node - Property (Plus/Minus)

Posted: Mon Mar 11, 2019 12:01 pm
by angelofstealth
Looks like I got most of it working with a job, only issue seems when loading the treeview. When I click the node it loads the default imageindex[0] with a blank name. I clear this if the objects returns are zero from the job. Wondering if there is a way to stop the treeview from display the progress dropdown prior to updating the treeview. Code attached, thanks

Re: Treeview - Node - Property (Plus/Minus)

Posted: Mon Mar 11, 2019 12:23 pm
by jvierra
Not sure what the issue is. You need to start with a root node. The filler assumes a root and stars from there.

I also see no need for using a job. It completely defeats the point of my example.

Re: Treeview - Node - Property (Plus/Minus)

Posted: Mon Mar 11, 2019 12:29 pm
by angelofstealth
The point of using the job is so the GUI does not freeze(not responding) during a lookup that is taking a long time to return due to too many objects being returned.

In regards to the issue, if you comment out the clear in the else statement in CompletedScript you will see the default object get created. Not a big issue at all, was just curious if had to be created when clicked.

Re: Treeview - Node - Property (Plus/Minus)

Posted: Mon Mar 11, 2019 1:05 pm
by angelofstealth
I see it now, i am pre-creating it in the Add-Node function.

Re: Treeview - Node - Property (Plus/Minus)

Posted: Mon Mar 11, 2019 1:38 pm
by jvierra
The GUI will not freeze with my example. It only loads a node when the nose is clicked. No waiting. We load only the containers when a node is clicked. Even it you have 100 OUs the load is almost instantaneous,

Re: Treeview - Node - Property (Plus/Minus)

Posted: Mon Mar 11, 2019 6:01 pm
by angelofstealth
I agree, I have tested with your example and it does not freeze the GUI. But it does not give any indication of nodes having nodes/childnodes under them. The only way you can know is by clicking on the OU/childnode. When you have a very large Active Directory environment with cascading OU's that becomes a real pain. Just to give an example, we have one OU that has over 1600 OU's/childnodes below it. Trying to make it look/feel like how it looks in Active Directory Users and Computers.

Re: Treeview - Node - Property (Plus/Minus)

Posted: Mon Mar 11, 2019 6:45 pm
by jvierra
That is how it works or you have to load the whole thing at once. If you do that then the form will freeze.

This won't happen in a compiled program because we can use threading or tasks to load in the background. Loading a hierarchy with PowerShell cannot be done with multiple threads and jobs are not threads.

PowerShell cannot be used to create classic Windows applications. That is the limitation. You can synthesize some app behavior but PS is not designed or intended to be an applications development language. It is a management automation shell language. We can do many things to extend this but all require extensive programming skills and Windows programming experience.