public static void DelTemplateToUser(UserClass theUser, int fingerIndex)
        {
            FingerData newfinger = new FingerData();

            newfinger.CopyUserToFinger(theUser);
            newfinger.Templates[fingerIndex] = null;

            if (fingerIndex > 4)
            {
                newfinger.EnrolledFingersMask = newfinger.EnrolledFingersMask & (0xFE << ConvertSCtoFPIndex(fingerIndex));
            }
            else
            {
                newfinger.EnrolledFingersMask = newfinger.EnrolledFingersMask & (0xFE << ConvertSCtoFPIndex(fingerIndex));
            }
            newfinger.CopyFingerToUser(theUser);
        }
        public static void AddTemplateToUser(UserClass theUser, byte[] template, int fingerIndex)
        {
            System.IO.Stream dataStream     = new System.IO.MemoryStream(template);
            DPFP.Template    templateToLoad = new DPFP.Template(dataStream);

            FingerData newfinger = new FingerData();

            newfinger.CopyUserToFinger(theUser);
            newfinger.Templates[fingerIndex] = templateToLoad;

            if (fingerIndex > 4)
            {
                newfinger.EnrolledFingersMask = newfinger.EnrolledFingersMask | (0x01 << ConvertSCtoFPIndex(fingerIndex));
            }
            else
            {
                newfinger.EnrolledFingersMask = newfinger.EnrolledFingersMask | (0x01 << ConvertSCtoFPIndex(fingerIndex));
            }
            newfinger.CopyFingerToUser(theUser);
        }
        public string EnrollUser(string FPSerialNumber, string FirstName, string LastName, string template, bool bNotEnroll)
        {
            if (myFinger != null)
            {
                ReleaseFingerprint();
            }
            //   myFinger.SetTextBox("Request Enroll User :"******"{"))
                {
                    fingerSerial = "{" + FPSerialNumber;
                }
                else
                {
                    fingerSerial = FPSerialNumber;
                }

                if (!FPSerialNumber.Contains("}"))
                {
                    fingerSerial += "}";
                }

                Guid guid;
                if (!IsGuid(fingerSerial, out guid))
                {
                    return(null);
                }
            }

            FingerData newfinger = new FingerData();
            UserClass  TheUser   = new UserClass();

            if (!String.IsNullOrEmpty(template))
            {
                BinaryFormatter bf  = new BinaryFormatter();
                MemoryStream    mem = new MemoryStream(Convert.FromBase64String(template));
                TheUser = (UserClass)bf.Deserialize(mem);
            }
            else
            {
                TheUser.firstName = FirstName;
                TheUser.lastName  = LastName;
            }

            if (!bNotEnroll)
            {
                newfinger.CopyUserToFinger(TheUser);
                EnrollmentProcess Enroller = new EnrollmentProcess(fingerSerial, newfinger);
                Enroller.ShowDialog();  // process enrollment
                newfinger.CopyFingerToUser(TheUser);
            }

            BinaryFormatter bf2  = new BinaryFormatter();
            MemoryStream    mem2 = new MemoryStream();

            bf2.Serialize(mem2, TheUser);
            return(Convert.ToBase64String(mem2.ToArray()));
        }