| | |
| | | //}), pid.ToString(), 1, 1); |
| | | |
| | | //拍照裁剪 |
| | | var imageName = Guid.NewGuid().ToString() + ".png"; |
| | | var imageName = "headImage"; |
| | | //var imageName = Guid.NewGuid().ToString(); |
| | | CropImage.TakePicture((imagePath) => |
| | | { |
| | | CropImageCallBack(imagePath, imageName); |
| | |
| | | //}, pid.ToString(), 1, 1); |
| | | |
| | | //从相册选择图片裁剪 |
| | | var imageName = Guid.NewGuid().ToString() + ".png"; |
| | | //var imageName = Guid.NewGuid().ToString(); |
| | | var imageName = "headImage"; |
| | | CropImage.SelectPicture((imagePath) => |
| | | { |
| | | CropImageCallBack(imagePath, imageName); |
| | |
| | | } |
| | | |
| | | /// <summary> |
| | | /// |
| | | /// 裁剪完照片回调,统一处理 |
| | | /// </summary> |
| | | /// <param name="imagePath"></param> |
| | | /// <param name="imageName"></param> |
| | | /// <param name="imagePath">裁剪后的真实路径</param> |
| | | /// <param name="imageName">自定义的图片名称</param> |
| | | void CropImageCallBack(string imagePath, string imageName) |
| | | { |
| | | if (string.IsNullOrEmpty(imagePath) == true) |
| | | { |
| | | return; |
| | | } |
| | | //删除原来本地头像 |
| | | System.IO.File.Delete(userHeadImageView.ImagePath); |
| | | Utlis.WriteLine("删除: " + userHeadImageView.ImagePath); |
| | | |
| | | MainPage.Log("SelectPicture 裁剪图片返回路径: " + imagePath); |
| | | //userHeadImageView.ImageBytes = Shared.IO.FileUtils.ReadFile(imagePath); |
| | | FileUtils.FileCopyToRootPath(imagePath, imageName); |
| | | System.IO.File.Delete(imagePath); |
| | | //生成图片 |
| | | //Shared.IO.FileUtils.WriteFileByBytes(imageName, userHeadImageView.ImageBytes); |
| | | UserInfo.Current.headImagePagePath = imageName; |
| | | userHeadImageView.ImagePath = imageName; |
| | | updataHeadImage(); |
| | | |
| | | new System.Threading.Thread(() => |
| | | try |
| | | { |
| | | new DAL.Server.HttpServerRequest().UpdataUserHeadImage(imageName); |
| | | }) |
| | | { IsBackground = true }.Start(); UserInfo.Current.SaveUserInfo(); |
| | | MainPage.Log("SelectPicture 裁剪图片返回路径: " + imagePath); |
| | | |
| | | var headPath = imagePath; |
| | | #if __IOS__ |
| | | |
| | | |
| | | #else |
| | | //1.使用新名字,解决相同路径不刷新图片问题 |
| | | imageName = Guid.NewGuid().ToString() + ".png"; |
| | | //1.2删除原来本地头像 |
| | | System.IO.File.Delete(userHeadImageView.ImagePath); |
| | | Utlis.WriteLine("删除: " + userHeadImageView.ImagePath); |
| | | //1.3如果是安卓需要拷贝回来APP根目录 |
| | | FileUtils.FileCopyToRootPath(imagePath, imageName); |
| | | System.IO.File.Delete(imagePath); |
| | | headPath = imageName; |
| | | MainPage.Log("SelectPicture 最终路径: " + imageName); |
| | | #endif |
| | | |
| | | //清空原来图片 |
| | | userHeadImageView.ImagePath = "NULL"; |
| | | //生成图片 |
| | | UserInfo.Current.headImagePagePath = headPath; |
| | | userHeadImageView.ImagePath = headPath; |
| | | updataHeadImage(); |
| | | |
| | | new System.Threading.Thread(() => |
| | | { |
| | | new DAL.Server.HttpServerRequest().UpdataUserHeadImage(headPath); |
| | | }) |
| | | { IsBackground = true }.Start(); |
| | | UserInfo.Current.SaveUserInfo(); |
| | | } |
| | | catch { } |
| | | |
| | | } |
| | | |