Beispiel #1
0
        protected override void OnPaint(PaintEventArgs e)
        {
            Rectangle client = ClientRectangle;

            client.Inflate(-BorderThickness, -BorderThickness);
            e.Graphics.FillRectangle(Brushes.White, ClientRectangle);
            Rectangle border = ClientRectangle;

            border.Width--; border.Height--;
            e.Graphics.DrawRectangle(Pens.Gray, border);
            Rectangle rect = ImageLayoutHelper.GetImageBounds(client, Helper.GetThumbImage().Size, ImageLayoutMode.Squeeze);

            e.Graphics.DrawImage(Helper.GetThumbImage(), rect);
        }
Beispiel #2
0
        private void ShowDragWindow()
        {
            OwnerControl.Capture = false;
            Image img = GetThumbImage();

            if (img == null)
            {
                img = new Bitmap(100, 100);
            }
            Rectangle rect = ImageLayoutHelper.GetImageBounds(new Rectangle(Point.Empty, PhotoSize), img.Size, ImageLayoutMode.Squeeze);

            Window.Location = new Point(CurrentPoint.X - Offset.X, CurrentPoint.Y - Offset.Y);
            Window.Size     = CalcWindowSize(rect.Size);
            Window.Show();
        }
        public static Image GetIconImage(DmFile file)
        {
            if (file.IconImage != null)
            {
                return(file.IconImage);
            }
            Image sourceImage = GetThumbnailImage(file);

            if (sourceImage == null)
            {
                return(null);
            }
            Rectangle rect = ImageLayoutHelper.GetImageBounds(new Rectangle(0, 0, 64, 64), sourceImage.Size, ImageLayoutMode.ZoomOutside);
            Bitmap    bmp  = new Bitmap(64, 64);

            using (Graphics g = Graphics.FromImage(bmp)) {
                g.DrawImage(sourceImage, rect);
            }
            file.IconImage = bmp;
            return(file.IconImage);
        }
 Rectangle GetImageBounds(Rectangle buttonBounds, Size imageSize)
 {
     return(ImageLayoutHelper.GetImageBounds(buttonBounds, imageSize, ImageScaleMode.Clip, ImageAlignmentMode.MiddleLeft));
 }