示例#1
0
        public string path = Application.StartupPath + @"\alarm.wav"; //报警声音路径
        #endregion


        public Videobox()
        {
            InitializeComponent();
            #region 双缓存
            DoubleBuffered = true;
            SetStyle(ControlStyles.UserPaint, true);
            SetStyle(ControlStyles.AllPaintingInWmPaint, true); // 禁止擦除背景.
            SetStyle(ControlStyles.DoubleBuffer, true);         // 双缓冲
            #endregion

            #region 视频框鼠标事件转移
            pictureBox1.MouseDown        += PictureBox1_MouseDown;
            pictureBox1.MouseDoubleClick += PictureBox1_MouseDoubleClick;;
            pictureBox1.MouseEnter       += PictureBox1_MouseEnter;;
            pictureBox1.MouseLeave       += PictureBox1_MouseLeave;;
            pictureBox1.MouseUp          += PictureBox1_MouseUp;;
            //pictureBox1.Location = new Point(2, 2);
            #endregion

            timer          = new System.Windows.Forms.Timer();
            timer.Interval = 1000;
            timer.Tick    += Timer_Tick;

            info = new WheelGuard.WheelGuardInfo();

            player = new System.Media.SoundPlayer(path);
        }
示例#2
0
        private void wheelGuard_Click(object sender, EventArgs e)
        {
            if (selectedVb.thread != null && selectedVb.thread.IsAlive)
            {
                MessageBox.Show("当前视频框正在轮巡,请先停止轮巡再打开!");
                return;
            }

            WheelGuard.WheelGuardInfo WGI = new WheelGuard.WheelGuardInfo();
            WGI.DeviceIDList = new System.Collections.Generic.List <Guid>();
            WGI.WheelTime    = new System.Collections.Generic.List <int>();

            for (int i = 0; i < dgvWheelGuard.Rows.Count; i++)
            {
                WGI.DeviceIDList.Add((Guid)dgvWheelGuard.Rows[i].Cells[2].Value);
                WGI.WheelTime.Add(int.Parse(dgvWheelGuard.Rows[i].Cells[1].Value.ToString()));
            }
            selectedVb.info = WGI;

            selectedVb.thread = new System.Threading.Thread(new System.Threading.ThreadStart(selectedVb.WheelGuardThread));
            selectedVb.thread.IsBackground = true;
            selectedVb.thread.Start();
        }