Ejemplo n.º 1
0
 private string GetNamingName(TreeViewItemViewModel tree)
 {
     if (tree.Parent == null)
     {
         return tree.Name;
     }
     else
     {
         return GetNamingName(tree.Parent) + "/" + tree.Name;
     }
 }
Ejemplo n.º 2
0
        private void RecursiveCreateNamingServiceTree(PortType type, TreeViewItemViewModel tree, IEnumerable<string> names)
        {
            Debug.Assert(names != null, "names != null");

            if (names.Count() == 1)
            {
                var item = new ComponentItemViewModel()
                {
                    Name = names.First(),
                    Parent = tree
                };
                var compName = GetComponentName(item);

                ObservableCollection<PortService> portNames;
                switch (type)
                {
                    case PortType.DataInPort:
                        portNames = GetInPorts(compName);
                        break;
                    case PortType.DataOutPort:
                        portNames = GetOutPorts(compName);
                        break;
                    default:
                        return;
                }

                foreach (var portName in portNames)
                {
                    var prof = portName.get_port_profile();

                    switch (type)
                    {
                        case PortType.DataInPort:
                            var inport = new InPortItemViewModel()
                            {
                                Name = prof.name,
                                NamingName = GetNamingName(item),
                                DataType = prof.GetDataType(),
                                Parent = item
                            };
                            item.Children.Add(inport);
                            break;
                        case PortType.DataOutPort:
                            var outport = new OutPortItemViewModel()
                            {
                                Name = prof.name,
                                NamingName = GetNamingName(item),
                                DataType = prof.GetDataType(),
                                Parent = item
                            };
                            item.Children.Add(outport);
                            break;
                        default:
                            return;
                    }
                }

                tree.Children.Add(item);
            }
            else
            {
                var item = new ContextItemViewModel()
                {
                    Name = names.First(),
                    Parent = tree
                };

                tree.Children.Add(item);
                RecursiveCreateNamingServiceTree(type, item, names.Skip(1));
            }
        }
Ejemplo n.º 3
0
 private string GetComponentName(TreeViewItemViewModel tree)
 {
     if (tree.Parent is NamingServiceItemViewModel)
     {
         return tree.Name;
     }
     else
     {
         return GetComponentName(tree.Parent) + "/" + tree.Name;
     }
 }