Exemplo n.º 1
0
        private void recordingBtn_Click(object sender, EventArgs e)
        {
            //capture cpt = new capture();
            // cpt.Show();


            XmlDocument xmlDoc = new XmlDocument();

            try
            {
                string progPath = System.AppDomain.CurrentDomain.BaseDirectory;
                xmlDoc.Load(progPath + @"\options.xml");

                path = xmlDoc.GetElementsByTagName("savePath1");  // get the path from xml file
                string directory = path[0].InnerText;
                directory = directory.Replace("\\", @"\");

                DateTime Date = DateTime.Now; // this will be the file name
                string   fileName;
                fileName = Date.ToString();
                fileName = fileName.Replace("/", ""); fileName = fileName.Replace(":", "");

                XmlNodeList screens = xmlDoc.GetElementsByTagName("screens"); //  gets the screens that need to be recorded
                int         scr     = Convert.ToInt32(screens[0].InnerText);  //


                //***************************************************************************************************
                switch (scr)
                {
                case 0:     // capture primary only
                case 1:
                default:
                    job.CaptureRectangle = new Rectangle(0, 0, Screen.PrimaryScreen.Bounds.Width, Screen.PrimaryScreen.Bounds.Height);

                    break;

                case 2:      // capture secondary if exist if not capture primary
                    if (Screen.AllScreens.Count() > 1)
                    {
                        job.CaptureRectangle = new Rectangle(0 + Screen.PrimaryScreen.Bounds.Width, 0, Screen.AllScreens.ElementAt(1).Bounds.Width, Screen.AllScreens.ElementAt(1).Bounds.Height);
                    }
                    else
                    {
                        job.CaptureRectangle = new Rectangle(0, 0, Screen.PrimaryScreen.Bounds.Width, Screen.PrimaryScreen.Bounds.Height);
                    }
                    break;

                case 3:     // capture both if exist if not capture primary
                    if (Screen.AllScreens.Count() > 1)
                    {
                        job.CaptureRectangle = new Rectangle(0, 0, Screen.PrimaryScreen.Bounds.Width + Screen.AllScreens.ElementAt(1).Bounds.Width, Screen.PrimaryScreen.Bounds.Height + Screen.AllScreens.ElementAt(1).Bounds.Height);
                    }
                    else
                    {
                        job.CaptureRectangle = new Rectangle(0, 0, Screen.PrimaryScreen.Bounds.Width, Screen.PrimaryScreen.Bounds.Height);
                    }
                    break;
                }
                //*************************************************************************************
                job.CaptureMouseCursor = true;

                try
                {
                    stopBtn.Visible                 = true;
                    stopBtn.Enabled                 = false;
                    recordingBtn.Enabled            = false;
                    job.OutputScreenCaptureFileName = directory + @"\" + fileName + ".wmv";

                    messageWin ms = new messageWin();
                    ms.Show();
                    ms.SetDesktopLocation(0, 0);

                    // this sets a timer delay for 2 seconds
                    //------------------------------------------------------------
                    DateTime dt1  = DateTime.Now;
                    int      diff = 0;

                    while (diff < 3)
                    {
                        DateTime dt2 = DateTime.Now;
                        TimeSpan ts  = dt2.Subtract(dt1);
                        diff = (int)ts.TotalSeconds;
                        Application.DoEvents();
                    }
                    //-------------------------------------------------------------
                    ms.Close();

                    this.WindowState = FormWindowState.Minimized;
                    job.Start();
                    stopBtn.Enabled      = true;
                    recordingBtn.Enabled = true;
                }
                catch
                {
                    if (!Directory.Exists(@"C:\temp"))
                    {
                        Directory.CreateDirectory(@"C:\temp");
                    }
                    job.OutputScreenCaptureFileName = @"C:\tmep\" + fileName + ".wmv";
                    job.Start();
                }
            }
            catch (Exception err)
            {
                MessageBox.Show("Cannot start recording, please try again" + err.ToString());
            }
            //  timer = new System.Threading.Timer(ComputeBoundOp, null, 0, 2000);
        }
Exemplo n.º 2
0
        private void recordingBtn_Click(object sender, EventArgs e)
        {
            //capture cpt = new capture();
               // cpt.Show();

            XmlDocument xmlDoc = new XmlDocument();
            try
            {
                string progPath = System.AppDomain.CurrentDomain.BaseDirectory;
                xmlDoc.Load(progPath + @"\options.xml");

                path = xmlDoc.GetElementsByTagName("savePath1");  // get the path from xml file
                string directory = path[0].InnerText;
                directory = directory.Replace("\\", @"\");

                DateTime Date = DateTime.Now; // this will be the file name
                string fileName;
                fileName = Date.ToString();
                fileName = fileName.Replace("/", ""); fileName = fileName.Replace(":", "");

                XmlNodeList screens = xmlDoc.GetElementsByTagName("screens");  //  gets the screens that need to be recorded
                int scr =Convert.ToInt32(screens[0].InnerText);               //

              //***************************************************************************************************
                switch (scr)
                {
                    case 0: // capture primary only
                    case 1:
                    default:
                job.CaptureRectangle = new Rectangle(0, 0, Screen.PrimaryScreen.Bounds.Width, Screen.PrimaryScreen.Bounds.Height);

                   break;
                    case 2:  // capture secondary if exist if not capture primary
                   if (Screen.AllScreens.Count() > 1)
                       job.CaptureRectangle = new Rectangle(0 + Screen.PrimaryScreen.Bounds.Width, 0, Screen.AllScreens.ElementAt(1).Bounds.Width, Screen.AllScreens.ElementAt(1).Bounds.Height);
                   else
                       job.CaptureRectangle = new Rectangle(0, 0, Screen.PrimaryScreen.Bounds.Width, Screen.PrimaryScreen.Bounds.Height);
                   break;
                   case 3 : // capture both if exist if not capture primary
                   if (Screen.AllScreens.Count() > 1)
                      job.CaptureRectangle = new Rectangle(0, 0, Screen.PrimaryScreen.Bounds.Width + Screen.AllScreens.ElementAt(1).Bounds.Width, Screen.PrimaryScreen.Bounds.Height + Screen.AllScreens.ElementAt(1).Bounds.Height);
                   else
                       job.CaptureRectangle = new Rectangle(0, 0, Screen.PrimaryScreen.Bounds.Width, Screen.PrimaryScreen.Bounds.Height);
                   break;

               }
             //*************************************************************************************
                job.CaptureMouseCursor = true;

                try
                {
                    stopBtn.Visible = true;
                    stopBtn.Enabled = false;
                    recordingBtn.Enabled = false;
                    job.OutputScreenCaptureFileName = directory + @"\" + fileName + ".wmv";

                    messageWin ms = new messageWin();
                    ms.Show();
                    ms.SetDesktopLocation(0, 0);

                    // this sets a timer delay for 2 seconds
                    //------------------------------------------------------------
                    DateTime dt1 = DateTime.Now;
                    int diff = 0;

                    while (diff < 3)
                    {

                        DateTime dt2 = DateTime.Now;
                        TimeSpan ts = dt2.Subtract(dt1);
                        diff = (int)ts.TotalSeconds;
                        Application.DoEvents();

                    }
                    //-------------------------------------------------------------
                    ms.Close();

                    this.WindowState = FormWindowState.Minimized;
                    job.Start();
                    stopBtn.Enabled = true;
                    recordingBtn.Enabled = true;
                }
                catch
                {
                    if (!Directory.Exists(@"C:\temp"))
                        Directory.CreateDirectory(@"C:\temp");
                    job.OutputScreenCaptureFileName = @"C:\tmep\" + fileName + ".wmv";
                    job.Start();

                }
            }
            catch (Exception err)
            {
                MessageBox.Show("Cannot start recording, please try again" + err.ToString());
            }
              //  timer = new System.Threading.Timer(ComputeBoundOp, null, 0, 2000);
        }