?? panellayoutbuttons.cs
字號(hào):
using System;
using System.Collections.Generic;
using System.Text;
using System.Windows.Forms;
namespace ProgramCalculator
{
/// <summary>
/// 繼承于Panel,用于放置函數(shù)按鈕的面板
/// </summary>
class PanelLayoutButtons:Panel
{
private readonly int dxButtonLoc = 6;
private readonly int dyButtonLoc = 6;
private readonly int xButtonCount = 4;
public PanelLayoutButtons()
{
this.AutoScroll = true;
}
/// <summary>
/// 添加函數(shù)按鈕到面板
/// </summary>
/// <param name="btn">按鈕對(duì)象</param>
public void AddButton(ref Button btn)
{
//計(jì)算按鈕高度與寬度
btn.Width = (this.Width - (xButtonCount - 1) * dxButtonLoc) / xButtonCount;
btn.Height = (int)(btn.Width / 2.5);
//計(jì)算按鈕位置
int index = this.Controls.Count;
int rowLoc = (index) / xButtonCount;
int columnLoc = index % xButtonCount;
btn.Location = new System.Drawing.Point(
columnLoc * (btn.Width + dxButtonLoc), rowLoc * (btn.Height + dyButtonLoc));
if ( !this.Contains(btn) )
{
this.Controls.Add(btn);
}
}
}
}
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -