Form1.cs 6.3 KB

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