Beispiel #1
0
        public static MockFolderMediaLocation[] CreateMockLocations(string config)
        {
            var builder = new Builder();
            var depth   = 0;

            foreach (var line in config.Split('\n'))
            {
                if (line.Trim().Length == 0)
                {
                    continue;
                }

                var rowInfo = new RowInfo(line.TrimEnd());

                if (rowInfo.Depth == depth)
                {
                    builder.AddSibling(rowInfo);
                }
                else if (rowInfo.Depth > depth)
                {
                    builder.AddChild(rowInfo);
                }
                else
                {
                    builder.AddParent(rowInfo, depth - rowInfo.Depth);
                }

                depth = rowInfo.Depth;
            }

            return(builder.RootFolders);
        }
Beispiel #2
0
        public static MockFolderMediaLocation[] CreateMockLocations(string config)
        {
            var builder = new Builder();
            var depth   = 0;

            foreach (var line in config.Split(new string[] { Environment.NewLine },
                                              StringSplitOptions.RemoveEmptyEntries))
            {
                var rowInfo = new RowInfo(line);

                if (rowInfo.Depth == depth)
                {
                    builder.AddSibling(rowInfo);
                }
                else if (rowInfo.Depth > depth)
                {
                    builder.AddChild(rowInfo);
                }
                else
                {
                    builder.AddParent(rowInfo, depth - rowInfo.Depth);
                }

                depth = rowInfo.Depth;
            }

            return(builder.RootFolders);
        }
        public static MockFolderMediaLocation[] CreateMockLocations(string config)
        {
            var builder = new Builder();
            var depth = 0;

            foreach (var line in config.Split(new string[] { Environment.NewLine },
                StringSplitOptions.RemoveEmptyEntries))
                {
                    var rowInfo = new RowInfo(line);

                    if (rowInfo.Depth == depth) {
                        builder.AddSibling(rowInfo);
                    } else if (rowInfo.Depth > depth) {
                        builder.AddChild(rowInfo);
                    } else {
                        builder.AddParent(rowInfo, depth - rowInfo.Depth);
                    }

                    depth = rowInfo.Depth;
                }

            return builder.RootFolders;
        }
        public static MockFolderMediaLocation[] CreateMockLocations(string config)
        {
            var builder = new Builder();
            var depth = 0;

            foreach (var line in config.Split('\n')) {

                if (line.Trim().Length == 0) continue;

                var rowInfo = new RowInfo(line.TrimEnd());

                if (rowInfo.Depth == depth) {
                    builder.AddSibling(rowInfo);
                } else if (rowInfo.Depth > depth) {
                    builder.AddChild(rowInfo);
                } else {
                    builder.AddParent(rowInfo, depth - rowInfo.Depth);
                }

                depth = rowInfo.Depth;
            }

            return builder.RootFolders;
        }
Beispiel #5
0
            public bool Navigate()
            {
                int chosenNumber = 0;

                if (current.IsDynamic())
                {
                    MenuEntry dummy = current.GetChildren()[0];
                    current.RemoveDummy();
                    foreach (uiListable listable in current.GetDynamicEntries())
                    {
                        Builder b = new Builder();
                        b = b.SetHeader(dummy.GetHeader()).
                            SetDescription(listable.GetDescription()).
                            SetStaticPerform(dummy.staticPerform).
                            SetDynamicPerformPrePick(dummy.dynamicPerformPrePick).
                            SetDynamicPerformPostPick(dummy.dynamicPerformPostPick).
                            SetFuncGetDynamicEntries(dummy.getDynamicEntries).
                            SetFuncIsVisible(dummy.isVisible).
                            SetFuncEndsProgram(dummy.endsProgram).
                            SetParent(current);
                        foreach (MenuEntry child in dummy.GetChildren())
                        {
                            b = b.AddChild(child).Return();
                        }
                        current.AddChild(b.Build());
                    }
                }
                MenuEntry choice = LetUserPick(current, ref chosenNumber);

                if (chosenNumber == -1)
                {
                    if (current.IsDynamic())
                    {
                        if (current.GetDynamicEntries().Count == 0 && choice == null)
                        {
                            return(false);
                        }
                        current.ReplaceAllChildrenWithDummy();
                    }
                    if (choice == null)
                    {
                        return(true);
                    }
                }
                else
                {
                    choice.StaticPerform();
                    if (current.IsDynamic())
                    {
                        current.GetDynamicPerformPostPick()(current.GetDynamicEntries()[chosenNumber]);
                    }
                    if (context != null)
                    {
                        choice.GetDynamicPerformPrePick()(context);
                    }
                    if (current.IsDynamic())
                    {
                        context = current.GetDynamicEntries()[chosenNumber];
                    }
                    else
                    {
                        context = null;
                    }
                }
                current = choice;
                return(current.EndsProgram());
            }