Esempio n. 1
0
        void BuildViewCtrl_Schema(INodeItem nodeItem, NodeItemView node)
        {
            if (null == nodeItem)
            {
                return;
            }

            ISchemaItem  item    = nodeItem.Schema;
            NodeItemView subNode = null;

            if (!item.RepetitionContainerNode && (item.StructureDefOnlyNode || item.IsMessage))
            {
                if (null == item)
                {
                    return;//dead end
                }

                subNode = new NodeItemView();

                FillViewInfo(nodeItem, subNode);
                BuildViewCtrl_Fields(nodeItem, subNode, false);

                node.Nodes.Add(subNode);
            }
            else
            {
                subNode = node;
            }

            foreach (INodeItem sub in nodeItem.Nodes)
            {
                BuildViewCtrl_Schema(sub, subNode);
            }
        }
Esempio n. 2
0
        void BuildViewCtrl_Populated(INodeItem nodeItem, NodeItemView node, bool bPopulatedFieldsOnly)
        {
            if (null == nodeItem)
            {
                return;
            }

            ISchemaItem  item    = nodeItem.Schema;
            NodeItemView subNode = null;

            if ((item.IsGroup && nodeItem.AnySubItemHasRepetition) || item.IsMessage || (!item.RepetitionContainerNode && !item.StructureDefOnlyNode))
            {
                if (null == item)
                {
                    return;//dead end
                }

                subNode = new NodeItemView();

                FillViewInfo(nodeItem, subNode);
                BuildViewCtrl_Fields(nodeItem, subNode, bPopulatedFieldsOnly);

                node.Nodes.Add(subNode);
            }
            else
            {
                subNode = node;
            }

            foreach (INodeItem sub in nodeItem.Nodes)
            {
                BuildViewCtrl_Populated(sub, subNode, bPopulatedFieldsOnly);
            }
        }
Esempio n. 3
0
        public NodeItemView BuildViewCtrl_Populated(bool bPopulatedFieldsOnly)
        {
            NodeItemView root = new NodeItemView();

            BuildViewCtrl_Populated(Message, root, bPopulatedFieldsOnly);

            if (root.Nodes.Count == 1)
            {
                return(root.Nodes[0]);
            }
            else
            {
                return(root);
            }
        }
Esempio n. 4
0
        public NodeItemView BuildViewCtrl_All()
        {
            NodeItemView root = new NodeItemView();

            BuildViewCtrl_All(Message, root);

            if (root.Nodes.Count == 1)
            {
                return(root.Nodes[0]);
            }
            else
            {
                return(root);
            }
        }
Esempio n. 5
0
        void BuildViewCtrl_All(INodeItem nodeItem, NodeItemView node)
        {
            if (null == nodeItem)
            {
                return;
            }

            ISchemaItem  item    = nodeItem.Schema;
            NodeItemView subNode = null;

            bool IsSchemaItem             = (!item.RepetitionContainerNode && (item.StructureDefOnlyNode || item.IsMessage));
            bool IsContentItem            = ((item.IsGroup && nodeItem.AnySubItemHasRepetition) || item.IsMessage || (!item.RepetitionContainerNode && !item.StructureDefOnlyNode));
            bool ParentContainsContentRep = false;

            if (nodeItem.ParentItem != null)
            {
                if (nodeItem.ParentItem.Schema.RepetitionContainerNode)
                {
                    ParentContainsContentRep = nodeItem.ParentItem.Nodes.Count > 1;
                }
            }

            if ((IsSchemaItem && !ParentContainsContentRep) || IsContentItem)
            {
                if (null == item)
                {
                    return;//dead end
                }

                subNode = new NodeItemView();

                FillViewInfo(nodeItem, subNode);
                BuildViewCtrl_Fields(nodeItem, subNode, false);

                node.Nodes.Add(subNode);
            }
            else
            {
                subNode = node;
            }

            foreach (INodeItem sub in nodeItem.Nodes)
            {
                BuildViewCtrl_All(sub, subNode);
            }
        }
Esempio n. 6
0
        private void UpdateView()
        {
            try
            {
                NodeItemView tvc = null;

                switch (comboBox1.SelectedIndex)
                {
                case 0:
                    tvc = Model.BuildViewCtrl_Populated(true);
                    break;

                case 1:
                    tvc = Model.BuildViewCtrl_Populated(false);
                    break;

                case 2:
                    tvc = Model.BuildViewCtrl_Schema();
                    break;

                case 3:
                    tvc = Model.BuildViewCtrl_All();
                    break;

                default:
                    throw new Exception();
                }

                propertyGrid1.PropertySort   = PropertySort.NoSort;
                propertyGrid1.SelectedObject = new NodeItemViewWrapper(tvc);
            }
            catch (System.Exception ex)
            {
                OnError(ex);
            }

            try
            {
                textBox1.Text = Model.PipeMessage;
            }
            catch (System.Exception ex)
            {
                OnError(ex);
            }
        }
Esempio n. 7
0
        void FillViewInfo(INodeItem nodeItem, NodeItemView tvc)
        {
            if (null == nodeItem)
            {
                return;
            }

            ISchemaItem schema = nodeItem.Schema;

            tvc.Name  = schema.ItemName;
            tvc.Text  = schema.ItemName;
            tvc.Tag   = null;
            tvc.Model = this;

            if (schema.IsGroup || schema.IsMessage)
            {
                tvc.Expand = true;
            }
        }
Esempio n. 8
0
 static string GetName(NodeItemView node)
 {
     return(node.Name);
 }
Esempio n. 9
0
 public NodeItemViewWrapperPropertyDescriptor(NodeItemView node)
     : base(GetName(node), nix)
 {
     this.node = node;
 }
Esempio n. 10
0
 public NodeItemViewWrapper(NodeItemView node)
 {
     this.node = node;
 }
Esempio n. 11
0
        void BuildViewCtrl_Fields(INodeItem nodeItem, NodeItemView node, bool bPopulatedFieldsOnly)
        {
            for (int seq = 0; seq < nodeItem.Fields.Count; seq++)
            {
                if (!bPopulatedFieldsOnly)
                {
                    if (nodeItem.Fields[seq].Repetitions.Count == 0)
                    {
                        NodeItemView subNode = new NodeItemView();
                        subNode.Name        = nodeItem.Schema.ItemName + "-" + (seq + 1);
                        subNode.Text        = nodeItem.Schema.ItemName + "-" + (seq + 1);
                        subNode.Text       += " (" + nodeItem.Fields[seq].FieldFactory.NameFromType + ")";
                        subNode.Value       = "";
                        subNode.Tag         = nodeItem.Fields[seq];
                        subNode.Model       = this;
                        subNode.DataType    = nodeItem.Fields[seq].FieldFactory.NameFromType;
                        subNode.NodeType    = "field";
                        subNode.IsPopulated = false;

                        node.Nodes.Add(subNode);
                    }
                }

                for (int rep = 0; rep < nodeItem.Fields[seq].Repetitions.Count; rep++)
                {
                    bool subcomphasvalue = false;

                    NodeItemView subNode = new NodeItemView();
                    subNode.Name = nodeItem.Schema.ItemName + "-" + (seq + 1);
                    subNode.Text = nodeItem.Schema.ItemName + "-" + (seq + 1);

                    IField f = nodeItem.Fields[seq].Repetitions[rep];

                    if (!f.IsEmpty)
                    {
                        if (!f.HasSubComponents)
                        {
                            subNode.NodeType = "field";
                        }

                        subNode.IsPopulated = true;

                        if (rep > 0)
                        {
                            subNode.Text += "(rep " + rep + ")" + ": " + f.Value;
                        }
                        else
                        {
                            subNode.Text += ": " + f.Value;
                        }
                        subNode.Rep   = rep;
                        subNode.Value = f.Value;
                        subNode.Tag   = f;
                        subNode.Model = this;
                    }

                    if (f.HasSubComponents)
                    {
                        //add parent's wholesome value
                        {
                            string DeepValue = f.DeepValue;
                            if (!string.IsNullOrEmpty(DeepValue))
                            {
                                subNode.IsPopulated = true;
                                if (rep > 0)
                                {
                                    subNode.Text += "(rep " + rep + ")" + ": " + DeepValue;
                                }
                                else
                                {
                                    subNode.Text += ": " + DeepValue;
                                }
                                subNode.Rep   = rep;
                                subNode.Value = DeepValue;
                                subNode.Tag   = f;
                                subNode.Model = this;
                            }
                        }

                        for (int subcomp = 0; subcomp < f.Components.Length; subcomp++)
                        {
                            NodeItemView subcompNode = new NodeItemView();
                            subcompNode.Name  = nodeItem.Schema.ItemName + "-" + (seq + 1) + "-" + (subcomp + 1).ToString();
                            subcompNode.Text  = nodeItem.Schema.ItemName + "-" + (seq + 1) + "-" + (subcomp + 1).ToString();
                            subcompNode.Tag   = f.Components[subcomp];
                            subcompNode.Model = this;

                            if (!f.Components[subcomp].IsEmpty)
                            {
                                subcompNode.NodeType    = "field";
                                subcompNode.IsPopulated = true;

                                if (rep > 0)
                                {
                                    subcompNode.Text += "(rep " + rep + ")" + ": " + f.Components[subcomp].Value;
                                }
                                else
                                {
                                    subcompNode.Text += ": " + f.Components[subcomp].Value;
                                }
                                subcompNode.Rep   = rep;
                                subcompNode.Value = f.Components[subcomp].Value;
                                subcompNode.Tag   = f;
                                subcompNode.Model = this;
                                subcomphasvalue   = true;
                            }
                            subNode.Nodes.Add(subcompNode);

                            //
                            if (f.Components[subcomp].HasSubComponents)
                            {
                                for (int subcomp1 = 0; subcomp1 < f.Components[subcomp].Components.Length; subcomp1++)
                                {
                                    NodeItemView subcompNode1 = new NodeItemView();
                                    subcompNode1.Name  = nodeItem.Schema.ItemName + "-" + (seq + 1) + "-" + subcomp + "-" + subcomp1;
                                    subcompNode1.Text  = nodeItem.Schema.ItemName + "-" + (seq + 1) + "-" + subcomp + "-" + subcomp1;
                                    subcompNode1.Tag   = f.Components[subcomp].Components[subcomp1];
                                    subcompNode1.Model = this;

                                    if (!f.Components[subcomp].Components[subcomp1].IsEmpty)
                                    {
                                        subcompNode.NodeType    = "field";
                                        subcompNode.IsPopulated = true;

                                        if (rep > 0)
                                        {
                                            subcompNode.Text += "(rep " + rep + ")" + ": " + f.Components[subcomp].Components[subcomp1].Value;
                                        }
                                        else
                                        {
                                            subcompNode.Text += ": " + f.Components[subcomp].Components[subcomp1].Value;
                                        }
                                        subcompNode.Rep   = rep;
                                        subcompNode.Value = f.Components[subcomp].Components[subcomp1].Value;
                                        subcompNode.Tag   = f;
                                        subcompNode.Model = this;
                                        subcomphasvalue   = true;
                                    }
                                    subcompNode.Nodes.Add(subcompNode1);
                                }
                            }
                        }
                    }

                    subNode.Text    += " (" + nodeItem.Fields[seq].FieldFactory.NameFromType + ")";
                    subNode.DataType = nodeItem.Fields[seq].FieldFactory.NameFromType;
                    if (!f.IsEmpty || !bPopulatedFieldsOnly || subcomphasvalue)
                    {
                        node.Nodes.Add(subNode);
                    }
                }
            }
        }