Exemplo n.º 1
0
        private static void SetupSummonerSearchView()
        {
            var summonerSearchInfoWindow = new FrameView("Find summoner")
            {
                X = Pos.Percent(0),
                Y = 1, // Leave place for top level menu and Summoner search

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

            UsernameTextField = new TextField("")
            {
                X      = Pos.Center(),
                Y      = Pos.Percent(3),
                Width  = 30,
                Height = 1
            };
            summonerSearchInfoWindow.Add(UsernameTextField);

            var searchSummoner = new Button("Search")
            {
                X = Pos.Center() + 30,
                Y = Pos.Percent(3)
            };

            searchSummoner.Clicked += SearchButtonClickedHandler;

            summonerSearchInfoWindow.Add(searchSummoner);
            SummonerSearchView = summonerSearchInfoWindow;
        }
Exemplo n.º 2
0
        public override void ConfigureSettingsPane()
        {
            SettingsPane = new FrameView("Settings")
            {
                X           = Pos.Right(LeftPane),
                Y           = 1, // for menu
                Width       = Dim.Fill(),
                Height      = 8,
                CanFocus    = false,
                ColorScheme = Colors.TopLevel,
            };

            _deviceDetailsFrame = new FrameView("Device Details")
            {
                X      = 0,
                Y      = 0,
                Height = 6,
                Width  = Dim.Percent(50),
            };
            SettingsPane.Add(_deviceDetailsFrame);

            _deviceLocationFrame = new FrameView("Device Location")
            {
                X      = Pos.Right(_deviceDetailsFrame),
                Y      = Pos.Y(_deviceDetailsFrame),
                Height = 6,
                Width  = Dim.Percent(50),
            };

            SettingsPane.Add(_deviceLocationFrame);
            ConfigureHostPane("");
        }
Exemplo n.º 3
0
        private void RenderListBox(XListBox listBox)
        {
            var result = new FrameView()
            {
                Title = listBox.Title,
                X     = Pos.Left(this) + listBox.Left + _left,
            };

            var list = new ListView
            {
                Width  = Dim.Fill(),
                Height = Dim.Fill(),
            };

            list.SelectedItemChanged += List_SelectedItemChanged;

            if (Binder.IsBindable(listBox.ItemSourceProperty))
            {
                list.SetSource(_binder.GetList(listBox.ItemSourceProperty));
            }
            if (Binder.IsBindable(listBox.SelectedIndex))
            {
                list.SelectedItem = Convert.ToInt32(_binder.GetBindedText(listBox.SelectedIndex));
                _binder.Register(listBox, list, typeof(int));
            }

            result.Add(list);
            result.Height = Dim.Fill();
            UiPage.SetWidth(result, listBox);

            Add(result);
            _left += Pos.Right(result);
        }
Exemplo n.º 4
0
        private void RenderTextBox(XTextBox textBox)
        {
            var result = new FrameView()
            {
                X = Pos.Left(this) + textBox.Left + _left,
            };

            var text = new TextView
            {
                Width    = Dim.Fill(),
                Height   = Dim.Fill(),
                ReadOnly = textBox.IsReadonly
            };

            if (Binder.IsBindable(textBox.Text))
            {
                text.Text = _binder.GetBindedText(textBox.Text);
                _binder.Register(textBox, text, typeof(string));
            }
            else
            {
                text.Text = textBox.Text;
            }

            result.Add(text);
            result.Height = Dim.Fill();
            UiPage.SetWidth(result, textBox);

            Add(result);
            _left += Pos.Right(result);
        }
Exemplo n.º 5
0
        public void CanFocus_Faced_With_Container()
        {
            var t = new Toplevel();
            var w = new Window();
            var f = new FrameView();
            var v = new View()
            {
                CanFocus = true
            };

            f.Add(v);
            w.Add(f);
            t.Add(w);

            Assert.True(t.CanFocus);
            Assert.True(w.CanFocus);
            Assert.True(f.CanFocus);
            Assert.True(v.CanFocus);

            f.CanFocus = false;
            Assert.False(f.CanFocus);
            Assert.True(v.CanFocus);

            v.CanFocus = false;
            Assert.False(f.CanFocus);
            Assert.False(v.CanFocus);

            v.CanFocus = true;
            Assert.False(f.CanFocus);
            Assert.True(v.CanFocus);
        }
Exemplo n.º 6
0
        public void PosCombine_Will_Throws()
        {
            Application.Init(new FakeDriver(), new FakeMainLoop(() => FakeConsole.ReadKey(true)));

            var t = Application.Top;

            var w = new Window("w")
            {
                X = Pos.Left(t) + 2,
                Y = Pos.Top(t) + 2
            };
            var f  = new FrameView("f");
            var v1 = new View("v1")
            {
                X = Pos.Left(w) + 2,
                Y = Pos.Top(w) + 2
            };
            var v2 = new View("v2")
            {
                X = Pos.Left(v1) + 2,
                Y = Pos.Top(v1) + 2
            };

            f.Add(v1);              // v2 not added
            w.Add(f);
            t.Add(w);

            f.X = Pos.X(v2) - Pos.X(v1);
            f.Y = Pos.Y(v2) - Pos.Y(v1);

            Assert.Throws <InvalidOperationException> (() => Application.Run());
            Application.Shutdown();
        }
Exemplo n.º 7
0
    static View CreateProcessArea()
    {
        var text = new ReadOnlyTextView()
        {
            Width  = Dim.Fill(),
            Height = Dim.Fill()
        };

        text.Text =
            @"PID USER      PR  NI    VIRT    RES    SHR S  %CPU %MEM     TIME+ COMMAND
    1 root      20   0    8892    308    272 S   0.0  0.0   0:00.12 init
    5 root      20   0    8908    224    172 S   0.0  0.0   0:00.00 init
    6 pablo     20   0   16276   3792   3520 S   0.0  0.0   0:00.54 bash
   74 root      20   0    8908    224    172 S   0.0  0.0   0:00.01 init
   75 pablo     20   0   16260   3648   3544 S   0.0  0.0   0:00.11 bash
   92 pablo     20   0   14560   1544   1072 R   0.0  0.0   0:00.00 top";

        text.ReadOnly = true;

        FrameView frame = new FrameView("Process list");

        frame.Add(text);

        return(frame);
    }
Exemplo n.º 8
0
        public void PosCombine_Will_Throws()
        {
            Application.Init(new FakeDriver(), new FakeMainLoop(() => FakeConsole.ReadKey(true)));

            var t = Application.Top;

            var w = new Window("w")
            {
                Width  = Dim.Width(t) - 2,
                Height = Dim.Height(t) - 2
            };
            var f  = new FrameView("f");
            var v1 = new View("v1")
            {
                Width  = Dim.Width(w) - 2,
                Height = Dim.Height(w) - 2
            };
            var v2 = new View("v2")
            {
                Width  = Dim.Width(v1) - 2,
                Height = Dim.Height(v1) - 2
            };

            f.Add(v1);              // v2 not added
            w.Add(f);
            t.Add(w);

            f.Width  = Dim.Width(t) - Dim.Width(v2);
            f.Height = Dim.Height(t) - Dim.Height(v2);

            Assert.Throws <InvalidOperationException> (() => Application.Run());
            Application.Shutdown();
        }
Exemplo n.º 9
0
        public void FocusNearestView_Ensure_Focus_Ordered()
        {
            var top = new Toplevel();

            var win        = new Window();
            var winSubview = new View("WindowSubview")
            {
                CanFocus = true
            };

            win.Add(winSubview);
            top.Add(win);

            var frm        = new FrameView();
            var frmSubview = new View("FrameSubview")
            {
                CanFocus = true
            };

            frm.Add(frmSubview);
            top.Add(frm);

            top.ProcessKey(new KeyEvent(Key.Tab, new KeyModifiers()));
            Assert.Equal($"WindowSubview", top.MostFocused.Text);
            top.ProcessKey(new KeyEvent(Key.Tab, new KeyModifiers()));
            Assert.Equal("FrameSubview", top.MostFocused.Text);
            top.ProcessKey(new KeyEvent(Key.Tab, new KeyModifiers()));
            Assert.Equal($"WindowSubview", top.MostFocused.Text);

            top.ProcessKey(new KeyEvent(Key.BackTab | Key.ShiftMask, new KeyModifiers()));
            Assert.Equal("FrameSubview", top.MostFocused.Text);
            top.ProcessKey(new KeyEvent(Key.BackTab | Key.ShiftMask, new KeyModifiers()));
            Assert.Equal($"WindowSubview", top.MostFocused.Text);
        }
Exemplo n.º 10
0
        private void ConfigureCapabilityPane(CapabilitySummary selectedCapability)
        {
            _componentFrame = new FrameView()
            {
                X           = 0,
                Y           = 0,
                Height      = Dim.Fill(),
                Width       = Dim.Fill(),
                Title       = $"Capability Details",
                ColorScheme = Colors.TopLevel
            };

            _capabilityPresentationJsonView = new TextView()
            {
                Y           = 0,
                X           = 0,
                Width       = Dim.Fill(),
                Height      = Dim.Fill(),
                ReadOnly    = true,
                ColorScheme = Colors.Dialog,
            };
            GetCapabilityPresentation(selectedCapability);
            _componentFrame.Add(_capabilityPresentationJsonView);
            HostPane.Add(_componentFrame);

            _capabilityPresentationJsonView.SetFocus();

            HostPane.ColorScheme = Colors.TopLevel;
        }
Exemplo n.º 11
0
        private void InitView()
        {
            var ChatHistoryFrame = new FrameView(new Rect(1, 1, 45, 22), "History: ");

            ChatHistory = new Label(new Rect(1, 1, 40, 18), "");

            ChatHistoryFrame.Add(ChatHistory);

            var MessageInputFrame = new FrameView(new Rect(1, 23, 30, 5), "Message: ");

            MessageInput = new TextField(1, 1, 25, "");
            MessageInputFrame.Add(MessageInput);

            SendButton          = new Button(32, 23, "Send");
            SendButton.Clicked += new Action(() =>
            {
                var message = MessageInput.Text.ToString();

                if (SendClicked != null && !String.IsNullOrEmpty(message))
                {
                    SendClicked.Invoke(new MessageToSend {
                        To = Contact, Content = message
                    });
                    ChatHistory.Text += message + "\n";

                    MessageInput.Text = "";
                }
            });

            Add(ChatHistoryFrame);
            Add(MessageInputFrame);
            Add(SendButton);
        }
Exemplo n.º 12
0
        View CreateClass(Type type)
        {
            // Instantiate view
            var view = (View)Activator.CreateInstance(type);

            //_curView.X = Pos.Center ();
            //_curView.Y = Pos.Center ();
            view.Width  = Dim.Percent(75);
            view.Height = Dim.Percent(75);

            // Set the colorscheme to make it stand out
            view.ColorScheme = Colors.Base;

            // If the view supports a Text property, set it so we have something to look at
            if (view.GetType().GetProperty("Text") != null)
            {
                try {
                    view.GetType().GetProperty("Text")?.GetSetMethod()?.Invoke(view, new [] { ustring.Make("Test Text") });
                } catch (TargetInvocationException e) {
                    MessageBox.ErrorQuery("Exception", e.InnerException.Message, "Ok");
                    view = null;
                }
            }

            // If the view supports a Title property, set it so we have something to look at
            if (view != null && view.GetType().GetProperty("Title") != null)
            {
                view?.GetType().GetProperty("Title")?.GetSetMethod()?.Invoke(view, new [] { ustring.Make("Test Title") });
            }

            // If the view supports a Source property, set it so we have something to look at
            if (view != null && view.GetType().GetProperty("Source") != null && view.GetType().GetProperty("Source").PropertyType == typeof(Terminal.Gui.IListDataSource))
            {
                var source = new ListWrapper(new List <ustring> ()
                {
                    ustring.Make("Test Text #1"), ustring.Make("Test Text #2"), ustring.Make("Test Text #3")
                });
                view?.GetType().GetProperty("Source")?.GetSetMethod()?.Invoke(view, new [] { source });
            }

            // Set Settings
            _computedCheckBox.Checked = view.LayoutStyle == LayoutStyle.Computed;

            // Add
            _hostPane.Add(view);
            //DimPosChanged ();
            _hostPane.LayoutSubviews();
            _hostPane.Clear();
            _hostPane.SetNeedsDisplay();
            UpdateSettings(view);
            UpdateTitle(view);

            view.LayoutComplete += LayoutCompleteHandler;

            return(view);
        }
Exemplo n.º 13
0
    static View CreateCpuArea()
    {
        var progressColorScheme = new ColorScheme();

        progressColorScheme.Normal = Terminal.Gui.Attribute.Make(Color.BrightGreen, Color.Black);
        progressColorScheme.Focus  = Terminal.Gui.Attribute.Make(Color.White, Color.DarkGray);

        var labelColorScheme = new ColorScheme();

        labelColorScheme.Normal = Terminal.Gui.Attribute.Make(Color.BrighCyan, Color.Black);

        var cores = new List <HtopProgressBar>();

        FrameView frame = new FrameView("CPU");

        for (int i = 0; i < 8; ++i)
        {
            var labelCore = new Label(i + ":")
            {
                X           = 0,
                Y           = i,
                ColorScheme = labelColorScheme
            };

            var core = new HtopProgressBar()
            {
                X           = Pos.Right(labelCore) + 1,
                Y           = i,
                Height      = 1,
                Width       = Dim.Fill(),
                ColorScheme = progressColorScheme
            };

            cores.Add(core);

            frame.Add(labelCore, core);
        }

        Random rnd = new Random();

        bool timer(MainLoop caller)
        {
            foreach (var core in cores)
            {
                core.Fraction = (float)rnd.NextDouble();
            }

            return(true);
        }

        Application.MainLoop.AddTimeout(TimeSpan.FromMilliseconds(600), timer);

        return(frame);
    }
Exemplo n.º 14
0
        private void InitTime()
        {
            timeFrame.X      = Pos.Percent(30);
            timeFrame.Y      = 3;
            timeFrame.Width  = Dim.Percent(43);
            timeFrame.Height = Dim.Fill();

            timeListView.CanFocus = true;

            timeFrame.Add(timeListView);
            this.Add(timeFrame);
        }
Exemplo n.º 15
0
        private void InitDate()
        {
            dateFrame.X      = 0;
            dateFrame.Y      = 3;
            dateFrame.Width  = Dim.Percent(30);
            dateFrame.Height = Dim.Fill();

            dateListView.CanFocus      = true;
            dateListView.AllowsMarking = true;

            dateFrame.Add(dateListView);
            this.Add(dateFrame);
        }
Exemplo n.º 16
0
        private void InitResultsView()
        {
            resultsFrame.X      = 0;
            resultsFrame.Y      = 3;
            resultsFrame.Width  = Dim.Fill();
            resultsFrame.Height = Dim.Fill();

            resultsView.CanFocus      = true;
            resultsView.AllowsMarking = true;

            resultsFrame.Add(resultsView);
            this.Add(resultsFrame);
        }
Exemplo n.º 17
0
        static FrameView GenFrame(int yCoord)
        {
            var optionsArr = new[] { "One", "Two", "Three" };
            var frame      = new FrameView("A generated frame")
            {
                X      = 1,
                Y      = yCoord,
                Width  = 60,
                Height = optionsArr.Length + 6
            };
            var categoryRadio = new RadioGroup(1, 1, optionsArr);

            frame.Add(categoryRadio);
            frame.Add(new Button("Check")
            {
                Y      = optionsArr.Length + 2,
                X      = 1,
                Width  = 7,
                Height = 1
            });
            return(frame);
        }
Exemplo n.º 18
0
        private static void SetupChampionSearch()
        {
            var summonerSearchInfoWindow = new FrameView("Item search and filtering")
            {
                X = Pos.Percent(0),
                Y = 1, // Leave place for top level menu and Summoner search

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

            ItemName = new TextField("")
            {
                X      = Pos.Left(summonerSearchInfoWindow),
                Y      = Pos.Percent(3),
                Width  = 30,
                Height = 1
            };

            ItemName.TextChanged += ItemName_TextChanged;
            summonerSearchInfoWindow.Add(ItemName);

            NStack.ustring[] elo  = new NStack.ustring[] { "All   ", "Armor   ", "Damage   ", "SpellDamage   ", "AttackSpeed   ", "Health   ", "Mana   " };
            RadioGroup       test = new RadioGroup(elo)
            {
                X      = Pos.Right(ItemName) + 5,
                Y      = Pos.Percent(3),
                Width  = 40,
                Height = 1
            };

            SelectedFiltering         = 0;
            test.DisplayMode          = DisplayModeLayout.Horizontal;
            test.SelectedItemChanged += FilterItemList;
            TagsRadio = test;
            summonerSearchInfoWindow.Add(test);
            SummonerSearchView = summonerSearchInfoWindow;
        }
Exemplo n.º 19
0
        private void InitInfo()
        {
            infoFrame.X      = Pos.Percent(60);
            infoFrame.Y      = 3;
            infoFrame.Width  = Dim.Fill();
            infoFrame.Height = Dim.Fill();

            infoListView.CanFocus      = true;
            infoListView.AllowsMarking = true;

            infoFrame.Add(infoListView);
            this.Add(infoFrame);
        }
Exemplo n.º 20
0
        public static FrameView FrameView <T>(string text, out T @var, Action <FrameView> attr = null, params View[] children)
            where T : View
        {
            var field = new FrameView(text);

            attr?.Invoke(field);

            if (children?.Any() == true)
            {
                field.Add(children);
            }

            @var = (T)(View)field;
            return(field);
        }
Exemplo n.º 21
0
        public void PosCombine_Do_Not_Throws()
        {
            Application.Init(new FakeDriver(), new FakeMainLoop(() => FakeConsole.ReadKey(true)));

            var t = Application.Top;

            var w = new Window("w")
            {
                X = Pos.Left(t) + 2,
                Y = Pos.Top(t) + 2
            };
            var f  = new FrameView("f");
            var v1 = new View("v1")
            {
                X = Pos.Left(w) + 2,
                Y = Pos.Top(w) + 2
            };
            var v2 = new View("v2")
            {
                X = Pos.Left(v1) + 2,
                Y = Pos.Top(v1) + 2
            };

            f.Add(v1, v2);
            w.Add(f);
            t.Add(w);

            f.X = Pos.X(t) + Pos.X(v2) - Pos.X(v1);
            f.Y = Pos.Y(t) + Pos.Y(v2) - Pos.Y(v1);

            t.Ready += () => {
                Assert.Equal(0, t.Frame.X);
                Assert.Equal(0, t.Frame.Y);
                Assert.Equal(2, w.Frame.X);
                Assert.Equal(2, w.Frame.Y);
                Assert.Equal(2, f.Frame.X);
                Assert.Equal(2, f.Frame.Y);
                Assert.Equal(4, v1.Frame.X);
                Assert.Equal(4, v1.Frame.Y);
                Assert.Equal(6, v2.Frame.X);
                Assert.Equal(6, v2.Frame.Y);
            };

            Application.Iteration += () => Application.RequestStop();

            Application.Run();
            Application.Shutdown();
        }
Exemplo n.º 22
0
        public void DimCombine_Do_Not_Throws()
        {
            Application.Init(new FakeDriver(), new FakeMainLoop(() => FakeConsole.ReadKey(true)));

            var t = Application.Top;

            var w = new Window("w")
            {
                Width  = Dim.Width(t) - 2,
                Height = Dim.Height(t) - 2
            };
            var f  = new FrameView("f");
            var v1 = new View("v1")
            {
                Width  = Dim.Width(w) - 2,
                Height = Dim.Height(w) - 2
            };
            var v2 = new View("v2")
            {
                Width  = Dim.Width(v1) - 2,
                Height = Dim.Height(v1) - 2
            };

            f.Add(v1, v2);
            w.Add(f);
            t.Add(w);

            f.Width  = Dim.Width(t) - Dim.Width(v2);
            f.Height = Dim.Height(t) - Dim.Height(v2);

            t.Ready += () => {
                Assert.Equal(80, t.Frame.Width);
                Assert.Equal(25, t.Frame.Height);
                Assert.Equal(78, w.Frame.Width);
                Assert.Equal(23, w.Frame.Height);
                Assert.Equal(6, f.Frame.Width);
                Assert.Equal(6, f.Frame.Height);
                Assert.Equal(76, v1.Frame.Width);
                Assert.Equal(21, v1.Frame.Height);
                Assert.Equal(74, v2.Frame.Width);
                Assert.Equal(19, v2.Frame.Height);
            };

            Application.Iteration += () => Application.RequestStop();

            Application.Run();
            Application.Shutdown();
        }
Exemplo n.º 23
0
        View CreateClass(Type type)
        {
            // Instantiate view
            var view = (View)Activator.CreateInstance(type);

            //_curView.X = Pos.Center ();
            //_curView.Y = Pos.Center ();
            //_curView.Width = Dim.Fill (5);
            //_curView.Height = Dim.Fill (5);

            // Set the colorscheme to make it stand out
            view.ColorScheme = Colors.Base;

            // If the view supports a Text property, set it so we have something to look at
            if (view.GetType().GetProperty("Text") != null)
            {
                try {
                    view.GetType().GetProperty("Text")?.GetSetMethod()?.Invoke(view, new [] { ustring.Make("Test Text") });
                } catch (TargetInvocationException e) {
                    MessageBox.ErrorQuery("Exception", e.InnerException.Message, "Ok");
                    view = null;
                }
            }

            if (view == null)
            {
                return(null);
            }

            // If the view supports a Title property, set it so we have something to look at
            if (view.GetType().GetProperty("Title") != null)
            {
                view?.GetType().GetProperty("Title")?.GetSetMethod()?.Invoke(view, new [] { ustring.Make("Test Title") });
            }

            // Set Settings
            _computedCheckBox.Checked = view.LayoutStyle == LayoutStyle.Computed;

            // Add
            _hostPane.Add(view);
            //DimPosChanged ();
            _hostPane.LayoutSubviews();
            _hostPane.Clear();
            _hostPane.SetNeedsDisplay();
            UpdateSettings(view);
            UpdateTitle(view);
            return(view);
        }
Exemplo n.º 24
0
        private void ConfigureComponentsStatusPane(Device selectedDevice)
        {
            _componentFrame = new FrameView()
            {
                X           = 0,
                Y           = 0,
                Height      = Dim.Fill(),
                Width       = Dim.Fill(),
                Title       = "main",
                ColorScheme = Colors.TopLevel
            };

            _componentList = new ListView(selectedDevice.Components.FirstOrDefault().Capabilities.Select(c => c.Id).ToList());

            _componentList.X             = 0;
            _componentList.Y             = 0;
            _componentList.Width         = Dim.Percent(30);
            _componentList.Height        = Dim.Fill();
            _componentList.AllowsMarking = false;
            _componentList.ColorScheme   = Colors.TopLevel;

            _componentList.SelectedItemChanged += (args) =>
            {
                _selectedCapabilityIndex = args.Item;
                GetComponentStatus(selectedDevice, args.Item);
            };

            _capabilitiesStatusJsonView = new TextView()
            {
                Y           = 0,
                X           = Pos.Right(_componentList),
                Width       = Dim.Fill(),
                Height      = Dim.Fill(),
                ReadOnly    = true,
                ColorScheme = Colors.Dialog,
            };

            _componentFrame.Add(_componentList, _capabilitiesStatusJsonView);

            HostPane.Add(_componentFrame);

            _componentList.SetFocus();
            GetComponentStatus(selectedDevice, 0);
            HostPane.ColorScheme = Colors.TopLevel;
        }
Exemplo n.º 25
0
        public void CanFocus_Faced_With_Container_After_Run()
        {
            Application.Init(new FakeDriver(), new FakeMainLoop(() => FakeConsole.ReadKey(true)));

            var t = Application.Top;

            var w = new Window("w");
            var f = new FrameView("f");
            var v = new View("v")
            {
                CanFocus = true
            };

            f.Add(v);
            w.Add(f);
            t.Add(w);

            t.Ready += () => {
                Assert.True(t.CanFocus);
                Assert.True(w.CanFocus);
                Assert.True(f.CanFocus);
                Assert.True(v.CanFocus);

                f.CanFocus = false;
                Assert.False(f.CanFocus);
                Assert.False(v.CanFocus);

                v.CanFocus = false;
                Assert.False(f.CanFocus);
                Assert.False(v.CanFocus);

                Assert.Throws <InvalidOperationException> (() => v.CanFocus = true);
                Assert.False(f.CanFocus);
                Assert.False(v.CanFocus);

                f.CanFocus = true;
                Assert.True(f.CanFocus);
                Assert.True(v.CanFocus);
            };

            Application.Iteration += () => Application.RequestStop();

            Application.Run();
            Application.Shutdown();
        }
Exemplo n.º 26
0
        public void CreateUserInterface()
        {
            // Create server info labels
            _serverInfoFrameView = new FrameView {
                Width = Dim.Fill(), Height = 8
            };
            _upTimeLabel = new Label {
                Y = 0, Width = Dim.Fill(), Height = 1
            };
            _fpsLabel = new Label {
                Y = 1, Width = Dim.Fill(), Height = 1
            };
            _stateLabel = new Label {
                Y = 2, Width = Dim.Fill(), Height = 1
            };
            _playersLabel = new Label {
                Y = 3, Width = Dim.Fill(), Height = 1
            };
            _mapLabel = new Label {
                Y = 4, Width = Dim.Fill(), Height = 1
            };
            _modeLabel = new Label {
                Y = 5, Width = Dim.Fill(), Height = 1
            };

            _serverInfoFrameView.Add(_upTimeLabel);
            _serverInfoFrameView.Add(_fpsLabel);
            _serverInfoFrameView.Add(_stateLabel);
            _serverInfoFrameView.Add(_playersLabel);
            _serverInfoFrameView.Add(_mapLabel);
            _serverInfoFrameView.Add(_modeLabel);

            // Create logging/input elements
            _logList      = new List <string>();
            _logsListView = new ListView {
                X = 0, Y = 8, Width = Dim.Fill(), Height = Dim.Fill(1)
            };
            _logsListView.SelectedItemChanged += LogsListView_SelectedItemChanged;
            _logsListView.SetSource(_logList);
            _logSelectedIndex     = 0;
            _logAutoScrollEnabled = true;

            _inputTextField = new TextField {
                X = 0, Y = Pos.AnchorEnd(1), Width = Dim.Fill(), Height = 1
            };
            _inputTextField.EnsureFocus();

            Add(_serverInfoFrameView);
            Add(_logsListView);
            Add(_inputTextField);
        }
Exemplo n.º 27
0
        public void CanFocus_Container_Toggling_All_Subviews_To_Old_Value_When_Is_True()
        {
            Application.Init(new FakeDriver(), new FakeMainLoop(() => FakeConsole.ReadKey(true)));

            var t = Application.Top;

            var w  = new Window("w");
            var f  = new FrameView("f");
            var v1 = new View("v1");
            var v2 = new View("v2")
            {
                CanFocus = true
            };

            f.Add(v1, v2);
            w.Add(f);
            t.Add(w);

            t.Ready += () => {
                Assert.True(t.CanFocus);
                Assert.True(w.CanFocus);
                Assert.True(f.CanFocus);
                Assert.False(v1.CanFocus);
                Assert.True(v2.CanFocus);

                w.CanFocus = false;
                Assert.True(w.CanFocus);
                Assert.False(f.CanFocus);
                Assert.False(v1.CanFocus);
                Assert.False(v2.CanFocus);

                w.CanFocus = true;
                Assert.True(w.CanFocus);
                Assert.True(f.CanFocus);
                Assert.False(v1.CanFocus);
                Assert.True(v2.CanFocus);
            };

            Application.Iteration += () => Application.RequestStop();

            Application.Run();
            Application.Shutdown();
        }
Exemplo n.º 28
0
    public StatView(Rect area, BoardView board) : base(area)
    {
        _board          = board;
        _currentProcess = Process.GetCurrentProcess();

        var frame = new FrameView(new Rect(0, 0, area.Width, area.Height), "Stats");

        var cellHeaderLabel = new Label(0, 0, "Cell Count:");

        _numCellsLabel = new Label(new Rect(0, 1, area.Width - 2, 1), NumCells);
        _numCellsLabel.TextAlignment = TextAlignment.Right;

        var generationsHeaderLabel = new Label(0, 3, "Generation Count:");

        _numGenerationsLabel = new Label(new Rect(0, 4, area.Width - 2, 1), NumGenerations);
        _numGenerationsLabel.TextAlignment = TextAlignment.Right;

        var updateTimeHeaderLabel = new Label(0, 6, "Update Time");

        _updateTimeLabel = new Label(new Rect(0, 7, area.Width - 2, 1), UpdateTime);
        _updateTimeLabel.TextAlignment = TextAlignment.Right;

        var totalMemoryHeaderLabel = new Label(0, 9, "Total Memory:");

        _totalMemoryLabel = new Label(new Rect(0, 10, area.Width - 2, 1), TotalMemory);
        _totalMemoryLabel.TextAlignment = TextAlignment.Right;


        frame.Add(cellHeaderLabel);
        frame.Add(_numCellsLabel);
        frame.Add(generationsHeaderLabel);
        frame.Add(_numGenerationsLabel);
        frame.Add(updateTimeHeaderLabel);
        frame.Add(_updateTimeLabel);
        frame.Add(totalMemoryHeaderLabel);
        frame.Add(_totalMemoryLabel);

        Add(frame);
    }
Exemplo n.º 29
0
        public SyncView(IRepository repository, IHistoryDivergenceService historyDivergenceService)
            : base(Resources.Sync)
        {
            this.repository = repository;
            this.historyDivergenceService = historyDivergenceService;

            aheadListView  = new ListView <Commit>(columnDefinitions);
            aheadFrameView = new FrameView(string.Empty)
            {
                Y = 1, Width = Dim.Percent(50)
            };
            aheadFrameView.Add(aheadListView);

            behindListView  = new ListView <Commit>(columnDefinitions);
            behindFrameView = new FrameView(string.Empty)
            {
                Y = 1, Width = Dim.Percent(100)
            };
            behindFrameView.Add(behindListView);

            Content = new StackPanel(StackPanelOrientation.Horizontal, aheadFrameView, behindFrameView);
        }
Exemplo n.º 30
0
        private static void SetupMatchHistoryView()
        {
            var matchHistoryWindow = new FrameView("Match History")
            {
                X = Pos.Percent(35),
                Y = Pos.Percent(10) + 1, // Leave place for top level menu and Summoner search

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

            MatchHistoryListView = new ListView()
            {
                X      = 0,
                Y      = 0,
                Width  = Dim.Fill(),
                Height = Dim.Fill()
            };

            matchHistoryWindow.Add(MatchHistoryListView);
            MatchHistoryView = matchHistoryWindow;
        }