Пример #1
0
        // 摄像按钮
        private void Photograph(object sender, RoutedEventArgs e)
        {
            if (t3.Text == "" || IDCard.Text == "")
            {
                MessageBoxX.Info(LanguageUtils.ConvertLanguage("请填写完整信息", "Please fill in the complete information"));
                return;
            }
            // 切换用户图片的显示,解决线程占用问题

            BitmapImage bitmap = new BitmapImage(new Uri(@"\view\images\NoPhoto.png", UriKind.Relative));

            pic.Source = bitmap;

            Photograph photograph = new Photograph
            {
                Owner                 = Window.GetWindow(this),
                ShowActivated         = true,
                ShowInTaskbar         = false,
                WindowStartupLocation = WindowStartupLocation.CenterScreen
            };

            //如果不存在摄像头,不必打开界面
            if (!photograph.existCameras)
            {
                return;
            }

            photograph.getName      = t3.Text;
            photograph.id           = IDCard.Text;
            photograph.oldPhotoName = SelectUser.User_PhotoLocation;
            photograph.ShowDialog();
            photoName = photograph.photoName;
            //photograph.Close();
            Console.WriteLine(photoName);
            //在更新页面上展示用户 刚刚更新的照片
            string photoUpdatePhoto = CommUtil.GetUserPic() + photoName;

            if (File.Exists(photoUpdatePhoto))
            {
                //MessageBox.Show("hi open!");
                BitmapImage image = new BitmapImage(new Uri(photoUpdatePhoto, UriKind.Absolute)); //打开图片
                pic.Source = image.Clone();                                                       //将控件和图片绑定
            }
        }
Пример #2
0
        // 摄像
        private void Photograph(object sender, RoutedEventArgs e)
        {
            if (t3.Text == "" || IDCard.Text == "")
            {
                MessageBoxX.Info(LanguageUtils.ConvertLanguage("请填写完整信息", "Please fill in the complete information"));
                return;
            }

            Photograph photograph = new Photograph
            {
                Owner                 = Window.GetWindow(this),
                ShowActivated         = true,
                ShowInTaskbar         = false,
                WindowStartupLocation = WindowStartupLocation.CenterScreen
            };

            //如果不存在摄像头,不必打开界面
            if (photograph.existCameras == false)
            {
                return;
            }

            photograph.getName      = t3.Text;
            photograph.id           = IDCard.Text;
            photograph.oldPhotoName = oldPhotoName;
            photograph.ShowDialog();
            photoName    = photograph.photoName;
            oldPhotoName = photoName;
            //photograph.Close();
            //展示摄像的时候的图片
            if (File.Exists(CommUtil.GetUserPic() + photoName))
            {
                //MessageBox.Show("hi open!");
                BitmapImage bitmap = new BitmapImage(new Uri(CommUtil.GetUserPic() + photoName, UriKind.Absolute)); //打开图片
                pic.Source = bitmap.Clone();                                                                        //将控件和图片绑定
            }
        }