private VirtualTreeView DeserializeTreeView(string testResource)
        {
            VirtualTreeView treeView = new VirtualTreeView();

            new TreeViewSerializer().DeserializeTreeView(treeView, GetTestResource(testResource));
            return(treeView);
        }
Ejemplo n.º 2
0
        public void Setup()
        {
            _vtv = new VirtualTreeView();
            _tv  = _vtv;

            // ensure handle is created. Some tests fail if you don't do this.
            IntPtr h = _vtv.Handle;
        }
Ejemplo n.º 3
0
        public void Setup()
        {
            _vtv = new VirtualTreeView();
            _tv  = _vtv;

            // ensure handle is created. Some tests fail if you don't do this.
            Assert.NotNull(_vtv.Handle);
        }
Ejemplo n.º 4
0
        public void SwitchToSearchTab()
        {
            MainWindowWrapper mainWindowWrapper = new MainWindowWrapper(Program.MainWindow);

            // Select the XenCenter node
            VirtualTreeView treeView = mainWindowWrapper.TreeView;

            MW(delegate() { treeView.SelectedNode = treeView.Nodes[0]; });

            // Switch to the Search tab
            GoToTabPage(Program.MainWindow.TabPageSearch);
        }
Ejemplo n.º 5
0
        public string SerializeTreeView(VirtualTreeView treeView)
        {
            Util.ThrowIfParameterNull(treeView, "treeView");

            StringWriter sw = new StringWriter();

            XmlTextWriter textWriter = new XmlTextWriter(sw);

            // writing the xml declaration tag
            textWriter.WriteStartDocument();
            //textWriter.WriteRaw("\r\n");
            // writing the main tag that encloses all node tags
            textWriter.WriteStartElement("VirtualTreeView");

            // save the nodes, recursive method
            SaveNodes(treeView.Nodes, textWriter);

            textWriter.WriteEndElement();

            textWriter.Close();

            return(sw.ToString());
        }
Ejemplo n.º 6
0
        public void DeserializeTreeView(VirtualTreeView treeView, string fileName)
        {
            Util.ThrowIfParameterNull(treeView, "treeView");
            Util.ThrowIfStringParameterNullOrEmpty(fileName, "fileName");

            XmlTextReader reader = null;

            try
            {
                // disabling re-drawing of treeview till all nodes are added
                treeView.BeginUpdate();
                reader =
                    new XmlTextReader(fileName);

                VirtualTreeNode parentNode = null;

                while (reader.Read())
                {
                    if (reader.NodeType == XmlNodeType.Element)
                    {
                        if (reader.Name == XmlNodeTag)
                        {
                            VirtualTreeNode newNode        = new VirtualTreeNode("");
                            bool            isEmptyElement = reader.IsEmptyElement;

                            // loading node attributes
                            int attributeCount = reader.AttributeCount;
                            if (attributeCount > 0)
                            {
                                for (int i = 0; i < attributeCount; i++)
                                {
                                    reader.MoveToAttribute(i);

                                    SetAttributeValue(newNode, reader.Name, reader.Value);
                                }
                            }

                            // add new node to Parent Node or VirtualTreeView
                            if (parentNode != null)
                            {
                                parentNode.Nodes.Add(newNode);
                            }
                            else
                            {
                                treeView.Nodes.Add(newNode);
                            }

                            // making current node 'ParentNode' if its not empty
                            if (!isEmptyElement)
                            {
                                parentNode = newNode;
                            }
                        }
                    }
                    // moving up to in VirtualTreeView if end tag is encountered
                    else if (reader.NodeType == XmlNodeType.EndElement)
                    {
                        if (reader.Name == XmlNodeTag)
                        {
                            parentNode = parentNode.Parent;
                        }
                    }
                    else if (reader.NodeType == XmlNodeType.XmlDeclaration)
                    {                     //Ignore Xml Declaration
                    }
                    else if (reader.NodeType == XmlNodeType.None)
                    {
                        return;
                    }
                    else if (reader.NodeType == XmlNodeType.Text)
                    {
                        parentNode.Nodes.Add(new VirtualTreeNode(reader.Value));
                    }
                }
            }
            finally
            {
                // enabling redrawing of treeview after all nodes are added
                treeView.EndUpdate();
                reader.Close();
            }
        }