Esempio n. 1
0
        private void InitGridView()
        {
            MoreDataMessage = "more data below".ToConsoleString(DefaultColors.H1Color);
            this.KeyInputReceived.SubscribeForLifetime(OnKeyInputReceived, this);

            this.filterTextDebouncer = new TimerActionDebouncer(TimeSpan.FromSeconds(0), () =>
            {
                if (Application != null && FilterTextBox != null)
                {
                    Application.InvokeNextCycle(() =>
                    {
                        FilterText = FilterTextBox.Value.ToString();
                    });
                }
            });

            // don't accept focus unless I have at least one item in the data view
            this.Focused.SubscribeForLifetime(() =>
            {
                if (DataView.Items.Count == 0)
                {
                    Application.FocusManager.TryMoveFocus();
                }
            }, this);
        }
Esempio n. 2
0
        private void DebounceResize()
        {
            console.Clear();
            bool done      = false;
            var  debouncer = new TimerActionDebouncer(TimeSpan.FromSeconds(.25), () =>
            {
                done = true;
            });

            debouncer.Trigger();
            while (done == false)
            {
                if (console.BufferWidth != lastConsoleWidth || console.WindowHeight != lastConsoleHeight)
                {
                    lastConsoleWidth  = console.BufferWidth;
                    lastConsoleHeight = console.WindowHeight;
                    debouncer.Trigger();
                }
            }
        }