Esempio n. 1
0
        private async void InitAsync()
        {
            InitLayout();
            InitListView();
            InitChart();
            InitSelectionHandlers();
            InitMinSizeEnforcer();


            var start = DateTime.Now;

            while (true)
            {
                var now = DateTime.Now;
                chartOptions.XMinOverride = now.AddSeconds(-30).Ticks;
                chartOptions.XMaxOverride = now.Ticks;
                for (var i = 0; i < resources.Count; i++)
                {
                    ScopeDataToLast30Seconds(now, i);

                    var sample = resources[i].GetSample();
                    data[i].Add(new DataPoint()
                    {
                        X = now.Ticks, Y = sample
                    });
                }
                listView.Refresh();
                chart.Refresh();
                await Task.Delay(50);
            }
        }
Esempio n. 2
0
 /// <summary>スレッド完了(必要ならスレッド再起動)
 /// </summary>
 /// <param name="sender">イベントの発生したオブジェクト</param>
 /// <param name="e">発生したイベント</param>
 private void backgroundWorker1_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
 {
     ListGrid.RowCount = TimeTable.EvaluationItems.Count;
     if (contwrk)
     {
         ListGrid.Refresh();
         contwrk = false;
         Run();
     }
     else
     {
         ListGrid.Refresh();
     }
 }
Esempio n. 3
0
        public void TestDataGridRefresh()
        {
            var items = new List <Item>();

            for (var i = 0; i < 100; i++)
            {
                items.Add(new Item()
                {
                    Bar = "Bar" + i,
                    Foo = "Foo" + i,
                });
            }

            var app = new CliTestHarness(TestContext, 80, 20, true)
            {
                SecondsBetweenKeyframes = .05
            };

            var dataGrid = new ListGrid <Item>(new ListGridOptions <Item>()
            {
                DataSource = new SyncList <Item>(items),
                Columns    = new List <ListGridColumnDefinition <Item> >()
                {
                    new ListGridColumnDefinition <Item>()
                    {
                        Header    = "Foo".ToGreen(),
                        Width     = 20,
                        Type      = GridValueType.Pixels,
                        Formatter = (item) => new Label()
                        {
                            Text = item.Foo.ToConsoleString()
                        }
                    },
                    new ListGridColumnDefinition <Item>()
                    {
                        Header    = "Bar".ToRed(),
                        Width     = 1,
                        Type      = GridValueType.RemainderValue,
                        Formatter = (item) => new Label()
                        {
                            Text = item.Bar.ToConsoleString()
                        }
                    }
                }
            });

            app.InvokeNextCycle(async() =>
            {
                var selectionLabel = app.LayoutRoot.Add(new Label()
                {
                    Text = "DEFAULT".ToConsoleString(), Height = 1
                }).CenterHorizontally();
                selectionLabel.Text = $"SelectedRowIndex: {dataGrid.SelectedRowIndex}, SelectedCellIndex: {dataGrid.SelectedColumnIndex}".ToConsoleString();
                dataGrid.SelectionChanged.SubscribeForLifetime(() =>
                {
                    selectionLabel.Text = $"SelectedRowIndex: {dataGrid.SelectedRowIndex}, SelectedCellIndex: {dataGrid.SelectedColumnIndex}".ToConsoleString();
                }, dataGrid);
                app.LayoutRoot.Add(dataGrid).Fill(padding: new Thickness(0, 0, 1, 0));
                await app.PaintAndRecordKeyFrameAsync();

                for (var i = 0; i < 100; i++)
                {
                    items[i].Foo = "FooRefreshed" + i;
                    items[i].Bar = "BarRefreshed" + i;
                }

                dataGrid.Refresh();
                await app.PaintAndRecordKeyFrameAsync();

                app.Stop();
            });

            app.Start().Wait();
            app.AssertThisTestMatchesLKG();
        }