Exemple #1
0
        private void ClipForm_MouseWheel(object sender, MouseEventArgs e)
        {
            if (e.Delta > 0)
            {
                _ZoomRefreshLimiter.Restart();
                _ZoomLevel      = Math.Round(_ZoomLevel * 1.1d, 2);
                _MagnifierShown = true;
                zdbZoomedImageDisplay._Show();
                DrawZoomedImage(e.Location);
            }
            else
            {
                _ZoomLevel = Math.Round(_ZoomLevel * 0.9d, 2);
                if (_ZoomLevel <= 1)
                {
                    _ZoomRefreshLimiter.Reset();

                    _MagnifierShown = false;
                    _ZoomLevel      = 1;

                    zdbZoomedImageDisplay._Hide();
                    ScaledImage?.Dispose();
                    ScaledImage = null;
                    //GC.Collect();
                }
                else
                {
                    DrawZoomedImage(e.Location);
                }
            }
        }
Exemple #2
0
        private void DrawZoomedImage(Point mousePos)
        {
            zdbZoomedImageDisplay.Size = new Size(
                _ZoomControlSize.Width + (zdbZoomedImageDisplay.BorderThickness << 1),
                _ZoomControlSize.Height + (zdbZoomedImageDisplay.BorderThickness << 1));

            if (SettingsManager.ClipSettings.Zoom_Follow_Mouse)
            {
                zdbZoomedImageDisplay.Location = new Point(
                    mousePos.X - (zdbZoomedImageDisplay.ClientSize.Width >> 1),
                    mousePos.Y - (zdbZoomedImageDisplay.ClientSize.Height >> 1));
            }

            // if the clip has been dragged larger then we need
            // to resize the image before trying to zoom in on it
            if (ClientSize != StartWindowSize)
            {
                Size scaledImageSize = new Size(
                    Width - (Options.BorderThickness << 1),
                    Height - (Options.BorderThickness << 1));

                // if the zoomed image is null or not the size its supposed to be
                // try and dispose of it, then remake it
                if (ScaledImage == null || ScaledImage.Size != scaledImageSize)
                {
                    ScaledImage?.Dispose();
                    ScaledImage = new Bitmap(scaledImageSize.Width, scaledImageSize.Height);

                    using (Graphics g = Graphics.FromImage(ScaledImage))
                    {
                        g.InterpolationMode = InterpolationMode.NearestNeighbor;
                        g.PixelOffsetMode   = PixelOffsetMode.Half;

                        g.DrawImage(
                            Image,
                            new Rectangle(new Point(Options.BorderThickness, Options.BorderThickness), scaledImageSize),
                            new Rectangle(0, 0, Image.Width, Image.Height), GraphicsUnit.Pixel);
                    }
                }


                zdbZoomedImageDisplay.DrawImage(ScaledImage,
                                                new Rectangle(0, 0, _ZoomControlSize.Width, _ZoomControlSize.Height),
                                                new Rectangle(
                                                    mousePos.X - (int)Math.Round(zdbZoomedImageDisplay.Size.Width / _ZoomLevel / 2),
                                                    mousePos.Y - (int)Math.Round(zdbZoomedImageDisplay.Size.Height / _ZoomLevel / 2),
                                                    (int)Math.Round(_ZoomControlSize.Width / _ZoomLevel),
                                                    (int)Math.Round(_ZoomControlSize.Height / _ZoomLevel)));
            }
            else
            {
                zdbZoomedImageDisplay.DrawImage(Image,
                                                new Rectangle(0, 0, _ZoomControlSize.Width, _ZoomControlSize.Height),
                                                new Rectangle(
                                                    mousePos.X - (int)Math.Round(zdbZoomedImageDisplay.Size.Width / _ZoomLevel / 2),
                                                    mousePos.Y - (int)Math.Round(zdbZoomedImageDisplay.Size.Height / _ZoomLevel / 2),
                                                    (int)Math.Round(_ZoomControlSize.Width / _ZoomLevel),
                                                    (int)Math.Round(_ZoomControlSize.Height / _ZoomLevel)));
            }
        }
Exemple #3
0
        /// <summary>
        /// Clean up any resources being used.
        /// </summary>
        /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
        protected override void Dispose(bool disposing)
        {
            _ChangeTracker?.Dispose();
            cmMain?.Dispose();
            ScaledImage?.Dispose();
            zdbZoomedImageDisplay?.Dispose();

            if (disposing && (components != null))
            {
                components.Dispose();
            }
            base.Dispose(disposing);
        }