Advertisement
Guest User

Untitled

a guest
Nov 22nd, 2019
134
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.53 KB | None | 0 0
  1. using System;
  2. using System.Collections;
  3. using System.Threading;
  4. using Microsoft.SPOT;
  5. using Microsoft.SPOT.Presentation;
  6. using Microsoft.SPOT.Presentation.Controls;
  7. using Microsoft.SPOT.Presentation.Media;
  8. using Microsoft.SPOT.Presentation.Shapes;
  9. using Microsoft.SPOT.Touch;
  10.  
  11. using Gadgeteer.Networking;
  12. using GT = Gadgeteer;
  13. using GTM = Gadgeteer.Modules;
  14. using Gadgeteer.Modules.GHIElectronics;
  15.  
  16. namespace GadgeteerApp4
  17. {
  18. public partial class Program
  19. {
  20. #region Programos sablonas
  21. #region kintamuju aprasymas
  22. private Boolean timerPaleistas = false;
  23. private GT.Timer timer = new GT.Timer(2);
  24. private GT.Timer timer2 = new GT.Timer(200);
  25. private int minutes = 0;
  26. private int sekundes = 0;
  27. private Font font = Resources.GetFont(Resources.FontResources.NinaB);
  28. private Font font2 = Resources.GetFont(Resources.FontResources.consolas_72);
  29. private Font font3 = Resources.GetFont(Resources.FontResources.Arial_18);
  30. private Window window;
  31. private Canvas canvas;
  32. private Text antraste;
  33. private Text laikas;
  34. private Text vlinija;
  35. private Text linija;
  36. int x = 0;
  37. int t = 55;
  38. private int sk = 1;
  39. private Image paleistiStabdyti;
  40. private Image atkurti;
  41. #endregion
  42. void ProgramStarted()
  43. {
  44. /*******************************************************************************************
  45. Modules added in the Program.gadgeteer designer view are used by typing
  46. their name followed by a period, e.g. button. or camera.
  47.  
  48. Many modules generate useful events. Type +=<tab><tab> to add a handler to an event, e.g.:
  49. button.ButtonPressed +=<tab><tab>
  50.  
  51. If you want to do something periodically, use a GT.Timer and handle its Tick event, e.g.:
  52. GT.Timer timer = new GT.Timer(1000); // every second (1000ms)
  53. timer.Tick +=<tab><tab>
  54. timer.Start();
  55. *******************************************************************************************/
  56.  
  57.  
  58. // Use Debug.Print to show messages in Visual Studio's "Output" window during debugging.
  59. Debug.Print("Program Started");
  60. timer2.Tick += new GT.Timer.TickEventHandler(timer_Tick);
  61. timer.Tick += new GT.Timer.TickEventHandler(timer_Tick2);
  62. SetupWindow();
  63. }
  64. void timer_Tick(GT.Timer timer)
  65. {
  66. //linija = new Text(font, "");
  67. //linija.ForeColor = GT.Color.Black;
  68. //canvas.Children.Add(linija);
  69. displayT43.SimpleGraphics.DisplayTextInRectangle(sk.ToString(), 10, t, 30, 15, Color.Black, font);
  70. displayT43.SimpleGraphics.DisplayTextInRectangle(lightSense.GetIlluminance().ToString(), 60, t, 250, 15, Color.Black, font);
  71.  
  72. //Canvas.SetLeft(linija, 50);
  73. //Canvas.SetTop(linija, t);
  74. //if (t >= 290)
  75. t += 30;
  76. sk += 1;
  77. }
  78. void timer_Tick2(GT.Timer timer)
  79. {
  80. vlinija = new Text(font, "");
  81. linija = new Text(font, "");
  82. linija.ForeColor = GT.Color.Black;
  83. canvas.Children.Add(linija);
  84. linija.TextContent += "--------------------------------------------------------------------------------------------------";
  85. vlinija.TextContent += "------------";
  86. displayT43.SimpleGraphics.DisplayTextInRectangle("L", 20, x, 15, 15, Color.Black, font);
  87.  
  88. //Canvas.SetLeft(vlinija, 30);
  89. //Canvas.SetTop(vlinija, x);
  90. //Canvas.SetLeft(linija, 0);
  91. //Canvas.SetTop(linija, x);
  92. x += 30;
  93. }
  94. void SetupWindow()
  95. {
  96. #region Lango elementu konfiguravimas
  97. window = displayT43.WPFWindow;
  98. canvas = new Canvas();
  99. window.Child = canvas;
  100. //paleistiStabdyti = new Image(Resources.GetBitmap(Resources.BitmapResources.Paleisti_Stabdyti));
  101. //atkurti = new Image(Resources.GetBitmap(Resources.BitmapResources.Atkurti));
  102. //canvas.Children.Add(paleistiStabdyti);
  103. //canvas.Children.Add(atkurti);
  104. //Canvas.SetLeft(paleistiStabdyti, 10);
  105. //Canvas.SetTop(paleistiStabdyti, 230);
  106. //Canvas.SetLeft(atkurti, 230);
  107. //Canvas.SetTop(atkurti, 230);
  108. //antraste = new Text(font2, "Laikmatis");
  109. //antraste.ForeColor = GT.Color.Black;
  110. //laikas = new Text(font, "00:00");
  111. //laikas.ForeColor = GT.Color.Black;
  112.  
  113. //canvas.Children.Add(antraste);
  114. //canvas.Children.Add(laikas);
  115. //Canvas.SetLeft(antraste, 140);
  116. //Canvas.SetTop(antraste, 0);
  117.  
  118. //Canvas.SetLeft(laikas, 100);
  119. //Canvas.SetTop(laikas, 120);
  120. #endregion
  121. #endregion
  122. //Veiksmas 1
  123. //timer.Start();
  124. //timer2.Start();
  125. //Veiksmas 2
  126. button.ButtonPressed += new Button.ButtonEventHandler(button_ButtonPressed);
  127. button2.ButtonPressed += new Button.ButtonEventHandler(button2_ButtonPressed);
  128. button2.ButtonReleased += new Button.ButtonEventHandler(button2_ButtonReleased);
  129. //Veiksmas 3
  130.  
  131. }
  132.  
  133. void button2_ButtonReleased(Button sender, Button.ButtonState state)
  134. {
  135. timer2.Stop();
  136. }
  137.  
  138. void button2_ButtonPressed(Button sender, Button.ButtonState state)
  139. {
  140. timer2.Start();
  141. }
  142.  
  143. void button_ButtonPressed(Button sender, Button.ButtonState state)
  144. {
  145. displayT43.SimpleGraphics.DisplayRectangle(Color.Black, 1, Color.White, 0, 0, 45, 25);
  146. displayT43.SimpleGraphics.DisplayRectangle(Color.Black, 1, Color.White, 50, 0, 200, 25);
  147.  
  148. displayT43.SimpleGraphics.DisplayTextInRectangle("Nr.", 5, 5, 30, 15, Color.Black, font);
  149. displayT43.SimpleGraphics.DisplayTextInRectangle("LightSense module readings", 55, 5, 200, 15, Color.Black, font);
  150.  
  151. displayT43.SimpleGraphics.DisplayRectangle(Color.Black, 1, Color.White, 50, 30, 200, 250);
  152. displayT43.SimpleGraphics.DisplayRectangle(Color.Black, 1, Color.White, 0, 30, 45, 250);
  153. displayT43.SimpleGraphics.DisplayRectangle(Color.White, 1, Color.White, 260, 0, 300, 500);
  154. t = 35;
  155. }
  156. }
  157. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement