예제 #1
0
 private void SetCrop(object sender, System.Windows.Input.GestureEventArgs e)
 {
     if (this._inSelectOwnPhotoArea)
     {
         ParametersRepository.SetParameterForId("UserPicSquare", (object)this.imageViewer.RectangleFillRelative);
         this._inSelectOwnPhotoArea = false;
         ((UIElement)this.gridChooseThumbnail).Visibility = Visibility.Collapsed;
         this.EnsureSelectCurrentAndConfirm();
     }
     else
     {
         if (this._isInSetResetCrop)
         {
             return;
         }
         this._isInSetResetCrop = true;
         ParametersRepository.SetParameterForId("UserPicSquare", (object)new Rect(0.0, 0.0, 1.0, 1.0));
         Rect rectToCrop = this.imageViewer.RectangleFillInCurrentImageCoordinates;
         ((DependencyObject)Deployment.Current).Dispatcher.BeginInvoke((Action)(() =>
         {
             ImageEditorViewModel imageEditorVm = this._imageEditorVM;
             double rotate = 0.0;
             CropRegion rect = new CropRegion();
             // ISSUE: explicit reference operation
             rect.X = (int)((Rect)@rectToCrop).X;
             // ISSUE: explicit reference operation
             rect.Y = (int)((Rect)@rectToCrop).Y;
             // ISSUE: explicit reference operation
             rect.Width = (int)((Rect)@rectToCrop).Width;
             // ISSUE: explicit reference operation
             rect.Height = (int)((Rect)@rectToCrop).Height;
             WriteableBitmap source = this.imageViewer.CurrentImage.Source as WriteableBitmap;
             Action <BitmapSource> callback = (Action <BitmapSource>)(result =>
             {
                 this._isInSetResetCrop = false;
                 this.HandleEffectApplied(result);
                 this.ToggleCropMode();
                 ((UIElement)this.imageViewer.CurrentImage).RenderTransform = ((Transform)RectangleUtils.TransformRect(this.imageViewer.CurrentImageFitRectOriginal, this.imageViewer.RectangleFill, false));
                 this.imageViewer.AnimateImage(1.0, 1.0, 0.0, 0.0, (Action)null);
             });
             imageEditorVm.SetCrop(rotate, rect, source, callback);
         }));
     }
 }
예제 #2
0
        public void SetCrop(double rotate, CropRegion rect, WriteableBitmap imSource, Action <BitmapSource> callback)
        {
            if (this.ApplyingEffects)
            {
                return;
            }
            this.ApplyingEffects = true;
            Action <WriteableBitmap> _9__1 = null;

            Deployment.Current.Dispatcher.BeginInvoke(delegate
            {
                WriteableBitmap imSource2 = imSource;
                Picture galleryImage      = this.GetGalleryImage(this._albumId, this._seqNo);
                bool flag  = false;
                double num = this.GetCorrectImageSize(galleryImage, this._albumId, this._seqNo, out flag).Width / (double)imSource2.PixelWidth;
                galleryImage.Dispose();
                WriteableBitmap writeableBitmap = imSource2.Crop((int)((double)rect.X / num), (int)((double)rect.Y / num), (int)((double)rect.Width / num), (int)((double)rect.Height / num));
                Rect rect2 = RectangleUtils.ResizeToFit(new Rect(default(Point), this.ViewportSize), new Size((double)writeableBitmap.PixelWidth, (double)writeableBitmap.PixelHeight));
                WriteableBitmap writeableBitmap2 = writeableBitmap.Resize((int)rect2.Width, (int)rect2.Height, Interpolation.Bilinear);
                ImageEditorViewModel.SaveWB(writeableBitmap2, this.GetPathForCrop());
                this._currentEffects.CropRect    = rect;
                this._currentEffects.RotateAngle = rotate;
                ImageEditorViewModel arg_167_0   = this;
                WriteableBitmap arg_167_1        = writeableBitmap2;
                Action <WriteableBitmap> arg_167_2;
                if ((arg_167_2 = _9__1) == null)
                {
                    arg_167_2 = (_9__1 = delegate(WriteableBitmap bitmap)
                    {
                        callback.Invoke(bitmap);
                        this.ApplyingEffects = false;
                    });
                }
                arg_167_0.ApplyEffects(arg_167_1, arg_167_2);
                this.CallPropertyChanged();
            });
        }