public void DoJob() { writer = new VideoFileWriter(); string fullName = DateTime.Now.ToString("yyyy-MM-dd"); writer.Open( fullName + ".mp4", Screen.PrimaryScreen.WorkingArea.Width, Screen.PrimaryScreen.WorkingArea.Height, (int)10, VideoCodec.MPEG4, (int)(bitRate._400kbit)); streamVideo = new ScreenCaptureStream(Screen.PrimaryScreen.WorkingArea); DateTime frameControl = DateTime.Now; streamVideo.NewFrame += new NewFrameEventHandler((sender, eventArgs) => { writer.WriteVideoFrame(eventArgs.Frame); frameControl = DateTime.Now; }); streamVideo.Start(); }
private void DoJob() { try { streamVideo = new ScreenCaptureStream(screenSize); streamVideo.NewFrame += new NewFrameEventHandler(video_NewFrame); streamVideo.Start(); stopWatch.Start(); } catch (Exception ex) { MessageBox.Show(ex.Message); } }
private void DoJob() { try { // create screen capture video source streamVideo = new ScreenCaptureStream(screenArea); // set NewFrame event handler streamVideo.NewFrame += new NewFrameEventHandler(video_NewFrame); // start the video source streamVideo.Start(); // stopWatch stopWatch.Start(); } catch (Exception gfdgdfhdf) { MessageBox.Show(gfdgdfhdf.Message); } }
public TestForm(string userId, bool load) { InitializeComponent(); uId = userId; if (load)//загружаем старую сессию { test = XML.LoadUserData(userId, out idQuestions, out idAnswers, out time, out curQuestion, out trueAnswers, out date); } else { test = XML.LoadRandQuestions(out idQuestions);//загружаем вопросы date = DateTime.Now.ToString(); } timer.Interval = new TimeSpan(0, 0, 1); //тик в каждую секунду timer.IsEnabled = true; timer.Tick += new EventHandler(timer_Tick); cUsrId.Content = userId; cAmountQuestions.Content = test.Count; //отображаем, сколько всего будет вопросов сCurQuestion.Content = curQuestion;//показываем номер текущего вопроса ShowQuestion(curQuestion - 1);//загружаем в форму содержимое вопроса //начинаем запись видео Rectangle screenArea = Rectangle.Empty; foreach (System.Windows.Forms.Screen screen in System.Windows.Forms.Screen.AllScreens) //получаем размер экрана { screenArea = Rectangle.Union(screenArea, screen.Bounds); } string videoPath = MainWindow.path + "\\video\\" + DateTime.Now.Date.ToShortDateString(); DirectoryInfo dir = new DirectoryInfo(videoPath); //записи хранятся рассортированными по папкам с датой в названии if (!dir.Exists)//проверяем, есть ли уже папка с сегодняшней датой dir.Create(); //если нет, то создаем ее int vidCount = dir.EnumerateFiles(userId + "*").Count(); //проверяем, есть ли уже записи с тамим именем if (vidCount ==0 ) videoPath = MainWindow.path + "\\video\\" + DateTime.Now.Date.ToShortDateString() + "\\" + userId + ".avi"; else videoPath = MainWindow.path + "\\video\\" + DateTime.Now.Date.ToShortDateString() + "\\" + userId + "_"+ vidCount + ".avi"; //если есть, то добавим порядковый номер stream = new ScreenCaptureStream(screenArea); stream.NewFrame += new NewFrameEventHandler(video_NewFrame); stream.FrameInterval = 100 / FRAMERATE; try { writer = new AVIWriter("XVID"); writer.FrameRate = FRAMERATE; writer.Quality = 1; writer.Open(videoPath, screenArea.Width, screenArea.Height); stream.Start(); } catch (Exception ex) { MessageBox.Show(ex.Message); } }