Advertisement
Guest User

Untitled

a guest
Jun 25th, 2017
53
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.67 KB | None | 0 0
  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.Windows.Forms;
  9.  
  10. namespace Uppgift_1._2
  11. {
  12. public partial class Form1 : Form
  13. {
  14. public Form1()
  15. {
  16. InitializeComponent();
  17. }
  18.  
  19.  
  20. private void button1_Click(object sender, EventArgs e)
  21. {
  22.  
  23.  
  24. int värde1 = int.Parse(textvärde1.Text);
  25. int värde2 = int.Parse(textvärde2.Text);
  26. int värde3 = int.Parse(textvärde3.Text);
  27. int värde4 = int.Parse(textvärde4.Text);
  28.  
  29. Graphics paper;
  30. paper = pictureBox1.CreateGraphics();
  31. Pen pen = new Pen(Color.BlueViolet);
  32.  
  33. paper.DrawLine(pen, 10, 10, 10, 180);
  34. paper.DrawLine(pen, 10, 180, 540, 180);
  35. paper.DrawLine(pen, 10, 10, 540, 10);
  36. paper.DrawLine(pen, 540, 10, 540, 180);
  37. paper.DrawLine(pen, 100, 10, 100, 180);
  38.  
  39. label1.Visible = true;
  40. label2.Visible = true;
  41. label3.Visible = true;
  42. label4.Visible = true;
  43.  
  44.  
  45.  
  46. SolidBrush mybrush = new SolidBrush(Color.Green);
  47.  
  48. paper.FillRectangle(mybrush, 100, 20, värde1, 20);
  49. paper.FillRectangle(mybrush, 100, 60, värde2, 20);
  50. paper.FillRectangle(mybrush, 100, 100, värde3, 20);
  51. paper.FillRectangle(mybrush, 100, 140, värde4, 20);
  52. }
  53.  
  54. private void button2_Click(object sender, EventArgs e)
  55. {
  56. pictureBox1.Invalidate();
  57. }
  58. }
  59. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement