Advertisement
antunes1

Untitled

May 20th, 2018
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.18 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Drawing;
  4. using System.IO;
  5. using System.Windows.Forms;
  6. using System.Xml.Serialization;
  7.  
  8. namespace WindowsFormsApp24
  9. {
  10. public partial class FormCronologia : Form
  11. {
  12. int ano = 1914;
  13.  
  14. List<PictureBox> pins = new List<PictureBox>();
  15. List<Evento> eventosDoAno = new List<Evento>();
  16.  
  17. public Image Image { get; private set; }
  18.  
  19. public FormCronologia()
  20. {
  21. InitializeComponent();
  22. }
  23.  
  24. private void Circulo1914_Click(object sender, EventArgs e)
  25. {
  26. Circulo1914.Image = imageList.Images[0];
  27. Circulo1915.Image = imageList.Images[1];
  28. Circulo1916.Image = imageList.Images[1];
  29. Circulo1917.Image = imageList.Images[1];
  30. Circulo1918.Image = imageList.Images[1];
  31.  
  32. ano = 1914;
  33. AtualizaEventos();
  34. }
  35.  
  36. private void Circulo1915_Click(object sender, EventArgs e)
  37. {
  38. Circulo1914.Image = imageList.Images[1];
  39. Circulo1915.Image = imageList.Images[0];
  40. Circulo1916.Image = imageList.Images[1];
  41. Circulo1917.Image = imageList.Images[1];
  42. Circulo1918.Image = imageList.Images[1];
  43.  
  44. ano = 1915;
  45. AtualizaEventos();
  46. }
  47.  
  48. private void Circulo1916_Click(object sender, EventArgs e)
  49. {
  50. Circulo1914.Image = imageList.Images[1];
  51. Circulo1915.Image = imageList.Images[1];
  52. Circulo1916.Image = imageList.Images[0];
  53. Circulo1917.Image = imageList.Images[1];
  54. Circulo1918.Image = imageList.Images[1];
  55.  
  56. ano = 1916;
  57. AtualizaEventos();
  58. }
  59.  
  60. private void Circulo1917_Click(object sender, EventArgs e)
  61. {
  62. Circulo1914.Image = imageList.Images[1];
  63. Circulo1915.Image = imageList.Images[1];
  64. Circulo1916.Image = imageList.Images[1];
  65. Circulo1917.Image = imageList.Images[0];
  66. Circulo1918.Image = imageList.Images[1];
  67.  
  68. ano = 1917;
  69. AtualizaEventos();
  70. }
  71.  
  72. private void Circulo1918_Click(object sender, EventArgs e)
  73. {
  74. Circulo1914.Image = imageList.Images[1];
  75. Circulo1915.Image = imageList.Images[1];
  76. Circulo1916.Image = imageList.Images[1];
  77. Circulo1917.Image = imageList.Images[1];
  78. Circulo1918.Image = imageList.Images[0];
  79.  
  80. ano = 1918;
  81. AtualizaEventos();
  82. }
  83.  
  84. private void FormCronologia_Load(object sender, EventArgs e)
  85. {
  86. AtualizaEventos();
  87. }
  88. public void AtualizaEventos()
  89. {
  90. Eventos dadosLidos;
  91.  
  92. XmlSerializer serializer = new XmlSerializer(typeof(Eventos));
  93.  
  94. using (FileStream fileStream = new FileStream("Eventos.xml", FileMode.Open))
  95. {
  96. dadosLidos = (Eventos)serializer.Deserialize(fileStream);
  97. }
  98.  
  99. Descricao.Clear();
  100.  
  101. foreach (PictureBox pin in pins)
  102. {
  103. Controls.Remove(pin);
  104. }
  105.  
  106. pins.Clear();
  107. eventosDoAno.Clear();
  108.  
  109.  
  110. foreach (Evento ev in dadosLidos.Lista)
  111. {
  112. if (ev.Data.Ano == ano)
  113. {
  114. Descricao.AppendText(ev.Data.Dia + " de " + ev.Data.Mes + " de " + ev.Data.Ano + "\n");
  115. Descricao.AppendText("\n");
  116. Descricao.AppendText(ev.Descricao + "\n");
  117. Descricao.AppendText("\n");
  118. Descricao.AppendText("\n");
  119.  
  120. int ajusteNaSeiPorque = 7;
  121.  
  122. int w = Properties.Resources.Pin.Width + ajusteNaSeiPorque;
  123. int h = Properties.Resources.Pin.Height + ajusteNaSeiPorque;
  124.  
  125.  
  126. Bitmap baseImage;
  127. Bitmap pin = new Bitmap(w, h);
  128.  
  129. baseImage = new Bitmap(Mapa.Image);
  130.  
  131. Rectangle cropRect = new Rectangle(ev.Coordenadas.X, ev.Coordenadas.Y, w, h);
  132.  
  133. using (Graphics g = Graphics.FromImage(pin))
  134. {
  135. g.DrawImage(baseImage, new Rectangle(0, 0, w, h), cropRect, GraphicsUnit.Pixel);
  136. g.DrawImage(Properties.Resources.Pin, 0, 0);
  137. }
  138.  
  139. PictureBox local = new PictureBox()
  140. {
  141. Name = "local",
  142. Size = new Size(w, h),
  143. Location = new Point(ev.Coordenadas.X + Mapa.Location.X, ev.Coordenadas.Y + Mapa.Location.Y),
  144. };
  145.  
  146. local.Image = pin;
  147. local.MouseClick += new System.EventHandler(this.localMouseclick);
  148.  
  149. void localMouseclick(object sender, EventArgs e);
  150.  
  151. Controls.Add(local);
  152. local.BringToFront();
  153.  
  154. pins.Add(local);
  155. eventosDoAno.Add(ev);
  156. }
  157. }
  158. }
  159. }
  160. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement