/// <summary>
        /// Starts this instance.
        /// </summary>
        public void Start()
        {
            if (IsStarted)
            {
                return;
            }

            IsStarted = true;

            dialog = new Dialog(applicationName, toplevel.Frame.Width - 2, toplevel.Frame.Height - 1);

            progress = new ProgressBar()
            {
                X      = Pos.Center(),
                Y      = Pos.Center(),
                Height = 1,
                Width  = Dim.Percent(50),
            };

            label = new Label(initialText)
            {
                X      = Pos.Center(),
                Y      = Pos.Center() + 1,
                Height = 1,
                Width  = Dim.Percent(50)
            };

            dialog.Add(progress, label);

            runState = Application.Begin(dialog);

            Application.RunLoop(runState, false);
        }
Пример #2
0
 public AdvancedConsoleExecutionDisplay()
 {
     _consoleApp = new App();
     _runToken   = Application.Begin(_consoleApp);
     Task.Run(() => Application.RunLoop(_runToken));
     _timer           = new System.Timers.Timer(1000);
     _timer.Elapsed  += RefreshData;
     _timer.AutoReset = true;
     _timer.Enabled   = true;
 }
Пример #3
0
		public void RunState_Dispose_Cleans_Up ()
		{
			var rs = new Application.RunState (null);
			Assert.NotNull (rs);

			// Should not throw because Toplevel was null
			rs.Dispose ();

			var top = new Toplevel ();
			rs = new Application.RunState (top);
			Assert.NotNull (rs);

			// Should throw because there's no stack
			Assert.Throws<InvalidOperationException> (() => rs.Dispose ());
		}
Пример #4
0
        public static void Init()
        {
            Application.Init();
            Colors.Base.Normal = Application.Driver.MakeAttribute(Color.BrightGreen, Color.Black);
            Colors.Base.Focus  = Application.Driver.MakeAttribute(Color.BrightGreen, Color.Black);

            if (Window == null)
            {
                Window = new Typing.DisplayWindow("NetRPG")
                {
                    X      = 0,
                    Y      = 0,
                    Width  = 80,
                    Height = 24
                };

                Window.ColorScheme = Colors.Base;
            }

            State = Application.Begin(Application.Top);
        }
Пример #5
0
        public static void Show(int waitTimeInSeconds)
        {
            string message      = $"The program will wait {waitTimeInSeconds} seconds and then retry the request.";
            int    messageWidth = TextFormatter.MaxWidth(message, 50);

            if (_internalDialog != null)
            {
                _internalDialog.Height = TextFormatter.MaxLines(message, messageWidth) + 2;
                _internalDialog.Width  = Math.Max(50, Math.Max(_internalDialog.Title.RuneCount + 8, messageWidth + 4 + 8));
                _dialogLabel.Text      = message;
                Application.RunLoop(_runState, false);
                return;
            }

            _internalDialog = new Dialog
            {
                Title       = "You are being ratelimited",
                Height      = TextFormatter.MaxLines(message, messageWidth) + 2,
                ColorScheme = Colors.Error,
            };

            _internalDialog.Width = Math.Max(50, Math.Max(_internalDialog.Title.RuneCount + 8, messageWidth + 4 + 8));

            _dialogLabel = new Label(0, 1, message)
            {
                LayoutStyle   = LayoutStyle.Computed,
                TextAlignment = TextAlignment.Centered,
                X             = Pos.Center(),
                Y             = Pos.Center(),
                Width         = Dim.Fill(2),
                Height        = Dim.Fill()
            };

            _internalDialog.Add(_dialogLabel);

            _runState = Application.Begin(_internalDialog);
            Application.RunLoop(_runState, false);
        }