title: Restrict resizable panel (ratio & min/max size)
body: <p>I'm currently trying to add a resizable panel to my C# winforms project.</p>
  
  <p>Currently i'm using this code to get what i want:</p>
  
  <pre><code>using System;
  using System.Drawing;
  using System.Windows.Forms;
  
  class ResizablePanel : Panel
  {
      private const int grab = 16;
  
      public ResizablePanel()
      {
          this.ResizeRedraw = true;
      }
  
      protected override void OnPaint(PaintEventArgs e)
      {
          base.OnPaint(e);
          var rc = new Rectangle(this.ClientSize.Width - grab, this.ClientSize.Height - grab, grab, grab);
          ControlPaint.DrawSizeGrip(e.Graphics, this.BackColor, rc);
      }
  
      protected override void WndProc(ref Message m)
      {
          base.WndProc(ref m);
  
          if (m.Msg == 0x84)
          {
              var pos = this.PointToClient(new Point(m.LParam.ToInt32() &amp; 0xffff, m.LParam.ToInt32() &gt;&gt; 16));
  
              if (pos.X &gt;= this.ClientSize.Width - grab &amp;&amp; pos.Y &gt;= this.ClientSize.Height - grab)
                  m.Result = new IntPtr(17);
          }
      }
  }
  </code></pre>
  
  <p>Its working fine but now i would like to limit a few things.</p>
  
  <ol>
  <li><p>I dont want the panel to be smaller than 420x236.
  I tried to set the MinimumSize but its ignoring that when i try to resize.</p></li>
  <li><p>I want to keep an aspect ratio of 16:9.</p></li>
  </ol>
  
  <p>How would i get that with the code above? Is there any way to do that?</p>