Пример #1
0
        public void Run(Form f)
        {
            Terminal.SetScreenSize(ScreenSize.Width, ScreenSize.Height);

start:

            try
            {
                MainForm = f;

                _show(f);

                Terminal.Clear();
                PerformPaint();

                // Start the message loop
                Message msg = null;
                _currentApp = this;

                while ((MessageQueue.GetMessage(ref msg)))
                {
                    if (msg.MessageType == WM_MessageType.WM_KEY)
                    {
                        var key_info = (KeyInfo)msg.Parameter;
                        ActiveForm.SendKey(key_info);
                    }
                    else if (msg.MessageType == WM_MessageType.WM_SHOW_FORM)
                    {
                        var form = (Form)msg.Parameter;
                        _show(form);
                    }
                    else if (msg.MessageType == WM_MessageType.WM_RESIZE)
                    {
                        ActiveForm.OnResize(new EventArgs());
                    }
                    else if (msg.MessageType == WM_MessageType.WM_TIMER)
                    {
                        var timer = (Timer)msg.Parameter;
                        timer.OnTick(EventArgs.Empty);
                    }
                    else if (msg.MessageType == WM_MessageType.WM_QUIT)
                    {
                        break;
                    }

                    PerformPaint();
                }
            }
            catch (Exception ex)
            {
                var error_form = new ErrorForm();
                error_form.ErrorText = ex.ToString();
                var old_size = error_form.Size;
                error_form.Size = ScreenSize;
                error_form.PerformAnchoring(old_size, error_form.Size);
                Terminal.Clear();
                Show(error_form);
                PerformPaint();

                goto start;
            }

            Terminal.Clear();
        }