Example #1
0
        /// <summary>
        /// 控制項狀態更新
        /// </summary>
        private void RefreshControl()
        {
            _byPhoto.Enabled            = _view.EnableByPhoto();
            _byCam.Enabled              = _view.EnableByCam();
            _Borwse.Enabled             = _view.EnableBrowse();
            _continuedOrCapture.Enabled = _view.StopCapture();
            _trainButton.Enabled        = !_isTraining;
            _userNameLabel.Text         = "";

            //Save Face
            _saveFaceButton.Enabled  = _faceService.IsFaceDetected();
            _usernameTextBox.Enabled = _faceService.IsFaceDetected();
            //username list
            _userNameListBox.DataSource = _faceService.GetAllUsernames();
            //user faces group
            try
            {
                _facesListBox.DataSource = _faceService.GetFacesByUserName(_userNameListBox.SelectedItem.ToString());
                facesGroupBox.Enabled    = true;
            }
            catch (Exception)
            {
                _facesListBox.DataSource = null;
                facesGroupBox.Enabled    = false;
                //MessageBox.Show(e.Message);
            }

            //Capture State
            refreshCaptureState();
        }
        /// <summary>
        /// 取得所有資料庫中的人名
        /// </summary>
        /// <returns></returns>
        public ActionResult GetAllPersonName()
        {
            _faceService = new FaceDP(Server.MapPath("~"));
            List <string> userNames = _faceService.GetAllUsernames();
            string        json      = JsonConvert.SerializeObject(userNames);
            var           temp      = Content(json, "application/json");

            temp.ContentEncoding = Encoding.UTF8;

            return(temp);
        }