AGS.Editor.Utilities.CalculateGraphicsProportion C# (CSharp) Метод

CalculateGraphicsProportion() публичный статический Метод

Returns relation between current graphics resolution and default DpiY (96.0). Can be used when arranging controls and resizing forms.
public static CalculateGraphicsProportion ( Control control ) : float
control System.Windows.Forms.Control
Результат float
        public static float CalculateGraphicsProportion(Control control)
        {
            Graphics graphics = control.CreateGraphics();
            float proportion = (float)(graphics.DpiY / 96.0);
            graphics.Dispose();
            return proportion;
        }

Usage Example

Пример #1
0
 private void ArrangeSpecial(string bitmapResName, ImageLayout bitmapLayout, string tagLine, Color tagColor)
 {
     BackgroundImage = Resources.ResourceManager.GetBitmap(bitmapResName);
     if (bitmapLayout == ImageLayout.None)
     {
         // Changing control size to the constant bitmap size here,
         // we have to apply proportions factor based on system font scaling
         float proportion = Utilities.CalculateGraphicsProportion(this);
         Size = new Size((int)((float)BackgroundImage.Size.Width * proportion),
                         (int)((float)BackgroundImage.Size.Height * proportion));
         BackgroundImageLayout = ImageLayout.Stretch;
     }
     else
     {
         BackgroundImageLayout = bitmapLayout;
     }
     lblBottomTagLine.Font      = new Font("Tahoma", 9.75F, System.Drawing.FontStyle.Bold);
     lblBottomTagLine.ForeColor = tagColor;
     lblBottomTagLine.Text      = tagLine;
     lblBottomTagLine.TextAlign = ContentAlignment.MiddleRight;
 }