コード例 #1
0
        public ApplicationController()
        {
            _cropService = new CropService();

            _tendService = new TendService();

            _gardenService = new GardenService();
        }
コード例 #2
0
        protected override void Dispose(bool disposing)
        {
            if (disposing && farmService != null)
            {
                farmService.Dispose();
                farmService = null;
            }

            if (disposing && cropService != null)
            {
                cropService.Dispose();
                cropService = null;
            }
        }
コード例 #3
0
        public Bitmap GetBitmapCrop()
        {
            var cropArea = CropService.GetCroppedArea();

            int X = (int)cropArea.CroppedRectAbsolute.X;
            int Y = (int)cropArea.CroppedRectAbsolute.Y;

            int Width  = (int)cropArea.CroppedRectAbsolute.Width;
            int Height = (int)cropArea.CroppedRectAbsolute.Height;

            if (Width == 0 || Height == 0)
            {
                return(BitmapImageToBitmap(SourceBitmapImage));
            }

            if (SourceBitmapImage.PixelHeight != SourceImage.ActualHeight || SourceBitmapImage.PixelWidth != SourceImage.ActualWidth)
            {
                float ratioH = (float)SourceImage.ActualHeight * 100 / (float)SourceBitmapImage.PixelHeight;
                float ratioW = (float)SourceImage.ActualWidth * 100 / (float)SourceBitmapImage.PixelWidth;

                Width  = (int)(Width / ratioW * 100);
                Height = (int)(Height / ratioH * 100);

                X = (int)(X / ratioW * 100);
                Y = (int)(Y / ratioH * 100);
            }

            Rectangle cropRect = new Rectangle(X, Y, Width, Height);

            Bitmap target       = new Bitmap(cropRect.Width, cropRect.Height, PixelFormat.Format32bppArgb);
            Bitmap SourceBitmap = BitmapImageToBitmap(SourceBitmapImage);

            using (Graphics g = Graphics.FromImage(target))
            {
                g.DrawImage(SourceBitmap, new System.Drawing.Rectangle(0, 0, target.Width, target.Height),
                            cropRect,
                            GraphicsUnit.Pixel);
            }

            return(target);
        }
コード例 #4
0
 private void RootGrid_Loaded(object sender, RoutedEventArgs e)
 {
     CropService = new CropService(this);
     CropService.CroppedAreaChangedEvent += OnCroppedAreaChanged;
 }
コード例 #5
0
 public void SetCropAreaRatio(int rWidth, int rHeight)
 {
     CropService.SetCropAreaRatio(SourceImage.ActualWidth, SourceImage.ActualHeight, rWidth, rHeight);
 }
コード例 #6
0
 public void SetCropArea(double Width, double Height)
 {
     CropService.SetCropArea(Width, Height);
 }
コード例 #7
0
 public void SetKeepRatio(bool KeepRatio)
 {
     CropService.SetKeepRatio(KeepRatio);
 }
コード例 #8
0
 private void RootGrid_Loaded(object sender, RoutedEventArgs e)
 {
     CropService = new CropService(this);
     CropService.ShowText(_TextVisible);
 }
コード例 #9
0
 public AdminLteController()
 {
     farmService = new FarmService();
     cropService = new CropService();
 }
コード例 #10
0
 private void RootGrid_Loaded(object sender, RoutedEventArgs e)
 {
     CropService = new CropService(this, SquareSelection);
 }