예제 #1
0
        private void OnKeyPress(object sender, KeyPressEventArgs e)
        {
            switch (char.ToUpper(e.KeyChar))
            {
            case (char)Keys.P:     // Pause
            case (char)Keys.OemPeriod:
            case '.':              // Single Step
            case (char)Keys.S:     // Save Image
                // These keys will be handled in the AriadneFormBase.OnKeyPress() method.
                break;

            case (char)Keys.I:
                if (captionInfoItem == CaptionInfoEnum.ImagePath && captionInfoImageNumber + 1 < mazeUserControl.ImageCount)
                {
                    captionInfoImageNumber++;
                }
                else
                {
                    captionInfoImageNumber = 0;
                    captionInfoItem        = (CaptionInfoEnum)((int)(captionInfoItem + 1) % (int)CaptionInfoEnum.Count);
                }
                UpdateCaption();
                e.Handled = true;
                break;

            default:
                Close();
                e.Handled = true;
                break;
            }
        }
예제 #2
0
        public override void OnNew(object sender, EventArgs e)
        {
            // Discard this call until ScreenSaverForm_Load() has been executed.
            // Note: The repeatMode flag is initially false and will be set above.
            if (ariadneController.RepeatMode == false)
            {
                return;
            }

            //base.OnNew(sender, e); // TODO: remove this call

            // Choose new locations of controls, before the maze is built.
            if (visibleControls.Count == 0)
            {
                PreparePlaceholderControls();
            }

            // Reset the displayed caption info.
            this.captionInfoItem = 0;

            // Build and display the new maze.
            base.OnNew(sender, e);

            // Place visible controls at the locations determined for their placeholders.
            for (int i = 0; i < visibleControls.Count; i++)
            {
                Control control     = visibleControls[i];
                Control placeholder = placeholderControls[i];

                control.Location = placeholder.Location;
                control.Visible  = true;

                this.Controls.Remove(placeholder);
            }
        }
예제 #3
0
        /// <summary>
        /// Process the keystrokes sent to the targetWindow.
        /// </summary>
        /// <param name="sender">The target window (a Form).</param>
        /// <param name="e"></param>
        private void OnKeyPress(object sender, KeyPressEventArgs e)
        {
            switch (char.ToUpper(e.KeyChar))
            {
            case (char)Keys.P:
                ariadneController.Pause();
                e.Handled = true;
                break;

            case (char)Keys.OemPeriod:
            case '.':
                ariadneController.SingleStep();
                e.Handled = true;
                break;

            case (char)Keys.S:
                ariadneController.SaveImage(this.mazeUserControl);
                e.Handled = true;
                break;

            case (char)Keys.I:
                if (captionInfoItem == CaptionInfoEnum.ImagePath && captionInfoImageNumber + 1 < mazeUserControl.ImageCount)
                {
                    captionInfoImageNumber++;
                }
                else
                {
                    captionInfoImageNumber = 0;
                    captionInfoItem        = (CaptionInfoEnum)((int)(captionInfoItem + 1) % (int)CaptionInfoEnum.Count);
                }
                UpdateCaption();
                e.Handled = true;
                break;

            case (char)Keys.OemQuestion:
            case '?':
                captionInfoItem = CaptionInfoEnum.Help;
                UpdateCaption();
                e.Handled = true;
                break;

            default:
                (sender as Form).Close();
                e.Handled = true;
                break;
            }
        }