示例#1
0
        /// <summary>
        /// Called when the control should process keyboard information.
        /// </summary>
        /// <param name="info">The keyboard information.</param>
        /// <returns>True if the keyboard was handled by this control.</returns>
        public override bool ProcessKeyboard(Input.Keyboard info)
        {
            if (info.IsKeyReleased(Keys.Space) || info.IsKeyReleased(Keys.Enter))
            {
                IsSelected = true;

                return(true);
            }
            else if (Parent != null)
            {
                if (info.IsKeyReleased(Keys.Up))
                {
                    Parent.TabPreviousControl();
                }

                else if (info.IsKeyReleased(Keys.Down))
                {
                    Parent.TabNextControl();
                }

                return(true);
            }

            return(false);
        }
示例#2
0
        /// <summary>
        /// Detects if the SPACE and ENTER keys are pressed and calls the <see cref="Click"/> method.
        /// </summary>
        /// <param name="info"></param>
        public override bool ProcessKeyboard(Input.Keyboard info)
        {
            if (info.IsKeyReleased(Keys.Space) || info.IsKeyReleased(Keys.Enter))
            {
                DoClick();
                return(true);
            }

            return(false);
        }
示例#3
0
        private void DestoryEmulator()
        {
            if (_board != null)
            {
                _board.SystemClock.OnPhaseEnd -= _drive.DriveClock.Run;
                _board.OnLoadState            -= _drive.ReadDeviceState;
                _board.OnSaveState            -= _drive.WriteDeviceState;

                _board    = null;
                _drive    = null;
                _keyboard = null;
            }
        }
示例#4
0
        /// <summary>
        /// Focuses the previous or next selection button depending on if the UP or DOWN arrow keys were pressed.
        /// </summary>
        /// <param name="info">The keyboard state.</param>
        public override bool ProcessKeyboard(Input.Keyboard info)
        {
            if (info.IsKeyReleased(Keys.Up) && PreviousSelection != null)
            {
                PreviousSelection.IsFocused = true;

                return(true);
            }

            else if (info.IsKeyReleased(Keys.Down) && NextSelection != null)
            {
                NextSelection.IsFocused = true;

                return(true);
            }

            return(base.ProcessKeyboard(info));
        }
示例#5
0
        /// <summary>
        /// Focuses the previous or next selection button depending on if the UP or DOWN arrow keys were pressed.
        /// </summary>
        /// <param name="info">The keyboard state.</param>
        public override bool ProcessKeyboard(Input.Keyboard info)
        {
            if (info.IsKeyReleased(Keys.Up))
            {
                SelectPrevious();

                return(true);
            }

            else if (info.IsKeyReleased(Keys.Down))
            {
                SelectNext();

                return(true);
            }

            return(base.ProcessKeyboard(info));
        }
示例#6
0
        private void CreateEmulator()
        {
            lock (_syncRoot)
            {
                DestoryEmulator();

                _board = new Board.Board(new GdiVideo(_videoOutput), _kernel, _basic, _charGen);

                _drive = new DiskDrive.CBM1541(_driveKernel, _board.Serial);

                _board.SystemClock.OnPhaseEnd += _drive.DriveClock.Run;
                _board.OnLoadState            += _drive.ReadDeviceState;
                _board.OnSaveState            += _drive.WriteDeviceState;

                _keyboard = new Input.Keyboard(_board.SystemCias[0].PortA, _board.SystemCias[0].PortB, null);

                _emulatorRunning = true;
            }
        }
示例#7
0
        /// <summary>
        /// LoadContent will be called once per game and is the place to load
        /// all of your content.
        /// </summary>
        protected override void LoadContent()
        {
            // instantiate the sprite batch
            this.Drawer = new SpriteBatch(this.GraphicsDevice);
            this.Keyboard = new Input.Keyboard();

            // load the game font
            this._font = this.Content.Load<SpriteFont>("europa");

            // set up the console
            this._europaConsole = new EuropaConsole(this);
        }
示例#8
0
 /// <summary>
 /// Not Used.
 /// </summary>
 /// <param name="state"></param>
 public override bool ProcessKeyboard(Input.Keyboard state)
 {
     return(false);
 }
示例#9
0
        /// <summary>
        /// Called when the control should process keyboard information.
        /// </summary>
        /// <param name="info">The keyboard information.</param>
        /// <returns>True if the keyboard was handled by this control.</returns>
        public override bool ProcessKeyboard(Input.Keyboard info)
        {
            if (info.KeysPressed.Count != 0)
            {
                if (DisableKeyboard)
                {
                    for (int i = 0; i < info.KeysPressed.Count; i++)
                    {
                        if (info.KeysPressed[i].Key == Keys.Enter)
                        {
                            this.IsDirty    = true;
                            DisableKeyboard = false;
                            Text            = _editingText;
                        }
                    }
                    return(true);
                }
                else
                {
                    System.Text.StringBuilder newText = new System.Text.StringBuilder(_editingText, textSurface.Width - 1);

                    this.IsDirty = true;

                    for (int i = 0; i < info.KeysPressed.Count; i++)
                    {
                        if (_isNumeric)
                        {
                            if (info.KeysPressed[i].Key == Keys.Back && newText.Length != 0)
                            {
                                newText.Remove(newText.Length - 1, 1);
                            }

                            else if (info.KeysPressed[i].Key == Keys.Enter)
                            {
                                DisableKeyboard = true;

                                Text = _editingText;

                                return(true);
                            }
                            else if (info.KeysPressed[i].Key == Keys.Escape)
                            {
                                DisableKeyboard = true;
                                return(true);
                            }

                            else if (char.IsDigit(info.KeysPressed[i].Character) || (_allowDecimalPoint && info.KeysPressed[i].Character == '.'))
                            {
                                newText.Append(info.KeysPressed[i].Character);
                            }

                            PositionCursor();
                        }

                        else
                        {
                            if (info.KeysPressed[i].Key == Keys.Back && newText.Length != 0 && _carrotPos != 0)
                            {
                                if (_carrotPos == newText.Length)
                                {
                                    newText.Remove(newText.Length - 1, 1);
                                }
                                else
                                {
                                    newText.Remove(_carrotPos - 1, 1);
                                }

                                _carrotPos -= 1;

                                if (_carrotPos == -1)
                                {
                                    _carrotPos = 0;
                                }
                            }
                            else if (info.KeysPressed[i].Key == Keys.Space && (MaxLength == 0 || (MaxLength != 0 && newText.Length < MaxLength)))
                            {
                                newText.Insert(_carrotPos, ' ');
                                _carrotPos++;

                                if (_carrotPos > newText.Length)
                                {
                                    _carrotPos = newText.Length;
                                }
                            }

                            else if (info.KeysPressed[i].Key == Keys.Delete && _carrotPos != newText.Length)
                            {
                                newText.Remove(_carrotPos, 1);

                                if (_carrotPos > newText.Length)
                                {
                                    _carrotPos = newText.Length;
                                }
                            }

                            else if (info.KeysPressed[i].Key == Keys.Enter)
                            {
                                Text            = _editingText;
                                DisableKeyboard = true;
                                return(true);
                            }
                            else if (info.KeysPressed[i].Key == Keys.Escape)
                            {
                                DisableKeyboard = true;
                                return(true);
                            }
                            else if (info.KeysPressed[i].Key == Keys.Left)
                            {
                                _carrotPos -= 1;

                                if (_carrotPos == -1)
                                {
                                    _carrotPos = 0;
                                }
                            }
                            else if (info.KeysPressed[i].Key == Keys.Right)
                            {
                                _carrotPos += 1;

                                if (_carrotPos > newText.Length)
                                {
                                    _carrotPos = newText.Length;
                                }
                            }

                            else if (info.KeysPressed[i].Key == Keys.Home)
                            {
                                _carrotPos = 0;
                            }

                            else if (info.KeysPressed[i].Key == Keys.End)
                            {
                                _carrotPos = newText.Length;
                            }

                            else if (info.KeysPressed[i].Character != 0 && (MaxLength == 0 || (MaxLength != 0 && newText.Length < MaxLength)))
                            {
                                newText.Insert(_carrotPos, info.KeysPressed[i].Character);
                                _carrotPos++;

                                if (_carrotPos > newText.Length)
                                {
                                    _carrotPos = newText.Length;
                                }
                            }

                            // Test to see if carrot is off edge of box
                            if (_carrotPos >= Width)
                            {
                                _leftDrawOffset = newText.Length - Width + 1;

                                if (_leftDrawOffset < 0)
                                {
                                    _leftDrawOffset = 0;
                                }
                            }
                            else
                            {
                                _leftDrawOffset = 0;
                            }
                        }
                    }

                    string newString = newText.ToString();
                    if (newString != _editingText)
                    {
                        _editingText = newString;
                    }

                    ValidateEdit();
                }

                return(true);
            }

            return(false);
        }
示例#10
0
        private void DestoryEmulator()
        {
            if (_board != null)
            {
                _board.SystemClock.OnPhaseEnd -= _drive.DriveClock.Run;
                _board.OnLoadState -= _drive.ReadDeviceState;
                _board.OnSaveState -= _drive.WriteDeviceState;

                _board = null;
                _drive = null;
                _keyboard = null;
            }
        }
示例#11
0
        private void CreateEmulator()
        {
            lock (_syncRoot)
            {
                DestoryEmulator();

                _board = new Board.Board(new GdiVideo(_videoOutput), _kernel, _basic, _charGen);

                _drive = new DiskDrive.CBM1541(_driveKernel, _board.Serial);

                _board.SystemClock.OnPhaseEnd += _drive.DriveClock.Run;
                _board.OnLoadState += _drive.ReadDeviceState;
                _board.OnSaveState += _drive.WriteDeviceState;

                _keyboard = new Input.Keyboard(_board.SystemCias[0].PortA, _board.SystemCias[0].PortB, null);

                _emulatorRunning = true;
            }
        }