Detect if a Gtk.TreeNode is expanded - c#

Basically I want to know if a given nodes children are visible in a Gtk.NodeView. I've tried tracking it myself however when you click on expand symbol next to a node it goes through a different function than when you click on the node itself.
so here's a basic diagram to try to explain.
-MainNode1
----ChildNode1
----ChildNode2
-MainNode2
so what I want to know is can the user see the child nodes of mainNode1. The problem that I'm running into trying to track this behavior with a bool value on the node itself is there are so many ways the node can be expanded that the bool value might get set to the wrong thing so I'm looking for a better way.
any ideas?

I've found the solution there's a function called getrowexpanded that I apparently missed when looking for a solution

Related

How to skim through a page, element by element, and determine which element I'm looking at?

Premise:
I'm trying to write a selenium program that is as abstract as possible, so that when I make new tests, there is minimal work required. The idea that I came up with is for me to iterate through the elements on the page, then I would take the element, all of the attributes, parent, children,(which I can find out later, not necessarily in scope for this question though) and other such things, and then I'd pack this into an object that I made called 'Element'. After running this and getting every element on the page, I'll make a change to the page i.e. tab out of the text box, click a button etc., and then do the iteration all again, and note the differences.
The Question:
How do I start from the top of the page, and iterate through each element that exists on the page. I want to include elements including but not limited to things such as labels, divs, textboxes, buttons, everything. Everything that is an element, I want to find it, and add it to the collection.
Side tasks after:
After this I'll try to locate it's attributes, and then determine if it has any children, and if it has any parents.
I've found methods online regarding how to find an element by something like id or name or other, and I could find multiple elements like this and pack it into a collection, but I don't see how this would help out my specific case because then I would have to make a case for every single type of element which sounds like more work than I'd want.
EDIT: THIS WILL NOT INCLUDE THE HEAD, ONLY THE BODY.
You can retrieve all child elements calling FindElements from another IWebElement like this
IWebElement body = Driver.FindElement(By.TagName("Body"));
ReadOnlyCollection<IWebElement> bodyChilds = body.FindElements(By.XPath(".//*"));
That will return all child elements of the body.
Then you can iterate over every element in the list finding its elements to know if they have childs or not.
Regarding the attributes part, as far as i know it's not possible just with selenium, but there are easy to find examples out there on how to do it with javascript

Draw a line between two nodes

I have a solution using AngularJS which generates a bracket of matches in a tournament tree:
My question is how do I draw a line between two nodes which are generated using ng-repeat so it will look something like this?
I have been looking into other questions such as Question 1 and I have been trying to use this code example: jsfiddle.net/kDs2Q/1047/
but I cant figure out how to use it with ng-repeat.
EDIT:
I have made a simple Fiddle to try and setup some of my solution.
jsfiddle.net/U3pVM/14850/
When you click the "Draw line" it draws a line that is way off the two nodes. How do I get it to connect the two nodes with the drawn line? Also in such a way that if I add another node it will connect to the next one.
[Node1]---[Node2]---[Node3]
EDIT 2:
Okay so I have done my best to create a Fiddle out from my own solution. I have made a setup where each node has an Id and a ParentId. This way I should be able to set the line to be drawn from child to parent.
But it seems like I am hitting a continious loop in traverseScopesLoop in the angularjs. I cant get it to render.
I suspect that the document.body.innerHTML += htmlLine; in the "connect" function might be the cause of the loop?
Please have a look at this fiddle and have in mind that the function "iterateAndGenerateDivsForDrawnLines" is outcommmented. You need to remove the outcomment to run the function and start the loop.
jsfiddle.net/U3pVM/14934/
Help, suggestions, links - everything is appreciated! Thank you in advance. :)

Is it possible to know when a node has been added to a treeview?

I have a treeview that utilizes the StateImageList to implement "proper" tri-state checks in a tree. The problem however is the first layer of nodes that get added to the tree. By default the StateImageIndex on a new TreeNode is -1, and I have no way of really knowing that they have been added. Nodes that are child nodes I can catch on the BeforeExpand and set the StateImageIndex properly but I cant seem to figure out what to do about the Top Layer of nodes.
My current work around (that I really really hate) is I have a timer running in the background checking to see if the number of nodes in the treeview has changed, if it has I run through and find all the root nodes that have a StateImageIndex set to -1 and set them to 0. It works, but it seems like a terrible waste of resources. Any one have a better suggestion?
No event, you can't generate one either. The native control doesn't support an event because only code can add nodes, not the user. You can't generate one because you can't break into the TreeNodeCollection class. A simple workaround is to add a static CreateNode() factory method to your class with the expectation that the client code uses that to create a properly initialized node.
You ought to consider the DrawMode property so you can just draw the node the way you want it. HitTest() to detect clicks, ControlPaint.DrawCheckBox() to draw the box.

How to get child location in a treeview?

I currently have a simple tree view that contains one parent node with multiple child nodes. I was wondering if there is a way to find the location of the selected node in the parent tree.
I currently have an action event on the treeview and when the user clicks on the child it prints out the string value of the selected child. I have tried using:
int val = TreeView.SelectedItemProperty.GlobalIndex;
but it always returns 0. I have seen some examples in VB but I cant seem to get the same idea to work in C#.
You have to use the ItemContainerGenerator property of the Treeview.
http://msdn.microsoft.com/en-us/library/system.windows.controls.itemcontainergenerator.aspx
See: ContainerFromIndex and IndexFromContainer
Note that each TreeViewItem also has an ItemContainerGenerator (its an ItemsControl), so you'd have to recursively search down the tree if you have multiple levels.
I think the answer to all your treeview problems (and most ui ones) in wpf is to build a ViewModel. Anytime you start crawling the visual tree to look for elements that you are already binding to, you are doing things the hard way. Once you start using ItemsContainerGenerator you have to start worrying about a whole lot of issues you should not have to.
You are binding to a hierarchical structure. If that structure has a selected item property on each item and it is bound to the TreeViewItem selected item then you can just get the selected item in code and do everything else from there. Have a look at a similiar question here.
So i didn't find the answer i was looking for (I may of confused others with what my question was. by saying location). Anyways how I solved it was I got the string value of the child selected and compared it to my list. Thanks to those who answered!

TreeView Winforms if a node can bee seen?

I have a treeView , and i want to know if some node can be seen by a user.
I mean that no node abave it not needed to be expanded that that node will be seen .
Any idea how i can check this with out rotating to upper lever for that ?
Checked msdn but couldn't see property responsible for that ....
Some Example will really help....
Thanks a lot for help.
I assume if you want to know if a treenodes parent is expanded
TreeNode.Parent.IsExpanded
I think this is what you need:
Node myNode;
if(myNode.Parent.Expanded)
//Visible

Categories

Resources