private void BarButtonItem1_ItemClick(object sender, ItemClickEventArgs e) { if (!(PostCardView.GetFocusedRow() is PostCardInfo postCard)) { return; } ReCropPostCard(postCard); }
private void Photocroper_KeyUp(object sender, System.Windows.Input.KeyEventArgs e) { if (!(PostCardView.GetFocusedRow() is PostCardInfo postCard)) { return; } if (!(elementHost1.Child is Photocroper photoCroper)) { return; } //提交 switch (e.Key) { case Key.Enter: if (!photoCroper.Preview) { SubmitPostCard(PostCardView.FocusedRowHandle, photoCroper.CropInfo); } else { MoveToNextPosition(PostCardView.FocusedRowHandle); } //photocroper.FastChange = true; break; case Key.LeftCtrl: case Key.RightCtrl: photoCroper.FastChange = true; break; case Key.LeftShift: case Key.RightShift: photoCroper.SizeLimit = true; break; case Key.Space: photoCroper.Preview = false; break; case Key.A: case Key.B: case Key.C: case Key.D: ChangeFrontStyle(e.Key.ToString()); break; case Key.Escape: // 重新裁切 ReCropPostCard(postCard); break; } }
/// <summary> /// 修改明信片正面版式 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void BarButtonItem3_ItemClick(object sender, ItemClickEventArgs e) { if (PostCardView.GetFocusedRow() is PostCardInfo postCard) { PostCardItemApi.ChangePostCardFrontStyle(postCard.PostCardId, e.Item.Tag as string, resp => { var postCardInfo = resp.TranlateToPostCard(); // postCard.ProcessStatus = postCardInfo.ProcessStatus; postCard.ProductFileId = postCardInfo.ProductFileId; postCard.FrontStyle = postCardInfo.FrontStyle; postCard.ProcessStatusText = postCardInfo.ProcessStatusText; PostCardChanged(); }, message => { XtraMessageBox.Show(message); }); } }
private void ChangeFrontStyle(string style) { if (!(PostCardView.GetFocusedRow() is PostCardInfo postCard)) { return; } PostCardItemApi.ChangePostCardFrontStyle(postCard.PostCardId, style, resp => { var postCardInfo = resp.TranlateToPostCard(); // postCard.ProcessStatus = postCardInfo.ProcessStatus; postCard.ProductFileId = postCardInfo.ProductFileId; postCard.FrontStyle = postCardInfo.FrontStyle; postCard.ProcessStatusText = postCardInfo.ProcessStatusText; PostCardChanged(); }, message => { XtraMessageBox.Show(message); }); }
private void PostCardControlKeyUp(object sender, KeyEventArgs e) { if (!(PostCardView.GetFocusedRow() is PostCardInfo postCard)) { return; } switch (e.KeyCode) { case Keys.A: case Keys.B: case Keys.C: case Keys.D: ChangeFrontStyle(e.KeyCode.ToString()); break; case Keys.Escape: ReCropPostCard(postCard); break; } }
private void PostCardChanged() { if (PostCardView.GetFocusedRow() is PostCardInfo postCardInfo) { // 还原当前选中双面裁切信息 _doubleSidePostCardCropInfo = null; progressBarControl1.EditValue = 0; // cropContext.CropInfoSubmitDto = new CropInfoSubmitDto(cropContext.Image.Size, cropContext.PicturePrintAreaSize, fit: cropContext.StyleInfo.Fit); // pictureCropControl1.CropContext = cropContext; if (elementHost1.Child is Photocroper photoCropper) { photoCropper.ProductSize = new Size(postCardInfo.ProductSize.Width, postCardInfo.ProductSize.Height); photoCropper.FrontStyle = postCardInfo.FrontStyle; if (string.IsNullOrEmpty(postCardInfo.ProductFileId)) { photoCropper.Preview = false; //FileApi.GetInstance(). photoCropper.InitImage(Settings.Default.Host + "/file/" + postCardInfo.FileId, tempCropInfo => { switch (postCardInfo.FrontStyle) { // D版,直接缩放 case "D": tempCropInfo.CropHeight = 1; tempCropInfo.CropWidth = 1; tempCropInfo.CropTop = 0; tempCropInfo.CropLeft = 0; if (postCardInfo.ProcessStatusText == "未提交") { timer1.Interval = 1000; timer1.Start(); } break; // C版,向左旋转 case "C": // 向左旋转 photoCropper.LeftRotate(); // 最大化 photoCropper.FixMax(); break; default: // A版、B版:判断是否自动旋转 if (barCheckItem1.Checked && postCardInfo.ProcessStatusText == "未提交" && Math.Abs(tempCropInfo.CropWidth - 1) <= 0.001 && Math.Abs(tempCropInfo.CropHeight - 1) <= 0.001) { tempCropInfo.CropHeight = 1; tempCropInfo.CropWidth = 1; tempCropInfo.CropTop = 0; tempCropInfo.CropLeft = 0; timer1.Interval = 10; //开始定时器,自动提交反面 timer1.Start(); // 提交 } break; } }); } else { //FileApi.GetInstance(). photoCropper.Preview = true; photoCropper.FrontStyle = "B"; photoCropper.InitImage(Settings.Default.Host + "/file/" + postCardInfo.ProductFileId); } } } }
private void SubmitPostCard(int rowHandler, CropInfo cropInfo) { if (_currentEnvelopeInfo == null) { return; } if (PostCardView.GetRow(rowHandler) is PostCardInfo postCardInfo) { // 如果当前提交doubleSide提交为null,创建一个(第一次提交为 null if (_doubleSidePostCardCropInfo == null) { _doubleSidePostCardCropInfo = new DoubleSidePostCardCropInfo { PostCardId = postCardInfo.PostCardId, // ID,用于提交数据 ProductHeight = postCardInfo.ProductSize.Height, // 成品高度,用于确定成品尺寸 ProductWidth = postCardInfo.ProductSize.Width, // 成品宽度,用于确定成品尺寸 PostCardType = postCardInfo.FrontStyle, // 正面样式,A B C D,用于确定板式 FrontCropCropInfo = new PostCardProcessCropInfo // 正面裁切信息 { FileId = postCardInfo.FileId, CropLeft = cropInfo.CropLeft, CropTop = cropInfo.CropTop, CropHeight = cropInfo.CropHeight, CropWidth = cropInfo.CropWidth, Rotation = cropInfo.Rotation, ImageWidth = cropInfo.ImageWidth, ImageHeight = cropInfo.ImageHeight } }; // 如果是双面,裁切双面 if (!string.IsNullOrEmpty(postCardInfo.BackFileId)) { // 肯定是的,设置为反面 if (elementHost1.Child is Photocroper photoCropper) { photoCropper.ProductSize = new Size(postCardInfo.ProductSize.Width, postCardInfo.ProductSize.Height); photoCropper.FrontStyle = "B"; photoCropper.Preview = false; photoCropper.InitImage(Settings.Default.Host + "/file/" + postCardInfo.BackFileId, action: tempCropInfo => { if (Math.Abs(tempCropInfo.CropWidth - 1) <= 0.001 && Math.Abs(tempCropInfo.CropHeight - 1) <= 0.001) { tempCropInfo.CropHeight = 1; tempCropInfo.CropWidth = 1; tempCropInfo.CropTop = 0; tempCropInfo.CropLeft = 0; timer1.Interval = 100; //开始定时器,自动提交反面 timer1.Start(); // 提交 } }); return; } } } else { // 如果有反面文件ID,提交反面数据,否则不提交 if (!string.IsNullOrEmpty(postCardInfo.BackFileId)) { _doubleSidePostCardCropInfo.BackCropCropInfo = new PostCardProcessCropInfo { FileId = postCardInfo.BackFileId, CropLeft = cropInfo.CropLeft, // 反面左边 CropTop = cropInfo.CropTop, // 反面右边 CropHeight = cropInfo.CropHeight, // 反面高度 CropWidth = cropInfo.CropWidth, // 反面宽度 Rotation = cropInfo.Rotation, // 反面旋转角度 ImageWidth = cropInfo.ImageWidth, // 原始图像宽度 ImageHeight = cropInfo.ImageHeight // 原始图像高度 } } ; } postCardInfo.ProcessStatusText = "已提交"; PostCardProcessQueue.Process(_doubleSidePostCardCropInfo, info => { PostCardItemApi.UpdatePostCardProcessStatus(postCardInfo.PostCardId, "AFTER_SUBMIT"); }, info => { PostCardItemApi.UpdatePostCardProcessStatus(postCardInfo.PostCardId, "SUBMIT_FAILURE"); }); } MoveToNextPosition(rowHandler); }