public void SetupThumbnails() { var db = new GalleryContext(); //db.Thumbnails.Where(t => t.Description == "medium"); var thumbs = from t in db.Thumbnails where t.MaxHeight == 600 select t; var tu = thumbs.First(); // var tu = db.Thumbnails.(); //Thumbnail tn = new Thumbnail(); //tn.Description = "medium"; //tn.MaxWidth = 600; //db.Thumbnails.Add(tn); //db.Thumbnails.SaveChanges(); GalleryImage master = new GalleryImage(); master.Filename = @"C:\Users\Ken\Documents\GitHub\SimplePhotoGallery\SimplePhotoGallery\Images\img_0519.jpg"; db.Images.Add(master); var mediumThumb = new ScaledImage(tu, master); // this adds the medium thumb to the ProcessedImages collection mediumThumb.Process(); // todo: add initialization code to ScaledImage to pass in BaseImage and Thumbnail //master.CreateThumbnail(tu, "medium"); db.Images.Add(mediumThumb); db.SaveChanges(); }
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); } } }
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))); } }
/// <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); }