DarkRoomW.frmMain.ReScale C# (CSharp) Method

ReScale() public method

public ReScale ( ) : void
return void
        public void ReScale()
        {
            if (Properties.Settings.Default.PageWidth > 0)
            {
                pnlPage.Width = Properties.Settings.Default.PageWidth;
            }
            else
            {
                pnlPage.Width = this.ClientSize.Width - (pnlNav.Visible ? pnlNav.Width : 0);
            }

            if (pnlPage.Width > this.ClientSize.Width)
            {
                pnlPage.Width = this.ClientSize.Width - (pnlNav.Visible ? pnlNav.Width : 0);
            }

            pnlPage.Left = (this.ClientSize.Width - (pnlPage.Width + (pnlNav.Visible ? pnlNav.Width : 0))) / 2;

            if (Properties.Settings.Default.PageHeight > 0)
            {
                pnlPage.Height = Properties.Settings.Default.PageHeight;
            }
            else
            {
                pnlPage.Height = this.Height;
            }
            if (pnlPage.Height > this.Height)
            {
                pnlPage.Height = this.Height;
            }
            if (mnuMenuStrip.Visible)
            {
                pnlPage.Height = pnlPage.Height - mnuMenuStrip.Height * 2 - 3;
            }
            txtPage.Width = pnlPage.Width - (Properties.Settings.Default.PagePadding * 2);
            txtPage.Top = Properties.Settings.Default.PagePadding;
            txtPage.Left = Properties.Settings.Default.PagePadding;
            txtPage.Height = pnlPage.Height - (Properties.Settings.Default.PagePadding * 2);
            pnlNav.Top = pnlPage.Top;
            pnlNav.Left = pnlPage.Left + pnlPage.Width;
        }

Usage Example

コード例 #1
0
 private void txtPageWidth_TextChanged(object sender, EventArgs e)
 {
     if (txtPageWidth.Text.Trim() != "" & IsValidNumber(txtPageWidth.Text))
     {
         if ((System.Convert.ToInt32(txtPageWidth.Text) > 100 | System.Convert.ToInt32(txtPageWidth.Text) == 0))
         {
             Properties.Settings.Default.PageWidth = Int32.Parse(txtPageWidth.Text);
             Properties.Settings.Default.Save();
             parent.ReScale();
         }
     }
     else
     {
         MessageBox.Show("Invalid Page Width. You may only use numeric characters.");
     }
 }