Пример #1
0
        public void Traverse_IntegerTreeNode_AllNodesTraversed()
        {
            // Create a tree like the following
            // 1
            // 2 3 5
            // 6 7 4 9 10
            // 11 12 13 14
            // 16 15 17
            var rootNode   = new TreeNode <int>(1);
            var firstLevel = rootNode.AddChildren(2, 3, 5).ToList();

            firstLevel.First().AddChildren(6).First().AddChildren(11, 12).Last().AddChildren(16);
            firstLevel.Skip(1).First().AddChildren(7, 4);
            var node5Children = firstLevel.Skip(2).First().AddChildren(9, 10).ToList();

            node5Children.First().AddChildren(13);
            var node14 = node5Children.Skip(1).First().AddChildren(14).First();

            node14.AddChildren(15, 17);

            var expected = new List <int> {
                0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
            };

            var actual = new List <int>();

            rootNode.Traverse(
                i =>
            {
                i -= i;
                actual.Add(i);
            });

            CollectionAssert.AreEqual(expected, actual);
        }
Пример #2
0
        public void Flatten_IntegerTreeNode_EquivalentToExpectedList()
        {
            // Create a tree like the following
            // 1
            // 2 3 5
            // 6 7 4 9 10
            // 11 12 13 14
            // 16 15 17
            var rootNode   = new TreeNode <int>(1);
            var firstLevel = rootNode.AddChildren(2, 3, 5).ToList();

            firstLevel.First().AddChildren(6).First().AddChildren(11, 12).Last().AddChildren(16);
            firstLevel.Skip(1).First().AddChildren(7, 4);
            var node5Children = firstLevel.Skip(2).First().AddChildren(9, 10).ToList();

            node5Children.First().AddChildren(13);
            var node14 = node5Children.Skip(1).First().AddChildren(14).First();

            node14.AddChildren(15, 17);

            var expected = new List <int> {
                1, 2, 3, 4, 5, 6, 7, 9, 10, 11, 12, 13, 14, 15, 16, 17
            };
            var actual = rootNode.Flatten().ToList();

            CollectionAssert.AreEquivalent(expected, actual);
        }
Пример #3
0
        public void RemoveChild_IntegerTreeNode_AllChildrenCascadingRemoved()
        {
            // Create a tree like the following
            // 1
            // 2 3 5
            // 6 7 4 9 10
            // 11 12 13 14
            // 16 15 17
            var rootNode     = new TreeNode <int>(1);
            var firstLevel   = rootNode.AddChildren(2, 3, 5).ToList();
            var nodeToRemove = firstLevel.First().AddChildren(6).First();

            nodeToRemove.AddChildren(11, 12).Last().AddChildren(16);
            firstLevel.Skip(1).First().AddChildren(7, 4);
            var node5Children = firstLevel.Skip(2).First().AddChildren(9, 10).ToList();

            node5Children.First().AddChildren(13);
            var node14 = node5Children.Skip(1).First().AddChildren(14).First();

            node14.AddChildren(15, 17);

            var removed = nodeToRemove.Parent.RemoveChild(nodeToRemove);

            Assert.IsTrue(removed);

            foreach (var number in new List <int> {
                6, 11, 12, 16
            })
            {
                Assert.IsNull(rootNode.FirstOrDefault(i => i == number));
            }
        }
Пример #4
0
        public void FirstCommonAncestor_TreeNodeOfIntegersSameNode_ReturnsNode()
        {
            // Create a tree like the following
            // 1
            // 2 3 5
            // 6 7 4 9 10
            // 11 12 13 14
            // 16 15 17
            var rootNode   = new TreeNode <int>(1);
            var firstLevel = rootNode.AddChildren(2, 3, 5).ToList();

            firstLevel.First().AddChildren(6).First().AddChildren(11, 12).Last().AddChildren(16);
            firstLevel.Skip(1).First().AddChildren(7, 4);
            var node5Children = firstLevel.Skip(2).First().AddChildren(9, 10).ToList();

            node5Children.First().AddChildren(13);
            var node15 = node5Children.Skip(1).First().AddChildren(14).First().AddChildren(15, 17).First();

            var actual = rootNode.FirstCommonAncestor(
                new[]
            {
                node15,
                node15
            });

            Assert.AreEqual(node15.Value, actual.Value);
        }
Пример #5
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);

            // Set our view from the "main" layout resource
            SetContentView(Resource.Layout.Main);

            //create root
            TreeNode root   = TreeNode.InvokeRoot();
            TreeNode parent = new TreeNode("parent");
            TreeNode child0 = new TreeNode("ChildNode0");
            TreeNode child1 = new TreeNode("ChildNode1");

            TreeItem item = new TreeItem()
            {
                text = "abc"
            };
            TreeNode child10 = new TreeNode(item).SetViewHolder(new MyHolder(this));

            child1.AddChild(child10);
            parent.AddChildren(child0, child1);
            root.AddChild(parent);

            AndroidTreeView atv = new AndroidTreeView(this, root);

            LinearLayout rootlayout = FindViewById <LinearLayout>(Resource.Id.rootlayout);

            rootlayout.AddView(atv.View);

            rootlayout.Invalidate();
        }
Пример #6
0
        public List <TreeNode <MultiValuesHeuristicResult> > Expand(TreeNode <MultiValuesHeuristicResult> node)
        {
            var state  = node.Data.Action.NewState;
            var player = state.Agents[state.CurrentAgent];

            var moves = player.PossibleMoves(state).Select(move => new MultiValuesHeuristicResult(move, new double[0])).ToList();

            if (state.GoalState || !moves.Any())
            {
                var s = node.Data.Action.NewState;
                node.Data.Values = s.MultiAgents.Select(a => a.MultiScore(s)).ToArray();
                return(node.AddChildren(new List <MultiValuesHeuristicResult>()));
            }

            return(node.AddChildren(moves));
        }
Пример #7
0
        public void FirstOrDefault_IntegerTreeNodeWithDuplicateValues_GetsFirstValue()
        {
            // Create a tree like the following
            // 1
            // 2 3 5
            // 6 7 4 9 10
            // 14* 12 13 14
            // 16 15 17
            var rootNode    = new TreeNode <int>(1);
            var firstLevel  = rootNode.AddChildren(2, 3, 5).ToList();
            var childrenOf6 = firstLevel.First().AddChildren(6).First().AddChildren(14, 12).ToList();

            childrenOf6.Last().AddChildren(16);
            var expected = childrenOf6.First();

            firstLevel.Skip(1).First().AddChildren(7, 4);
            var node5Children = firstLevel.Skip(2).First().AddChildren(9, 10).ToList();

            node5Children.First().AddChildren(13);
            var node14B = node5Children.Skip(1).First().AddChildren(14).First();

            node14B.AddChildren(15, 17);

            var actual = rootNode.FirstOrDefault(i => i == 14);

            Assert.AreSame(expected, actual);
        }
        public void GivenTreeNode_WhenGetSequenceResult_ThenCorrectResultReturned()
        {
            // Arrange
            var root = new TreeNode <string> {
                Value = "Node1"
            };

            root.AddChildren(new List <string> {
                "Node2a", "Node2b"
            });
            var child = root.Children.Single(child => child.Value == "Node2a");

            child.AddChildren(new List <string> {
                "Node3a", "Node3b", "Node3c"
            });

            var grandchild = child.Children.Single(child => child.Value == "Node3c");

            // Act
            var result = grandchild.ToSequenceResult();

            // Assert
            result.SequenceFound.Should().BeTrue();
            result.Words.Count.Should().Be(3);
            result.Words[0].Should().Be("Node1");
            result.Words[1].Should().Be("Node2a");
            result.Words[2].Should().Be("Node3c");
        }
Пример #9
0
        private void fillFolder(TreeNode folder)
        {
            TreeNode file1 = new TreeNode("File1").SetViewHolder(new SelectableItemHolder(Activity));
            TreeNode file2 = new TreeNode("File2").SetViewHolder(new SelectableItemHolder(Activity));
            TreeNode file3 = new TreeNode("File3").SetViewHolder(new SelectableItemHolder(Activity));

            folder.AddChildren(file1, file2, file3);
        }
Пример #10
0
        public void GivenTreeNode_WhenAddChildren_ThenChildrenAdded()
        {
            var treeNode = new TreeNode <string>();

            treeNode.AddChildren(new List <string> {
                "Test1", "Test2"
            });

            treeNode.Children.Count.Should().Be(2);
            treeNode.Children.Should().Contain(child => child.Value == "Test1");
            treeNode.Children.Should().Contain(child => child.Value == "Test2");
        }
        public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
        {
            View      rootView      = inflater.Inflate(Resource.Layout.fragment_default, null, false);
            ViewGroup containerView = rootView.FindViewById <ViewGroup>(Resource.Id.container);

            statusBar = rootView.FindViewById <TextView>(Resource.Id.status_bar);

            TreeNode root         = TreeNode.InvokeRoot();
            TreeNode computerRoot = new TreeNode(new IconTreeItem(Resource.String.ic_laptop, "My Computer"));

            TreeNode myDocuments = new TreeNode(new IconTreeItem(Resource.String.ic_folder, "My Documents"));
            TreeNode downloads   = new TreeNode(new IconTreeItem(Resource.String.ic_folder, "Downloads"));
            TreeNode file1       = new TreeNode(new IconTreeItem(Resource.String.ic_drive_file, "Folder 1"));
            TreeNode file2       = new TreeNode(new IconTreeItem(Resource.String.ic_drive_file, "Folder 2"));
            TreeNode file3       = new TreeNode(new IconTreeItem(Resource.String.ic_drive_file, "Folder 3"));
            TreeNode file4       = new TreeNode(new IconTreeItem(Resource.String.ic_drive_file, "Folder 4"));

            fillDownloadsFolder(downloads);
            downloads.AddChildren(file1, file2, file3, file4);

            TreeNode myMedia = new TreeNode(new IconTreeItem(Resource.String.ic_photo_library, "Photos"));
            TreeNode photo1  = new TreeNode(new IconTreeItem(Resource.String.ic_photo_library, "Folder 1"));
            TreeNode photo2  = new TreeNode(new IconTreeItem(Resource.String.ic_photo_library, "Folder 2"));
            TreeNode photo3  = new TreeNode(new IconTreeItem(Resource.String.ic_photo_library, "Folder 3"));

            myMedia.AddChildren(photo1, photo2, photo3);

            myDocuments.AddChild(downloads);
            computerRoot.AddChildren(myDocuments, myMedia);

            root.AddChildren(computerRoot);

            tView = new AndroidTreeView(Activity, root);
            tView.SetDefaultAnimation(true);
            tView.SetDefaultContainerStyle(Resource.Style.TreeNodeStyleCustom);
            tView.SetDefaultViewHolder(Java.Lang.Class.FromType(typeof(IconTreeItemHolder)));
            tView.SetDefaultNodeClickListener(new CustomTreeNodeClickListener(statusBar));
            tView.SetDefaultNodeLongClickListener(new CustomTreeNodeLongClickListener(Activity));

            containerView.AddView(tView.View);

            if (savedInstanceState != null)
            {
                string state = savedInstanceState.GetString("tState");
                if (!string.IsNullOrEmpty(state))
                {
                    tView.RestoreState(state);
                }
            }

            return(rootView);
        }
    // Start is called before the first frame update
    void Start()
    {
        StartNode = new TreeNode <int>(1);
        var depth1 = StartNode.AddChildren(new int[] { 2, 6 });
        var depth2 = StartNode[0].AddChildren(new int[] { 3, 4, 5 });
        var depth3 = StartNode[1].AddChildren(new int[] { 7, 11 });
        var depth4 = StartNode[1][0].AddChildren(new int[] { 8, 9 });
        var depth5 = StartNode[1][0][0].AddChildren(new int[] { 10 });

        _depth = 4;
        Visualize2DLayout(StartNode);

        StartCoroutine(VisitInInOrder());
    }
        /// <summary>
        /// Populates the tree from flattened data.
        /// </summary>
        /// <param name="tree">
        /// The tree.
        /// </param>
        /// <param name="data">
        /// The data.
        /// </param>
        /// <typeparam name="TNode">
        /// The type of the object to be represented as a tree node
        /// </typeparam>
        /// <returns>
        /// The <see cref="TreeNode{TNode}"/>.
        /// </returns>
        internal static TreeNode<TNode> Populate<TNode>(this TreeNode<TNode> tree, IEnumerable<TNode> data)
            where TNode : IHasKeyId, IHasParent
        {
            var nodes = data as TNode[] ?? data.ToArray();
            var children = nodes.Where(x => x.ParentKey == tree.Value.Key);

            tree.AddChildren(children.ToArray());
            foreach (var child in tree.Children)
            {
                Populate(child, nodes);
            }

            return tree;
        }
Пример #14
0
        public List <TreeNode <MultiHeuristicResult> > Expand(TreeNode <MultiHeuristicResult> node)
        {
            var state  = node.Data.Action.NewState;
            var player = state.Agents[state.CurrentAgent];

            var moves = player.PossibleMoves(state).Select(move => new MultiHeuristicResult(move, 0)).ToList();

            if (!moves.Any())
            {
                var s = node.Data.Action.NewState;
                var p = Root.Data.Action.Performer.Id;

                node.Data.Value = s.MultiAgents.First(ma => ma.Id == p).MultiScore(s);
            }
            return(node.AddChildren(moves));
        }
Пример #15
0
        public void Initialize()
        {
            // Tree with 6 nodes
            // Nodes are enumerated according to breadth search order
            tree6Nodes = new TreeNode(1);
            tree6Nodes.AddChildren(new TreeNode(2, new TreeNode(5), new TreeNode(6)), new TreeNode(3), new TreeNode(4));

            // Tree with 12 nodes
            // Nodes are enumerated according to depth search order
            tree12Nodes = new TreeNode(1);
            TreeNode auxNode1 = new TreeNode(2, new TreeNode(3), new TreeNode(4, new TreeNode(5), new TreeNode(6)));
            TreeNode auxNode2 = new TreeNode(7, new TreeNode(8, new TreeNode(9)));
            TreeNode auxNode3 = new TreeNode(10, new TreeNode(11), new TreeNode(12));

            tree12Nodes.AddChildren(auxNode1, auxNode2, auxNode3);
        }
        private void addProfileData(TreeNode profile)
        {
            TreeNode socialNetworks = new TreeNode(new IconTreeItem(Resource.String.ic_people, "Social")).SetViewHolder(new HeaderHolder(Activity));
            TreeNode places         = new TreeNode(new IconTreeItem(Resource.String.ic_place, "Places")).SetViewHolder(new HeaderHolder(Activity));

            TreeNode facebook = new TreeNode(new SocialViewHolder.SocialItem(Resource.String.ic_post_facebook)).SetViewHolder(new SocialViewHolder(Activity));
            TreeNode linkedin = new TreeNode(new SocialViewHolder.SocialItem(Resource.String.ic_post_linkedin)).SetViewHolder(new SocialViewHolder(Activity));
            TreeNode google   = new TreeNode(new SocialViewHolder.SocialItem(Resource.String.ic_post_gplus)).SetViewHolder(new SocialViewHolder(Activity));
            TreeNode twitter  = new TreeNode(new SocialViewHolder.SocialItem(Resource.String.ic_post_twitter)).SetViewHolder(new SocialViewHolder(Activity));

            TreeNode lake      = new TreeNode(new PlaceHolderHolder.PlaceItem("A rose garden")).SetViewHolder(new PlaceHolderHolder(Activity));
            TreeNode mountains = new TreeNode(new PlaceHolderHolder.PlaceItem("The white house")).SetViewHolder(new PlaceHolderHolder(Activity));

            places.AddChildren(lake, mountains);
            socialNetworks.AddChildren(facebook, google, twitter, linkedin);
            profile.AddChildren(socialNetworks, places);
        }
Пример #17
0
        private static List <TreeNode <SearchHeuristicResult> > Expand(TreeNode <SearchHeuristicResult> node)
        {
            var action = node.Data.Action;
            var state  = node.Data.SimulatedState;

            if (!(action.Performer is AbstractSearchAgent agent))
            {
                throw new Exception("Expand with non-AI agent");
            }

            var source = state.Graph.Vertex(agent.Position);

            var results = source.Neighbors
                          .Select(v => agent.Heuristic(new Traverse(state, state.Clone(), agent.Id, v)) as SearchHeuristicResult)
                          .ToList();

            return(node.AddChildren(results));
        }
        public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
        {
            // Use this to return your custom view for this Fragment
            // return inflater.Inflate(Resource.Layout.YourFragment, container, false);
            View      rootView      = inflater.Inflate(Resource.Layout.fragment_default, null, false);
            ViewGroup containerView = rootView.FindViewById <ViewGroup>(Resource.Id.container);

            rootView.FindViewById(Resource.Id.status_bar).Visibility = ViewStates.Gone;

            TreeNode root = TreeNode.InvokeRoot();

            TreeNode myProfile = new TreeNode(new IconTreeItem(Resource.String.ic_person, "My Profile")).SetViewHolder(new ProfileHolder(Activity));
            TreeNode bruce     = new TreeNode(new IconTreeItem(Resource.String.ic_person, "Bruce Wayne")).SetViewHolder(new ProfileHolder(Activity));
            TreeNode clark     = new TreeNode(new IconTreeItem(Resource.String.ic_person, "Clark Kent")).SetViewHolder(new ProfileHolder(Activity));
            TreeNode barry     = new TreeNode(new IconTreeItem(Resource.String.ic_person, "Barry Allen")).SetViewHolder(new ProfileHolder(Activity));

            addProfileData(myProfile);
            addProfileData(clark);
            addProfileData(bruce);
            addProfileData(barry);
            root.AddChildren(myProfile, bruce, barry, clark);

            tView = new AndroidTreeView(Activity, root);
            tView.SetDefaultAnimation(true);
            tView.SetDefaultContainerStyle(Resource.Style.TreeNodeStyleDivided, true);
            containerView.AddView(tView.View);

            if (savedInstanceState != null)
            {
                string state = savedInstanceState.GetString("tState");
                if (!string.IsNullOrEmpty(state))
                {
                    tView.RestoreState(state);
                }
            }

            return(rootView);
        }
        public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
        {
            View rootView = inflater.Inflate(Resource.Layout.fragment_selectable_nodes, null, false);

            rootView.FindViewById(Resource.Id.status).Visibility = ViewStates.Gone;
            ViewGroup containerView = rootView.FindViewById <ViewGroup>(Resource.Id.container);

            TreeNode root = TreeNode.InvokeRoot();

            TreeNode s1 = new TreeNode(new IconTreeItem(Resource.String.ic_folder, "Folder with very long name ")).SetViewHolder(new ArrowExpandSelectableHeaderHolder(Activity));
            TreeNode s2 = new TreeNode(new IconTreeItem(Resource.String.ic_folder, "Another folder with very long name")).SetViewHolder(new ArrowExpandSelectableHeaderHolder(Activity));

            fillFolder(s1);
            fillFolder(s2);

            root.AddChildren(s1, s2);

            tView = new AndroidTreeView(Activity, root);
            tView.SetDefaultAnimation(true);
            tView.SetUse2dScroll(true);
            tView.SetDefaultContainerStyle(Resource.Style.TreeNodeStyleCustom);
            tView.SetDefaultViewHolder(Java.Lang.Class.FromType(typeof(ArrowExpandSelectableHeaderHolder)));
            tView.SetDefaultNodeClickListener(new CustomTreeNodeClickListener(Activity));
            containerView.AddView(tView.View);

            tView.ExpandAll();

            if (savedInstanceState != null)
            {
                string state = savedInstanceState.GetString("tState");
                if (!string.IsNullOrEmpty(state))
                {
                    tView.RestoreState(state);
                }
            }

            return(rootView);
        }
Пример #20
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);

            // Set our view from the "main" layout resource
            SetContentView(Resource.Layout.Main);

            TreeNode root = TreeNode.InvokeRoot();

            TreeItem parent_item = new TreeItem()
            {
                text = "parent2"
            };

            parent = new TreeNode(parent_item).SetViewHolder(new MyHolder(this));

            ///Parent2 root children
            TreeItem child1_item = new TreeItem()
            {
                text = "Child1"
            };
            TreeNode child1 = new TreeNode(child1_item).SetViewHolder(new MyHolder(this));

            TreeItem item = new TreeItem()
            {
                text = " Level1"
            };
            TreeNode child10 = new TreeNode(item).SetViewHolder(new MyHolder(this));

            child1.AddChild(child10);

            TreeItem item1 = new TreeItem()
            {
                text = " Level2"
            };
            TreeNode child11 = new TreeNode(item1).SetViewHolder(new MyHolder(this));

            child10.AddChild(child11);

            TreeItem item2 = new TreeItem()
            {
                text = " Level2-1"
            };
            TreeNode child111_1 = new TreeNode(item2).SetViewHolder(new MyHolder(this));

            child11.AddChild(child111_1);

            TreeItem item3 = new TreeItem()
            {
                text = " Level2-2"
            };
            TreeNode child111_2 = new TreeNode(item3).SetViewHolder(new MyHolder(this));

            child11.AddChild(child111_2);

            ///

            parent.AddChildren(child1);
            root.AddChild(parent);


            AndroidTreeView atv        = new AndroidTreeView(this, root);
            LinearLayout    rootlayout = FindViewById <LinearLayout>(Resource.Id.rootlayout);

            rootlayout.AddView(atv.View);
            rootlayout.Invalidate();
            parent.SetClickListener(this);
        }
Пример #21
0
        public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
        {
            View      rootView      = inflater.Inflate(Resource.Layout.fragment_selectable_nodes, null, false);
            ViewGroup containerView = rootView.FindViewById <ViewGroup>(Resource.Id.container);

            rootView.FindViewById(Resource.Id.btn_toggleSelection).Click += (sender, e) => {
                selectionModeEnabled       = !selectionModeEnabled;
                tView.SelectionModeEnabled = selectionModeEnabled;
            };

            rootView.FindViewById(Resource.Id.btn_selectAll).Click += (sender, e) => {
                if (!selectionModeEnabled)
                {
                    Toast.MakeText(Activity, "Enable selection mode first", ToastLength.Short).Show();
                }
                tView.SelectAll(true);
            };

            rootView.FindViewById(Resource.Id.btn_deselectAll).Click += (sender, e) => {
                if (!selectionModeEnabled)
                {
                    Toast.MakeText(Activity, "Enable selection mode first", ToastLength.Short).Show();
                }
                tView.DeselectAll();
            };

            rootView.FindViewById(Resource.Id.btn_checkSelection).Click += (sender, e) => {
                if (!selectionModeEnabled)
                {
                    Toast.MakeText(Activity, "Enable selection mode first", ToastLength.Short).Show();
                }
                else
                {
                    Toast.MakeText(Activity, tView.Selected.Count() + " selected", ToastLength.Short).Show();
                }
            };

            TreeNode root = TreeNode.InvokeRoot();

            TreeNode s1 = new TreeNode(new IconTreeItem(Resource.String.ic_sd_storage, "Storage1")).SetViewHolder(new ProfileHolder(Activity));
            TreeNode s2 = new TreeNode(new IconTreeItem(Resource.String.ic_sd_storage, "Storage2")).SetViewHolder(new ProfileHolder(Activity));

            s1.Selectable = false;
            s2.Selectable = false;

            TreeNode folder1 = new TreeNode(new IconTreeItem(Resource.String.ic_folder, "Folder 1")).SetViewHolder(new SelectableHeaderHolder(Activity));
            TreeNode folder2 = new TreeNode(new IconTreeItem(Resource.String.ic_folder, "Folder 2")).SetViewHolder(new SelectableHeaderHolder(Activity));
            TreeNode folder3 = new TreeNode(new IconTreeItem(Resource.String.ic_folder, "Folder 3")).SetViewHolder(new SelectableHeaderHolder(Activity));

            fillFolder(folder1);
            fillFolder(folder2);
            fillFolder(folder3);

            s1.AddChildren(folder1, folder2);
            s2.AddChildren(folder3);

            root.AddChildren(s1, s2);

            tView = new AndroidTreeView(Activity, root);
            tView.SetDefaultAnimation(true);
            containerView.AddView(tView.View);

            if (savedInstanceState != null)
            {
                string state = savedInstanceState.GetString("tState");
                if (!string.IsNullOrEmpty(state))
                {
                    tView.RestoreState(state);
                }
            }

            return(rootView);
        }
Пример #22
0
 public void AddWidgets(IEnumerable <Widget> widget)
 {
     TreeNode.AddChildren(widget);
 }
Пример #23
0
        static void InitGlobalConfiguration()
        {
            LibraryInfo.SetFlag(FeatureFlags.Pipeline_AutoID_Random, 1);
            LibraryInfo.SetFlag(FeatureFlags.FileWR_AutoCreateFile, 1);
            LoadConfiguation();
            {
                StorageFile ManageModuleFile;
                if (ApplicationStorage.Configuration.CreateFile(TrustedInstaller, "ManageModules.ini", out ManageModuleFile))
                {
                    Trace.WriteLine(Localization.Language.Query("LWMS.Config.CreateDefaultCommandManifest", "Create default command module manifest."));
                    ManageCommandModules = ListData <string> .LoadFromStream(ManageModuleFile.OpenFileWR());

                    ManageCommandModules.Add(Path.Combine(ApplicationStorage.BasePath, "LWMS.Management.Commands.dll"));
                    ManageCommandModules.Save();
                }
                else
                {
                    ManageCommandModules = ListData <string> .LoadFromStream(ManageModuleFile.OpenFileWR(TrustedInstaller));
                }
            }
            {
                StorageFile RPipelineUnitDefinitionFile;
                if (ApplicationStorage.Configuration.CreateFile(TrustedInstaller, "RPipelineUnit.tsd", out RPipelineUnitDefinitionFile))
                {
                    RProcessUnits = TreeStructureData.CreateToFile(RPipelineUnitDefinitionFile.ToFileInfo(TrustedInstaller));
                    {
                        //LWMS.Core.dll
                        TreeNode treeNode = new TreeNode();
                        treeNode.Name  = "DLL";
                        treeNode.Value = "LWMS.Core.dll";
                        {
                            TreeNode unit = new TreeNode();
                            unit.Name  = "Unit.0";
                            unit.Value = "LWMS.Core.DefaultStaticFileUnit";
                            treeNode.AddChildren(unit);
                        }
                        RProcessUnits.RootNode.AddChildren(treeNode);
                    }
                    RProcessUnits.Serialize();
                }
                else
                {
                    RProcessUnits = TreeStructureData.LoadFromStream(RPipelineUnitDefinitionFile.OpenFileWR(TrustedInstaller));
                }
            }
            {
                StorageFile WPipelineUnitDefinitionFile;
                if (ApplicationStorage.Configuration.CreateFile(TrustedInstaller, "WPipelineUnit.tsd", out WPipelineUnitDefinitionFile))
                {
                    WProcessUnits = TreeStructureData.LoadFromStream(WPipelineUnitDefinitionFile.OpenFileWR(TrustedInstaller));
                    {
                        //LWMS.Core.dll
                        TreeNode treeNode = new TreeNode();
                        treeNode.Name  = "DLL";
                        treeNode.Value = "LWMS.Core.dll";
                        {
                            TreeNode unit = new TreeNode();
                            unit.Name  = "DefaultUnit";
                            unit.Value = "LWMS.Core.HttpRoutedLayer.DefaultStreamProcessUnit";
                            treeNode.AddChildren(unit);
                        }
                        WProcessUnits.RootNode.AddChildren(treeNode);
                    }
                    WProcessUnits.Serialize();
                }
                else
                {
                    WProcessUnits = TreeStructureData.LoadFromStream(WPipelineUnitDefinitionFile.OpenFileWR(TrustedInstaller));
                }
            }
            {
                //Load CMDOUT Pipelne units.
                StorageFile CMDOUTPipelineUnitsFile;
                if (ApplicationStorage.Configuration.CreateFile(TrustedInstaller, "CMDOUTPipelineUnit.tsd", out CMDOUTPipelineUnitsFile))
                {
                    CMDOUTProcessUnits = TreeStructureData.LoadFromStream(CMDOUTPipelineUnitsFile.OpenFileWR(TrustedInstaller));
                    {
                        //LWMS.Core.dll
                        TreeNode treeNode = new TreeNode();
                        treeNode.Name  = "DLL";
                        treeNode.Value = "LWMS.Management.dll";
                        {
                            TreeNode unit = new TreeNode();
                            unit.Name  = "ConsoleOutput";
                            unit.Value = "LWMS.Management.ConsoleCmdOutUnit";
                            treeNode.AddChildren(unit);
                        }
                        {
                            TreeNode unit = new TreeNode();
                            unit.Name  = "LogOutput";
                            unit.Value = "LWMS.Management.LogCmdOutUnit";
                            treeNode.AddChildren(unit);
                        }
                        CMDOUTProcessUnits.RootNode.AddChildren(treeNode);
                    }
                    {
                        //LWMS.Core.RemoteShell.Server.dll
                        TreeNode treeNode = new TreeNode();
                        treeNode.Name  = "DLL";
                        treeNode.Value = "LWMS.Core.RemoteShell.Server.dll";
                        {
                            TreeNode unit = new TreeNode();
                            unit.Name  = "RSCMDReciver";
                            unit.Value = "LWMS.Core.RemoteShell.Server.RSCMDReciver";
                            treeNode.AddChildren(unit);
                        }
                        CMDOUTProcessUnits.RootNode.AddChildren(treeNode);
                    }
                    CMDOUTProcessUnits.Serialize();
                }
                else
                {
                    CMDOUTProcessUnits = TreeStructureData.LoadFromStream(CMDOUTPipelineUnitsFile.OpenFileWR(TrustedInstaller));
                }
            }
            {
                //Init these fields.
                _ = MAX_LOG_SIZE;
                _ = LOG_WATCH_INTERVAL;
                //_ = WebSiteContentRoot;
                //_ = WebSiteModuleStorageRoot;
                //if (l == 0)
                //{

                //}
            }
        }