Esempio n. 1
0
        public override void Setup()
        {
            int    i         = 1;
            string txt       = "Hello world, how are you doing today";
            var    labelList = new List <Label> ();

            labelList.Add(new Label($"Label:"));
            labelList.Add(new Label($"{i++}-{txt}")
            {
                TextAlignment = Terminal.Gui.TextAlignment.Left, Width = Dim.Fill(1), X = 0, Y = Pos.Bottom(labelList.LastOrDefault()) + 1
            });
            labelList.Add(new Label($"{i++}-{txt}")
            {
                TextAlignment = Terminal.Gui.TextAlignment.Right, Width = Dim.Fill(1), X = 0, Y = Pos.Bottom(labelList.LastOrDefault()) + 1
            });
            labelList.Add(new Label($"{i++}-{txt}")
            {
                TextAlignment = Terminal.Gui.TextAlignment.Centered, Width = Dim.Fill(1), X = 0, Y = Pos.Bottom(labelList.LastOrDefault()) + 1
            });
            labelList.Add(new Label($"{i++}-{txt}")
            {
                TextAlignment = Terminal.Gui.TextAlignment.Justified, Width = Dim.Fill(1), X = 0, Y = Pos.Bottom(labelList.LastOrDefault()) + 1
            });
            txt += "\nSecond line";
            labelList.Add(new Label($"{i++}-{txt}")
            {
                TextAlignment = Terminal.Gui.TextAlignment.Left, Width = Dim.Fill(1), Height = 4, X = 0, Y = Pos.Bottom(labelList.LastOrDefault()) + 1
            });

            Win.Add(labelList.ToArray());
            Win.LayoutSubviews();
        }
Esempio n. 2
0
        public override void Setup()
        {
            var charMap = new CharMap()
            {
                X           = 0,
                Y           = 0,
                Width       = CharMap.RowWidth + 2,
                Height      = Dim.Fill(),
                Start       = 0x2500,
                ColorScheme = Colors.Dialog
            };

            Win.Add(charMap);
            var label = new Label("Jump To Unicode Block:")
            {
                X = Pos.Right(charMap) + 1, Y = Pos.Y(charMap)
            };

            Win.Add(label);

            (ustring radioLabel, int start, int end) CreateRadio(ustring title, int start, int end)
            {
                return($"{title} (U+{start:x5}-{end:x5})", start, end);
            }

            var radioItems = new (ustring radioLabel, int start, int end) [] {
Esempio n. 3
0
        private void CreateFindReplace(bool isFind = true)
        {
            winDialog = new Window(isFind ? "Find" : "Replace")
            {
                X           = Win.Bounds.Width / 2 - 30,
                Y           = Win.Bounds.Height / 2 - 10,
                ColorScheme = Colors.Menu
            };

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

            tabView.AddTab(new TabView.Tab("Find", FindTab()), isFind);
            var replace = ReplaceTab();

            tabView.AddTab(new TabView.Tab("Replace", replace), !isFind);
            tabView.SelectedTabChanged += (s, e) => tabView.SelectedTab.View.FocusFirst();
            winDialog.Add(tabView);

            Win.Add(winDialog);

            winDialog.Width  = replace.Width + 4;
            winDialog.Height = replace.Height + 4;

            winDialog.SuperView.BringSubviewToFront(winDialog);
            winDialog.SetFocus();
        }
Esempio n. 4
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("_Quit", "", () => Quit()),
                })
            });

            Top.Add(menu);

            treeView = new TreeView()
            {
                X      = 0,
                Y      = 0,
                Width  = Dim.Fill(),
                Height = Dim.Fill(1),
            };
            treeView.KeyPress += TreeView_KeyPress;

            Win.Add(treeView);

            var statusBar = new StatusBar(new StatusItem [] {
                new StatusItem(Key.CtrlMask | Key.Q, "~^Q~ Quit", () => Quit()),
                new StatusItem(Key.CtrlMask | Key.C, "~^C~ Add Child", () => AddChildNode()),
                new StatusItem(Key.CtrlMask | Key.T, "~^T~ Add Root", () => AddRootNode()),
                new StatusItem(Key.CtrlMask | Key.R, "~^R~ Rename Node", () => RenameNode()),
            });

            Top.Add(statusBar);
        }
Esempio n. 5
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);
Esempio n. 6
0
        public override void Setup()
        {
            Label ml;
            int   count = 0;

            ml = new Label(new Rect(1, 1, 50, 1), "Mouse: ");
            Application.RootMouseEvent += delegate(MouseEvent me) {
                ml.TextColor = Colors.TopLevel.Normal;
                ml.Text      = $"Mouse: ({me.X},{me.Y}) - {me.Flags} {count++}";
            };


            var test = new Label(1, 2, "Se iniciará el análisis");

            Win.Add(test);
            Win.Add(ml);

            // I have no idea what this was intended to show off in demo.c
            var drag = new Label("Drag: ")
            {
                X = 1, Y = 4
            };
            var dragText = new TextField("")
            {
                X     = Pos.Right(drag),
                Y     = Pos.Top(drag),
                Width = 40
            };

            Win.Add(drag, dragText);
        }
Esempio n. 7
0
        public override void Setup()
        {
            //Top.LayoutStyle = LayoutStyle.Computed;
            // Demonstrate using Dim to create a horizontal ruler that always measures the parent window's width
            // BUGBUG: Dim.Fill returns too big a value sometimes.
            const string rule            = "|123456789";
            var          horizontalRuler = new Label("")
            {
                X           = 0,
                Y           = 0,
                Width       = Dim.Fill(1),             // BUGBUG: I don't think this should be needed; DimFill() should respect container's frame. X does.
                ColorScheme = Colors.Error
            };

            Win.Add(horizontalRuler);

            // Demonstrate using Dim to create a vertical ruler that always measures the parent window's height
            // TODO: Either build a custom control for this or implement linewrap in Label #352
            const string vrule = "|\n1\n2\n3\n4\n5\n6\n7\n8\n9\n";

            var verticalRuler = new Label("")
            {
                X           = 0,
                Y           = 0,
                Width       = 1,
                Height      = Dim.Fill(),
                ColorScheme = Colors.Error
            };

            Application.Resized += (sender, a) => {
                horizontalRuler.Text = rule.Repeat((int)Math.Ceiling((double)(horizontalRuler.Bounds.Width) / (double)rule.Length)) [0..(horizontalRuler.Bounds.Width)];
Esempio n. 8
0
File: Text.cs Progetto: 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);
        }
Esempio n. 9
0
 public override void Setup()
 {
     Win.Add(new Button("Press me!")
     {
         X       = Pos.Center(),
         Y       = Pos.Center(),
         Clicked = () => MessageBox.Query(20, 7, "Hi", "Neat?", "Yes", "No")
     });
 }
Esempio n. 10
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();
        }
Esempio n. 11
0
        public override void Setup()
        {
            Top.LayoutStyle = LayoutStyle.Computed;
            // Demonstrate using Dim to create a ruler that always measures the top-level window's width
            // BUGBUG: Dim.Fill returns too big a value sometimes.
            //const string rule = "|123456789";
            //var labelRuler = new Label ("ruler") {
            //	X = 0,
            //	Y = 0,
            //	Width = Dim.Fill (1),  // BUGBUG: I don't think this should be needed; DimFill() should respect container's frame. X does.
            //	ColorScheme = Colors.Error
            //};

            //Application.OnResized += () => {
            //	labelRuler.Text = rule.Repeat ((int)Math.Ceiling((double)(labelRuler.Bounds.Width) / (double)rule.Length))[0..(labelRuler.Bounds.Width)];
            //};

            //win.Add (labelRuler);

            // Demonstrate using Dim to create a window that fills the parent with a margin
            int margin = 20;
            var subWin = new Window($"Sub Windoww with {margin} character margin")
            {
                X      = margin,
                Y      = 2,
                Width  = Dim.Fill(margin),
                Height = Dim.Fill()
            };

            Win.Add(subWin);

            int    i         = 1;
            string txt       = "Hello world, how are you doing today";
            var    labelList = new List <Label> ();

            labelList.Add(new Label($"Label:"));
            labelList.Add(new Label($"{i++}-{txt}")
            {
                TextAlignment = Terminal.Gui.TextAlignment.Left, Width = Dim.Fill(1), X = 0, Y = Pos.Bottom(labelList.LastOrDefault()) + 1, ColorScheme = Colors.Dialog
            });
            labelList.Add(new Label($"{i++}-{txt}")
            {
                TextAlignment = Terminal.Gui.TextAlignment.Right, Width = Dim.Fill(1), X = 0, Y = Pos.Bottom(labelList.LastOrDefault()) + 1, ColorScheme = Colors.Dialog
            });
            labelList.Add(new Label($"{i++}-{txt}")
            {
                TextAlignment = Terminal.Gui.TextAlignment.Centered, Width = Dim.Fill(1), X = 0, Y = Pos.Bottom(labelList.LastOrDefault()) + 1, ColorScheme = Colors.Dialog
            });
            labelList.Add(new Label($"{i++}-{txt}")
            {
                TextAlignment = Terminal.Gui.TextAlignment.Justified, Width = Dim.Fill(1), X = 0, Y = Pos.Bottom(labelList.LastOrDefault()) + 1, ColorScheme = Colors.Dialog
            });

            subWin.Add(labelList.ToArray());
            //subWin.LayoutSubviews ();
        }
Esempio n. 12
0
 public override void Setup()
 {
     // Put your scenario code here, e.g.
     Win.Add(new Button("Press me!")
     {
         X       = Pos.Center(),
         Y       = Pos.Center(),
         Clicked = () => MessageBox.Query(20, 7, "Hi", "Neat?", "Yes", "No")
     });
 }
Esempio n. 13
0
        public override void Setup()
        {
            Win.Title  = this.GetName();
            Win.Y      = 1;           // menu
            Win.Height = Dim.Fill(1); // status bar
            Top.LayoutSubviews();

            this.tableView = new TableViewColors()
            {
                X      = 0,
                Y      = 0,
                Width  = Dim.Fill(),
                Height = Dim.Fill(1),
            };

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

            Top.Add(menu);

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

            Top.Add(statusBar);

            Win.Add(tableView);

            tableView.CellActivated += EditCurrentCell;

            var dt = new DataTable();

            dt.Columns.Add("Col1");
            dt.Columns.Add("Col2");

            dt.Rows.Add("some text", "Rainbows and Unicorns are so fun!");
            dt.Rows.Add("some text", "When it rains you get rainbows");
            dt.Rows.Add(DBNull.Value, DBNull.Value);
            dt.Rows.Add(DBNull.Value, DBNull.Value);
            dt.Rows.Add(DBNull.Value, DBNull.Value);
            dt.Rows.Add(DBNull.Value, DBNull.Value);

            tableView.ColorScheme = new ColorScheme()
            {
                Disabled = Win.ColorScheme.Disabled,
                HotFocus = Win.ColorScheme.HotFocus,
                Focus    = Win.ColorScheme.Focus,
                Normal   = Application.Driver.MakeAttribute(Color.DarkGray, Color.Black)
            };

            tableView.Table = dt;
        }
Esempio n. 14
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);
        }
Esempio n. 15
0
        public override void Setup()
        {
            var vx     = 30;
            var x      = 30;
            var y      = 14;
            var colors = System.Enum.GetValues(typeof(Color));

            foreach (Color bg in colors)
            {
                var vl = new Label(bg.ToString(), TextDirection.TopBottom_LeftRight)
                {
                    X      = vx,
                    Y      = 0,
                    Width  = 1,
                    Height = 13,
                    VerticalTextAlignment = VerticalTextAlignment.Bottom,
                    ColorScheme           = new ColorScheme()
                    {
                        Normal = new Attribute(bg, colors.Length - 1 - bg)
                    }
                };
                Win.Add(vl);
                var hl = new Label(bg.ToString())
                {
                    X             = 15,
                    Y             = y,
                    Width         = 13,
                    Height        = 1,
                    TextAlignment = TextAlignment.Right,
                    ColorScheme   = new ColorScheme()
                    {
                        Normal = new Attribute(bg, colors.Length - 1 - bg)
                    }
                };
                Win.Add(hl);
                vx++;
                foreach (Color fg in colors)
                {
                    var c = new Attribute(fg, bg);
                    var t = x.ToString();
                    var l = new Label(x, y, t [t.Length - 1].ToString())
                    {
                        ColorScheme = new ColorScheme()
                        {
                            Normal = c
                        }
                    };
                    Win.Add(l);
                    x++;
                }
                x = 30;
                y++;
            }
        }
Esempio n. 16
0
        public override void Setup()
        {
            var pressMe = new Button("Press me!")
            {
                X = Pos.Center(),
                Y = Pos.Center(),
            };

            pressMe.Clicked += () => MessageBox.Query(20, 7, "Hi", "Neat?", "Yes", "No");
            Win.Add(pressMe);
        }
Esempio n. 17
0
        public override void Setup()
        {
            Win.X      = 3;
            Win.Y      = 3;
            Win.Width  = Dim.Fill() - 3;
            Win.Height = Dim.Fill() - 3;
            var label = new Label("ScrollView (new Rect (2, 2, 50, 20)) with a 200, 100 ContentSize...")
            {
                X           = 0,
                Y           = 0,
                ColorScheme = Colors.Dialog
            };

            Win.Add(label);

            // BUGBUG: ScrollView only supports Absolute Positioning (#72)
            var scrollView = new ScrollView(new Rect(2, 2, 50, 20))
            {
                ColorScheme = Colors.TopLevel,
                ContentSize = new Size(200, 100),
                //ContentOffset = new Point (0, 0),
                ShowVerticalScrollIndicator   = true,
                ShowHorizontalScrollIndicator = true,
            };

            const string rule            = "0123456789";
            var          horizontalRuler = new Label()
            {
                X           = 0,
                Y           = 0,
                Width       = Dim.Fill(),             // FIXED: I don't think this should be needed; DimFill() should respect container's frame. X does.
                Height      = 2,
                ColorScheme = Colors.Error
            };

            scrollView.Add(horizontalRuler);
            const string vrule = "0\n1\n2\n3\n4\n5\n6\n7\n8\n9\n";

            var verticalRuler = new Label()
            {
                X           = 0,
                Y           = 0,
                Width       = 1,
                Height      = Dim.Fill(),
                ColorScheme = Colors.Error
            };

            scrollView.Add(verticalRuler);

            void Top_Loaded()
            {
                horizontalRuler.Text = rule.Repeat((int)Math.Ceiling((double)(horizontalRuler.Bounds.Width) / (double)rule.Length)) [0..(horizontalRuler.Bounds.Width)] +
Esempio n. 18
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("_Quit", "", () => Quit()),
                })
                ,
                new MenuBarItem("_View", new MenuItem [] {
                    miShowPrivate = new MenuItem("_Include Private", "", () => ShowPrivate())
                    {
                        Checked   = false,
                        CheckType = MenuItemCheckStyle.Checked
                    },
                    new MenuItem("_Expand All", "", () => treeView.ExpandAll()),
                    new MenuItem("_Collapse All", "", () => treeView.CollapseAll())
                }),
            });

            Top.Add(menu);

            treeView = new TreeView <object> ()
            {
                X      = 0,
                Y      = 0,
                Width  = Dim.Percent(50),
                Height = Dim.Fill(),
            };


            treeView.AddObjects(AppDomain.CurrentDomain.GetAssemblies());
            treeView.AspectGetter      = GetRepresentation;
            treeView.TreeBuilder       = new DelegateTreeBuilder <object> (ChildGetter, CanExpand);
            treeView.SelectionChanged += TreeView_SelectionChanged;

            Win.Add(treeView);

            textView = new TextView()
            {
                X      = Pos.Right(treeView),
                Y      = 0,
                Width  = Dim.Fill(),
                Height = Dim.Fill()
            };

            Win.Add(textView);
        }
Esempio n. 19
0
        public override void Setup()
        {
            Win.Title = this.GetName() + "-" + _fileName ?? "Untitled";

            CreateDemoFile(_fileName);
            //CreateUnicodeDemoFile (_fileName);

            _hexView = new HexView(LoadFile())
            {
                X      = 0,
                Y      = 0,
                Width  = Dim.Fill(),
                Height = Dim.Fill(),
            };
            _hexView.Edited          += _hexView_Edited;
            _hexView.PositionChanged += _hexView_PositionChanged;
            Win.Add(_hexView);

            var menu = new MenuBar(new MenuBarItem [] {
                new MenuBarItem("_File", new MenuItem [] {
                    new MenuItem("_New", "", () => New()),
                    new MenuItem("_Open", "", () => Open()),
                    new MenuItem("_Save", "", () => Save()),
                    null,
                    new MenuItem("_Quit", "", () => Quit()),
                }),
                new MenuBarItem("_Edit", new MenuItem [] {
                    new MenuItem("_Copy", "", () => Copy()),
                    new MenuItem("C_ut", "", () => Cut()),
                    new MenuItem("_Paste", "", () => Paste())
                }),
                new MenuBarItem("_Options", new MenuItem [] {
                    miAllowEdits = new MenuItem("_AllowEdits", "", () => ToggleAllowEdits())
                    {
                        Checked = _hexView.AllowEdits, CheckType = MenuItemCheckStyle.Checked
                    }
                })
            });

            Top.Add(menu);

            statusBar = new StatusBar(new StatusItem [] {
                new StatusItem(Key.F2, "~F2~ Open", () => Open()),
                new StatusItem(Key.F3, "~F3~ Save", () => Save()),
                new StatusItem(Key.CtrlMask | Key.Q, "~^Q~ Quit", () => Quit()),
                siPositionChanged = new StatusItem(Key.Null,
                                                   $"Position: {_hexView.Position} Line: {_hexView.CursorPosition.Y} Col: {_hexView.CursorPosition.X} Line length: {_hexView.BytesPerLine}", () => {})
            });
            Top.Add(statusBar);
        }
Esempio n. 20
0
        public override void Setup()
        {
#if true
            string txt = "Hello world, how are you today? Pretty neat!";
#else
            string txt = "Hello world, how are you today? Unicode:  ~  gui.cs  . Neat?";
#endif
            var alignments = Enum.GetValues(typeof(Terminal.Gui.TextAlignment)).Cast <Terminal.Gui.TextAlignment> ().ToList();
            var label      = new Label($"Demonstrating single-line (should clip!):")
            {
                Y = 0
            };
            Win.Add(label);
            foreach (var alignment in alignments)
            {
                label = new Label($"{alignment}:")
                {
                    Y = Pos.Bottom(label)
                };
                Win.Add(label);
                label = new Label(txt)
                {
                    TextAlignment = alignment, Y = Pos.Bottom(label), Width = Dim.Fill(), Height = 1, ColorScheme = Colors.Dialog
                };
                Win.Add(label);
            }

            txt  += "\nSecond line\n\nFourth Line.";
            label = new Label($"Demonstrating multi-line and word wrap:")
            {
                Y = Pos.Bottom(label) + 1
            };
            Win.Add(label);
            foreach (var alignment in alignments)
            {
                label = new Label($"{alignment}:")
                {
                    Y = Pos.Bottom(label)
                };
                Win.Add(label);
                label = new Label(txt)
                {
                    TextAlignment = alignment, Width = Dim.Fill(), Height = 6, ColorScheme = Colors.Dialog, Y = Pos.Bottom(label)
                };
                Win.Add(label);
            }
        }
Esempio n. 21
0
        public override void Setup()
        {
            var charMap = new CharMap()
            {
                X           = 0, Y = 0, Width = CharMap.RowWidth + 2, Height = Dim.Fill(), Start = 0x2500,
                ColorScheme = Colors.Dialog
            };

            Win.Add(charMap);

            Button CreateBlock(Window win, ustring title, int start, int end, View align)
            {
                var button = new Button($"{title} (U+{start:x5}-{end:x5})")
                {
                    X       = Pos.X(align),
                    Y       = Pos.Bottom(align),
                    Clicked = () => {
                        charMap.Start = start;
                    },
                };

                win.Add(button);
                return(button);
            };

            var label = new Label("Unicode Blocks:")
            {
                X = Pos.Right(charMap) + 2, Y = Pos.Y(charMap)
            };

            Win.Add(label);
            var button = CreateBlock(Win, "Currency Symbols", 0x20A0, 0x20CF, label);

            button = CreateBlock(Win, "Letterlike Symbols", 0x2100, 0x214F, button);
            button = CreateBlock(Win, "Arrows", 0x2190, 0x21ff, button);
            button = CreateBlock(Win, "Mathematical symbols", 0x2200, 0x22ff, button);
            button = CreateBlock(Win, "Miscellaneous Technical", 0x2300, 0x23ff, button);
            button = CreateBlock(Win, "Box Drawing & Geometric Shapes", 0x2500, 0x25ff, button);
            button = CreateBlock(Win, "Miscellaneous Symbols", 0x2600, 0x26ff, button);
            button = CreateBlock(Win, "Dingbats", 0x2700, 0x27ff, button);
            button = CreateBlock(Win, "Braille", 0x2800, 0x28ff, button);
            button = CreateBlock(Win, "Miscellaneous Symbols and Arrows", 0x2b00, 0x2bff, button);
            button = CreateBlock(Win, "Alphabetic Presentation Forms", 0xFB00, 0xFb4f, button);
            button = CreateBlock(Win, "Cuneiform Numbers and Punctuation[1", 0x12400, 0x1240f, button);
            button = CreateBlock(Win, "Chess Symbols", 0x1FA00, 0x1FA0f, button);
            button = CreateBlock(Win, "End", CharMap.MaxCodePointVal - 16, CharMap.MaxCodePointVal, button);
        }
Esempio n. 22
0
        public override void Setup()
        {
            var menu = new MenuBar(new MenuBarItem [] {
                new MenuBarItem("_Settings", new MenuItem [] {
                    null,
                    new MenuItem("_Quit", "", () => Quit()),
                }),
            });

            Top.Add(menu);

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

            Top.Add(statusBar);

            //Top.LayoutStyle = LayoutStyle.Computed;
            // Demonstrate using Dim to create a horizontal ruler that always measures the parent window's width
            // BUGBUG: Dim.Fill returns too big a value sometimes.
            const string rule            = "|123456789";
            var          horizontalRuler = new Label("")
            {
                X           = 0,
                Y           = 0,
                Width       = Dim.Fill(1),             // BUGBUG: I don't think this should be needed; DimFill() should respect container's frame. X does.
                ColorScheme = Colors.Error
            };

            Win.Add(horizontalRuler);

            // Demonstrate using Dim to create a vertical ruler that always measures the parent window's height
            // TODO: Either build a custom control for this or implement linewrap in Label #352
            const string vrule = "|\n1\n2\n3\n4\n5\n6\n7\n8\n9\n";

            var verticalRuler = new Label("")
            {
                X           = 0,
                Y           = 0,
                Width       = 1,
                Height      = Dim.Fill(),
                ColorScheme = Colors.Error
            };

            Win.LayoutComplete += (a) => {
                horizontalRuler.Text = rule.Repeat((int)Math.Ceiling((double)(horizontalRuler.Bounds.Width) / (double)rule.Length)) [0..(horizontalRuler.Bounds.Width)];
Esempio n. 23
0
        public override void Setup()
        {
            _customRenderCB = new CheckBox("Render with columns")
            {
                X      = 0,
                Y      = 0,
                Height = 1,
            };
            Win.Add(_customRenderCB);
            _customRenderCB.Toggled += _customRenderCB_Toggled;;

            _allowMarkingCB = new CheckBox("Allow Marking")
            {
                X      = Pos.Right(_customRenderCB) + 1,
                Y      = 0,
                Height = 1,
            };
            Win.Add(_allowMarkingCB);
            _allowMarkingCB.Toggled += AllowMarkingCB_Toggled;

            _allowMultipleCB = new CheckBox("Allow Multi-Select")
            {
                X       = Pos.Right(_allowMarkingCB) + 1,
                Y       = 0,
                Height  = 1,
                Visible = _allowMarkingCB.Checked
            };
            Win.Add(_allowMultipleCB);
            _allowMultipleCB.Toggled += AllowMultipleCB_Toggled;

            _listView = new ListView()
            {
                X      = 1,
                Y      = 2,
                Height = Dim.Fill(),
                Width  = Dim.Fill(1),
                //ColorScheme = Colors.TopLevel,
                AllowsMarking           = false,
                AllowsMultipleSelection = false
            };
            Win.Add(_listView);


            _listView.SetSource(_scenarios);
        }
Esempio n. 24
0
        public override void Setup()
        {
            Label ml;
            int   count = 0;

            ml = new Label(new Rect(1, 1, 50, 1), "Mouse: ");
            List <string> rme = new List <string> ();

            var test = new Label(1, 2, "Se iniciará el análisis");

            Win.Add(test);
            Win.Add(ml);

            var rmeList = new ListView(rme)
            {
                X           = Pos.Right(test) + 25,
                Y           = Pos.Top(test) + 1,
                Width       = Dim.Fill() - 1,
                Height      = Dim.Fill(),
                ColorScheme = Colors.TopLevel
            };

            Win.Add(rmeList);

            Application.RootMouseEvent += delegate(MouseEvent me) {
                ml.TextColor = Colors.TopLevel.Normal;
                ml.Text      = $"Mouse: ({me.X},{me.Y}) - {me.Flags} {count}";
                rme.Add($"({me.X},{me.Y}) - {me.Flags} {count++}");
                rmeList.MoveDown();
            };

            // I have no idea what this was intended to show off in demo.c
            var drag = new Label("Drag: ")
            {
                X = 1, Y = 4
            };
            var dragText = new TextField("")
            {
                X     = Pos.Right(drag),
                Y     = Pos.Top(drag),
                Width = 40
            };

            Win.Add(drag, dragText);
        }
Esempio n. 25
0
        public override void Setup()
        {
            Win.Title  = this.GetName() + "-" + _fileName ?? "Untitled";
            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()),
                    null,
                    new MenuItem("_Quit", "", () => Quit()),
                }),
                new MenuBarItem("_Edit", new MenuItem [] {
                    new MenuItem("_Copy", "", () => Copy()),
                    new MenuItem("C_ut", "", () => Cut()),
                    new MenuItem("_Paste", "", () => Paste())
                }),
            });

            Top.Add(menu);

            var statusBar = new StatusBar(new StatusItem [] {
                //new StatusItem(Key.Enter, "~ENTER~ ApplyEdits", () => { _hexView.ApplyEdits(); }),
                new StatusItem(Key.F2, "~F2~ Open", () => Open()),
                new StatusItem(Key.F3, "~F3~ Save", () => Save()),
                new StatusItem(Key.ControlQ, "~^Q~ Quit", () => Quit()),
            });

            Top.Add(statusBar);

            CreateDemoFile(_fileName);

            _hexView = new HexView(LoadFile())
            {
                X      = 0,
                Y      = 0,
                Width  = Dim.Fill(),
                Height = Dim.Fill(),
            };
            _hexView.CanFocus = true;
            Win.Add(_hexView);
        }
Esempio n. 26
0
        public override void Setup()
        {
            Win.ColorScheme = Colors.TopLevel;

            List <Label> labels     = new List <Label> ();
            var          foreColors = Enum.GetValues(typeof(Color)).Cast <Color> ().ToArray();

            for (int y = 0; y < foreColors.Length; y++)
            {
                var fore  = foreColors [y];
                var back  = foreColors [(y + 1) % foreColors.Length];
                var color = Application.Driver.MakeAttribute(fore, back);

                var label = new Label($"{fore} on {back}")
                {
                    ColorScheme = new ColorScheme(),
                    Y           = y
                };
                label.ColorScheme.Normal = color;
                Win.Add(label);
                labels.Add(label);
            }

            var button = new Button("Invert color!")
            {
                X = Pos.Center(),
                Y = foreColors.Length + 1,
            };

            button.Clicked += () => {
                foreach (var label in labels)
                {
                    var color = label.ColorScheme.Normal;
                    color = Application.Driver.MakeAttribute(color.Background, color.Foreground);

                    label.ColorScheme.Normal = color;
                    label.Text = $"{color.Foreground} on {color.Background}";
                    label.SetNeedsDisplay();
                }
            };
            Win.Add(button);
        }
Esempio n. 27
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 Label (IsDefault = true); if user presses ENTER in the TextField
            // the scenario will quit
            var defaultLabel = new Label("_Quit")
            {
                X = Pos.Center(),
                //TODO: Change to use Pos.AnchorEnd()
                Y = Pos.Bottom(Win) - 3,
                //IsDefault = true,
                HotKeySpecifier = (System.Rune) '_',
                CanFocus        = true,
            };

            defaultLabel.Clicked += () => Application.RequestStop();
            Win.Add(defaultLabel);

            var swapLabel = new Label(50, 0, "S_wap Default (Absolute Layout)")
            {
                HotKeySpecifier = (System.Rune) '_',
                CanFocus        = true,
            };

            swapLabel.Clicked += () => {
                //defaultLabel.IsDefault = !defaultLabel.IsDefault;
                //swapLabel.IsDefault = !swapLabel.IsDefault;
            };
            Win.Add(swapLabel);
Esempio n. 28
0
        /// <summary>
        /// Setup the scenario.
        /// </summary>
        public override void Setup()
        {
            // Scenario Window's.
            Win.Title = this.GetName();

            // Forground ColorPicker.
            foregroundColorPicker               = new ColorPicker("Foreground Color");
            foregroundColorPicker.X             = 0;
            foregroundColorPicker.Y             = 0;
            foregroundColorPicker.ColorChanged += ForegroundColor_ColorChanged;
            Win.Add(foregroundColorPicker);

            foregroundColorLabel   = new Label();
            foregroundColorLabel.X = Pos.Left(foregroundColorPicker);
            foregroundColorLabel.Y = Pos.Bottom(foregroundColorPicker) + 1;
            Win.Add(foregroundColorLabel);

            // Background ColorPicker.
            backgroundColorPicker               = new ColorPicker();
            backgroundColorPicker.Text          = "Background Color";
            backgroundColorPicker.X             = Pos.AnchorEnd() - (Pos.Right(backgroundColorPicker) - Pos.Left(backgroundColorPicker));
            backgroundColorPicker.Y             = 0;
            backgroundColorPicker.ColorChanged += BackgroundColor_ColorChanged;
            Win.Add(backgroundColorPicker);

            backgroundColorLabel   = new Label();
            backgroundColorLabel.X = Pos.AnchorEnd() - (Pos.Right(backgroundColorLabel) - Pos.Left(backgroundColorLabel));
            backgroundColorLabel.Y = Pos.Bottom(backgroundColorPicker) + 1;
            Win.Add(backgroundColorLabel);

            // Demo Label.
            demoLabel   = new Label("Lorem Ipsum");
            demoLabel.X = Pos.Center();
            demoLabel.Y = 1;
            Win.Add(demoLabel);

            // Set default colors.
            backgroundColorPicker.SelectedColor = demoLabel.SuperView.ColorScheme.Normal.Background;
            foregroundColorPicker.SelectedColor = demoLabel.SuperView.ColorScheme.Normal.Foreground;
        }
Esempio n. 29
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 [] {
                    miWrap = new MenuItem("_Word Wrap", "", () => WordWrap())
                    {
                        CheckType = MenuItemCheckStyle.Checked
                    },
                    new MenuItem("_Quit", "", () => Quit()),
                })
            });

            Top.Add(menu);

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

            textView.Init();

            textView.Text = "SELECT TOP 100 * \nfrom\n MyDb.dbo.Biochemistry;";

            Win.Add(textView);

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


            Top.Add(statusBar);
        }
Esempio n. 30
0
        public override void Setup()
        {
            int    i   = 1;
            string txt = "Hello world, how are you doing today?";

            var alignments = Enum.GetValues(typeof(Terminal.Gui.TextAlignment)).Cast <Terminal.Gui.TextAlignment> ().ToList();

            foreach (var alignment in alignments)
            {
                Win.Add(new Label($"{alignment}:")
                {
                    Y = ++i
                });
                Win.Add(new Label(txt)
                {
                    TextAlignment = alignment, Y = i++, Width = Dim.Fill(), ColorScheme = Colors.Dialog
                });
            }

            // Demonstrate that wrapping labels are not yet implemented (#352)
            txt += "\nSecond line";
            Win.Add(new Label($"Demonstrating multi-line (note wrap is not yet implemented):")
            {
                Y = ++i
            });

            foreach (var alignment in alignments)
            {
                Win.Add(new Label($"{alignment}:")
                {
                    Y = ++i
                });
                Win.Add(new Label(txt)
                {
                    TextAlignment = alignment, Y = ++i, Width = Dim.Fill(), Height = 2, ColorScheme = Colors.Dialog
                });
                i += 2;
            }
        }