/// <summary>
        /// Stop all selected cameras that are running
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void stopAllBut_Click(object sender, EventArgs e)
        {
            this.stopAllBut.Text      = "....";
            this.stopAllBut.BackColor = Color.Yellow;
            this.stopAllBut.Refresh();

            for (int i = Program.TempCAMs.cameras.Count - 1; i >= 0; i--)
            {
                foreach (Control C in cameraControls[i].Controls)
                {
                    if (C is CheckBox)
                    {
                        if (((CheckBox)C).Checked)
                        {
                            //Stop the camera
                            AureusEdge.StopCameraByIndex(Int32.Parse(Program.TempCAMs.cameras[i].cameraIndex.Trim()), Program.msg);
                            //Set the values on the camera level
                            Program.TempCAMs.cameras[i].running = false;
                            Program.usedLicense -= 1;
                        }
                    }
                }
            }

            if (Program.usedLicense < 0)
            {
                Program.usedLicense = 0;
            }

            loadControls();

            this.stopAllBut.Text = "Stop All Selected";
            this.stopAllBut.UseVisualStyleBackColor = true;
            this.stopAllBut.Refresh();
        }
Exemplo n.º 2
0
        static void Main(string[] args)
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            mp_aureus = AureusEdge.CreateAndInitializeAureus(msg);
            checkLicense();

            settingsContent = readFromFile(Settings);

            //Declare all of the new global variables from above
            CAMS       = new CameraCollection();
            defaultAOI = new AOISettings();
            email      = new EmailSettings();

            //Call the function to load everything
            loadAll();

            TempCAMs = CAMS.clone(true);

            getLicenseNumber();

            CM = new CameraMonitor();
            camMonitorThread = new System.Threading.Thread(new System.Threading.ThreadStart(CM.monitor));
            camMonitorThread.Start();

            CF = new CameraForm();
            Application.Run(CF);
        }
        /// <summary>
        /// Start all selected cameras
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void startAllBut_Click(object sender, EventArgs e)
        {
            string failedCam = "";

            this.startAllBut.Text      = "....";
            this.startAllBut.BackColor = Color.Yellow;
            this.startAllBut.Refresh();

            //for (int i = Program.TempCAMs.cameras.Count - 1; i >= 0; i--)
            for (int i = 0; i < Program.TempCAMs.cameras.Count; i++)
            {
                foreach (Control C in cameraControls[i].Controls)
                {
                    if (C is CheckBox)
                    {
                        if (((CheckBox)C).Checked)
                        {
                            if (Program.usedLicense < Program.numberOfLicense)
                            {
                                //Create the post folder needed for a camera
                                Program.createDirectory(Program.TempCAMs.cameras[i].save_xml_folder);
                                Program.createDirectory(Program.TempCAMs.cameras[i].save_images_folder);
                                //Create the camera
                                AureusEdge.CreateCamera(Program.mp_aureus, Int32.Parse(Program.TempCAMs.cameras[i].cameraIndex.Trim()), 2, Program.msg);
                                //Start Camera
                                AureusEdge.StartCameraByIndex(Int32.Parse(Program.TempCAMs.cameras[i].cameraIndex.Trim()), Program.msg);
                                //Check the status
                                if (AureusEdge.RunningStatus(Int32.Parse(Program.TempCAMs.cameras[i].cameraIndex.Trim())) == 0)
                                {
                                    Program.TempCAMs.cameras[i].running = true;
                                    Program.usedLicense += 1;
                                }
                                else
                                {
                                    failedCam += formatError(Program.TempCAMs.cameras[i], "Reason: System Error.         ");
                                }
                            }
                            else
                            {
                                failedCam += formatError(Program.TempCAMs.cameras[i], "Reason: Camera Limit Reached. ");
                            }
                        }
                    }
                }
            }

            if (failedCam.Trim() != "")
            {
                MessageBox.Show("The following cameras have filed to start\r\n\r\n" + failedCam, "ERROR", MessageBoxButtons.OK);
            }
            loadControls();

            this.startAllBut.Text = "Start All Selected";
            this.startAllBut.UseVisualStyleBackColor = true;
            this.startAllBut.Refresh();
        }
Exemplo n.º 4
0
 /// <summary>
 /// Get the number of cameras that we are allowed to use
 /// </summary>
 internal static void getLicenseNumber()
 {
     try
     {
         AureusEdge.GetLicenseInfo(mp_aureus, msg);
         string info = msg.ToString();
         int    a    = info.IndexOf("=") + 2;
         int    b    = info.IndexOf("Time remaining");
         info = info.Substring(a, b - a).Trim();
         //Try to parse the number
         numberOfLicense = Int32.Parse(info);
     }
     catch
     {
         //If it fails, default to 1
         numberOfLicense = 1;
     }
 }
Exemplo n.º 5
0
        /// <summary>
        /// Call the get license info and display it
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void LicensePage_Load(object sender, EventArgs e)
        {
            AureusEdge.GetLicenseInfo(Program.mp_aureus, Program.msg);
            this.mainDIsplay.Text = Program.msg.ToString();
            this.mainDIsplay.Text = this.mainDIsplay.Text.Replace("\n", "\r\n\r\n");

            //string expDate = "";
            //Days
            int    a    = this.mainDIsplay.Text.IndexOf("Time remaining") + 14;
            int    b    = this.mainDIsplay.Text.IndexOf("days");
            string days = this.mainDIsplay.Text.Substring(a, b - a).Trim();
            ////Hours
            //a = this.mainDIsplay.Text.IndexOf("days,") + 5;
            //b = this.mainDIsplay.Text.IndexOf("hours");
            //expDate = this.mainDIsplay.Text.Substring(a, b - a).Trim();
            //DT = DT.AddHours(Int32.Parse(expDate));
            ////Minutes
            //a = this.mainDIsplay.Text.IndexOf("hours,") + 6;
            //b = this.mainDIsplay.Text.IndexOf("min");
            //expDate = this.mainDIsplay.Text.Substring(a, b - a).Trim();
            //DT = DT.AddMinutes(Int32.Parse(expDate));
            ////Seconds
            //a = this.mainDIsplay.Text.IndexOf("min,") + 4;
            //b = this.mainDIsplay.Text.IndexOf("sec");
            //expDate = this.mainDIsplay.Text.Substring(a, b - a).Trim();
            //DT = DT.AddSeconds(Int32.Parse(expDate));
            DateTime DT = Program.getLicenseExp(Program.msg.ToString());

            //Save the License Info
            string newLicense = "<licenseInformation><dateIssued>" + DateTime.Now.ToString("yyyyMMddHHmmss") + "</dateIssued><daysLeft>" + days + "</daysLeft><dateExpires>" + DT.ToString("yyyyMMddHHmmss") + "</dateExpires></licenseInformation>";

            Program.save("LICENSE", newLicense);

            this.mainDIsplay.Text += "\r\n\r\nExpiration Date:\r\n\t" + DT.ToString();
            this.mainDIsplay.Text  = this.mainDIsplay.Text.Replace(" = ", ":\r\n\t").Replace("Time remaining ", "Time remaining:\r\n\t");
            this.mainDIsplay.Refresh();
        }
Exemplo n.º 6
0
        /// <summary>
        /// Check if the user has their license. If not, do not let them continue
        /// This will put the user in essentially an infinite loop until they get their license
        /// </summary>
        internal static void checkLicense()
        {
            bool   canContinue = false;
            bool   firstLoop   = true;
            string failReason  = "";

            while (!canContinue)
            {
                if (File.Exists(licenseFile))
                {
                    //File does exist
                    string fileContent = readFromFile(licenseFile).Trim();
                    if (fileContent == "")
                    {
                        //File exists but is empty
                        failReason = "FILE-EMPTY";
                    }
                    else
                    {
                        if (!firstLoop)
                        {
                            //Kill it
                            AureusEdge.FreeAureus(mp_aureus, msg);
                            //Re-initilize it
                            mp_aureus = AureusEdge.CreateAndInitializeAureus(msg);
                        }
                        //Check if the license is valid
                        AureusEdge.GetLicenseInfo(mp_aureus, msg);
                        if (msg.ToString().Contains("Error!"))
                        {
                            //Invalid license
                            failReason = "INVALID-CONTENT";
                        }
                        else
                        {
                            //Do calculation
                            licenseEXP = getLicenseExp(msg.ToString());
                            if (licenseEXP <= DateTime.Now)
                            {
                                //License has expired
                                failReason = "EXPIRED";
                            }
                            else
                            {
                                canContinue = true;
                                break;
                            }
                        }
                    }
                }
                else
                {
                    //File does not exist.
                    failReason = "FILE-NOT-FOUND";
                }
                if (!canContinue)
                {
                    //Display the error form
                    IL = new InvalidLicense();
                    IL.errorMessage = failReason;
                    IL.loadDisplay();
                    IL.ShowDialog();
                    if (killApplication)
                    {
                        canContinue = true; break;
                    }
                }
                firstLoop = false;
            }

            //Kill the application. We needed to exit the loop first
            if (canContinue && killApplication)
            {
                exitApp(true);
            }
        }
Exemplo n.º 7
0
        //=================================== ALL OF THE GLOBAL FUNCTIONS WILL BE BELOW HERE ===================================\\

        /// <summary>
        /// Exit the application and kill all running items
        /// </summary>
        internal static void exitApp(bool exitEnvironment = false)
        {
            //Delete the contents of the "Results" folder
            if (System.IO.Directory.Exists(@"C:\Allevate\Face-Searcher\Results"))
            {
                System.IO.Directory.Delete(@"C:\Allevate\Face-Searcher\Results", true);
                System.IO.Directory.CreateDirectory(@"C:\Allevate\Face-Searcher\Results");
            }
            //Kill the monitor thread
            if (camMonitorThread != null)
            {
                camMonitorThread.Abort();
            }
            //Kil the AureusEdge program
            AureusEdge.FreeAureus(mp_aureus, msg);
            //If anything else needs to be done before exit. Do it here
            try
            {
                if (CF != null)
                {
                    CF.Dispose();
                }
                if (DT != null)
                {
                    DT.Dispose();
                }
                if (ES != null)
                {
                    ES.Dispose();
                }
                if (LP != null)
                {
                    LP.Dispose();
                }
                if (NF != null)
                {
                    NF.Dispose();
                }
                if (DA != null)
                {
                    DA.Dispose();
                }
                if (IL != null)
                {
                    IL.Dispose();
                }

                Application.Exit();
                try
                {
                    Environment.Exit(0);
                }catch
                {
                    Environment.Exit(1);
                }
                //if (exitEnvironment)
                //{
                //    Environment.Exit(0);
                //}
            }
            catch
            {
                //Do Nothing
            }
        }
        /// <summary>
        /// Start and stop the inividual camera
        /// </summary>
        /// <param name="CV"></param>
        private void startStopIndivCam(CameraValues CV, Button START)
        {
            string action = START.Text;

            START.Text      = "....";
            START.BackColor = Color.Yellow;
            START.Refresh();
            try
            {
                if (action == "START")
                {
                    if (Program.usedLicense < Program.numberOfLicense)
                    {
                        //Add camera by index
                        try
                        {
                            //Create the folder
                            Program.createDirectory(CV.save_xml_folder);
                            Program.createDirectory(CV.save_images_folder);
                            //Create the camera in Aureus Edge
                            AureusEdge.CreateCamera(Program.mp_aureus, Int32.Parse(CV.cameraIndex.Trim()), 2, Program.msg);
                        }
                        catch
                        {
                            //Do nothing. Camera was already added
                        }
                        //Start Camera
                        AureusEdge.StartCameraByIndex(Int32.Parse(CV.cameraIndex.Trim()), Program.msg);
                        //Check the status
                        if (AureusEdge.RunningStatus(Int32.Parse(CV.cameraIndex.Trim())) == 0)
                        {
                            //Good to go. Update the display
                            CV.running           = true;
                            START.Text           = "STOP";
                            START.BackColor      = Color.Red;
                            Program.usedLicense += 1;
                        }
                        else
                        {
                            //Camera did not start
                            MessageBox.Show("Camera " + CV.cameraIndex + " Failed to start\r\n" + CV.URL, "ERROR", MessageBoxButtons.OK);
                        }
                    }
                    else
                    {
                        MessageBox.Show("Cannot start camera. All allowed cameras are currently in use", "Warning", MessageBoxButtons.OK);
                    }
                }
                else
                {
                    AureusEdge.StopCameraByIndex(Int32.Parse(CV.cameraIndex), Program.msg);
                    //AureusEdge.DestroyCameraByIndex(Int32.Parse(CV.cameraIndex));
                    //Check the status
                    CV.running           = false;
                    START.Text           = "START";
                    START.BackColor      = Color.MediumSeaGreen;
                    Program.usedLicense -= 1;
                }
            }
            catch
            {
                if (action == "START")
                {
                    START.Text      = "START";
                    START.BackColor = Color.MediumSeaGreen;
                }
                else
                {
                    START.Text      = "STOP";
                    START.BackColor = Color.Red;
                }
                START.Refresh();
            }

            if (Program.usedLicense < 0)
            {
                Program.usedLicense = 0;
            }

            loadControls();
        }