55 lines
		
	
	
		
			1.3 KiB
		
	
	
	
		
			C#
		
	
	
	
	
	
			
		
		
	
	
			55 lines
		
	
	
		
			1.3 KiB
		
	
	
	
		
			C#
		
	
	
	
	
	
using System.Drawing;
 | 
						|
 | 
						|
namespace DevComponents.DotNetBar.SuperGrid
 | 
						|
{
 | 
						|
    ///<summary>
 | 
						|
    /// CheckDisplay
 | 
						|
    ///</summary>
 | 
						|
    static public class ExpandDisplay
 | 
						|
    {
 | 
						|
        #region RenderButton
 | 
						|
 | 
						|
        ///<summary>
 | 
						|
        /// RenderButton
 | 
						|
        ///</summary>
 | 
						|
        ///<param name="g"></param>
 | 
						|
        ///<param name="image"></param>
 | 
						|
        ///<param name="buttonBounds"></param>
 | 
						|
        ///<param name="clipBounds"></param>
 | 
						|
        static public Size RenderButton(Graphics g,
 | 
						|
            Image image, Rectangle buttonBounds, Rectangle clipBounds)
 | 
						|
        {
 | 
						|
            if (image != null && buttonBounds.IsEmpty == false)
 | 
						|
            {
 | 
						|
                Rectangle r = buttonBounds;
 | 
						|
                r.Width++;
 | 
						|
                r.Height++;
 | 
						|
 | 
						|
                Size isize = Dpi.Size(image.Size);
 | 
						|
 | 
						|
                if (r.Width > isize.Width)
 | 
						|
                {
 | 
						|
                    r.X += (r.Width - isize.Width) / 2;
 | 
						|
                    r.Width = isize.Width;
 | 
						|
                }
 | 
						|
 | 
						|
                if (r.Height > isize.Height)
 | 
						|
                {
 | 
						|
                    r.Y += (r.Height - isize.Height) / 2;
 | 
						|
                    r.Height = isize.Height;
 | 
						|
                }
 | 
						|
 | 
						|
                r.Intersect(clipBounds);
 | 
						|
 | 
						|
                g.DrawImageUnscaledAndClipped(image, r);
 | 
						|
 | 
						|
                return (r.Size);
 | 
						|
            }
 | 
						|
 | 
						|
            return (Size.Empty);
 | 
						|
        }
 | 
						|
 | 
						|
        #endregion
 | 
						|
    }
 | 
						|
}
 |