| | |
| | | btnTakePicture.MouseUpEventHandler = (sender, e) => |
| | | { |
| | | btnTakePicture.IsSelected = false; |
| | | var pid = Guid.NewGuid(); |
| | | CropImage.TakePicture((Action<string>)((imagePath) => |
| | | //var pid = Guid.NewGuid(); |
| | | //CropImage.TakePicture((Action<string>)((imagePath) => |
| | | //{ |
| | | // if (imagePath != null) |
| | | // { |
| | | // UserInfo.Current.headImagePagePath = imagePath.ToString(); |
| | | // userHeadImageView.ImagePath = imagePath.ToString(); |
| | | // updataHeadImage(); |
| | | // new System.Threading.Thread(() => |
| | | // { |
| | | // new DAL.Server.HttpServerRequest().UpdataUserHeadImage(imagePath); |
| | | // }) |
| | | // { IsBackground = true }.Start(); |
| | | // UserInfo.Current.SaveUserInfo(); |
| | | // MainPage.Log("SelectPicture 裁剪图片返回路径: " + imagePath); |
| | | // } |
| | | //}), pid.ToString(), 1, 1); |
| | | |
| | | //拍照裁剪 |
| | | var imageName = Guid.NewGuid().ToString() + ".png"; |
| | | CropImage.TakePicture((imagePath) => |
| | | { |
| | | if (imagePath != null) |
| | | { |
| | | UserInfo.Current.headImagePagePath = imagePath.ToString(); |
| | | userHeadImageView.ImagePath = imagePath.ToString(); |
| | | updataHeadImage(); |
| | | new System.Threading.Thread(() => |
| | | { |
| | | new DAL.Server.HttpServerRequest().UpdataUserHeadImage(imagePath); |
| | | }) |
| | | { IsBackground = true }.Start(); |
| | | UserInfo.Current.SaveUserInfo(); |
| | | MainPage.Log("SelectPicture 裁剪图片返回路径: " + imagePath); |
| | | } |
| | | }), pid.ToString(), 1, 1); |
| | | CropImageCallBack(imagePath, imageName); |
| | | |
| | | }, imageName, 1, 1); |
| | | |
| | | pictureOptionView.RemoveFromParent(); |
| | | baseView.RemoveFromParent(); |
| | | }; |
| | |
| | | btnAlbum.MouseUpEventHandler = (sender, e) => |
| | | { |
| | | btnAlbum.IsSelected = false; |
| | | var pid = Guid.NewGuid(); |
| | | //var pid = Guid.NewGuid(); |
| | | //CropImage.SelectPicture((imagePath) => |
| | | //{ |
| | | // if (imagePath != null) |
| | | // { |
| | | // UserInfo.Current.headImagePagePath = imagePath.ToString(); |
| | | // userHeadImageView.ImagePath = imagePath.ToString(); |
| | | // updataHeadImage(); |
| | | |
| | | // new System.Threading.Thread(() => |
| | | // { |
| | | // new DAL.Server.HttpServerRequest().UpdataUserHeadImage(imagePath); |
| | | // }) |
| | | // { IsBackground = true }.Start(); UserInfo.Current.SaveUserInfo(); |
| | | // MainPage.Log("SelectPicture 裁剪图片返回路径: " + imagePath); |
| | | // } |
| | | //}, pid.ToString(), 1, 1); |
| | | |
| | | //从相册选择图片裁剪 |
| | | var imageName = Guid.NewGuid().ToString() + ".png"; |
| | | CropImage.SelectPicture((imagePath) => |
| | | { |
| | | if (imagePath != null) |
| | | { |
| | | UserInfo.Current.headImagePagePath = imagePath.ToString(); |
| | | userHeadImageView.ImagePath = imagePath.ToString(); |
| | | updataHeadImage(); |
| | | CropImageCallBack(imagePath, imageName); |
| | | }, imageName, 1, 1); |
| | | |
| | | new System.Threading.Thread(() => |
| | | { |
| | | new DAL.Server.HttpServerRequest().UpdataUserHeadImage(imagePath); |
| | | }) |
| | | { IsBackground = true }.Start(); UserInfo.Current.SaveUserInfo(); |
| | | MainPage.Log("SelectPicture 裁剪图片返回路径: " + imagePath); |
| | | } |
| | | }, pid.ToString(), 1, 1); |
| | | pictureOptionView.RemoveFromParent(); |
| | | baseView.RemoveFromParent(); |
| | | }; |
| | | } |
| | | |
| | | /// <summary> |
| | | /// |
| | | /// </summary> |
| | | /// <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(() => |
| | | { |
| | | new DAL.Server.HttpServerRequest().UpdataUserHeadImage(imageName); |
| | | }) |
| | | { IsBackground = true }.Start(); UserInfo.Current.SaveUserInfo(); |
| | | |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 加载修改用户名称事件 |
| | | /// </summary> |
| | | void LoadEvent_EditUserName() |