Ejemplo n.º 1
0
        private void video_button_Click(object sender, EventArgs e)
        {
            if (!isopen)
            {
                MessageBox.Show("请先打开摄像头!", "提示", MessageBoxButtons.OK);
                return;
            }

            //record();
            tim = DateTime.Now.Year.ToString() + DateTime.Now.Month.ToString("d2") + DateTime.Now.Day.ToString("d2") + DateTime.Now.Hour.ToString("d2") + DateTime.Now.Minute.ToString("d2") + DateTime.Now.Second.ToString("d2");

            if (!start_record)
            {
                creatDic(tim);
                record_video(tim);
                Image_save.record_event = true;
                Thread.Sleep(10);
                start        = timeGetTime();
                start_record = true;
                //Image_save.writer.Open(NCVM_Form.FileV, 1280, 720, 25, VideoCodec.MPEG4, 5120000);
                //Image_save.writer.Open(FileV, 1280, 960, 25, VideoCodec.MPEG4, 5120000);
                //Image_save.writer.Open(FileV, 1280, 960, 25, VideoCodec.MPEG4, 5120000);
                Image_save.thread_save();

                video_button.Text     = "结束录像";
                label13.Visible       = true;
                Start_button.Enabled  = false;
                replay_button.Enabled = false;
                //checkBox1.Enabled = false;
                checkBox2.Enabled = false;
                rec_counter       = 0;
                //timer_rec.Start();
            }
            else
            {
                end = timeGetTime();

                start_record = false;
                Thread.Sleep(10);
                Image_save.record_event = true;
                video_button.Text       = "开始录像";
                label13.Visible         = false;
                Start_button.Enabled    = true;
                replay_button.Enabled   = true;

                checkBox2.Enabled = true;
                if (gcode_prog != null)
                {
                    listBox1.SelectedIndex = 0;
                }

                Thread.Sleep(40);
                //writer.Close();
                sw.Close();
            }
        }
Ejemplo n.º 2
0
 static void Main()
 {
     Application.EnableVisualStyles();
     Application.SetCompatibleTextRenderingDefault(false);
     Setting_save.openfile("save.dat");
     //AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException);
     Image_save.thread_video();
     Control.CheckForIllegalCrossThreadCalls = false;
     Application.Run(new NCVM_Form());
 }
Ejemplo n.º 3
0
        /// <summary>
        /// 通用计时,用于记录窗体跟随,加载回放记录,回放完成后返回正常界面
        /// </summary>
        /// <param name="source"></param>
        /// <param name="e"></param>
        public void tick_count(object source, System.Timers.ElapsedEventArgs e)
        {
            stringm();
            if (ispgavaliable)
            {
                freplay.Location = new System.Drawing.Point(this.Location.X + 860, this.Location.Y + 1);
            }
            else
            {
                freplay.Location = new System.Drawing.Point(this.Location.X + 645, this.Location.Y + 1);
            }
            counter++;
            rec_counter++;

            if (load_item != null)
            {
                repaly(load_item);
                Form3.selecteds = null;
                load_item       = null;
            }

            if (!isreplay)
            {
                if (Image_save.bm != null)
                {
                    Image_save.image_mutex.WaitOne();
                    Bitmap temp_bm = (Bitmap)Image_save.bm.Clone();
                    Image_save.image_mutex.ReleaseMutex();

                    Image last = pictureBox1.Image;
                    pictureBox1.Image = new Bitmap(temp_bm, new Size(600, 450));
                    last.Dispose();
                    temp_bm.Dispose();

                    listBox1.SelectedIndex = HNC_Connect.gline;
                }
            }

            if ((!HNC_Connect.iscon) || (isreplay))
            {
                video_button.Enabled = false;
            }
            else if (HNC_Connect.iscon && (!checkBox2.Checked))
            {
                video_button.Enabled = true;
            }

            if (start_record)
            {
                sw.Write("T" + rec_counter.ToString("d5") + "\n");
                sw.Write(wm[0] + "\n");
                sw.Write(wm[1] + "\n");
                sw.Write(wm[2] + "\n");
                sw.Write(wm[3] + "\n");
                sw.Write(wm[4] + "\n");
                sw.Write("L" + wm[5].Remove(4) + "\n");
                sw.Write("N" + "\n");
            }

            if (HNC_Connect.progch_event)
            {
                HNC_Connect.progch_event = false;

                string progn = HNC_Connect.progN /*.Remove(0, 8)*/;
                label21.Text = progn;

                Thread.Sleep(100);
                if (HNC_Connect.load_event)
                {
                    HNC_Connect.load_event = false;
                    listBox1.Items.Clear();
                    temp_path = gcode_path + progn;
                    while (!read_gcode(temp_path))
                    {
                        ;
                    }
                    listBox1.SelectedIndex = 0;
                }
            }


            if (checkBox2.Checked)
            {
                if (HNC_Connect.cyc_event == true)
                {
                    HNC_Connect.cyc_event = false;

                    tim = DateTime.Now.Year.ToString() + DateTime.Now.Month.ToString("d2") + DateTime.Now.Day.ToString("d2") + DateTime.Now.Hour.ToString("d2") + DateTime.Now.Minute.ToString("d2") + DateTime.Now.Second.ToString("d2");

                    if (HNC_Connect.cyc != 0)
                    {
                        creatDic(tim);
                        record_video(tim);
                        Image_save.record_event = true;
                        Thread.Sleep(10);
                        start_record = true;
                        //Image_save.writer.Open(NCVM_Form.FileV, 1280, 720, 25, VideoCodec.MPEG4, 5120000);
                        //Image_save.writer.Open(NCVM_Form.FileV, 1280, 960, 25, VideoCodec.MPEG4, 5120000);
                        Image_save.thread_save();
                        video_button.Text     = "结束录像";
                        label13.Visible       = true;
                        Start_button.Enabled  = false;
                        replay_button.Enabled = false;
                        //checkBox1.Enabled = false;
                        checkBox2.Enabled = false;
                        rec_counter       = 0;
                    }
                    else
                    {
                        start_record = false;
                        Thread.Sleep(10);
                        Image_save.record_event = true;
                        video_button.Text       = "开始录像";
                        label13.Visible         = false;
                        Start_button.Enabled    = true;
                        replay_button.Enabled   = true;
                        //checkBox1.Enabled = true;
                        checkBox2.Enabled      = true;
                        listBox1.SelectedIndex = 0;
                        Thread.Sleep(40);
                        sw.Close();
                    }
                }
            }

            if (HNC_Connect.cyc != 0)
            {
                listBox1.SelectedIndex = HNC_Connect.gline;
            }
            //Marshal.ReleaseComObject();
        }