123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167 |
- using System;
- using System.Collections.Generic;
- using System.Data;
- using System.Runtime.InteropServices;
- using System.Text;
- using System.Threading;
- using System.Windows.Forms;
- using UAS_MES_NEW.DataOperate;
- using UAS_MES_NEW.PublicMethod;
- namespace UAS_MES_NEW
- {
- public partial class Form1 : Form
- {
- DataHelper datahelper;
- DataTable dt = new DataTable();
- public List<string> GetList()
- {
- List<string> list = new List<string>()
- {
- "Janurary","February", "March" ,"April ","May","June","July","August" ,
- "September", "October", "November", "December","张三","张三丰","小张","丰田太郎",
- "三林油田","李四张三","张冠李戴",
- "Monday","Tuesday","Wednesday","Thursday","Friday","Saturday","Sunday"
- };
- return list;
- }
- public Form1()
- {
- InitializeComponent();
- datahelper = new DataHelper();
- dt = (DataTable)datahelper.ExecuteSql("select id form loginfo","slect");
- BindingSource bs = new BindingSource();
- bs.DataSource = dt;
- dataNavigator1.DataSource = bs;
- }
- private void Form1_Load(object sender, EventArgs e)
- {
- //Com.PortName = "COM4";
- //Com.ReadTimeout = 5000;
- //Com.WriteTimeout = 5000;
- //Com.BaudRate = 9600;
- //Com.StopBits = StopBits.One;
- //Com.Parity = Parity.None;
- foreach (var item in GetList())
- {
- mruEdit1.Properties.Items.Add(item);
- }
- int i = 3 << 1;
- Console.WriteLine(i+"");
- }
- [DllImport("WinIo64.dll")]
- public static extern bool InitializeWinIo();
- [DllImport("WinIo64.dll")]
- public static extern void ShutdownWinIo();
- [DllImport("WinIo64.dll")]
- public static extern bool GetPortVal(IntPtr wPortAddr, out int pdwPortVal, byte bSize);
- [DllImport("WinIo64.dll")]
- public static extern bool SetPortVal(IntPtr wPortAddr, int dwPortVal, byte bSize);
- //以下是与并口无关
- [DllImport("WinIo64.dll")]
- public static extern byte MapPhysToLin(byte pbPhysAddr, uint dwPhysSize, IntPtr PhysicalMemoryHandle);
- [DllImport("WinIo64.dll")]
- public static extern bool UnmapPhysicalMemory(IntPtr PhysicalMemoryHandle, byte pbLinAddr);
- [DllImport("WinIo64.dll")]
- public static extern bool GetPhysLong(IntPtr pbPhysAddr, byte pdwPhysVal);
- [DllImport("WinIo64.dll")]
- public static extern bool SetPhysLong(IntPtr pbPhysAddr, byte dwPhysVal);
- [DllImport("user32.dll")]
- public static extern int MapVirtualKey(uint Ucode, uint uMapType);
- [DllImport("user32.dll", EntryPoint = "FindWindow")]
- private extern static IntPtr FindWindow(string lpClassName, string lpWindowName);
- [DllImport("user32.dll")]
- static extern IntPtr GetActiveWindow();
- [DllImport("user32.dll", EntryPoint = "GetWindowText")]
- public extern static int GetWindowText(IntPtr hWnd, StringBuilder lpSting, int nMaxCount);
- [DllImport("user32.dll", CharSet = CharSet.Auto, ExactSpelling = true)]
- public static extern IntPtr GetForegroundWindow();
- public bool online = false; //WinIo打开标志
- //数据端口共8位,控制端口共4位,可以组成1~12位的任意数字输出端口;
- //状态端口共5位,控制端口共4位,可以组成1~9位的任意数字输入端口
- private static IntPtr data_port = (IntPtr)0x378; //数据端口地址 D0-D7 8个端口
- private static IntPtr state_port = (IntPtr)0x379; //状态端口地址 S3-S7 只能读取5位
- private static IntPtr control_port = (IntPtr)0x37A; //控制端口地址 C0-C3 只能控制或输出4位
- ModeBusTCPServer md;
- private void button3_Click_1(object sender, EventArgs e)
- {
- //md = new ModeBusTCPServer();
- //md.Open();
- //txtMsg.AppendText("SUCCESS");
- //int a = GetHashCode();
- //MessageBox.Show(a.ToString());
- //string password = Encryption.EncryptStr("hcsy");
- //MessageBox.Show(password);
- //string really = Encryption.DecryptStr(password);
- //MessageBox.Show(really);
- //byte[] date = new byte[] { 1, 2, 3, 4, 5 };
- //string aaa = Encoding.ASCII.GetString(date);
- //Console.WriteLine(aaa);
- object al = null;
- string ab = al == null ? "a" : al.ToString();
- Console.WriteLine(ab);
- }
- private void button4_Click(object sender, EventArgs e)
- {
- //md.SendOrder(enterTextBox2.Text);
- }
- private void timer1_Tick(object sender, EventArgs e)
- {
- //char[] s = new char[] { };
- //IntPtr st = GetForegroundWindow();
- //StringBuilder sb = new StringBuilder(512);
- //GetWindowText(st, sb, sb.Capacity);
- //if (sb.ToString() != this.FindForm().Name) {
- // //SendKeys.Send("~");
- // Console.WriteLine(sb.ToString());
- //}
- }
- private void tabNavigationPage2_Paint(object sender, PaintEventArgs e)
- {
- }
- private void dataNavigator1_Click(object sender, EventArgs e)
- {
-
- }
- private void dataNavigator1_ButtonClick(object sender, DevExpress.XtraEditors.NavigatorButtonClickEventArgs e)
- {
- //下一页
- if ((e.Button).ButtonType == DevExpress.XtraEditors.NavigatorButtonType.NextPage)
- {
- Console.WriteLine("A");
- }
- //上一页
- if ((e.Button).ButtonType == DevExpress.XtraEditors.NavigatorButtonType.PrevPage)
- {
- Console.WriteLine("B");
- }
- //首页
- if ((e.Button).ButtonType == DevExpress.XtraEditors.NavigatorButtonType.Next)
- {
- Console.WriteLine("C");
- }
- //尾页
- if ((e.Button).ButtonType == DevExpress.XtraEditors.NavigatorButtonType.Prev)
- {
- Console.WriteLine("D");
- }
- }
- }
- }
|