示例#1
0
 private async void ApplyBitmapTransformation(ITransformable transformation)
 {
     var f = new BitmapTransformation(transformation);
     if (transformation is IProgressTracking) {
         var progressBarForm = new ProgressForm {
             Text = "Идёт применение фильтра: {0} (0%)".F(transformation.ToString())
         };
         progressBarForm.Show();
         var trackingObj = transformation as IProgressTracking;
         trackingObj.ProgressChanged += (s, p) => BeginInvoke((MethodInvoker)delegate {
             progressBarForm.Progress.Value = p.Progress;
             progressBarForm.Text = "Идёт применение фильтра: {0} ({1}%)"
                 .F(transformation.ToString(), p.Progress);
         });
         trackingObj.OperationComplete += (s, p) => BeginInvoke((MethodInvoker)progressBarForm.Close);
     }
     if (transformation is IСonfigurable) {
         var optionsWin = new TransformationOptions {
             PreviewBitmap = (Bitmap) _workingBitmap.Clone()
         };
         optionsWin.Show();
     }
     _workingBitmap = await Task<Bitmap>.Factory.StartNew(() => f.Apply(_workingBitmap));
     _history.SaveState(_workingBitmap);
     UpdateMenuHistoryItems();
     SyncPicture();
 }