# FarPoint.Win.FpButton.GetPreferredSize

## Content

<div class="doc-site-dotnet-api-container">



<h1 id="FarPoint_Win_FpButton_GetPreferredSize_" data-uid="FarPoint.Win.FpButton.GetPreferredSize*">GetPreferredSize Method
</h1>
<div class="markdown level0 summary"></div>
<div class="markdown level0 conceptual"></div>



<a id="FarPoint_Win_FpButton_GetPreferredSize_" data-uid="FarPoint.Win.FpButton.GetPreferredSize*"></a>
<h4 id="FarPoint_Win_FpButton_GetPreferredSize_System_Drawing_Graphics_System_Drawing_Size_System_Drawing_Font_System_String_System_String_FarPoint_Win_ButtonTextAlign_System_Boolean_System_Int32_System_Drawing_Image_System_Drawing_Image_" data-uid="FarPoint.Win.FpButton.GetPreferredSize(System.Drawing.Graphics,System.Drawing.Size,System.Drawing.Font,System.String,System.String,FarPoint.Win.ButtonTextAlign,System.Boolean,System.Int32,System.Drawing.Image,System.Drawing.Image)">GetPreferredSize(Graphics, Size, Font, string, string, ButtonTextAlign, bool, int, Image, Image)</h4>
<div class="markdown level1 summary"><p>Calculates the height and width required to display the button text and picture.</p>
</div>
<div class="markdown level1 conceptual"></div>
<h5 class="declaration">Declaration</h5>
<div class="codewrapper">
  <pre><code class="lang-csharp hljs">public static Size GetPreferredSize(Graphics g, Size size, Font font, string text, string textDown, ButtonTextAlign nAlign, bool wordWrap, int shadowSize, Image pictUp, Image pictDown)</code></pre>
</div>
<div class="codewrapper">
  <pre><code class="lang-vbnet hljs">Public Shared Function GetPreferredSize(g As Graphics, size As Size, font As Font, text As String, textDown As String, nAlign As ButtonTextAlign, wordWrap As Boolean, shadowSize As Integer, pictUp As Image, pictDown As Image) As Size</code></pre>
</div>
<h5 class="parameters">Parameters</h5>
<table class="table table-bordered table-condensed">
  <thead>
    <tr>
      <th>Type</th>
      <th>Name</th>
      <th>Description</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td><a class="xref" href="https://learn.microsoft.com/dotnet/api/system.drawing.graphics">Graphics</a></td>
      <td><span class="parametername">g</span></td>
      <td><p>GDI+ graphics surface</p>
</td>
    </tr>
    <tr>
      <td><a class="xref" href="https://learn.microsoft.com/dotnet/api/system.drawing.size">Size</a></td>
      <td><span class="parametername">size</span></td>
      <td><p>Size</p>
</td>
    </tr>
    <tr>
      <td><a class="xref" href="https://learn.microsoft.com/dotnet/api/system.drawing.font">Font</a></td>
      <td><span class="parametername">font</span></td>
      <td><p>Font</p>
</td>
    </tr>
    <tr>
      <td><a class="xref" href="https://learn.microsoft.com/dotnet/api/system.string">string</a></td>
      <td><span class="parametername">text</span></td>
      <td><p>Text of button when not pressed</p>
</td>
    </tr>
    <tr>
      <td><a class="xref" href="https://learn.microsoft.com/dotnet/api/system.string">string</a></td>
      <td><span class="parametername">textDown</span></td>
      <td><p>Text of button when pressed</p>
</td>
    </tr>
    <tr>
      <td><a class="xref" href="FarPoint.Win.ButtonTextAlign.html">ButtonTextAlign</a></td>
      <td><span class="parametername">nAlign</span></td>
      <td><p>Alignment of text</p>
</td>
    </tr>
    <tr>
      <td><a class="xref" href="https://learn.microsoft.com/dotnet/api/system.boolean">bool</a></td>
      <td><span class="parametername">wordWrap</span></td>
      <td><p>Whether text wraps to multiple lines</p>
</td>
    </tr>
    <tr>
      <td><a class="xref" href="https://learn.microsoft.com/dotnet/api/system.int32">int</a></td>
      <td><span class="parametername">shadowSize</span></td>
      <td><p>Size of shadow around button</p>
</td>
    </tr>
    <tr>
      <td><a class="xref" href="https://learn.microsoft.com/dotnet/api/system.drawing.image">Image</a></td>
      <td><span class="parametername">pictUp</span></td>
      <td><p>Picture (image) when button is not pressed</p>
</td>
    </tr>
    <tr>
      <td><a class="xref" href="https://learn.microsoft.com/dotnet/api/system.drawing.image">Image</a></td>
      <td><span class="parametername">pictDown</span></td>
      <td><p>Picture (image) when button is pressed</p>
</td>
    </tr>
  </tbody>
</table>
<h5 class="returns">Returns</h5>
<table class="table table-bordered table-condensed">
  <thead>
    <tr>
      <th>Type</th>
      <th>Description</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td><a class="xref" href="https://learn.microsoft.com/dotnet/api/system.drawing.size">Size</a></td>
      <td><p>An ordered pair of type Size representing the width and height.</p>
</td>
    </tr>
  </tbody>
</table>


<a id="FarPoint_Win_FpButton_GetPreferredSize_" data-uid="FarPoint.Win.FpButton.GetPreferredSize*"></a>
<h4 id="FarPoint_Win_FpButton_GetPreferredSize_System_Drawing_Graphics_System_Drawing_Size_System_Drawing_Font_System_String_System_String_FarPoint_Win_ButtonTextAlign_FarPoint_Win_TextOrientation_System_Boolean_System_Int32_System_Drawing_Image_System_Drawing_Image_System_Drawing_Text_HotkeyPrefix_" data-uid="FarPoint.Win.FpButton.GetPreferredSize(System.Drawing.Graphics,System.Drawing.Size,System.Drawing.Font,System.String,System.String,FarPoint.Win.ButtonTextAlign,FarPoint.Win.TextOrientation,System.Boolean,System.Int32,System.Drawing.Image,System.Drawing.Image,System.Drawing.Text.HotkeyPrefix)">GetPreferredSize(Graphics, Size, Font, string, string, ButtonTextAlign, TextOrientation, bool, int, Image, Image, HotkeyPrefix)</h4>
<div class="markdown level1 summary"><p>Calculates the height and width required to display the button text and picture.</p>
</div>
<div class="markdown level1 conceptual"></div>
<h5 class="declaration">Declaration</h5>
<div class="codewrapper">
  <pre><code class="lang-csharp hljs">public static Size GetPreferredSize(Graphics g, Size size, Font font, string text, string textDown, ButtonTextAlign nAlign, TextOrientation textOrientation, bool wordWrap, int shadowSize, Image pictUp, Image pictDown, HotkeyPrefix prefix)</code></pre>
</div>
<div class="codewrapper">
  <pre><code class="lang-vbnet hljs">Public Shared Function GetPreferredSize(g As Graphics, size As Size, font As Font, text As String, textDown As String, nAlign As ButtonTextAlign, textOrientation As TextOrientation, wordWrap As Boolean, shadowSize As Integer, pictUp As Image, pictDown As Image, prefix As HotkeyPrefix) As Size</code></pre>
</div>
<h5 class="parameters">Parameters</h5>
<table class="table table-bordered table-condensed">
  <thead>
    <tr>
      <th>Type</th>
      <th>Name</th>
      <th>Description</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td><a class="xref" href="https://learn.microsoft.com/dotnet/api/system.drawing.graphics">Graphics</a></td>
      <td><span class="parametername">g</span></td>
      <td><p>GDI+ graphics surface</p>
</td>
    </tr>
    <tr>
      <td><a class="xref" href="https://learn.microsoft.com/dotnet/api/system.drawing.size">Size</a></td>
      <td><span class="parametername">size</span></td>
      <td><p>Size</p>
</td>
    </tr>
    <tr>
      <td><a class="xref" href="https://learn.microsoft.com/dotnet/api/system.drawing.font">Font</a></td>
      <td><span class="parametername">font</span></td>
      <td><p>Font</p>
</td>
    </tr>
    <tr>
      <td><a class="xref" href="https://learn.microsoft.com/dotnet/api/system.string">string</a></td>
      <td><span class="parametername">text</span></td>
      <td><p>Text of button when not pressed</p>
</td>
    </tr>
    <tr>
      <td><a class="xref" href="https://learn.microsoft.com/dotnet/api/system.string">string</a></td>
      <td><span class="parametername">textDown</span></td>
      <td><p>Text of button when pressed</p>
</td>
    </tr>
    <tr>
      <td><a class="xref" href="FarPoint.Win.ButtonTextAlign.html">ButtonTextAlign</a></td>
      <td><span class="parametername">nAlign</span></td>
      <td><p>Alignment of text</p>
</td>
    </tr>
    <tr>
      <td><a class="xref" href="FarPoint.Win.TextOrientation.html">TextOrientation</a></td>
      <td><span class="parametername">textOrientation</span></td>
      <td><p>Text orientation</p>
</td>
    </tr>
    <tr>
      <td><a class="xref" href="https://learn.microsoft.com/dotnet/api/system.boolean">bool</a></td>
      <td><span class="parametername">wordWrap</span></td>
      <td><p>Whether text wraps to multiple lines</p>
</td>
    </tr>
    <tr>
      <td><a class="xref" href="https://learn.microsoft.com/dotnet/api/system.int32">int</a></td>
      <td><span class="parametername">shadowSize</span></td>
      <td><p>Size of shadow around button</p>
</td>
    </tr>
    <tr>
      <td><a class="xref" href="https://learn.microsoft.com/dotnet/api/system.drawing.image">Image</a></td>
      <td><span class="parametername">pictUp</span></td>
      <td><p>Picture when button is not pressed</p>
</td>
    </tr>
    <tr>
      <td><a class="xref" href="https://learn.microsoft.com/dotnet/api/system.drawing.image">Image</a></td>
      <td><span class="parametername">pictDown</span></td>
      <td><p>Picture when button is pressed</p>
</td>
    </tr>
    <tr>
      <td><a class="xref" href="https://learn.microsoft.com/dotnet/api/system.drawing.text.hotkeyprefix">HotkeyPrefix</a></td>
      <td><span class="parametername">prefix</span></td>
      <td><p>Hotkey prefix</p>
</td>
    </tr>
  </tbody>
</table>
<h5 class="returns">Returns</h5>
<table class="table table-bordered table-condensed">
  <thead>
    <tr>
      <th>Type</th>
      <th>Description</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td><a class="xref" href="https://learn.microsoft.com/dotnet/api/system.drawing.size">Size</a></td>
      <td><p>An ordered pair of type Size representing the width and height.</p>
</td>
    </tr>
  </tbody>
</table>


<a id="FarPoint_Win_FpButton_GetPreferredSize_" data-uid="FarPoint.Win.FpButton.GetPreferredSize*"></a>
<h4 id="FarPoint_Win_FpButton_GetPreferredSize_System_Drawing_Graphics_System_Drawing_Size_System_Drawing_Font_System_String_System_String_FarPoint_Win_ButtonTextAlign_FarPoint_Win_TextOrientation_System_Boolean_System_Int32_System_Drawing_Image_System_Drawing_Image_System_Drawing_Text_HotkeyPrefix_System_Double_" data-uid="FarPoint.Win.FpButton.GetPreferredSize(System.Drawing.Graphics,System.Drawing.Size,System.Drawing.Font,System.String,System.String,FarPoint.Win.ButtonTextAlign,FarPoint.Win.TextOrientation,System.Boolean,System.Int32,System.Drawing.Image,System.Drawing.Image,System.Drawing.Text.HotkeyPrefix,System.Double)">GetPreferredSize(Graphics, Size, Font, string, string, ButtonTextAlign, TextOrientation, bool, int, Image, Image, HotkeyPrefix, double)</h4>
<div class="markdown level1 summary"><p>Calculates the height and width required to display the button text and picture.</p>
</div>
<div class="markdown level1 conceptual"></div>
<h5 class="declaration">Declaration</h5>
<div class="codewrapper">
  <pre><code class="lang-csharp hljs">public static Size GetPreferredSize(Graphics g, Size size, Font font, string text, string textDown, ButtonTextAlign nAlign, TextOrientation textOrientation, bool wordWrap, int shadowSize, Image pictUp, Image pictDown, HotkeyPrefix prefix, double angle)</code></pre>
</div>
<div class="codewrapper">
  <pre><code class="lang-vbnet hljs">Public Shared Function GetPreferredSize(g As Graphics, size As Size, font As Font, text As String, textDown As String, nAlign As ButtonTextAlign, textOrientation As TextOrientation, wordWrap As Boolean, shadowSize As Integer, pictUp As Image, pictDown As Image, prefix As HotkeyPrefix, angle As Double) As Size</code></pre>
</div>
<h5 class="parameters">Parameters</h5>
<table class="table table-bordered table-condensed">
  <thead>
    <tr>
      <th>Type</th>
      <th>Name</th>
      <th>Description</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td><a class="xref" href="https://learn.microsoft.com/dotnet/api/system.drawing.graphics">Graphics</a></td>
      <td><span class="parametername">g</span></td>
      <td><p>GDI+ graphics surface</p>
</td>
    </tr>
    <tr>
      <td><a class="xref" href="https://learn.microsoft.com/dotnet/api/system.drawing.size">Size</a></td>
      <td><span class="parametername">size</span></td>
      <td><p>Size</p>
</td>
    </tr>
    <tr>
      <td><a class="xref" href="https://learn.microsoft.com/dotnet/api/system.drawing.font">Font</a></td>
      <td><span class="parametername">font</span></td>
      <td><p>Font</p>
</td>
    </tr>
    <tr>
      <td><a class="xref" href="https://learn.microsoft.com/dotnet/api/system.string">string</a></td>
      <td><span class="parametername">text</span></td>
      <td><p>Text of button when not pressed</p>
</td>
    </tr>
    <tr>
      <td><a class="xref" href="https://learn.microsoft.com/dotnet/api/system.string">string</a></td>
      <td><span class="parametername">textDown</span></td>
      <td><p>Text of button when pressed</p>
</td>
    </tr>
    <tr>
      <td><a class="xref" href="FarPoint.Win.ButtonTextAlign.html">ButtonTextAlign</a></td>
      <td><span class="parametername">nAlign</span></td>
      <td><p>Alignment of text</p>
</td>
    </tr>
    <tr>
      <td><a class="xref" href="FarPoint.Win.TextOrientation.html">TextOrientation</a></td>
      <td><span class="parametername">textOrientation</span></td>
      <td><p>Text orientation</p>
</td>
    </tr>
    <tr>
      <td><a class="xref" href="https://learn.microsoft.com/dotnet/api/system.boolean">bool</a></td>
      <td><span class="parametername">wordWrap</span></td>
      <td><p>Whether text wraps to multiple lines</p>
</td>
    </tr>
    <tr>
      <td><a class="xref" href="https://learn.microsoft.com/dotnet/api/system.int32">int</a></td>
      <td><span class="parametername">shadowSize</span></td>
      <td><p>Size of shadow around button</p>
</td>
    </tr>
    <tr>
      <td><a class="xref" href="https://learn.microsoft.com/dotnet/api/system.drawing.image">Image</a></td>
      <td><span class="parametername">pictUp</span></td>
      <td><p>Picture when button is not pressed</p>
</td>
    </tr>
    <tr>
      <td><a class="xref" href="https://learn.microsoft.com/dotnet/api/system.drawing.image">Image</a></td>
      <td><span class="parametername">pictDown</span></td>
      <td><p>Picture when button is pressed</p>
</td>
    </tr>
    <tr>
      <td><a class="xref" href="https://learn.microsoft.com/dotnet/api/system.drawing.text.hotkeyprefix">HotkeyPrefix</a></td>
      <td><span class="parametername">prefix</span></td>
      <td><p>HotkeyPrefix</p>
</td>
    </tr>
    <tr>
      <td><a class="xref" href="https://learn.microsoft.com/dotnet/api/system.double">double</a></td>
      <td><span class="parametername">angle</span></td>
      <td><p>The text rotation angle.</p>
</td>
    </tr>
  </tbody>
</table>
<h5 class="returns">Returns</h5>
<table class="table table-bordered table-condensed">
  <thead>
    <tr>
      <th>Type</th>
      <th>Description</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td><a class="xref" href="https://learn.microsoft.com/dotnet/api/system.drawing.size">Size</a></td>
      <td><p>An ordered pair of type Size representing the width and height.</p>
</td>
    </tr>
  </tbody>
</table>
</div>
