Advertisement
Guest User

Untitled

a guest
Apr 25th, 2017
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.27 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.Threading.Tasks;
  9. using System.Windows.Forms;
  10.  
  11. namespace WindowsFormsApplication38
  12. {
  13. public partial class Form1 : Form
  14. {
  15. public Form1()
  16. {
  17. InitializeComponent();
  18. }
  19.  
  20. private void Form1_Load(object sender, EventArgs e)
  21. {
  22.  
  23. }
  24.  
  25. private void Form1_Paint(object sender, PaintEventArgs e)
  26. {
  27. Graphics g = e.Graphics;
  28. Font verFont = new Font("Verdana", 10, FontStyle.Bold);
  29. Font horzFont = new Font("Verdana", 10, FontStyle.Bold);
  30. SolidBrush vertBrush = new SolidBrush(Color.Black);
  31. SolidBrush horzBrush = new SolidBrush(Color.Blue);
  32. Pen blackPen = new Pen(Color.Black, 2);
  33. Pen bluePen = new Pen(Color.Blue, 2);
  34. g.DrawLine(blackPen, 50, 250, 50, 25);
  35. g.DrawLine(bluePen, 50, 220, 250, 220);
  36. for (int i = 0; i < 11; i++)
  37. {
  38. g.DrawString(i.ToString(),
  39. horzFont, horzBrush, 30 + i * 20, 220);
  40. }
  41. StringFormat vertStrFormat = new StringFormat();
  42. vertStrFormat.FormatFlags = StringFormatFlags.DirectionVertical;
  43. for (int i = 0; i < 11; i++)
  44. {
  45. g.DrawString("-", horzFont, horzBrush,
  46. 50 + i * 20, 212, vertStrFormat);
  47. }
  48. int x = 0;
  49. g.DrawString("100-", verFont, vertBrush, 20, 20);
  50. for (int i = 90; i > 0; i -= 10)
  51. {
  52. x += 20;
  53. g.DrawString(i.ToString() + " -", verFont, vertBrush, 25, 20 + x);
  54. }
  55.  
  56. // Odbacivanje predmeta
  57. verFont.Dispose();
  58. horzFont.Dispose();
  59. vertBrush.Dispose();
  60. horzBrush.Dispose();
  61. blackPen.Dispose();
  62. bluePen.Dispose();
  63. }
  64.  
  65. private void button1_Click(object sender, EventArgs e)
  66. {
  67. Graphics g = this.CreateGraphics();
  68. Font verFont = new Font("Verdana", 10, FontStyle.Bold);
  69. Font horzFont = new Font("Verdana", 10, FontStyle.Bold);
  70. SolidBrush vertBrush = new SolidBrush(Color.Black);
  71. SolidBrush horzBrush = new SolidBrush(Color.Blue);
  72. Pen blackPen = new Pen(Color.Black, 2);
  73. Pen bluePen = new Pen(Color.Blue, 2);
  74. g.Clear(Color.White);
  75. g.DrawLine(blackPen, 50, 220, 50, 25);
  76. g.DrawLine(bluePen, 50, 220, 250, 220);
  77. // Crtanje po x-osi
  78. for (int i = 0; i < 11; i++)
  79. {
  80. g.DrawString(i.ToString(),
  81. horzFont, horzBrush, 30 + i * 20, 220);
  82. }
  83. // Crtanje vertikalnih stringova
  84. StringFormat vertStrFormat = new StringFormat();
  85. vertStrFormat.FormatFlags = StringFormatFlags.DirectionVertical;
  86. for (int i = 0; i < 10; i++)
  87. {
  88. g.DrawString("-", horzFont, horzBrush,
  89. 50 + i * 20, 212, vertStrFormat);
  90. }
  91. // Crtanje po y-osi
  92. int x = 0;
  93. g.DrawString("100-", verFont, vertBrush, 20, 20);
  94. for (int i = 90; i > 0; i -= 10)
  95. {
  96. x += 20;
  97. g.DrawString(i.ToString() + " -", verFont, vertBrush, 25, 20 + x);
  98. }
  99. }
  100.  
  101. private void button2_Click(object sender, EventArgs e)
  102. {
  103. Graphics g = this.CreateGraphics();
  104. Pen blackPen = new Pen(Color.Black, 2);
  105. g.DrawLine(blackPen, 70, 120, 150, 200);
  106.  
  107. }
  108.  
  109. private void button3_Click(object sender, EventArgs e)
  110. {
  111. Graphics g = this.CreateGraphics();
  112. Pen blackPen = new Pen(Color.Black, 2);
  113. g.DrawLine(blackPen, 150, 200, 150, 150);
  114. }
  115.  
  116. private void button4_Click(object sender, EventArgs e)
  117. {
  118. Graphics g = this.CreateGraphics();
  119. Pen blackPen = new Pen(Color.Black, 2);
  120. g.DrawLine(blackPen, 150, 150, 70, 120);
  121. }
  122. }
  123. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement