Пример #1
0
        public void Run(Action action)
        {
            if (action == null)
            {
                return;
            }

            Application.UngrabMouse();
            host.CloseAllMenus();
            Application.Refresh();

            Application.MainLoop.AddIdle(() => {
                action();
                return(false);
            });
        }
Пример #2
0
        public void DrawFrame_With_Negative_Positions()
        {
            var menu = new MenuBar(new MenuBarItem [] {
                new MenuBarItem(new MenuItem [] {
                    new MenuItem("One", "", null),
                    new MenuItem("Two", "", null)
                })
            })
            {
                X = -1,
                Y = -1
            };

            Assert.Equal(new Point(-1, -1), new Point(menu.Frame.X, menu.Frame.Y));

            menu.OpenMenu();
            Application.Begin(Application.Top);

            var expected = @"
──────┐
 One  │
 Two  │
──────┘
";

            var pos = GraphViewTests.AssertDriverContentsWithFrameAre(expected, output);

            Assert.Equal(new Rect(0, 0, 7, 4), pos);

            menu.CloseAllMenus();
            menu.Frame = new Rect(-1, -2, menu.Frame.Width, menu.Frame.Height);
            menu.OpenMenu();
            Application.Refresh();

            expected = @"
 One  │
 Two  │
──────┘
";

            pos = GraphViewTests.AssertDriverContentsWithFrameAre(expected, output);
            Assert.Equal(new Rect(1, 0, 7, 3), pos);

            menu.CloseAllMenus();
            menu.Frame = new Rect(0, 0, menu.Frame.Width, menu.Frame.Height);
            ((FakeDriver)Application.Driver).SetBufferSize(7, 5);
            menu.OpenMenu();
            Application.Refresh();

            expected = @"
┌──────
│ One
│ Two
└──────
";

            pos = GraphViewTests.AssertDriverContentsWithFrameAre(expected, output);
            Assert.Equal(new Rect(0, 1, 7, 4), pos);

            menu.CloseAllMenus();
            menu.Frame = new Rect(0, 0, menu.Frame.Width, menu.Frame.Height);
            ((FakeDriver)Application.Driver).SetBufferSize(7, 4);
            menu.OpenMenu();
            Application.Refresh();

            expected = @"
┌──────
│ One
│ Two
";

            pos = GraphViewTests.AssertDriverContentsWithFrameAre(expected, output);
            Assert.Equal(new Rect(0, 1, 7, 3), pos);
        }