private void RotateRight_Click(object sender, RoutedEventArgs e)
        {
            int index = images.SelectedIndex;

            parts[index].RotateFlip(RotateFlipType.Rotate90FlipNone);
            var item = images.SelectedItem as ListViewItem;

            ((System.Windows.Controls.Image)item.Content).Source = ImageActions.BitmapImageFromBitmap(parts[index]);
        }
        private void Crop_Click(object sender, RoutedEventArgs e)
        {
            if (!selectionRectangle.IsVisible)
            {
                MessageBox.Show("Nothing is Selected", "Attention", MessageBoxButton.OK, MessageBoxImage.Information);
                return;
            }

            selectionRectangle.Visibility = Visibility.Collapsed;
            parts.Add(CroppedImage);
            ListViewItem listitem = new ListViewItem()
            {
                Height  = 130,
                Content = new System.Windows.Controls.Image()
                {
                    Source  = ImageActions.BitmapImageFromBitmap(CroppedImage),
                    Stretch = Stretch.Uniform,
                }
            };

            images.Items.Add(listitem);
        }
        private void MakeScaledImage()
        {
            int wid = (int)(ImageScale * (OriginalImage.Width));
            int hgt = (int)(ImageScale * (OriginalImage.Height));

            ScaledImage = new Bitmap(wid, hgt);
            using (Graphics gr = Graphics.FromImage(ScaledImage))
            {
                Rectangle src_rect  = new Rectangle(0, 0, OriginalImage.Width, OriginalImage.Height);
                Rectangle dest_rect = new Rectangle(0, 0, wid, hgt);
                gr.PixelOffsetMode   = PixelOffsetMode.Half;
                gr.InterpolationMode = InterpolationMode.NearestNeighbor;
                gr.DrawImage(OriginalImage, dest_rect, src_rect, GraphicsUnit.Pixel);
            }

            DisplayImage = ScaledImage.Clone() as Bitmap;
            if (DisplayGraphics != null)
            {
                DisplayGraphics.Dispose();
            }
            DisplayGraphics = Graphics.FromImage(DisplayImage);
            image.Source    = ImageActions.BitmapImageFromBitmap(DisplayImage);
        }