Esempio n. 1
0
        private void SetZoom(Point pixelOffset, double zoomFactorOffset, Point pixelZoomPoint)
        {
            FileSystemImage fileImage = viewModel.CurrentImage;
            BitmapSource    img       = fileImage?.Image;

            if (img == null)
            {
                return;
            }

            Rect   rect       = fileImage.CropRect ?? new Rect(0, 0, img.PixelWidth, img.PixelHeight);
            double zoomFactor = Math.Max(img.PixelWidth / rect.Width, img.PixelHeight / rect.Height);

            if (zoomFactor * zoomFactorOffset > maxZoomFactor)
            {
                return;
            }

            pixelOffset.X /= imgCurrent.ActualWidth;
            pixelOffset.Y /= imgCurrent.ActualHeight;

            pixelZoomPoint.X = rect.X + pixelZoomPoint.X / imgCurrent.ActualWidth * rect.Width;
            pixelZoomPoint.Y = rect.Y + pixelZoomPoint.Y / imgCurrent.ActualHeight * rect.Height;

            fileImage.CropRect = Zoom(gidImage.ActualWidth / gidImage.ActualHeight,
                                      rect, pixelOffset, zoomFactorOffset, pixelZoomPoint);
        }
Esempio n. 2
0
        private static void CopyToClipboard(FileSystemImage image)
        {
            try
            {
                if (image?.Image != null)
                {
                    Clipboard.SetImage(image.Image);
                }
            }
            catch (Exception e)
            {
                MessageBox.Show(e.Message, "Copy file drop error", MessageBoxButton.OK, MessageBoxImage.Error);
            }

            try
            {
                if (image?.File == null)
                {
                    return;
                }

                StringCollection dropList = new StringCollection {
                    image.File.FullName
                };
                Clipboard.SetFileDropList(dropList);
            }
            catch (Exception e)
            {
                MessageBox.Show(e.Message, "Copy file drop error", MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }
Esempio n. 3
0
        private void BtnInfo_Click(object sender, RoutedEventArgs e)
        {
            FileSystemImage img  = viewModel.CurrentImage;
            BitmapSource    crop = (BitmapSource)img?.CroppedImage;
            string          text =
                $"Image: {img?.Image?.PixelWidth} x {img?.Image?.PixelHeight}\r\n" +
                $"Crop: {crop?.PixelWidth ?? -1} x {crop?.PixelHeight ?? -1}\r\n" +
                $"Size: {StdUtils.GetFormattedFileSize(img?.File.Length ?? -1)}";

            MessageBox.Show(text);
        }