Form1.cs 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Data;
  4. using System.Runtime.InteropServices;
  5. using System.Text;
  6. using System.Threading;
  7. using System.Windows.Forms;
  8. using UAS_MES_NEW.DataOperate;
  9. using UAS_MES_NEW.PublicMethod;
  10. namespace UAS_MES_NEW
  11. {
  12. public partial class Form1 : Form
  13. {
  14. DataHelper datahelper;
  15. DataTable dt = new DataTable();
  16. public List<string> GetList()
  17. {
  18. List<string> list = new List<string>()
  19. {
  20. "Janurary","February", "March" ,"April ","May","June","July","August" ,
  21. "September", "October", "November", "December","张三","张三丰","小张","丰田太郎",
  22. "三林油田","李四张三","张冠李戴",
  23. "Monday","Tuesday","Wednesday","Thursday","Friday","Saturday","Sunday"
  24. };
  25. return list;
  26. }
  27. public Form1()
  28. {
  29. InitializeComponent();
  30. datahelper = new DataHelper();
  31. dt = (DataTable)datahelper.ExecuteSql("select id form loginfo","slect");
  32. BindingSource bs = new BindingSource();
  33. bs.DataSource = dt;
  34. dataNavigator1.DataSource = bs;
  35. }
  36. private void Form1_Load(object sender, EventArgs e)
  37. {
  38. //Com.PortName = "COM4";
  39. //Com.ReadTimeout = 5000;
  40. //Com.WriteTimeout = 5000;
  41. //Com.BaudRate = 9600;
  42. //Com.StopBits = StopBits.One;
  43. //Com.Parity = Parity.None;
  44. foreach (var item in GetList())
  45. {
  46. mruEdit1.Properties.Items.Add(item);
  47. }
  48. int i = 3 << 1;
  49. Console.WriteLine(i+"");
  50. }
  51. [DllImport("WinIo64.dll")]
  52. public static extern bool InitializeWinIo();
  53. [DllImport("WinIo64.dll")]
  54. public static extern void ShutdownWinIo();
  55. [DllImport("WinIo64.dll")]
  56. public static extern bool GetPortVal(IntPtr wPortAddr, out int pdwPortVal, byte bSize);
  57. [DllImport("WinIo64.dll")]
  58. public static extern bool SetPortVal(IntPtr wPortAddr, int dwPortVal, byte bSize);
  59. //以下是与并口无关
  60. [DllImport("WinIo64.dll")]
  61. public static extern byte MapPhysToLin(byte pbPhysAddr, uint dwPhysSize, IntPtr PhysicalMemoryHandle);
  62. [DllImport("WinIo64.dll")]
  63. public static extern bool UnmapPhysicalMemory(IntPtr PhysicalMemoryHandle, byte pbLinAddr);
  64. [DllImport("WinIo64.dll")]
  65. public static extern bool GetPhysLong(IntPtr pbPhysAddr, byte pdwPhysVal);
  66. [DllImport("WinIo64.dll")]
  67. public static extern bool SetPhysLong(IntPtr pbPhysAddr, byte dwPhysVal);
  68. [DllImport("user32.dll")]
  69. public static extern int MapVirtualKey(uint Ucode, uint uMapType);
  70. [DllImport("user32.dll", EntryPoint = "FindWindow")]
  71. private extern static IntPtr FindWindow(string lpClassName, string lpWindowName);
  72. [DllImport("user32.dll")]
  73. static extern IntPtr GetActiveWindow();
  74. [DllImport("user32.dll", EntryPoint = "GetWindowText")]
  75. public extern static int GetWindowText(IntPtr hWnd, StringBuilder lpSting, int nMaxCount);
  76. [DllImport("user32.dll", CharSet = CharSet.Auto, ExactSpelling = true)]
  77. public static extern IntPtr GetForegroundWindow();
  78. public bool online = false; //WinIo打开标志
  79. //数据端口共8位,控制端口共4位,可以组成1~12位的任意数字输出端口;
  80. //状态端口共5位,控制端口共4位,可以组成1~9位的任意数字输入端口
  81. private static IntPtr data_port = (IntPtr)0x378; //数据端口地址 D0-D7 8个端口
  82. private static IntPtr state_port = (IntPtr)0x379; //状态端口地址 S3-S7 只能读取5位
  83. private static IntPtr control_port = (IntPtr)0x37A; //控制端口地址 C0-C3 只能控制或输出4位
  84. ModeBusTCPServer md;
  85. private void button3_Click_1(object sender, EventArgs e)
  86. {
  87. //md = new ModeBusTCPServer();
  88. //md.Open();
  89. //txtMsg.AppendText("SUCCESS");
  90. //int a = GetHashCode();
  91. //MessageBox.Show(a.ToString());
  92. //string password = Encryption.EncryptStr("hcsy");
  93. //MessageBox.Show(password);
  94. //string really = Encryption.DecryptStr(password);
  95. //MessageBox.Show(really);
  96. //byte[] date = new byte[] { 1, 2, 3, 4, 5 };
  97. //string aaa = Encoding.ASCII.GetString(date);
  98. //Console.WriteLine(aaa);
  99. object al = null;
  100. string ab = al == null ? "a" : al.ToString();
  101. Console.WriteLine(ab);
  102. }
  103. private void button4_Click(object sender, EventArgs e)
  104. {
  105. //md.SendOrder(enterTextBox2.Text);
  106. }
  107. private void timer1_Tick(object sender, EventArgs e)
  108. {
  109. //char[] s = new char[] { };
  110. //IntPtr st = GetForegroundWindow();
  111. //StringBuilder sb = new StringBuilder(512);
  112. //GetWindowText(st, sb, sb.Capacity);
  113. //if (sb.ToString() != this.FindForm().Name) {
  114. // //SendKeys.Send("~");
  115. // Console.WriteLine(sb.ToString());
  116. //}
  117. }
  118. private void tabNavigationPage2_Paint(object sender, PaintEventArgs e)
  119. {
  120. }
  121. private void dataNavigator1_Click(object sender, EventArgs e)
  122. {
  123. }
  124. private void dataNavigator1_ButtonClick(object sender, DevExpress.XtraEditors.NavigatorButtonClickEventArgs e)
  125. {
  126. //下一页
  127. if ((e.Button).ButtonType == DevExpress.XtraEditors.NavigatorButtonType.NextPage)
  128. {
  129. Console.WriteLine("A");
  130. }
  131. //上一页
  132. if ((e.Button).ButtonType == DevExpress.XtraEditors.NavigatorButtonType.PrevPage)
  133. {
  134. Console.WriteLine("B");
  135. }
  136. //首页
  137. if ((e.Button).ButtonType == DevExpress.XtraEditors.NavigatorButtonType.Next)
  138. {
  139. Console.WriteLine("C");
  140. }
  141. //尾页
  142. if ((e.Button).ButtonType == DevExpress.XtraEditors.NavigatorButtonType.Prev)
  143. {
  144. Console.WriteLine("D");
  145. }
  146. }
  147. }
  148. }