コード例 #1
0
 static void SetColorScheme()
 {
     _leftPane.ColorScheme     = _baseColorScheme;
     _rightPane.ColorScheme    = _baseColorScheme;
     _appTitlePane.ColorScheme = _baseColorScheme;
     _top?.SetNeedsDisplay();
 }
コード例 #2
0
        static MenuItem[] CreateDiagnosticMenuItems()
        {
            MenuItem CheckedMenuMenuItem(ustring menuItem, Action action, Func <bool> checkFunction)
            {
                var mi = new MenuItem();

                mi.Title      = menuItem;
                mi.CheckType |= MenuItemCheckStyle.Checked;
                mi.Checked    = checkFunction();
                mi.Action     = () =>
                {
                    action?.Invoke();
                    mi.Title   = menuItem;
                    mi.Checked = checkFunction();
                };
                return(mi);
            }

            return(new MenuItem[] {
                CheckedMenuMenuItem("Use _System Console",
                                    () => {
                    _useSystemConsole = !_useSystemConsole;
                },
                                    () => _useSystemConsole),
                CheckedMenuMenuItem("Diagnostics: _Frame Padding",
                                    () => {
                    ConsoleDriver.Diagnostics ^= ConsoleDriver.DiagnosticFlags.FramePadding;
                    _top.SetNeedsDisplay();
                },
                                    () => (ConsoleDriver.Diagnostics & ConsoleDriver.DiagnosticFlags.FramePadding) == ConsoleDriver.DiagnosticFlags.FramePadding),
                CheckedMenuMenuItem("Diagnostics: Frame _Ruler",
                                    () => {
                    ConsoleDriver.Diagnostics ^= ConsoleDriver.DiagnosticFlags.FrameRuler;
                    _top.SetNeedsDisplay();
                },
                                    () => (ConsoleDriver.Diagnostics & ConsoleDriver.DiagnosticFlags.FrameRuler) == ConsoleDriver.DiagnosticFlags.FrameRuler),
            });
        }
コード例 #3
0
ファイル: UICatalog.cs プロジェクト: mzy666888/gui.cs
        /// <summary>
        /// Create all controls. This gets called once and the controls remain with their state between Sceanrio runs.
        /// </summary>
        private static void Setup()
        {
            StringBuilder aboutMessage = new StringBuilder();

            aboutMessage.AppendLine("UI Catalog is a comprehensive sample library for Terminal.Gui");
            aboutMessage.AppendLine("");
            aboutMessage.AppendLine($"Version: {typeof(UICatalogApp).Assembly.GetName ().Version}");
            aboutMessage.AppendLine($"Using Terminal.Gui Version: {typeof (Terminal.Gui.Application).Assembly.GetName ().Version}");
            aboutMessage.AppendLine("");


            var framePaddingMenuText = "Diagnostics: _Frame Padding";

            _menu = new MenuBar(new MenuBarItem [] {
                new MenuBarItem("_File", new MenuItem [] {
                    new MenuItem("_Quit", "", () => Application.RequestStop())
                }),
                new MenuBarItem("_Settings", new MenuItem [] {
                    CheckedMenuMenuItem("Use _System Console",
                                        () => {
                        _useSystemConsole = !_useSystemConsole;
                    },
                                        () => _useSystemConsole),
                    CheckedMenuMenuItem("Diagnostics: _Frame Padding",
                                        () => {
                        ConsoleDriver.Diagnostics ^= ConsoleDriver.DiagnosticFlags.FramePadding;
                        _top.SetNeedsDisplay();
                    },
                                        () => (ConsoleDriver.Diagnostics & ConsoleDriver.DiagnosticFlags.FramePadding) == ConsoleDriver.DiagnosticFlags.FramePadding),
                    CheckedMenuMenuItem("Diagnostics: Frame _Ruler",
                                        () => {
                        ConsoleDriver.Diagnostics ^= ConsoleDriver.DiagnosticFlags.FrameRuler;
                        _top.SetNeedsDisplay();
                    },
                                        () => (ConsoleDriver.Diagnostics & ConsoleDriver.DiagnosticFlags.FrameRuler) == ConsoleDriver.DiagnosticFlags.FrameRuler),
                }),
                new MenuBarItem("_About...", "About this app", () => MessageBox.Query("About UI Catalog", aboutMessage.ToString(), "Ok")),
            });

            _leftPane = new Window("Categories")
            {
                X        = 0,
                Y        = 1,          // for menu
                Width    = 25,
                Height   = Dim.Fill(),
                CanFocus = false,
            };


            _categories       = Scenario.GetAllCategories().OrderBy(c => c).ToList();
            _categoryListView = new ListView(_categories)
            {
                X             = 0,
                Y             = 0,
                Width         = Dim.Fill(0),
                Height        = Dim.Fill(0),
                AllowsMarking = false,
                CanFocus      = true,
            };
            _categoryListView.OpenSelectedItem += (o, a) => {
                _top.SetFocus(_rightPane);
            };
            _categoryListView.SelectedChanged += CategoryListView_SelectedChanged;
            _leftPane.Add(_categoryListView);

            _rightPane = new Window("Scenarios")
            {
                X        = 25,
                Y        = 1,          // for menu
                Width    = Dim.Fill(),
                Height   = Dim.Fill(),
                CanFocus = false,
            };

            _nameColumnWidth = Scenario.ScenarioMetadata.GetName(_scenarios.OrderByDescending(t => Scenario.ScenarioMetadata.GetName(t).Length).FirstOrDefault()).Length;

            _scenarioListView = new ListView()
            {
                X             = 0,
                Y             = 0,
                Width         = Dim.Fill(0),
                Height        = Dim.Fill(0),
                AllowsMarking = false,
                CanFocus      = true,
            };

            _scenarioListView.OpenSelectedItem += _scenarioListView_OpenSelectedItem;
            _rightPane.Add(_scenarioListView);

            _categoryListView.SelectedItem = 0;
            _categoryListView.OnSelectedChanged();

            _capslock   = new StatusItem(Key.CharMask, "Capslock", null);
            _numlock    = new StatusItem(Key.CharMask, "Numlock", null);
            _scrolllock = new StatusItem(Key.CharMask, "Scrolllock", null);

            _statusBar = new StatusBar(new StatusItem [] {
                new StatusItem(Key.ControlQ, "~CTRL-Q~ Quit", () => {
                    if (_runningScenario is null)
                    {
                        // This causes GetScenarioToRun to return null
                        _runningScenario = null;
                        Application.RequestStop();
                    }
                    else
                    {
                        _runningScenario.RequestStop();
                    }
                }),
                _capslock,
                _numlock,
                _scrolllock
            });