Questo sito utilizza cookies solo per scopi di autenticazione sul sito e nient'altro. Nessuna informazione personale viene tracciata. Leggi l'informativa sui cookies.
Username: Password: oppure
Colori - Form1.cs

Form1.cs

Caricato da: Poggi Marco
Scarica il programma completo

  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Data;
  5. using System.Drawing;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Threading.Tasks;
  9. using System.Windows.Forms;
  10.  
  11. namespace Colori
  12. {
  13.     public partial class Form1 : Form
  14.     {
  15.  
  16.         private Tela foglio;
  17.  
  18.         public Form1()
  19.         {
  20.             InitializeComponent();
  21.         }
  22.  
  23.         private void Form1_Load(object sender, EventArgs e)
  24.         {
  25.             this.Text = "Colori";
  26.             foglio = new Tela(pictureBoxRettangoli.Size.Width, pictureBoxRettangoli.Size.Height, 0f, 0f, 20f);
  27.             Cancella();
  28.         }
  29.  
  30.         private void Cancella()
  31.         {
  32.             textBoxVerde1.Text = "";
  33.             textBoxRosso1.Text = "";
  34.             textBoxBlu1.Text = "";
  35.             textBoxVerde2.Text = "";
  36.             textBoxRosso2.Text = "";
  37.             textBoxBlu2.Text = "";
  38.             foglio.Cancella(Color.FromArgb(126, 126, 126));
  39.             pictureBoxRettangoli.Image = foglio.Disegno;
  40.         }
  41.  
  42.         private void buttonDisegna_Click(object sender, EventArgs e)
  43.         {
  44.             Tratto rettangolo = new Tratto();
  45.             if (int.TryParse(textBoxVerde1.Text, out int verde) && int.TryParse(textBoxRosso1.Text, out int rosso) && int.TryParse(textBoxBlu1.Text, out int blu))
  46.             {
  47.                 rettangolo.inizio.X = 0f;
  48.                 rettangolo.inizio.Y = 10f;
  49.                 rettangolo.fine.X = 10f;
  50.                 rettangolo.fine.Y = 0f;
  51.                 foglio.Penna.Color = Color.FromArgb(rosso % 256, verde % 256, blu % 256);
  52.                 foglio.Rettangolo(rettangolo);
  53.             }
  54.             if (int.TryParse(textBoxVerde2.Text, out verde) && int.TryParse(textBoxRosso2.Text, out rosso) && int.TryParse(textBoxBlu2.Text, out blu))
  55.             {
  56.                 rettangolo.inizio.X = 10f;
  57.                 rettangolo.inizio.Y = 10f;
  58.                 rettangolo.fine.X = 20f;
  59.                 rettangolo.fine.Y = 0f;
  60.                 foglio.Penna.Color = Color.FromArgb(rosso % 256, verde % 256, blu % 256);
  61.                 foglio.Rettangolo(rettangolo);
  62.             }
  63.  
  64.             pictureBoxRettangoli.Image = foglio.Disegno;
  65.         }
  66.     }
  67. }