Esempio n. 1
0
        private void CopyXmlToTreeViewReal(XmlNode xmlNode, TreeViewItem treeViewItemParent)
        {
            SolidColorBrush elemBrush = new SolidColorBrush(Colors.MediumVioletRed);

            if (xmlNode != null)
            {
                TreeViewItem item = new TreeViewItem();
                item.IsExpanded = true;
                StackPanel panel = new StackPanel();
                panel.Orientation = System.Windows.Controls.Orientation.Horizontal;
                TextBlock tbTagOpen  = new TextBlock();
                TextBlock tbTagClose = new TextBlock();
                TextBlock tbName     = new TextBlock();
                tbTagOpen.Name        = "tbTagOpen";
                tbTagClose.Name       = "tbTagClose";
                tbName.Name           = "tbName";
                tbTagOpen.Text        = "<";
                tbTagClose.Text       = ">";
                tbName.Text           = xmlNode.Name;
                tbTagOpen.Foreground  = elemBrush;
                tbTagClose.Foreground = elemBrush;
                tbName.Foreground     = elemBrush;

                if (!xmlNode.NodeType.ToString().Equals("Text"))
                {
                    item.Name  = "OpenItemXmlNode";
                    panel.Name = "OpenPanelXMLNode";
                    TreeViewItem closeitem = new TreeViewItem();
                    panel.Children.Insert(0, tbTagOpen);
                    panel.Children.Add(tbName);
                    if (!xmlNode.NamespaceURI.Equals(""))
                    {
                        this.InsertNamespace(panel, xmlNode.NamespaceURI, xmlNode.Prefix);
                    }
                    if (xmlNode.Attributes != null)
                    {
                        this.InsertAttributes(panel, xmlNode.Attributes);
                    }
                    panel.Children.Add(tbTagClose);
                    if (!animationRunning)
                    {
                        XmlNode[] ElementsToEnc = _soap.GetElementsToEncrypt();

                        foreach (XmlNode node in ElementsToEnc)
                        {
                            if (node.Name.Equals(xmlNode.Name))
                            {
                                this.AddOpenLockToPanel(panel, xmlNode.Name);
                            }
                        }
                        XmlNode[] EncryptedElements = _soap.GetEncryptedElements();
                        foreach (XmlNode node in EncryptedElements)
                        {
                            if (node.Name.Equals(xmlNode.Name))
                            {
                                this.AddClosedLockToPanel(panel);
                            }
                        }
                        XmlNode[] signedElements = _soap.GetSignedElements();
                        foreach (XmlNode node in signedElements)
                        {
                            if (node.Name.Equals(xmlNode.Name))
                            {
                                string id = "";
                                foreach (XmlAttribute att in node.Attributes)
                                {
                                    if (att.Name.Equals("Id"))
                                    {
                                        id = att.Value;
                                    }
                                }
                                this.AddSignedIconToPanel(panel, xmlNode.Name, id);
                            }
                        }
                        XmlNode[] elementsToSign = _soap.GetElementsToSign();
                        foreach (XmlNode node in elementsToSign)
                        {
                            if (node.Name.Equals(xmlNode.Name))
                            {
                                this.AddToSignIconToPanel(panel, xmlNode.Name);
                            }
                        }
                        XmlNode[] parameters = _soap.GetParameterToEdit();
                        foreach (XmlNode node in parameters)
                        {
                            if (node.Name.Equals(xmlNode.Name))
                            {
                                this.AddEditImageToPanel(panel, xmlNode.Name);
                            }
                        }
                    }
                    item.Header          = panel;
                    closeitem.Foreground = elemBrush;
                    treeViewItemParent.Items.Add(item);
                    if (xmlNode.HasChildNodes)
                    {
                        foreach (XmlNode child in xmlNode.ChildNodes)
                        {
                            _lastURI = xmlNode.NamespaceURI;;
                            this.CopyXmlToTreeViewReal(child, item);
                        }
                    }
                    StackPanel panel1 = new StackPanel();
                    panel1.Orientation = System.Windows.Controls.Orientation.Horizontal;
                    TextBlock elem1Open = new TextBlock();
                    elem1Open.Text = "<";
                    panel1.Children.Insert(0, elem1Open);
                    TextBlock elem1Close = new TextBlock();
                    elem1Close.Text = ">";
                    TextBlock elem1Name = new TextBlock();
                    elem1Name.Text = "/" + xmlNode.Name;
                    panel1.Children.Add(elem1Name);
                    panel1.Children.Add(elem1Close);

                    closeitem.Header = panel1;

                    treeViewItemParent.Items.Add(closeitem);
                }
                else
                {
                    item.Name  = "OpenItemTextNode";
                    panel.Name = "OpenPanelTextNode";
                    TextBlock tbText = new TextBlock();
                    tbText.Name = "TextNode";
                    tbText.Text = xmlNode.Value;
                    panel.Children.Add(tbText);
                    item.Header = panel;
                    treeViewItemParent.Items.Add(item);
                }
            }
        }