Example #1
0
        public void FrameViewDiscardClause()
        {
            FrameView original = GetTestFrame();

            FrameView filtered = original.Discard(original.Columns[0].Name);

            Assert.IsTrue(filtered.Columns.Count == original.Columns.Count - 1);
            Assert.IsTrue(filtered.Rows.Count == original.Rows.Count);

            for (int i = 0; i < filtered.Columns.Count; i++)
            {
                Assert.IsTrue(filtered.Columns[i].Name == original.Columns[i + 1].Name);
            }
        }
Example #2
0
        private static void SetupItemDetails()
        {
            var itemInfoView = new FrameView("Item Details")
            {
                X = Pos.Percent(50),
                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.Fill(),
                Height = 12
            };

            ItemDetailsView = itemInfoView;
        }
Example #3
0
        private static void SetupSummonerInfo()
        {
            var summonerInfoWindow = new FrameView("Summoner Information")
            {
                X = Pos.Percent(0),
                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(35),
                Height = Dim.Fill()
            };

            SummonerInfoView = summonerInfoWindow;
        }
Example #4
0
    static void ClearForm(View container, FrameView frame)
    {
        GetAllViews <TextField> (container)
        .ForEach((TextField textField) => textField.Text = string.Empty);
        var recordType = GetAllViews <RadioGroup> (container)
                         .FirstOrDefault(r => r.Id == "recordType");

        recordType.Selected = 0;

        var newsletter = GetAllViews <CheckBox> (container)
                         .FirstOrDefault(r => r.Id == "newsletter");

        newsletter.Checked = true;
        container.Remove(frame);
    }
Example #5
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);
        }
Example #6
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();
        }
Example #7
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();
        }
Example #8
0
        public void InvalidateTemplate()
        {
            if (GridView.InvalidateVisual != null)
            {
                GridView.InvalidateVisual();
            }

            if (TableView.InvalidateVisual != null)
            {
                TableView.InvalidateVisual();
            }

            if (FrameView.InvalidateVisual != null)
            {
                FrameView.InvalidateVisual();
            }
        }
Example #9
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;
        }
Example #10
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();
        }
Example #11
0
        public void Smoketest()
        {
            FrameTable frame;
            string     url     = "https://raw.githubusercontent.com/pandas-dev/pandas/master/doc/data/tips.csv";
            WebRequest request = WebRequest.Create(url);

            using (WebResponse response = request.GetResponse()) {
                using (Stream responseStream = response.GetResponseStream()) {
                    using (TextReader reader = new StreamReader(responseStream)) {
                        frame = FrameTable.FromCsv(reader);
                    }
                }
            }
            frame.AddComputedColumn("tip_fraction", r => ((double)r["tip"]) / ((double)r["total_bill"]));

            FrameView counts = frame.GroupBy("day", v => v.Rows.Count, "total").OrderBy("day");
            FrameView means  = frame.GroupBy("sex", v => v["tip_fraction"].As <double>().Mean(), "mean_tip_fraction");
        }
Example #12
0
    static void NewMember(View container, FrameView frame)
    {
        var d = new Dialog(
            "New Member", 40, 6,
            new Button("Ok", is_default: true)
        {
            Clicked = () => {
                ClearForm(container, frame);
                Application.RequestStop();
            }
        },
            new Button("Cancel")
        {
            Clicked = () => { Application.RequestStop(); }
        });

        Application.Run(d);
    }
Example #13
0
        public virtual void ConfigureHostPane(string title)
        {
            Pos settingsY = 1;

            if (SettingsPane?.Subviews.Count > 0)
            {
                settingsY = Pos.Bottom(SettingsPane);
            }

            HostPane = new FrameView(title)
            {
                X           = Pos.Right(LeftPane),
                Y           = settingsY,
                Width       = Dim.Fill(),
                Height      = Dim.Fill(), // + 1 for status bar
                ColorScheme = Colors.Dialog,
            };
            ConfigureJsonPane();
        }
Example #14
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();
        }
Example #15
0
        public void FrameViewOrderByColumn()
        {
            FrameView original = GetTestFrame();

            string columnName = "bmi";

            FrameView reordered = original.OrderBy(columnName, SortOrder.Descending);

            Assert.IsTrue(reordered.Columns.Count == original.Columns.Count);
            Assert.IsTrue(reordered.Rows.Count == original.Rows.Count);

            int columnIndex = reordered.GetColumnIndex(columnName);

            for (int i = 1; i < reordered.Rows.Count; i++)
            {
                IComparable previous = (IComparable)reordered[i - 1, columnIndex];
                IComparable current  = (IComparable)reordered[i, columnIndex];
                Assert.IsTrue(previous.CompareTo(current) >= 0);
            }
        }
Example #16
0
        public virtual void ShowImportFileMenu()
        {
            FilePicker = new FrameView("Select file")
            {
                X           = 0,
                Y           = 0,
                Width       = Dim.Fill(),
                Height      = Dim.Percent(75),
                ColorScheme = Colors.Menu
            };

            FilePicker.Leave += (args) =>
            {
                LeftPane.Remove(FilePicker);
                FilePicker = null;
            };

            GetDirectoriesAndFileView(Directory.GetCurrentDirectory());
            LeftPane.Add(FilePicker);
            FilePicker.SetFocus();
        }
Example #17
0
        public void FrameViewOrderByColumnWithNulls()
        {
            FrameView original = GetTestFrame();

            // This should support nulls
            FrameView reordered = original.OrderBy("name");

            Assert.IsTrue(reordered.Columns.Count == original.Columns.Count);
            Assert.IsTrue(reordered.Rows.Count == original.Rows.Count);

            List <string> reorderedCopy = original["name"].As <string>().ToList();

            reorderedCopy.Sort();

            IReadOnlyList <string> reorderedColumn = reordered["name"].As <string>();

            for (int i = 0; i < reorderedColumn.Count; i++)
            {
                Assert.IsTrue(reorderedColumn[i] == reorderedCopy[i]);
            }
        }
Example #18
0
        public void FrameViewOrderByAgreement()
        {
            FrameView view = GetTestFrame();

            FrameView sorted1 = view.OrderBy("bmi");
            FrameView sorted2 = view.OrderBy("bmi", SortOrder.Descending);
            FrameView sorted3 = view.OrderBy <double>("bmi", (v1, v2) => v1.CompareTo(v2));
            FrameView sorted4 = view.OrderBy((r1, r2) => ((double)r1["bmi"]).CompareTo((double)r2["bmi"]));

            List <double> sorted = view["bmi"].As <double>().ToList();

            sorted.Sort();

            for (int i = 0; i < sorted.Count; i++)
            {
                Assert.IsTrue(sorted1["bmi"].As <double>()[i] == sorted[i]);
                Assert.IsTrue(sorted2["bmi"].As <double>()[sorted.Count - 1 - i] == sorted[i]);
                Assert.IsTrue(sorted3["bmi"].As <double>()[i] == sorted[i]);
                Assert.IsTrue(sorted4["bmi"].As <double>()[i] == sorted[i]);
            }
        }
Example #19
0
 private void ToggleComponentStatus()
 {
     if (SelectedItem != null)
     {
         if (_componentFrame != null)
         {
             HostPane.Remove(_componentFrame);
             HostPane.Remove(_componentList);
             HostPane.Remove(_capabilitiesStatusJsonView);
             _componentFrame             = null;
             _componentList              = null;
             _capabilitiesStatusJsonView = null;
             ClassListView.SetFocus();
         }
         else
         {
             Device selectedDevice = (Device)SelectedItem;
             ConfigureComponentsStatusPane(selectedDevice);
         }
     }
 }
 private void ToggleCapability()
 {
     if (SelectedItem != null)
     {
         if (_componentFrame != null)
         {
             HostPane.Remove(_componentFrame);
             HostPane.Remove(_componentList);
             HostPane.Remove(_capabilityPresentationJsonView);
             _componentFrame = null;
             _componentList  = null;
             _capabilityPresentationJsonView = null;
             ClassListView.SetFocus();
         }
         else
         {
             CapabilitySummary selectedCapability = (CapabilitySummary)SelectedItem;
             ConfigureCapabilityPane(selectedCapability);
         }
     }
 }
Example #21
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);
        }
Example #22
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;
        }
Example #23
0
        public void FrameViewGroupByClause()
        {
            FrameView original = GetTestFrame();

            HashSet <bool?> values = new HashSet <bool?>(original["male"].As <bool?>().Distinct());

            FrameTable grouped = original.GroupBy("male", v => v["height"].As <double>().Mean(), "meanHeight");

            Assert.IsTrue(grouped.Rows.Count == values.Count);

            foreach (FrameRow row in grouped.Rows)
            {
                bool?value = (bool?)row["male"];
                Assert.IsTrue(values.Contains(value));
                // r["male"] == value doesn't work, because this is an object comparison,
                // and two equal values boxed to objects are not equal. This is a problem.
                //DataView selected = original.Where<bool?>("male", m => m.Equals(value));
                FrameView selected = original.Where(r => (bool?)r["male"] == value);
                double    height   = selected["height"].As <double>().Mean();
                Assert.IsTrue((double)row["meanHeight"] == height);
            }
        }
Example #24
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);
    }
Example #25
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);
        }
Example #26
0
        private static void SetupItemList()
        {
            var itemListWindow = new FrameView("Items")
            {
                X = Pos.Percent(20),
                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(30),
                Height = Dim.Fill()
            };

            ItemListWindow = itemListWindow;


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

            itemListView.SetSource(LeagueUtilities.GetItemListElements());
            ItemListView = itemListView;

            ItemListWindow.Add(itemListView);
            itemListView.SelectedItemChanged += SetItemDetails;
            itemListView.OpenSelectedItem    += ItemListView_OpenSelectedItem;
            //ItemView.ColorScheme = Colors.Dialog;
            //for (int i = 0; i < championsListView.Source.Count-1; i++)
            //{
            //    if (championsListView.Source.IsMarked(i))
            //    {
            //        championsListView.Source.ToList()[i]
            //    }
            //}
        }
Example #27
0
    void SetVertexAtPosition(CameraSpacePoint vertex, Transform vertexTransform, FrameView frameView)
    {
        Vector2 position = vertex.ToPoint(visualization, coordinateMapper);

        if (float.IsInfinity(position.x) || float.IsInfinity(position.y))
        {
            if (vertexTransform.gameObject.activeSelf)
            {
                vertexTransform.gameObject.SetActive(false);
            }
        }
        else
        {
            frameView.SetPositionOnFrame(ref position);

            if (!vertexTransform.gameObject.activeSelf)
            {
                vertexTransform.gameObject.SetActive(true);
            }

            vertexTransform.localPosition = position;
        }
    }
Example #28
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;
        }
Example #29
0
        private static (FrameView frame, ListView list) BuildListFrameView(
            string name,
            View?relativeTo = null,
            bool canFocus   = false
            )
        {
            var frame = new FrameView(name)
            {
                X                           = relativeTo != null?Pos.Right(relativeTo) : null,
                                     Width  = Dim.Fill(),
                                     Height = Dim.Fill()
            };

            var list = new ListView(Array.Empty <string>())
            {
                AllowsMarking = false,
                CanFocus      = canFocus
            };

            frame.Add(list);

            return(frame, list);
        }
Example #30
0
        public override void ConfigureSettingsPane()
        {
            SettingsPane = new FrameView("Settings")
            {
                Id          = "Settings",
                X           = Pos.Right(LeftPane),
                Y           = 1, // for menu
                Width       = Dim.Fill(),
                Height      = 8,
                CanFocus    = true,
                ColorScheme = Colors.TopLevel,
            };

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

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

            SettingsPane.Add(_deviceLocationFrame);
            ConfigureHostPane("");
        }