Exemple #1
0
        /// <summary>
        /// This method will draw the screen
        /// when the user presses keys.
        /// </summary>
        /// <param name="g"></param>
        private void drawPoint(Graphics g)
        {
            Brush     myBrush   = new SolidBrush(getRandomColor());
            Rectangle rectangle = new Rectangle(x, y, penSize, penSize);

            if (keyName == "Right")
            {
                x = x + penSize / 2;
            }
            else if (keyName == "Left")
            {
                x = x - penSize / 2;
            }
            else if (keyName == "Up")
            {
                y = y - penSize / 2;
            }
            else if (keyName == "Down")
            {
                y = y + penSize / 2;
            }
            else if (keyName == "Up" && keyName == "Left")
            {
                x = x + penSize / 2;
                y = y + penSize / 2;
            }
            else if (keyName == "Up" && keyName == "Right")
            {
                y = y - penSize / 2;
                x = x + penSize / 2;
            }
            else if (keyName == "Down" && keyName == "Right")
            {
                y = y - penSize / 2;
                x = x - penSize / 2;
            }
            else if (keyName == "Down" && keyName == "Left")
            {
                y = y + penSize / 2;
                x = x - penSize / 2;
            }
            else if (keyName == "B")
            {
                penSize = penSize + 1;
            }
            else if (keyName == "S")
            {
                penSize = penSize - 1;
            }
            else if (keyName == "F1")
            {
                g.FillEllipse(myBrush, rectangle);
            }
            else if (keyName == "F2")
            {
                this.BackColor = getRandomColor();
            }
            else if (keyName == "Escape")
            {
                response = MessageBox.Show("Are you sure you want to quit?", "Exit", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
                if (response == DialogResult.Yes)
                {
                    Application.Exit();
                }
            }
            else if (keyName == "C")
            {
                SketchForm sketchForm = new SketchForm();
                sketchForm.Show();
                this.Dispose(false);
            }

            if (keyPressed)
            {
                // g.FillEllipse(Brushes.Red, rectangle);
                g.FillEllipse(myBrush, rectangle);
            }
        }
Exemple #2
0
        /// <summary>
        /// Depending on input, the line can move over the screen/
        /// When escape is click a box is shown and C resets the form.
        /// </summary>
        private void drawPoint(Graphics g)
        {
            if (keyName == "Right")
            {
                x = x + penSize / 2;
            }
            else if (keyName == "Left")
            {
                x = x - penSize / 2;
            }
            else if (keyName == "Up")
            {
                y = y - penSize / 2;
            }
            else if (keyName == "Down")
            {
                y = y + penSize / 2;
            }
            else if (keyName == "Up" && keyName == "Left")
            {
                y = y + penSize / 2;
                x = x + penSize / 2;
            }
            else if (keyName == "Up" && keyName == "Right")
            {
                y = y - penSize / 2;
                x = x + penSize / 2;
            }
            else if (keyName == "Down" && keyName == "Right")
            {
                y = y - penSize / 2;
                x = x - penSize / 2;
            }
            else if (keyName == "Down" && keyName == "Left")
            {
                y = y + penSize / 2;
                x = x - penSize / 2;
            }
            else if (keyName == "Escape")
            {
                response = MessageBox.Show("Do you want to quit?", "Exit", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
                if (response == DialogResult.Yes)
                {
                    Application.Exit();
                }
            }
            else if (keyName == "")
            {
                SketchForm sketchForm = new SketchForm();
                sketchForm.Show();
                this.Dispose(false);
            }
            else if (keyName == "S")
            {
                penSize = penSize - 1;
            }
            else if (keyName == "B")
            {
                penSize = penSize + 1;
            }
            else if (keyName == "F1")
            {
                Random rnd         = new Random();
                Color  randomColor = Color.FromArgb(rnd.Next(256), rnd.Next(256), rnd.Next(256));
                this.BackColor = randomColor;
            }

            if (keyPressed)
            {
                g.FillEllipse(solidBrush, x, y, penSize, penSize);
            }
        }