Exemple #1
0
        //Make the controller to export a electric-level to open door
        private void btnACUnlock_Click(object sender, EventArgs e)
        {
            if (bIsConnected == false)
            {
                MessageBox.Show("Please connect the device first!", "Error");
                return;
            }

            if (txtDelay.Text.Trim() == "")
            {
                MessageBox.Show("Please input the Delay seconds first!", "Error");
                return;
            }
            int idwErrorCode = 0;
            int iDelay       = Convert.ToInt32(txtDelay.Text.Trim());//time to delay

            Cursor = Cursors.WaitCursor;
            if (axCZKEM1.ACUnlock(iMachineNumber, iDelay))
            {
                MessageBox.Show("ACUnlock, Dalay Seconds:" + iDelay.ToString(), "Success");
            }
            else
            {
                axCZKEM1.GetLastError(ref idwErrorCode);
                MessageBox.Show("Operation failed,ErrorCode=" + idwErrorCode.ToString(), "Error");
            }
            Cursor = Cursors.Default;
        }
Exemple #2
0
        bool openDoor()
        {
            if (bIsConnected)
            {
                axCZKEM1.ACUnlock(iMachineNumber, 9);
            }
            else
            {
                MessageBox.Show("The Device is Not Connected \n Please go to setup device", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }

            return(bIsConnected);
        }
Exemple #3
0
        private void Timer1_Tick(object sender, EventArgs e)
        {
            string appPath = @System.AppDomain.CurrentDomain.BaseDirectory;

            // 退出程序
            if (File.Exists(appPath + "/app_quit"))
            {
                DeleteFile(appPath + "/app_quit");
                System.Environment.Exit(0);
            }

            // 消除Teamviewer窗口
            IntPtr tmw = new IntPtr();

            tmw = FindWindow(null, "发起会话");
            if (tmw != new IntPtr())
            {
                IntPtr okbtn = FindWindowEx(tmw, IntPtr.Zero, null, "确定");
                SetForegroundWindow(okbtn);
                SendMessage(okbtn, WM_LBUTTONDOWN, IntPtr.Zero, null);
                SendMessage(okbtn, WM_LBUTTONUP, IntPtr.Zero, null);
            }

            // 启动放映
            if (File.Exists(appPath + "/led_play"))
            {
                DeleteFile(appPath + "/led_play");
                // 取消一遍
                this.BackgroundImage = null;
                this.BackColor       = Color.FromArgb(255, 0, 0, 51);
                this.BackColor       = Color.Black;
                this.VideoPlayer.Ctlcontrols.stop();
                this.VideoPlayer.Visible = false;
                this.VideoPlayer.URL     = "";
                this.Timer3.Enabled      = false;
                this.PicPos = 0;
                pictures    = new List <Image>();
                fileList    = null;

                ReadIt(appPath + "/playfile");
                String playFile = fileCmdContent;
                String fileType = fileCmdContent.Split('.')[1];
                if (fileType == "mp4")
                {
                    this.VideoPlayer.uiMode   = "None";
                    this.VideoPlayer.Visible  = true;
                    this.VideoPlayer.Location = new Point(0, 0);
                    this.VideoPlayer.Size     = this.Size;
                    this.VideoPlayer.Height   = this.Height - (this.Height - this.ClientRectangle.Height);
                    this.VideoPlayer.URL      = @appPath + "/tqupload/" + fileCmdContent;
                    this.VideoPlayer.settings.setMode("loop", true);
                    this.VideoPlayer.Ctlcontrols.play();
                }
                else
                {
                    this.BackgroundImage = Image.FromFile(appPath + "/tqupload/" + fileCmdContent);
                }
            }

            // 滚动放映
            if (File.Exists(appPath + "/led_carousel"))
            {
                DeleteFile(appPath + "/led_carousel");
                // 取消一遍
                this.BackgroundImage = null;
                this.BackColor       = Color.FromArgb(255, 0, 0, 51);
                this.BackColor       = Color.Black;
                this.VideoPlayer.Ctlcontrols.stop();
                this.VideoPlayer.Visible = false;
                this.VideoPlayer.URL     = "";
                this.Timer3.Enabled      = false;
                this.PicPos = 0;
                pictures    = new List <Image>();
                fileList    = null;

                ReadIt(appPath + "/playfiles");
                fileList = fileCmdContent.Split(',');
                for (int i = 0; i < fileList.Length; i++)
                {
                    Image subPlay = Image.FromFile(appPath + "/tqupload/" + fileList[i]);
                    pictures.Add(subPlay);
                }

                this.PicPos          = 0;
                this.BackgroundImage = pictures[0];
                Timer3.Enabled       = true;
            }

            // 取消放映
            if (File.Exists(appPath + "/led_stop"))
            {
                DeleteFile(appPath + "/led_stop");
                this.BackgroundImage = null;
                this.BackColor       = Color.FromArgb(255, 0, 0, 51);
                this.VideoPlayer.Ctlcontrols.stop();
                this.VideoPlayer.Visible = false;
                this.VideoPlayer.URL     = "";
                this.Timer3.Enabled      = false;
                this.PicPos = 0;
                pictures    = new List <Image>();
                fileList    = null;

                //Graphics g = this.CreateGraphics();
                //Font font = new Font("宋体", 24, FontStyle.Bold | FontStyle.Italic | FontStyle.Underline, GraphicsUnit.Point);//其中宋体是字体,24是字号,FontStyle的几个是字的样式,最后的GraphicsUnit是字的度量单位(可以看一下上边的表)
                //g.DrawString("四分之三·IT中心", font, Brushes.Brown, new Point(0, this.Height / 2));//绘制字体,font是上边定义的字体,Brushes.Brown是颜色,Point是字从哪个位置开始绘制
                //g.Dispose();
            }

            // 窗口复位
            if (File.Exists(appPath + "/app_max"))
            {
                DeleteFile(appPath + "/app_max");
                SetForegroundWindow(Handle1);
                this.FormBorderStyle = FormBorderStyle.None;
                // this.WindowState = FormWindowState.Maximized;
                this.Width  = System.Windows.Forms.Screen.PrimaryScreen.Bounds.Width;
                this.Height = System.Windows.Forms.Screen.PrimaryScreen.Bounds.Height;
                this.Left   = 0;
                this.Top    = 0;
                this.Show();
                this.Activate();
                this.TopMost = true;
            }

            // 屏幕开机
            if (File.Exists(appPath + "/led_open"))
            {
                DeleteFile(appPath + "/led_open");
                IntPtr subWindow = FindWindowEx(hwnd, IntPtr.Zero, null, "");
                IntPtr itbtn     = FindWindowEx(subWindow, IntPtr.Zero, null, "开机");
                SetForegroundWindow(itbtn);
                SendMessage(itbtn, WM_LBUTTONDOWN, IntPtr.Zero, null);
                SendMessage(itbtn, WM_LBUTTONUP, IntPtr.Zero, null);
            }

            // 屏幕关机
            if (File.Exists(appPath + "/led_close"))
            {
                DeleteFile(appPath + "/led_close");
                IntPtr subWindow = FindWindowEx(hwnd, IntPtr.Zero, null, "");
                IntPtr itbtn     = FindWindowEx(subWindow, IntPtr.Zero, null, "关机");
                SetForegroundWindow(itbtn);
                SendMessage(itbtn, WM_LBUTTONDOWN, IntPtr.Zero, null);
                SendMessage(itbtn, WM_LBUTTONUP, IntPtr.Zero, null);
            }

            // 一键开门
            if (File.Exists(appPath + "/opendoor"))
            {
                DeleteFile(appPath + "/opendoor");
                if (bIsConnected == false)
                {
                    return;
                }

                int idwErrorCode = 0;
                int iDelay       = Convert.ToInt32("-1");//time to delay

                Cursor = Cursors.WaitCursor;
                if (axCZKEM1.ACUnlock(iMachineNumber, iDelay))
                {
                    //MessageBox.Show("ACUnlock, Dalay Seconds:" +iDelay.ToString(), "Success");
                }
                else
                {
                    axCZKEM1.GetLastError(ref idwErrorCode);
                    MessageBox.Show("Operation failed,ErrorCode=" + idwErrorCode.ToString(), "Error");
                }
                Cursor = Cursors.Default;
            }

            // 开门15秒
            if (File.Exists(appPath + "/opendoor15"))
            {
                DeleteFile(appPath + "/opendoor15");
                if (bIsConnected == false)
                {
                    return;
                }

                int idwErrorCode = 0;
                int iDelay       = Convert.ToInt32("15");//time to delay

                Cursor = Cursors.WaitCursor;
                if (axCZKEM1.ACUnlock(iMachineNumber, iDelay))
                {
                    //MessageBox.Show("ACUnlock, Dalay Seconds:" +iDelay.ToString(), "Success");
                }
                else
                {
                    axCZKEM1.GetLastError(ref idwErrorCode);
                    MessageBox.Show("Operation failed,ErrorCode=" + idwErrorCode.ToString(), "Error");
                }
                Cursor = Cursors.Default;
            }

            // 一键关门
            if (File.Exists(appPath + "/closedoor"))
            {
                DeleteFile(appPath + "/closedoor");
                if (bIsConnected == false)
                {
                    return;
                }

                int idwErrorCode = 0;
                int iDelay       = Convert.ToInt32("0");//time to delay

                Cursor = Cursors.WaitCursor;
                if (axCZKEM1.ACUnlock(iMachineNumber, iDelay))
                {
                    //MessageBox.Show("ACUnlock, Dalay Seconds:" +iDelay.ToString(), "Success");
                }
                else
                {
                    axCZKEM1.GetLastError(ref idwErrorCode);
                    MessageBox.Show("Operation failed,ErrorCode=" + idwErrorCode.ToString(), "Error");
                }
                Cursor = Cursors.Default;
            }
        }