Beispiel #1
0
        public PageItem(
            int index,
            int totalItems,
            CommandBindingCollection commandBindings,
            HelpConfiguration helpScreen,
            HelpConfiguration helpScreen2,
            IconBase icon,
            string title,
            string description)
        {
            Index = index;
            var angleStep  = 360d / totalItems;
            var angleStart = AngleStart + index * angleStep;

            if (totalItems == 1)
            {
                angleStep = 180d;
            }

            Angle      = angleStart;
            StartAngle = Normalize(angleStart - angleStep / 2d);
            EndAngle   = Normalize(angleStart + angleStep / 2d);

            CommandBindings = commandBindings;
            HelpScreen      = helpScreen;
            HelpScreen2     = helpScreen2;
            Icon            = icon;
            Title           = title;
            Description     = description;
        }
        public void HelpConfiguration_Constructor_Properties_Initialized()
        {
            //------------Setup for test--------------------------

            //------------Execute Test---------------------------
            var helpConfiguration = new HelpConfiguration();

            //------------Assert Results-------------------------
            Assert.IsNotNull(helpConfiguration.IsCollapsed);
            Assert.IsInstanceOfType(helpConfiguration.IsCollapsed, typeof(ConcurrentDictionarySafe <Type, bool>));
        }
Beispiel #3
0
 public MenuPage(
     int index,
     HelpConfiguration helpScreen,
     HelpConfiguration helpScreen2,
     CommandBindingCollection commandBindings,
     IEnumerable <PageItem> items)
 {
     Index           = index;
     HelpScreen      = helpScreen;
     HelpScreen2     = helpScreen2;
     CommandBindings = commandBindings ?? new CommandBindingCollection(null);
     Items           = items?.ToList() ?? new List <PageItem>();
 }
Beispiel #4
0
        public Menu(CommandBindingCollection commandBindings, IEnumerable <MenuPage> pages, HelpConfiguration helpScreen, HelpConfiguration helpScreen2)
        {
            CommandBindings = commandBindings;
            var pagesList = pages?.ToList() ?? new List <MenuPage>();

            if (pagesList.Count == 0)
            {
                pagesList.Add(new MenuPage(0, null, null, null, null));
            }

            Pages       = pagesList;
            HelpScreen  = helpScreen;
            HelpScreen2 = helpScreen2;
        }
Beispiel #5
0
        public static MenuItemConfiguration ParseMenuItem(ITokenStream stream, ILogger logger)
        {
            if (!stream.Starts("item"))
            {
                return(null);
            }

            HelpConfiguration help  = null;
            HelpConfiguration help2 = null;
            var          bindings   = new List <CommandBinding>();
            string       name       = null;
            string       text       = null;
            List <Token> icon       = null;

            while (true)
            {
                if (stream.Ends("item", logger, out var row, out var token0))
                {
                    break;
                }

                if (token0 == "help")
                {
                    var h = ParseHelp(stream, logger);
                    if (h != null)
                    {
                        help = h;
                    }

                    continue;
                }

                if (token0 == "help2")
                {
                    var h2 = ParseHelp(stream, logger, "2");
                    if (h2 != null)
                    {
                        h2.Orientation = Orientation.Horizontal;
                        help2          = h2;
                    }

                    continue;
                }

                if (token0 == "bind")
                {
                    var binding = ParseCommandBinding(stream, logger);
                    if (binding != null)
                    {
                        bindings.Add(binding);
                    }

                    stream.Move();
                    continue;
                }

                if (row.Length < 3 || row[1].Value != "=")
                {
                    logger?.WriteLine($"Error: Malformed assignment at {stream.Path}:{stream.Line}.");
                    stream.Move();
                    continue;
                }

                var rest = string.Join(" ", row.Skip(2));
                switch (token0)
                {
                case "text":
                    text = rest;
                    break;

                case "icon":
                    icon = row.Skip(2).ToList();
                    break;

                case "name":
                    name = rest;
                    break;

                default:
                    logger?.UnexpectedLine(stream);
                    break;
                }

                stream.Move();
            }

            return(new MenuItemConfiguration(name, icon, text, bindings, help, help2));
        }
Beispiel #6
0
        public static PageConfiguration ParsePage(ITokenStream stream, ILogger logger)
        {
            if (!stream.Starts("page"))
            {
                return(null);
            }

            HelpConfiguration help  = null;
            HelpConfiguration help2 = null;
            var bindings            = new List <CommandBinding>();
            var items = new List <MenuItemConfiguration>();

            while (true)
            {
                if (stream.Ends("page", logger, out var row, out var token0))
                {
                    break;
                }

                switch (token0)
                {
                case "help":
                    var h = ParseHelp(stream, logger);
                    if (h != null)
                    {
                        help = h;
                    }

                    continue;

                case "bind":
                    var binding = ParseCommandBinding(stream, logger);
                    if (binding != null)
                    {
                        bindings.Add(binding);
                    }

                    stream.Move();
                    continue;

                case "help2":
                    var h2 = ParseHelp(stream, logger, "2");
                    if (h2 != null)
                    {
                        h2.Orientation = Orientation.Horizontal;
                        help2          = h2;
                    }

                    continue;

                case "item":
                    var item = ParseMenuItem(stream, logger);
                    if (item != null)
                    {
                        items.Add(item);
                    }

                    continue;

                default:
                    logger?.UnexpectedLine(stream);
                    stream.Move();
                    continue;
                }
            }

            return(new PageConfiguration(help, help2, bindings, items));
        }
Beispiel #7
0
        public static MenuConfiguration ParseMenuConfiguration(ITokenStream stream, ILogger logger)
        {
            if (!stream.Starts("menu", logger, out var name))
            {
                return(null);
            }

            HelpConfiguration help  = null;
            HelpConfiguration help2 = null;
            var bindings            = new List <CommandBinding>();
            var pages = new List <PageConfiguration>();

            while (true)
            {
                if (stream.Ends("menu", logger, out var row, out var token0))
                {
                    break;
                }

                switch (token0)
                {
                case "bind":
                    var binding = ParseCommandBinding(stream, logger);
                    if (binding != null)
                    {
                        bindings.Add(binding);
                    }

                    stream.Move();
                    continue;

                case "help":
                    var h = ParseHelp(stream, logger);
                    if (h != null)
                    {
                        help = h;
                    }

                    continue;

                case "help2":
                    var h2 = ParseHelp(stream, logger, "2");
                    if (h2 != null)
                    {
                        h2.Orientation = Orientation.Horizontal;
                        help2          = h2;
                    }

                    continue;

                case "page":
                    var page = ParsePage(stream, logger);
                    if (page != null)
                    {
                        pages.Add(page);
                    }

                    continue;

                default:
                    logger?.UnexpectedLine(stream);
                    stream.Move();
                    continue;
                }
            }

            return(name != null ? new MenuConfiguration(name, help, help2, bindings, pages) : null);
        }
 public HelpConfigurationTests()
 {
     _instanceUnderTest = new HelpConfiguration <object>(null, _sinkMock.Object);
 }