コード例 #1
0
        private Window CreateOperationsView(Toplevel top, Window win)
        {
            var operations = new Window("Actions")
            {
                X      = 0,
                Y      = Pos.Bottom(win),
                Width  = Dim.Fill(),
                Height = Dim.Fill()
            };

            var quit = new Button(1, 0, "Quit")
            {
                Clicked = Program.Start
            };

            var msg = new Button("Show file explorer position")
            {
                X       = Pos.Right(quit) + 1,
                Y       = 0,
                Clicked = () =>
                {
                    var result = MessageBox.Query(30, 15, "The title",
                                                  $"W:{win.Bounds.Width} H:{win.Bounds.Height} X:{win.Bounds.X} Y:{win.Bounds.Y}",
                                                  "Ok", "Not Ok");
                }
            };

            operations.Add(quit);
            operations.Add(msg);
            return(operations);
        }
コード例 #2
0
        public bool ShowDialog()
        {
            bool okClicked = false;

            var win = new Window(_prompt)
            {
                X = 0,
                Y = 0,

                // By using Dim.Fill(), it will automatically resize without manual intervention
                Width  = Dim.Fill(),
                Height = Dim.Fill()
            };

            var textField = new TextField(_initialText ?? "")
            {
                X      = 1,
                Y      = 1,
                Height = Dim.Fill(2),
                Width  = Dim.Fill(2)
            };

            var btnOk = new Button("Ok", true)
            {
                X         = 0,
                Y         = Pos.Bottom(textField),
                Width     = 10,
                Height    = 1,
                IsDefault = true
            };

            btnOk.Clicked += () =>
            {
                okClicked  = true;
                ResultText = textField.Text.ToString();
                Application.RequestStop();
            };

            var btnCancel = new Button("Cancel", true)
            {
                X      = Pos.Right(btnOk),
                Y      = Pos.Bottom(textField),
                Width  = 10,
                Height = 1
            };

            btnCancel.Clicked += () =>
            {
                okClicked = false;
                Application.RequestStop();
            };

            win.Add(textField);
            win.Add(btnOk);
            win.Add(btnCancel);

            Application.Run(win);

            return(okClicked);
        }
コード例 #3
0
        public ControlsWindow() : base("Controls")
        {
            X      = Pos.Right(Program.log);
            Y      = Pos.Bottom(Program.status);
            Width  = Dim.Fill();
            Height = Dim.Fill();


            Add(
                btnRestartClient = new Button(1, 1, "Restart client"),
                btnSkipItem      = new Button(1, 2, "Skip item"),
                statusGroup      = new RadioGroup(1, 3, new[] { "_Idle", "_Rare Item", "_Equip" })
                );;


            btnSkipItem.Clicked      = () => { Program.CancelScan = true; };
            btnRestartClient.Clicked = async() =>
            {
                Program.status.SetStatus("Initializing restart", "");
                Program.CancelScan = true;
                Program.Restart    = true;
                await Task.Delay(5000);
            };

            statusGroup.SelectionChanged += OnStatusChange;
        }
コード例 #4
0
ファイル: PosTests.cs プロジェクト: migueldeicaza/gui.cs
        public void Bottom_Equal_Inside_Window()
        {
            var win = new Window();

            var label = new Label("This should be the last line.")
            {
                TextAlignment = Terminal.Gui.TextAlignment.Centered,
                ColorScheme   = Colors.Menu,
                Width         = Dim.Fill(),
                X             = Pos.Center(),
                Y             = Pos.Bottom(win) - 4       // two lines top border more two lines above border
            };

            win.Add(label);

            var top = Application.Top;

            top.Add(win);
            Application.Begin(top);

            Assert.Equal(new Rect(0, 0, 80, 25), top.Frame);
            Assert.Equal(new Rect(0, 0, 80, 25), win.Frame);
            Assert.Equal(new Rect(1, 1, 78, 23), win.Subviews [0].Frame);
            Assert.Equal("ContentView()({X=1,Y=1,Width=78,Height=23})", win.Subviews [0].ToString());
            Assert.Equal(new Rect(0, 0, 80, 25), new Rect(
                             win.Frame.Left, win.Frame.Top,
                             win.Frame.Right, win.Frame.Bottom));
            Assert.Equal(new Rect(0, 21, 78, 1), label.Frame);
        }
コード例 #5
0
ファイル: Program.cs プロジェクト: yellow-dragon-coder/gui.cs
        public static void Main(string [] args)
        {
            Application.Init();

            var menu = new MenuBar(new MenuBarItem [] {
                new MenuBarItem("_File", new MenuItem [] {
                    new MenuItem("_Close", "", () => Close()),
                    new MenuItem("_Quit", "", () => { Application.RequestStop(); })
                }),
                new MenuBarItem("_Edit", new MenuItem [] {
                    new MenuItem("_Copy", "", null),
                    new MenuItem("C_ut", "", null),
                    new MenuItem("_Paste", "", null)
                }),
            });

            var login = new Label("Login: "******"Password: "******"")
            {
                X           = Pos.Right(password),
                Y           = Pos.Top(login),
                Width       = 40,
                ColorScheme = new ColorScheme()
                {
                    Focus     = Attribute.Make(Color.BrightYellow, Color.DarkGray),
                    Normal    = Attribute.Make(Color.Green, Color.BrightYellow),
                    HotFocus  = Attribute.Make(Color.BrightBlue, Color.Brown),
                    HotNormal = Attribute.Make(Color.Red, Color.BrightRed),
                },
            };

            var passText = new TextField("")
            {
                Secret = true,
                X      = Pos.Left(loginText),
                Y      = Pos.Top(password),
                Width  = Dim.Width(loginText)
            };

            surface.Add(login, password, loginText, passText);
            Application.Top.Add(menu, surface);
            Application.Run();
        }
コード例 #6
0
ファイル: AboutView.cs プロジェクト: Kelvysb/Grimoire
        private void Draw()
        {
            textView = new TextView()
            {
                X        = 1,
                Y        = 1,
                Width    = Dim.Fill(),
                Height   = Dim.Fill() - 1,
                ReadOnly = true
            };
            textView.Text = @$ "Grimoire

Automation Script Helper.

Open source by Kelvys B.

Visit the project repository at https://github.com/Kelvysb/Grimoire

Version = {Assembly.GetEntryAssembly().GetName().Version}
";
            Add(textView);

            btnOk = new Button("Ok", true)
            {
                X = Pos.Right(this) - 64,
                Y = Pos.Bottom(this) - 4
            };
            btnOk.Clicked = () => Ok.Invoke();
            Add(btnOk);
        }
コード例 #7
0
 private void InitializeComponents()
 {
     _labelSocketIdText = new Label("Socket Id :")
     {
         X = 1,
         Y = 1
     };
     Add(_labelSocketIdText);
     _labelSocketIdValue = new Label("0")
     {
         X = Pos.Right(_labelSocketIdText),
         Y = Pos.Top(_labelSocketIdText)
     };
     Add(_labelSocketIdValue);
     _labelRemoteIpText = new Label("Remote Endpoint :")
     {
         X = Pos.Left(_labelSocketIdText),
         Y = Pos.Bottom(_labelSocketIdText)
     };
     Add(_labelRemoteIpText);
     _labelRemoteIpValue = new Label("0.0.0.0:0000")
     {
         X = Pos.Right(_labelRemoteIpText),
         Y = Pos.Top(_labelRemoteIpText)
     };
     Add(_labelRemoteIpValue);
 }
コード例 #8
0
        public override void Setup()
        {
            // Add a label & text field so we can demo IsDefault
            var editLabel = new Label("TextField (to demo IsDefault):")
            {
                X = 0,
                Y = 0,
            };

            Win.Add(editLabel);
            // Add a TextField using Absolute layout.
            var edit = new TextField(31, 0, 15, "");

            Win.Add(edit);

            // This is the default button (IsDefault = true); if user presses ENTER in the TextField
            // the scenario will quit
            var defaultButton = new Button("_Quit")
            {
                X = Pos.Center(),
                //TODO: Change to use Pos.AnchorEnd()
                Y         = Pos.Bottom(Win) - 3,
                IsDefault = true,
                Clicked   = () => Application.RequestStop(),
            };

            Win.Add(defaultButton);

            var swapButton = new Button(50, 0, "Swap Default (Absolute Layout)");

            swapButton.Clicked = () => {
                defaultButton.IsDefault = !defaultButton.IsDefault;
                swapButton.IsDefault    = !swapButton.IsDefault;
            };
            Win.Add(swapButton);
コード例 #9
0
            public WorkerApp()
            {
                Data = "WorkerApp";

                Width  = Dim.Percent(80);
                Height = Dim.Percent(50);

                ColorScheme = Colors.Base;

                var label = new Label("Worker collection Log")
                {
                    X = Pos.Center(),
                    Y = 0
                };

                Add(label);

                listLog = new ListView(log)
                {
                    X      = 0,
                    Y      = Pos.Bottom(label),
                    Width  = Dim.Fill(),
                    Height = Dim.Fill()
                };
                Add(listLog);
            }
コード例 #10
0
    public void Run()
    {
        //new Example().Sample();

        Application.Init();
        var top = Application.Top;

        AddWorkspaceWindow(top);
        var repositoryWindow = new Window("Repository")
        {
            X      = 0,
            Y      = Pos.Bottom(_workspaceWindow),
            Width  = 15,
            Height = Dim.Fill()
        };

        top.Add(repositoryWindow);

        AddUnStagedWindow(top);
        var compareWindow = new Window("compare")
        {
            X      = Pos.Right(_unStagedWindow),
            Y      = 1,
            Width  = Dim.Fill(),
            Height = Dim.Fill()
        };

        top.Add(compareWindow);

        AddMenuBar(top);

        //top.Redraw(new Rect(0,0, Application.Top.Bounds.Width, Application.Top.Bounds.Height));
        Application.Run();
        Application.Shutdown();
    }
コード例 #11
0
ファイル: PosTests.cs プロジェクト: migueldeicaza/gui.cs
        public void Bottom_Equal_Inside_Window_With_MenuBar_And_StatusBar_On_Toplevel()
        {
            var win = new Window();

            var label = new Label("This should be the last line.")
            {
                TextAlignment = Terminal.Gui.TextAlignment.Centered,
                ColorScheme   = Colors.Menu,
                Width         = Dim.Fill(),
                X             = Pos.Center(),
                Y             = Pos.Bottom(win) - 4       // two lines top border more two lines above border
            };

            win.Add(label);

            var menu   = new MenuBar();
            var status = new StatusBar();
            var top    = Application.Top;

            top.Add(win, menu, status);
            Application.Begin(top);

            Assert.Equal(new Rect(0, 0, 80, 25), top.Frame);
            Assert.Equal(new Rect(0, 0, 80, 1), menu.Frame);
            Assert.Equal(new Rect(0, 24, 80, 1), status.Frame);
            Assert.Equal(new Rect(0, 1, 80, 23), win.Frame);
            Assert.Equal(new Rect(1, 1, 78, 21), win.Subviews [0].Frame);
            Assert.Equal(new Rect(0, 1, 80, 24), new Rect(
                             win.Frame.Left, win.Frame.Top,
                             win.Frame.Right, win.Frame.Bottom));
            Assert.Equal(new Rect(0, 20, 78, 1), label.Frame);
        }
コード例 #12
0
ファイル: Text.cs プロジェクト: vCas/gui.cs
        public override void Setup()
        {
            var s = "This is a test intended to show how TAB key works (or doesn't) across text fields.";

            Win.Add(new TextField(s)
            {
                X           = 5,
                Y           = 1,
                Width       = Dim.Percent(80),
                ColorScheme = Colors.Dialog
            });

            var textView = new TextView()
            {
                X           = 5,
                Y           = 3,
                Width       = Dim.Percent(80),
                Height      = Dim.Percent(40),
                ColorScheme = Colors.Dialog
            };

            textView.Text = s;
            Win.Add(textView);

            // BUGBUG: 531 - TAB doesn't go to next control from HexView
            var hexView = new HexView(new System.IO.MemoryStream(Encoding.ASCII.GetBytes(s)))
            {
                X           = 5,
                Y           = Pos.Bottom(textView) + 1,
                Width       = Dim.Percent(80),
                Height      = Dim.Percent(40),
                ColorScheme = Colors.Dialog
            };

            Win.Add(hexView);

            var dateField = new DateField(System.DateTime.Now)
            {
                X             = 5,
                Y             = Pos.Bottom(hexView) + 1,
                Width         = Dim.Percent(40),
                ColorScheme   = Colors.Dialog,
                IsShortFormat = false
            };

            Win.Add(dateField);

            var timeField = new TimeField(System.DateTime.Now)
            {
                X             = Pos.Right(dateField) + 5,
                Y             = Pos.Bottom(hexView) + 1,
                Width         = Dim.Percent(40),
                ColorScheme   = Colors.Dialog,
                IsShortFormat = false
            };

            Win.Add(timeField);
        }
コード例 #13
0
        public void ShowDialog()
        {
            var win = new Window("Edit " + DatabaseObject.GetType().Name)
            {
                X = 0,
                Y = 0,

                // By using Dim.Fill(), it will automatically resize without manual intervention
                Width  = Dim.Fill(),
                Height = Dim.Fill()
            };

            List <TreeNode> nodes = new List <TreeNode>();

            AddRecursively(DatabaseObject, 0, nodes);

            var list = new ListView(nodes)
            {
                X      = 0,
                Y      = 0,
                Width  = Dim.Fill(2),
                Height = Dim.Fill(2)
            };

            var btnSet = new Button("Edit")
            {
                X         = 0,
                Y         = Pos.Bottom(list),
                Width     = 5,
                Height    = 1,
                IsDefault = true
            };

            btnSet.Clicked += () =>
            {
                if (list.SelectedItem != -1)
                {
                    nodes[list.SelectedItem].Edit();
                }
            };

            var btnClose = new Button("Close")
            {
                X      = Pos.Right(btnSet) + 3,
                Y      = Pos.Bottom(list),
                Width  = 5,
                Height = 1
            };

            btnClose.Clicked += Application.RequestStop;


            win.Add(list);
            win.Add(btnSet);
            win.Add(btnClose);

            Application.Run(win);
        }
コード例 #14
0
        public void Dim_Add_Operator()
        {
            Application.Init(new FakeDriver(), new FakeMainLoop(() => FakeConsole.ReadKey(true)));

            var top = Application.Top;

            var view = new View()
            {
                X = 0, Y = 0, Width = 20, Height = 0
            };
            var field = new TextField()
            {
                X = 0, Y = Pos.Bottom(view), Width = 20
            };
            var count = 0;

            field.KeyDown += (k) => {
                if (k.KeyEvent.Key == Key.Enter)
                {
                    field.Text = $"Label {count}";
                    var label = new Label(field.Text)
                    {
                        X = 0, Y = view.Bounds.Height, Width = 20
                    };
                    view.Add(label);
                    Assert.Equal($"Label {count}", label.Text);
                    Assert.Equal($"Pos.Absolute({count})", label.Y.ToString());

                    Assert.Equal($"Dim.Absolute({count})", view.Height.ToString());
                    view.Height += 1;
                    count++;
                    Assert.Equal($"Dim.Absolute({count})", view.Height.ToString());
                }
            };

            Application.Iteration += () => {
                while (count < 20)
                {
                    field.OnKeyDown(new KeyEvent(Key.Enter, new KeyModifiers()));
                }

                Application.RequestStop();
            };

            var win = new Window();

            win.Add(view);
            win.Add(field);

            top.Add(win);

            Application.Run(top);

            Assert.Equal(20, count);

            // Shutdown must be called to safely clean up Application if Init has been called
            Application.Shutdown();
        }
コード例 #15
0
        public JoystickView(ustring title) : base(title)
        {
            XLabel = new Label("Raw X:")
            {
                X = 0,
                Y = 0
            };
            Add(XLabel);

            XValue = new TextField("0.0000000000")
            {
                X = Pos.Right(XLabel) + 1,
                Y = Pos.Top(XLabel)
            };
            Add(XValue);

            YLabel = new Label("Raw Y:")
            {
                X = Pos.Left(XLabel),
                Y = Pos.Bottom(XLabel)
            };
            Add(YLabel);

            YValue = new TextField("0.0000000000")
            {
                X = Pos.Right(YLabel) + 1,
                Y = Pos.Top(YLabel)
            };
            Add(YValue);

            XDegree = new TextField("180")
            {
                X = 50,
                Y = Pos.Top(XLabel)
            };
            Add(XDegree);

            XDegreeLabel = new Label("Servo X:")
            {
                X = Pos.Left(XDegree) - 9,
                Y = 0,
            };
            Add(XDegreeLabel);

            YDegree = new TextField("180")
            {
                X = 50,
                Y = Pos.Bottom(XDegreeLabel)
            };
            Add(YDegree);

            YDegreeLabel = new Label("Servo Y:")
            {
                X = Pos.Left(YDegree) - 9,
                Y = Pos.Bottom(XDegree),
            };
            Add(YDegreeLabel);
        }
コード例 #16
0
        private void Init()
        {
            Modal = true;

            ColorScheme = Colors.Error;

            // Creates the top-level window to show
            var win = new Window("Sleep")
            {
                X = 0,
                Y = 0,

                // By using Dim.Fill(), it will automatically resize without manual intervention
                Width  = Dim.Fill(),
                Height = Dim.Fill()
            };

            win.ColorScheme = Colors.ColorSchemes["Dialog"];

            Add(win);

            // Window Content
            _sleepModeLabel = new Label("Sleep mode is on, waiting for fingerprints...")
            {
                X     = 2,
                Y     = 1,
                Width = Dim.Fill()
            };
            _readCountLabel = new Label("Read: 0")
            {
                X     = Pos.Left(_sleepModeLabel),
                Y     = Pos.Bottom(_sleepModeLabel) + 1,
                Width = Dim.Fill()
            };
            _lastReadLabel = new Label("Last User: - 1")
            {
                X     = Pos.Left(_readCountLabel),
                Y     = Pos.Bottom(_readCountLabel),
                Width = Dim.Fill()
            };

            var stopButton = new Button("_Stop")
            {
                X = Pos.Right(this) - 11,
                Y = Pos.Bottom(this) - 2
            };

            stopButton.Clicked += () => { _fingerprintSensor.Waked -= FingerprintSensor_Waked; Application.RequestStop(); };

            win.Add(_sleepModeLabel, _readCountLabel, _lastReadLabel);

            Add(stopButton);

            _fingerprintSensor.Waked += FingerprintSensor_Waked;

            _fingerprintSensor.Sleep();
        }
コード例 #17
0
        public override void Setup()
        {
            Win.Title  = this.GetName();
            Win.Y      = 1;           // menu
            Win.Height = Dim.Fill(1); // status bar
            Top.LayoutSubviews();

            var menu = new MenuBar(new MenuBarItem [] {
                new MenuBarItem("_File", new MenuItem [] {
                    new MenuItem("_New", "", () => New()),
                    new MenuItem("_Open", "", () => Open()),
                    new MenuItem("_Save", "", () => Save()),
                    new MenuItem("_Save As", "", () => SaveAs()),
                    new MenuItem("_Close", "", () => Close()),
                    new MenuItem("_Quit", "", () => Quit()),
                })
            });

            Top.Add(menu);

            tabView = new TabView()
            {
                X      = 0,
                Y      = 0,
                Width  = Dim.Fill(),
                Height = Dim.Fill(1),
            };

            tabView.Style.ShowBorder = false;
            tabView.ApplyStyleChanges();

            Win.Add(tabView);

            var statusBar = new StatusBar(new StatusItem [] {
                new StatusItem(Key.CtrlMask | Key.Q, "~^Q~ Quit", () => Quit()),

                // These shortcut keys don't seem to work correctly in linux
                //new StatusItem(Key.CtrlMask | Key.N, "~^O~ Open", () => Open()),
                //new StatusItem(Key.CtrlMask | Key.N, "~^N~ New", () => New()),

                new StatusItem(Key.CtrlMask | Key.S, "~^S~ Save", () => Save()),
                new StatusItem(Key.CtrlMask | Key.W, "~^W~ Close", () => Close()),
            });

            Win.Add(lblStatus = new Label("Len:")
            {
                Y             = Pos.Bottom(tabView),
                Width         = Dim.Fill(),
                TextAlignment = TextAlignment.Right
            });

            tabView.SelectedTabChanged += (s, e) => UpdateStatus(e.NewTab);

            Top.Add(statusBar);

            New();
        }
コード例 #18
0
        public Dialog MenuView(Window previousWin, Player player, Toplevel top)
        {
            var gameButton = new Button("Jeu", false)
            {
                X = x,
                Y = y,
            };

            gameButton.Clicked += () =>
            {
                ChoosePseudoToLaunchGame(player, previousWin);
            };

            var settingsButton = new Button("Options", false)
            {
                X = x,
                Y = Pos.Bottom(gameButton) + 1
            };

            settingsButton.Clicked += () =>
            {
                Settings(outputDevice, previousWin);
            };

            var helpButton = new Button("Aide Jeu", false)
            {
                X = x,
                Y = Pos.Bottom(settingsButton) + 1
            };

            helpButton.Clicked += () =>
            {
                HelpView(previousWin);
            };

            var creditButton = new Button("Credits", false)
            {
                X = x,
                Y = Pos.Bottom(helpButton) + 1
            };

            creditButton.Clicked += () =>
            {
                Credit(previousWin);
            };

            buttons = new Dialog("Menu");

            buttons.Add(
                gameButton,
                settingsButton,
                helpButton,
                creditButton);

            return(buttons);
        }
コード例 #19
0
        public GeneratorSettingsWindow(GeneratorSettings settings) : base(
                "Code Generator - Generator Settings")
        {
            _settings = settings;

            var urlLabel = new Label(1, 2, "Server url:");

            _serverUrl = new TextField(_settings.ServerUrl)
            {
                X = 1,
                Y = Pos.Bottom(urlLabel)
            };


            var clientFileLabel = new Label(1, 5, "Client file name:");

            _clientFileName = new TextField(_settings.ClientFileName)
            {
                X = 1,
                Y = Pos.Bottom(clientFileLabel)
            };

            var typesFileLabel = new Label(1, 8, "Types file name:");

            _typesFileName = new TextField(_settings.TypesFileName)
            {
                X = 1,
                Y = Pos.Bottom(typesFileLabel)
            };

            var g1Label  = new Label(1, 11, "Types location:");
            var g1Holder = new View
            {
                Y      = Pos.Bottom(g1Label),
                X      = 1,
                Width  = Dim.Fill(1),
                Height = 4
            };

            _schemaPlace = new RadioGroup(new[] { "WithCode", "SeparatedFile", "AllSeparated" },
                                          (int)_settings.SchemePlace);
            g1Holder.Add(_schemaPlace);

            var exitButton = new Button("Ok")
            {
                X       = Pos.Center(),
                Y       = Pos.Percent(90),
                Clicked = Clicked
            };

            Add(urlLabel, _serverUrl,
                clientFileLabel, _clientFileName,
                typesFileLabel, _typesFileName,
                g1Label, g1Holder,
                exitButton);
        }
コード例 #20
0
        public override void Setup()
        {
            List <string> items = new List <string> ();

            foreach (var dir in new [] { "/etc", @"\windows\System32" })
            {
                if (Directory.Exists(dir))
                {
                    items = Directory.GetFiles(dir).Union(Directory.GetDirectories(dir))
                            .Select(Path.GetFileName)
                            .Where(x => char.IsLetterOrDigit(x [0]))
                            .OrderBy(x => x).ToList();
                }
            }

            // ListView
            var lbListView = new Label("Listview")
            {
                ColorScheme = Colors.TopLevel,
                X           = 0,
                Width       = 30
            };

            var listview = new ListView(items)
            {
                X      = 0,
                Y      = Pos.Bottom(lbListView) + 1,
                Height = Dim.Fill(2),
                Width  = 30
            };

            listview.OpenSelectedItem += (ListViewItemEventArgs e) => lbListView.Text = items [listview.SelectedItem];
            Win.Add(lbListView, listview);

            // ComboBox
            var lbComboBox = new Label("ComboBox")
            {
                ColorScheme = Colors.TopLevel,
                X           = Pos.Right(lbListView) + 1,
                Width       = Dim.Percent(60)
            };

            var comboBox = new ComboBox()
            {
                X      = Pos.Right(listview) + 1,
                Y      = Pos.Bottom(lbListView) + 1,
                Height = Dim.Fill(2),
                Width  = Dim.Percent(60)
            };

            comboBox.SetSource(items);

            comboBox.SelectedItemChanged += (object sender, ustring text) => lbComboBox.Text = text;
            Win.Add(lbComboBox, comboBox);
        }
コード例 #21
0
 public void Init()
 {
     this.TextView = new TextView()
     {
         X      = 0,
         Y      = Pos.Bottom(MainWindow.TopMenubar.MenuBar),
         Width  = Dim.Fill(),
         Height = Dim.Fill(),
         Text   = ""
     };
 }
コード例 #22
0
        private static void CreateInterface()
        {
            var top = Application.Top;

            var chatWindow = new Window("Chat")
            {
                X      = 0,
                Y      = 1,
                Width  = Dim.Fill(),
                Height = Dim.Fill(3)
            };

            var messageWindow = new Window("Send message")
            {
                X      = 0,
                Y      = Pos.Bottom(top) - 3,
                Width  = Dim.Fill(),
                Height = 3
            };

            top.Add(chatWindow);
            top.Add(messageWindow);

            MessageText = new CustomInput("")
            {
                X      = 0,
                Y      = 0,
                Width  = Dim.Fill(),
                Height = Dim.Fill(),
            };

            MessageText.OnPressEnter += MessageText_OnPressEnter;

            ChatText = new Label("")
            {
                X      = 0,
                Y      = 0,
                Width  = Dim.Fill() - 3,
                Height = Dim.Fill(),
            };

            messageWindow.Add(MessageText);
            chatWindow.Add(ChatText);

            var menu = new MenuBar(new MenuBarItem[] {
                new MenuBarItem("_File", new MenuItem [] {
                    new MenuItem("_Quit", "", () => { })
                })
            });

            top.Add(menu);

            top.SetFocus(MessageText);
        }
コード例 #23
0
        public JsonSettingsWindow(JsonSerializerSettings jsonSerializerSettings) : base(
                "Code Generator - Deserialization settings")
        {
            _jsonSerializerSettings = jsonSerializerSettings;

            var g1Label  = new Label(1, 1, "NullValueHandling:");
            var g1Holder = new View
            {
                Y      = Pos.Bottom(g1Label),
                X      = 1,
                Width  = Dim.Fill(1),
                Height = 3
            };

            _nullValueHandlingOptions = new RadioGroup(new[] { "Include", "Ignore" },
                                                       (int)_jsonSerializerSettings.NullValueHandling);
            g1Holder.Add(_nullValueHandlingOptions);

            var g2Label  = new Label(1, 5, "ConstructorHandling:");
            var g2Holder = new View
            {
                X      = 1,
                Y      = Pos.Bottom(g2Label),
                Width  = Dim.Fill(1),
                Height = 3
            };

            _constructorHandlingOptions = new RadioGroup(new[] { "	Default", "	AllowNonPublicDefaultConstructor" },
                                                         (int)_jsonSerializerSettings.ConstructorHandling);
            g2Holder.Add(_constructorHandlingOptions);

            var g3Label  = new Label(1, 9, "MissingMemberHandling:");
            var g3Holder = new View
            {
                X      = 1,
                Y      = Pos.Bottom(g3Label),
                Width  = Dim.Fill(1),
                Height = 3
            };

            _missingMemberHandlingOptions = new RadioGroup(new[] { "Ignore", "Error" },
                                                           (int)_jsonSerializerSettings.MissingMemberHandling);
            g3Holder.Add(_missingMemberHandlingOptions);


            var exitButton = new Button("Back")
            {
                X = Pos.Center(), Y = Pos.Percent(80), Clicked = ProcessInput
            };


            Add(g1Label, g1Holder, g2Label, g2Holder, g3Label, g3Holder, exitButton);
        }
コード例 #24
0
        public DashboardView(TcpSettingsGrid tcpSettingsGrid, TcpPerformanceGrid tcpPerformanceGrid)
        {
            Width  = Dim.Fill();
            Height = Dim.Fill();
            VisibilityChangedEvent += tcpPerformanceGrid.VisibilityChanged;

            tcpSettingsGrid.Y    = 0;
            tcpPerformanceGrid.Y = Pos.Bottom(tcpSettingsGrid) + 1;

            Add(tcpSettingsGrid);
            Add(tcpPerformanceGrid);
        }
コード例 #25
0
ファイル: ConnectView.cs プロジェクト: JamesLoyd/sshcommander
        public ConnectView()
        {
            var label = new Label("IP Address")
            {
                X     = 1,
                Y     = 3,
                Width = 50
            };
            var ipAddress = new TextField("")
            {
                X     = Pos.Bottom(label),
                Y     = Pos.Bottom(label),
                Width = Dim.Width(label)
            };

            var userNameLabel = new Label("Username")
            {
                X     = 1,
                Y     = 5,
                Width = Dim.Width(ipAddress)
            };

            var userNameText = new TextField("")
            {
                X     = Pos.Bottom(label),
                Y     = Pos.Bottom(userNameLabel),
                Width = Dim.Width(userNameLabel)
            };

            var keyFileLabel = new Label("Absolute Path to key file")
            {
                X     = 1,
                Y     = 7,
                Width = Dim.Width(ipAddress)
            };

            var keyFileText = new TextField("")
            {
                X     = Pos.Bottom(label),
                Y     = Pos.Bottom(keyFileLabel),
                Width = Dim.Width(keyFileLabel)
            };

            var button = new Button("Submit")
            {
                X     = 1,
                Y     = 10,
                Width = Dim.Width(ipAddress)
            };

            button.Clicked = () => label.Text = $"{userNameText.Text}@{ipAddress.Text}";
            Add(label, ipAddress, userNameLabel, userNameText, keyFileLabel, keyFileText, button);
        }
コード例 #26
0
ファイル: LoginView.cs プロジェクト: Yellow-Cake/KRATE.TUI
        public static Window generateWindow(Window baseWindow)
        {
            Window loginView = new Window(new Rect(0, 0, baseWindow.Frame.Width - 2, baseWindow.Frame.Height - 2), "Login");
            var    login     = new Label("Wallet Name: ")
            {
                X = 3, Y = 6
            };
            var password = new Label("Wallet Password: "******"")
            {
                X     = Pos.Right(password),
                Y     = Pos.Top(login),
                Width = 40
            };
            var passText = new TextField("")
            {
                Secret = true,
                X      = Pos.Left(loginText),
                Y      = Pos.Top(password),
                Width  = Dim.Width(loginText)
            };

            var loginButton = new Button("Login")
            {
                X         = 3,
                Y         = 19,
                IsDefault = true,
                Clicked   = () => {
                    var subView = baseWindow.Subviews[0];
                    subView.RemoveAll();

                    var costView = DashboardView.generateWindow(baseWindow);
                    baseWindow.Add(costView);
                    costView.FocusFirst();
                    costView.LayoutSubviews();
                }
            };


            loginView.Add(
                new TextField(14, 2, 40, "Welcome to login view"),
                login,
                loginText,
                password,
                passText,
                loginButton
                );
            return(loginView);
        }
コード例 #27
0
        public void DisplayMenu()
        {
            var loadButton = new Button("Load the openApi.json")
            {
                X = Pos.Center(), Y = Pos.Percent(20), Clicked = _selectFileCommand.Execute
            };
            var exitButton = new Button("Exit")
            {
                X = Pos.Center(), Y = Pos.Bottom(loadButton), Clicked = _exitCommand.Execute
            };

            _window.Add(loadButton, exitButton);
        }
コード例 #28
0
        public PickerApp()
        {
            int i = 0;

            foreach (var host in GetHosts())
            {
                _apps[i++] = host;
            }

            Application.Init();

            var top = Application.Top;

            var win = new Window("Picker")
            {
                X      = 0,
                Y      = 0,
                Width  = Dim.Fill(),
                Height = Dim.Fill()
            };

            top.Add(win);

            var options = new RadioGroup(1, 1, _apps.Select(a => a.Value.Name).ToArray());

            var confirm = new Button("OK")
            {
                Y       = Pos.Bottom(options) + 1,
                X       = 1,
                Clicked = () =>
                {
                    Application.RequestStop();
                    Application.Run(_apps[options.Selected].Top());
                }
            };

            var quit = new Button("Quit")
            {
                Y       = Pos.Bottom(options) + 1,
                X       = Pos.Right(confirm) + 1,
                Clicked = () =>
                {
                    Application.RequestStop();
                    Environment.Exit(0);
                }
            };

            win.Add(options, confirm, quit);

            Application.Run();
        }
コード例 #29
0
        private void AddRows(Window win)
        {
            _listView = new ListView(_itemSource)
            {
                X                       = Pos.Left(_filterLabel),
                Y                       = Pos.Bottom(_filterLabel) + 3, // 1 for space, 1 for header, 1 for header underline
                Width                   = Dim.Fill(2),
                Height                  = Dim.Fill(),
                AllowsMarking           = _applicationData.OutputMode != OutputModeOption.None,
                AllowsMultipleSelection = _applicationData.OutputMode == OutputModeOption.Multiple,
            };

            win.Add(_listView);
        }
コード例 #30
0
        public void ShowStatusBarMessage(string text)
        {
            StatusButton = new Button(text)
            {
                X         = 0,
                Y         = Pos.Bottom(HostPane),
                IsDefault = true,
            };
            StatusButton.Clicked += () =>
            {
                Top.Remove(StatusButton);
            };

            Top.Add(StatusButton);
        }