private void Window_Closed(object sender, EventArgs e)
        {
            sensor.OnImageReceived -= Fp_OnImageReceived;
            sensor.OnEnroll        -= Fp_OnEnroll;
            sensor.OnFeatureInfo   -= Sensor_OnFeatureInfo;

            SensorInstance.CloseSensorConnection();
        }
        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            SensorInstance.OpenSensorConnection();

            sensor.OnImageReceived += Fp_OnImageReceived;
            sensor.OnEnroll        += Fp_OnEnroll;
            sensor.OnFeatureInfo   += Sensor_OnFeatureInfo;

            sensor.CancelEnroll();
            sensor.EnrollCount = 3;
            sensor.BeginEnroll();
        }
        private void Identificacion_Desactivada()
        {
            if (sensor.Active)
            {
                sensor.OnCapture       -= Fp_OnCapture;
                sensor.OnImageReceived -= Fp_OnImageReceived;

                if (fpcHandle > 0)
                {
                    sensor.FreeFPCacheDB(fpcHandle);
                }

                SensorInstance.CloseSensorConnection();
            }
            profes.Clear();
        }
        private void Identificacion_Activada()
        {
            SensorInstance.OpenSensorConnection();

            if (sensor.Active)
            {
                fpcHandle = sensor.CreateFPCacheDB();

                sensor.OnCapture       += Fp_OnCapture;
                sensor.OnImageReceived += Fp_OnImageReceived;
            }
            else
            {
                MessageBoxResult res = MessageBox.Show("Desea cerrar el programa?", "Sensor no conectado", MessageBoxButton.YesNo);

                if (res == MessageBoxResult.Yes)
                {
                    this.Close();
                    Environment.Exit(0);
                }
            }

            hoy = Dia.ObtenerDia();

            List <Profesor> profeshoy   = DBServices.ObtenerProfesoresPorDia(hoy);
            List <Profesor> profestodos = DBServices.ObtenerProfesores();

            foreach (var profe in profeshoy)
            {
                if (!profes.ContainsKey(profe.id))
                {
                    profes.Add(profe.id, profe);
                    Trace.WriteLine("Profesor " + profe.nombre);

                    string huella   = profe.huella;
                    string huella10 = profe.huella10;

                    if (sensor.Active && sensor.AddRegTemplateStrToFPCacheDBEx(fpcHandle, profe.id, huella, huella10) == 1)
                    {
                        Trace.WriteLine("Huella ingresada " + profe.nombre);
                    }
                    else
                    {
                        Trace.WriteLine("Huella no ingresada");
                    }
                }
            }

            foreach (var profe in profestodos)
            {
                if (!profes.ContainsKey(profe.id))
                {
                    profes.Add(profe.id, profe);
                    Trace.WriteLine("Profesor " + profe.nombre);

                    string huella   = profe.huella;
                    string huella10 = profe.huella10;

                    if (sensor.Active && sensor.AddRegTemplateStrToFPCacheDBEx(fpcHandle, profe.id, huella, huella10) == 1)
                    {
                        Trace.WriteLine("Huella ingresada " + profe.nombre);
                    }
                    else
                    {
                        Trace.WriteLine("Huella no ingresada");
                    }
                }
            }
        }