コード例 #1
0
        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            this.Height = SystemParameters.WorkArea.Size.Height;
            var hwnd = new System.Windows.Interop.WindowInteropHelper(this).Handle;

            SetWindowLong(hwnd, GWL_STYLE, GetWindowLong(hwnd, GWL_STYLE) & ~WS_SYSMENU);
            //获取最初姓名
            origin_name = t2.Text;
            //获取最初姓名
            origin_name_pinyin = SelectUser.User_Namepinyin;
            //获得最初的手机号
            origin_phone = SelectUser.User_Phone;
            //获得最初的身份证号
            origin_IDCard = SelectUser.User_IDCard;
            photoName     = SelectUser.User_PhotoLocation;

            // 加zai用戶的照片
            //更新完用戶后刷新一下展示的tu片
            //selectUser = (User)UsersInfo.SelectedItem;
            string path = CommUtil.GetUserPic() + photoName; // huo的用戶的tu片url

            if (File.Exists(path))
            {
                BitmapImage i = new BitmapImage(new Uri(path,
                                                        UriKind.Absolute)); //打开图片
                pic.Source = i.Clone();                                     //将控件和图片绑定
            }
            else
            {
                BitmapImage bitmap = new BitmapImage(new Uri(@"\view\images\NoPhoto.png", UriKind.Relative));
                pic.Source = bitmap;
            }
        }
コード例 #2
0
        public Int16 GetPicturePackCount(string idCard)
        {
            UserService userService = new UserService();
            User        u           = userService.GetByIdCard(idCard);
            string      path        = CommUtil.GetUserPic(u.User_PhotoLocation);

            return((Int16)GetPicturePackCount(path, ProtocolConstant.PIC_PACK_SIZE));
        }
コード例 #3
0
        public byte[] GetPictureData(string idCard, int packNum)
        {
            UserService userService = new UserService();
            User        u           = userService.GetByIdCard(idCard);
            string      path        = CommUtil.GetUserPic(u.User_PhotoLocation);

            return(GetPictureData(path, packNum, ProtocolConstant.PIC_PACK_SIZE));
        }
コード例 #4
0
        // 用户自主选择照片
        private void Select_Picture_Show(object sender, RoutedEventArgs e)
        {
            if (t3.Text == "" || IDCard.Text == "")
            {
                MessageBoxX.Info(LanguageUtils.ConvertLanguage("请填写完整信息", "Please fill in the complete information"));
                return;
            }

            using (System.Windows.Forms.OpenFileDialog ofd = new System.Windows.Forms.OpenFileDialog())
            {
                ofd.Title           = "请选择要插入的图片";
                ofd.Filter          = "JPG图片|*.jpg|BMP图片|*.bmp|Gif图片|*.gif";
                ofd.CheckFileExists = true;
                ofd.CheckPathExists = true;
                ofd.Multiselect     = false;

                if (ofd.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                {
                    BitmapImage image = new BitmapImage(new Uri(ofd.FileName, UriKind.Absolute));//打开图片
                    var         win2  = new PhotoCutWindow(image)
                    {
                        Owner                 = Window.GetWindow(this),
                        ShowActivated         = true,
                        ShowInTaskbar         = false,
                        WindowStartupLocation = WindowStartupLocation.CenterScreen
                    };
                    win2.getName      = t3.Text;
                    win2.id           = IDCard.Text;
                    win2.oldPhotoName = oldPhotoName;
                    //如果是免冠照片
                    double p = image.Width / image.Height;//照片比例
                    if (p > 0.6 && p < 0.8)
                    {
                        PicZipUtil.GetPicThumbnail(ofd.FileName, CommUtil.GetUserPic() + win2.getPhotoName());
                    }
                    else
                    {
                        win2.ShowDialog();
                    }
                    photoName    = win2.photoName;
                    oldPhotoName = photoName;
                    //photograph.Close();
                    Console.WriteLine(photoName);
                    //在更新页面上展示用户 刚刚更新的照片
                    string photoUpdatePhoto = CommUtil.GetUserPic() + photoName;
                    if (File.Exists(photoUpdatePhoto))
                    {
                        //MessageBox.Show("hi open!");
                        BitmapImage i = new BitmapImage(new Uri(photoUpdatePhoto, UriKind.Absolute)); //打开图片
                        pic.Source = i.Clone();                                                       //将控件和图片绑定
                    }
                }
                else
                {
                    userIfSelectPic = false;
                }
            }
        }
コード例 #5
0
        //按钮:更新
        private void UserUpdata(object sender, RoutedEventArgs e)
        {
            // 切换用户图片的显示,解决线程占用问题
            BitmapImage bitmap = new BitmapImage(new Uri(@"\view\images\NoPhoto.png", UriKind.Relative));

            UserPhoto.Source = bitmap;

            //检查是否选中
            if ((User)UsersInfo.SelectedItem == null)
            //if (selectUser == null)//4.7 lzh
            {
                MessageBoxX.Warning(LanguageUtils.ConvertLanguage("请选择用户再进行操作!", "Please Select A Subject!"));
                // MessageBox.Show(LanguageUtils.ConvertLanguage("请选择用户再进行操作!", "Please Select A Subject!"));
                return;
            }

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

            //类中使用
            User user = (User)UsersInfo.SelectedItem;

            userUpdata.SelectUser = user;
            //UI中使用
            userUpdata.selectUser.DataContext = user;
            //Console.WriteLine("123123:   " + user.User_Privateinfo);
            userUpdata.noPublicInfoText.Text = user.User_Privateinfo;
            //Console.WriteLine("123123aaaaa:   " + userUpdata.noPublicInfoText.Text);
            userUpdata.ShowDialog();

            //关闭后刷新界面
            users = userService.GetAllUsers();
            UsersInfo.ItemsSource = users;

            // 加载用户头像
            string photoUrl = CommUtil.GetUserPic() + selectUser.User_PhotoLocation;

            if (selectUser.User_PhotoLocation != null)
            {
                try
                {
                    BitmapImage b = new BitmapImage(new Uri(photoUrl, UriKind.Absolute)); //打开图片
                    UserPhoto.Source = b.Clone();                                         //将控件和图片绑定
                }
                catch (Exception ee)
                {
                }
            }
            //更新之后,刷新左下角
            Refresh_RecordFrame_Action();
        }
コード例 #6
0
        /// <summary>
        /// 箭筒截图是否成功
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void ImageDealer_OnOnCutImaging(object sender, RoutedEventArgs e)
        {
            var    ddd = (BitmapSource)e.OriginalSource;
            Bitmap bit = BitmapFromSource(ddd);

            //指定照片尺寸这么大
            var      bmcpy = new Bitmap(183, 256);
            Graphics gh    = Graphics.FromImage(bmcpy);

            gh.DrawImage(bit, new System.Drawing.Rectangle(0, 0, 183, 256));

            bmcpy.Save(CommUtil.GetUserPic() + photoName, System.Drawing.Imaging.ImageFormat.Jpeg);
        }
コード例 #7
0
        //private void dgData_LoadingRow(object sender, DataGridRowEventArgs e)
        //{
        //    e.Row.Header = e.Row.GetIndex() + 1;
        //}



        /// <summary>
        /// 选中使用者信息时触发,将详细信息展示在左下角
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Grid_Click(object sender, MouseButtonEventArgs e)
        {
            ifSelecUser = true;
            if (UsersInfo.SelectedIndex == -1)
            {
                id.Content = null;
            }
            else
            {
                id.Content = UsersInfo.SelectedIndex + 1;//使用者详细信息展示框id设置
            }
            selectUser = (User)UsersInfo.SelectedItem;

            //UserInfo
            UserInfo.DataContext = selectUser;
            string path = null;

            // 选中用户的时候初始化
            is_signinformationrecord.Focus();

            //选中用户时展示 症状 训练 体力的记录框的frame
            //Radio_Check_Action();
            // 给frame加入数据
            Refresh_RecordFrame_Action();

            if (selectUser != null && selectUser.User_IDCard != null && selectUser.User_Namepinyin != null && selectUser.User_IDCard != "" && selectUser.User_Namepinyin != "")
            {
                path  = CommUtil.GetUserPic();
                path += selectUser.User_PhotoLocation;
            }
            else
            {
                return;
            }

            //看照片是否存在
            if (!File.Exists(path))
            {
                BitmapImage bitmap = new BitmapImage(new Uri(@"\view\images\NoPhoto.png", UriKind.Relative));

                UserPhoto.Source = bitmap;

                return;
            }
            else
            {
                UserPhoto.Source = new BitmapImage(new Uri(path)).Clone();
            }
        }
コード例 #8
0
        public byte[] GetPictureData(string idCard)
        {
            UserService userService = new UserService();
            User        u           = userService.GetByIdCard(idCard);
            string      path        = CommUtil.GetUserPic(u.User_PhotoLocation);

            using (FileStream fs = new FileStream(path, FileMode.Open))
            {
                byte[] byteData = new byte[fs.Length];
                fs.Read(byteData, 0, byteData.Length);


                return(byteData);
            }
        }
コード例 #9
0
        /// <summary>
        /// 点击裁剪按钮
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            //创建文件夹
            CreateDir(CommUtil.GetUserPic());
            ImageDealer.CutImage();

            /*
             * string newFileName = photoName.Replace(".jpg", ".gif");
             *
             * if (PicZipUtil.GetPicThumbnail(CommUtil.GetUserPic() + photoName, CommUtil.GetUserPic() + newFileName, 50))
             * {
             *
             *  photoName = newFileName;
             * }*/
            this.Close();
        }
コード例 #10
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();                                                       //将控件和图片绑定
            }
        }
コード例 #11
0
        public string getPhotoName()
        {
            if (string.IsNullOrEmpty(oldPhotoName))
            {
                photoName = getName + id;
            }
            else
            {
                photoName = oldPhotoName.Substring(0, oldPhotoName.LastIndexOf(".")) + "z";
                // 如果该文件已存在,继续在尾部追加“z”,知道文件不存在,就确定这个名字为文件名
                while (File.Exists(CommUtil.GetUserPic() + photoName + ".jpg") || File.Exists(CommUtil.GetUserPic() + photoName + ".gif"))
                {
                    oldPhotoName = photoName + ".jpg";
                    photoName    = oldPhotoName.Substring(0, oldPhotoName.LastIndexOf(".")) + "z";
                }
            }

            photoName += ".jpg";
            return(photoName);
        }
コード例 #12
0
        // 保存图片按钮
        private void SavePic(object sender, RoutedEventArgs e)
        {
            vce.Stop();
            if ((BitmapSource)picResult.Source == null)
            {
                return;
            }
            Bitmap bit = BitmapFromSource((BitmapSource)picResult.Source);

            //指定照片尺寸这么大
            var      bmcpy = new Bitmap(183, 256);
            Graphics gh    = Graphics.FromImage(bmcpy);

            gh.DrawImage(bit, new System.Drawing.Rectangle(0, 0, 183, 256));
            photoName = getName + id;
            if (oldPhotoName == getName + id + ".jpg" || oldPhotoName == getName + id + ".gif")
            {
                photoName += "_1";
            }

            photoName += ".jpg";


            var bytes = Bitmap2Byte(bmcpy);

            CreateDir(CommUtil.GetUserPic());
            //大于10K再压缩
            if (bytes.Length > 1024 * 10)
            {
                PicZipUtil.GetPicThumbnail(bmcpy, CommUtil.GetUserPic() + photoName, 80);
            }
            else
            {
                bmcpy.Save(CommUtil.GetUserPic() + photoName, System.Drawing.Imaging.ImageFormat.Jpeg);
            }



            this.Close();
        }
コード例 #13
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();                                                                        //将控件和图片绑定
            }
        }
コード例 #14
0
        /// <summary>
        /// 确定保存添加按钮
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Button_OK(object sender, RoutedEventArgs e)
        {
            //获取用户身份证的内容
            //string userID = t1.Text;
            //获取用户姓名的内容
            string userName = t2.Text;
            //获取用户姓名拼音的内容
            string usernamePY = t3.Text;
            //获取用户性别的内容
            string usersex = c1.Text;
            //获取用户出生年月的内容
            string brithday = t4.Text;
            //获得身份证号
            string IDCard = this.IDCard.Text;
            //获得手机号
            string phone = this.phoneNum.Text;

            //获取身份证与手机号之后马上查重
            //if (userService.GetByIdCard(IDCard) != null)
            //{
            //    //身份证重复气泡提示
            //    Error_Info_IDCard.Content = "该身份证已注册";
            //    bubble_IDCard.IsOpen = true;
            //}
            //if (userService.GetByPhone(phone) != null)
            //{
            //    //手机重复气泡提示
            //    Error_Info_Phone.Content = "该手机号已注册";
            //    bubble_phone.IsOpen = true;
            //}
            if (!String.IsNullOrEmpty(IDCard) || IDCard.Length > 31)
            {
                //if (IDCard.Length < 18)
                //{
                //    //for (int i = IDCard.Length; i < 18; i++)
                //    //{
                //    //    IDCard = IDCard + '0';
                //    //}
                //    if (userService.GetByIdCard(IDCard) != null)
                //    {
                //        //身份证重复气泡提示
                //        Error_Info_IDCard.Content = LanguageUtils.ConvertLanguage("该身份证已注册", "This ID is registered");
                //        bubble_IDCard.IsOpen = true;
                //        return;

                //    }
                //}
                //else
                if (IDCard.Length == 18 && !inputlimited.InputLimited.IsIDcard(IDCard))
                {
                    Error_Info_IDCard.Content = LanguageUtils.ConvertLanguage("请输入正确的身份证号码", "Please enter a valid ID number");
                    bubble_IDCard.IsOpen      = true;
                    return;
                }
                else if (userService.GetByIdCard(IDCard) != null)
                {
                    //身份证重复气泡提示
                    Error_Info_IDCard.Content = LanguageUtils.ConvertLanguage("该身份证已注册", "This ID is registered");
                    bubble_IDCard.IsOpen      = true;
                    return;
                }
                else
                {
                    bubble_IDCard.IsOpen = false;
                }
            }
            else
            {
                Error_Info_IDCard.Content = LanguageUtils.ConvertLanguage("请输入正确的身份证号码", "Please enter the ID number");
                bubble_IDCard.IsOpen      = true;
                return;
            }
            if (String.IsNullOrEmpty(phone))
            {
                Error_Info_Phone.Content = LanguageUtils.ConvertLanguage("请输入手机号", "Please enter phone number");
                bubble_phone.IsOpen      = true;
                return;
            }
            else
            {
                if (userService.GetByPhone(phone) != null)
                {
                    //手机重复气泡提示
                    Error_Info_Phone.Content = LanguageUtils.ConvertLanguage("该手机号已注册", "The phone number is registered");
                    bubble_phone.IsOpen      = true;
                    return;
                }
                else if (!inputlimited.InputLimited.IsHandset(phone) && !String.IsNullOrEmpty(phone))
                {
                    Error_Info_Phone.Content = LanguageUtils.ConvertLanguage("请输入正确的手机号", "Please enter a valid phone number");
                    bubble_phone.IsOpen      = true;
                    return;
                }
            }
            string IdCard = this.IDCard.Text;
            string name   = t3.Text;
            //获取小组名称的内容
            string groupName = c2.Text;
            //获取初期要介护度的内容
            string initial = c3.SelectedIndex.ToString();
            //获取现在要介护度的内容
            string now = c4.SelectedIndex.ToString();
            //获取疾病名称的内容
            string sicknessName = c5.Text;
            //获取残障名称的内容
            string disabilityName = c6.Text;
            //获取备忘的内容
            TextRange text = new TextRange(t6.Document.ContentStart, t6.Document.ContentEnd);
            string    memo = text.Text;
            //私密信息
            String noPublicInfo = this.noPublicInfoText.Text;
            //string secretMessage = this.Non_Public_Information.
            User user = new User();

            user.User_Privateinfo = noPublicInfo;
            user.User_Birth       = Convert.ToDateTime(brithday);
            user.User_GroupName   = groupName;
            //设置私密信息
            user.User_Privateinfo = noPublicInfo == null ? "" : noPublicInfo;
            //user.User_Privateinfo = secretMessage==null?"":secretMessage;
            if (IdCard == null || name == null || IDCard == "" || name == "")
            {
                MessageBoxX.Info(LanguageUtils.ConvertLanguage("没有填写身份证或者名字(拼音)", "No identity card or First Name"));
                return;
            }

            user.User_IDCard               = IDCard;
            user.User_IllnessName          = sicknessName;
            user.User_InitCare             = initial;
            user.User_Memo                 = memo;
            user.User_Name                 = userName;
            user.User_Namepinyin           = usernamePY;
            user.User_Nowcare              = now;
            user.User_PhysicalDisabilities = disabilityName;
            user.User_Sex   = (byte?)(LanguageUtils.EqualsResource(usersex, "AddOrEditView.M") ? 1 : 0);
            user.User_Phone = phone;

            // 如果用户是自己选择现成的图片,将图片保存在安装目录下
            if (IdCard != null && name != null && IDCard != "" && name != "" && userIfSelectPic != false)
            {
                // 用户选择的图片文件的 原路径
                string sourcePic = userPhotoPath;
                // 压缩
                string targetPic = CommUtil.GetUserPicTemp();
                Random random    = new Random();
                int    rd        = random.Next(0, 100000);
                targetPic += t3.Text.ToString() + rd.ToString() + ".gif";

                //targetPic += ".gif";
                // 获得保存图片的文件夹
                String dirPath = CommUtil.GetUserPicTemp();

                //判断是否存在
                if (Directory.Exists(dirPath))
                {
                    //Response.Write("已存在");
                }
                else
                {
                    //Response.Write("不存在,正在创建");
                    Directory.CreateDirectory(dirPath);//创建新路径
                }

                //压缩一下并且储存图片
                long picLen = 0;
                GetPicThumbnail(sourcePic, targetPic, 184, 259, 20);

                FileInfo di = new FileInfo(targetPic);
                picLen  = di.Length;
                picLen /= 1024;

                // 如果图片太大就重新选择
                if (picLen > 40)
                {
                    MessageBoxX.Info(LanguageUtils.ConvertLanguage("图片过大,请重新选择,不能超过40KB", "The picture is too large. Please select it again. Cannot exceed 40KB"));
                    File.Delete(targetPic);
                    return;
                }

                string userSelectFinalPic = CommUtil.GetUserPic(photoName);
                File.Copy(targetPic, userSelectFinalPic);
            }
            else if (userIfSelectPic != false)
            {
                MessageBoxX.Info(LanguageUtils.ConvertLanguage("没有填写身份证或者名字(拼音)", "No identity card or First Name"));
                return;
            }

            string tempPic = CommUtil.GetUserPicTemp(photoName);

            // 如果是正常拍照得到的图片
            if (File.Exists(tempPic))
            {
                string finalPic = CommUtil.GetUserPic(photoName);
                //如果增加时,对应位置存在这个图片,则删除
                if (File.Exists(finalPic))
                {
                    File.Delete(finalPic);
                }
                //确定没有重名,在进行复制
                File.Copy(tempPic, finalPic);
            }

            //将图片的url传到数据库
            user.User_PhotoLocation = photoName;
            userService.InsertUser(user);
            //保存照片的路径
            this.Close();
        }