Advertisement
Guest User

Untitled

a guest
Mar 23rd, 2017
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.03 KB | None | 0 0
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using System.ComponentModel;
  5. using System.Data;
  6. using System.Drawing;
  7. using System.Text;
  8. using System.Windows.Forms;
  9. using System.Threading;
  10. using System.Timers;
  11. using System.Runtime.InteropServices;
  12. using System.Diagnostics;
  13. using System.Threading;
  14.  
  15. namespace LPTTest
  16. {
  17.  
  18. public partial class Form1 : Form
  19. {
  20. PerformanceCounter counter = new PerformanceCounter("Processor", "% Processor Time", "_Total");
  21. ManualResetEvent ev = new ManualResetEvent(false);
  22. public static int i = 0, j = 0, adress = 888, adress1 = 890;
  23. public Form1()
  24. {
  25.  
  26. InitializeComponent();
  27. PortAccess.Output(888, 0);
  28.  
  29. PortAccess.Output(890, 4);
  30.  
  31. //new Thread(new ThreadStart(Method)).Start();
  32. }
  33.  
  34. bool cpu = false;
  35. float perc = 0;
  36.  
  37. //public void Method()
  38. //{
  39. // while (true)
  40. // {
  41. // ev.WaitOne();
  42. // perc = counter.NextValue();
  43.  
  44. // PortAccess.Output(890, 4);
  45. // PortAccess.Output(888, (int)(perc*2.55));
  46. // }
  47. //}
  48.  
  49. void onCheckBoxClick(object sender, EventArgs e)
  50. {
  51. }
  52.  
  53. private void button1_Click(object sender, EventArgs e)
  54. {
  55.  
  56. }
  57.  
  58. private void button2_Click(object sender, EventArgs e)
  59. {
  60.  
  61. }
  62.  
  63. static void bain()
  64. {
  65. }
  66. static void testdata()
  67. {
  68.  
  69. }
  70.  
  71.  
  72.  
  73. private void Form1_FormClosing(object sender, FormClosingEventArgs e)
  74. {
  75. PortAccess.Output(adress, 0);
  76. PortAccess.Output(adress1, 11);
  77. }
  78.  
  79. private void Form1_Load(object sender, EventArgs e)
  80. {
  81.  
  82. }
  83.  
  84. private void button3_Click(object sender, EventArgs e)
  85. {
  86. }
  87.  
  88. private void label1_Click(object sender, EventArgs e)
  89. {
  90.  
  91. }
  92. static void ShowCPU()
  93. {
  94.  
  95. }
  96. private void button4_Click(object sender, EventArgs e)
  97. {
  98.  
  99. }
  100.  
  101. static List<float> AvCPU = new List<float>();
  102. static PerformanceCounter cpuCounter;
  103.  
  104. void doS()
  105. {
  106.  
  107. }
  108. public class PortAccess
  109. {
  110. [DllImport("inpout32.dll", EntryPoint = "Out32")]
  111. public static extern void Output(int adress, int value);
  112. }
  113. void doP()
  114. {
  115.  
  116. }
  117.  
  118. private void Form1_KeyPress(object sender, KeyPressEventArgs e)
  119. {
  120. if (e.KeyChar.ToString() == "1")
  121. {
  122. PortAccess.Output(890, 4);
  123. PortAccess.Output(888, 128 + 1);
  124. }
  125. if (e.KeyChar.ToString() == "2")
  126. {
  127. PortAccess.Output(890, 4);
  128. PortAccess.Output(888, 128 + 2);
  129. }
  130. if (e.KeyChar.ToString() == "3")
  131. {
  132. PortAccess.Output(890, 4);
  133. PortAccess.Output(888, 128 + 4);
  134. }
  135. if (e.KeyChar.ToString() == "4")
  136. {
  137. PortAccess.Output(890, 4);
  138. PortAccess.Output(888, 128 + 8);
  139. }
  140. if (e.KeyChar.ToString() == "5")
  141. {
  142. PortAccess.Output(890, 4);
  143. PortAccess.Output(888, 64 + 1);
  144. }
  145. if (e.KeyChar.ToString() == "6")
  146. {
  147. PortAccess.Output(890, 4);
  148. PortAccess.Output(888, 64 + 2);
  149. }
  150. if (e.KeyChar.ToString() == "7")
  151. {
  152. PortAccess.Output(890, 4);
  153. PortAccess.Output(888, 64 + 4);
  154. }
  155. if (e.KeyChar.ToString() == "8")
  156. {
  157. PortAccess.Output(890, 4);
  158. PortAccess.Output(888, 64 + 8);
  159. }
  160.  
  161. if (e.KeyChar.ToString() == "9")
  162. {
  163. PortAccess.Output(890, 4);
  164. PortAccess.Output(888, 32 + 4);
  165. }
  166. if (e.KeyChar.ToString() == "0")
  167. {
  168. PortAccess.Output(890, 4);
  169. PortAccess.Output(888, 32 + 8);
  170. }
  171. if (e.KeyChar.ToString() == "-")
  172. {
  173. PortAccess.Output(890, 4);
  174. PortAccess.Output(888, 16 + 4);
  175. }
  176. if (e.KeyChar.ToString() == "q")
  177. {
  178. PortAccess.Output(890, 4);
  179. PortAccess.Output(888, 16 + 8);
  180. }
  181.  
  182. }
  183.  
  184. private void button1_Click_1(object sender, EventArgs e)
  185. {
  186. perc = counter.NextValue();
  187. percent.Text = perc.ToString();
  188. PortAccess.Output(888, 255 - (255 - (int)perc));
  189. }
  190.  
  191. private void button2_Click_1(object sender, EventArgs e)
  192. {
  193. PortAccess.Output(890, 4);
  194. PortAccess.Output(888, 128 + int.Parse(val.Text));
  195. }
  196.  
  197. private void button3_Click_1(object sender, EventArgs e)
  198. {
  199. PortAccess.Output(888, 0);
  200. PortAccess.Output(890, 11);
  201. }
  202.  
  203.  
  204. private void button4_Click_1(object sender, EventArgs e)
  205. {
  206. int value = 0;
  207. int value1 = 0;
  208.  
  209. if (checkBox1.Checked) value += 1;
  210. if (checkBox2.Checked) value += 2;
  211. if (checkBox3.Checked) value += 4;
  212. if (checkBox4.Checked) value += 8;
  213. if (checkBox5.Checked) value += 16;
  214. if (checkBox6.Checked) value += 32;
  215. if (checkBox7.Checked) value += 64;
  216. if (checkBox8.Checked) value += 128;
  217.  
  218. if (checkBox9.Checked) value1 += 1;
  219. if (checkBox10.Checked) value1 += 2;
  220. if (checkBox11.Checked) value1 += 3;
  221. if (checkBox12.Checked) value1 += 4;
  222.  
  223. PortAccess.Output(888, value);
  224. PortAccess.Output(890, 4);
  225. }
  226. }
  227. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement