예제 #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;
            }
        }
        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;
 }
 public void SetCropAreaRatio(int rWidth, int rHeight)
 {
     CropService.SetCropAreaRatio(SourceImage.ActualWidth, SourceImage.ActualHeight, rWidth, rHeight);
 }
 public void SetCropArea(double Width, double Height)
 {
     CropService.SetCropArea(Width, Height);
 }
 public void SetKeepRatio(bool KeepRatio)
 {
     CropService.SetKeepRatio(KeepRatio);
 }
 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);
 }