?? mainform.cs
字號(hào):
}
#endregion
#endregion
#region 查看--工具欄和狀態(tài)欄
private void 工具欄ToolStripMenuItem_Click(object sender, EventArgs e)
{
if (工具欄ToolStripMenuItem.Checked)
{
this.toolStrip1.Dock = DockStyle.None;
this.toolStrip1.Hide();
工具欄ToolStripMenuItem.Checked = false;
}
else
{
this.toolStrip1.Dock = DockStyle.Top;
this.toolStrip1.Show();
工具欄ToolStripMenuItem.Checked = true;
}
}
private void 格式欄ToolStripMenuItem_Click(object sender, EventArgs e)
{
if (格式欄ToolStripMenuItem.Checked)
{
this.toolStrip2.Dock = DockStyle.None;
this.toolStrip2.Hide();
格式欄ToolStripMenuItem.Checked = false;
}
else
{
this.toolStrip2.Dock = DockStyle.Top;
this.toolStrip2.Show();
格式欄ToolStripMenuItem.Checked = true;
}
}
private void 狀態(tài)欄ToolStripMenuItem_Click(object sender, EventArgs e)
{
if (狀態(tài)欄ToolStripMenuItem.Checked)
{
this.statusStrip1.Dock = DockStyle.None;
this.statusStrip1.Hide();
狀態(tài)欄ToolStripMenuItem.Checked = false;
}
else
{
this.statusStrip1.Dock = DockStyle.Bottom;
this.statusStrip1.Show();
狀態(tài)欄ToolStripMenuItem.Checked = true;
}
}
#endregion
#region 窗口--層疊顯示,水平排列和垂直排列
private void 層疊顯示ToolStripMenuItem_Click(object sender, EventArgs e)
{
this.LayoutMdi(MdiLayout.Cascade);
層疊顯示ToolStripMenuItem.Checked = true;
水平排列ToolStripMenuItem.Checked = false;
垂直排列ToolStripMenuItem.Checked = false;
}
private void 水平排列ToolStripMenuItem_Click(object sender, EventArgs e)
{
this.LayoutMdi(MdiLayout.TileHorizontal);
層疊顯示ToolStripMenuItem.Checked = false;
水平排列ToolStripMenuItem.Checked = true;
垂直排列ToolStripMenuItem.Checked = false;
}
private void 垂直排列ToolStripMenuItem_Click(object sender, EventArgs e)
{
this.LayoutMdi(MdiLayout.TileVertical);
層疊顯示ToolStripMenuItem.Checked = false;
水平排列ToolStripMenuItem.Checked = false;
垂直排列ToolStripMenuItem.Checked = true;
}
#endregion
#region 幫助--幫助主題和關(guān)于
private void 幫助主題ToolStripMenuItem_Click(object sender, EventArgs e)
{
string strHelpFilePath = Application.StartupPath + "\\Notepad 使用幫助.chm";
if (File.Exists(strHelpFilePath))
{
//如果你只加載這個(gè)文件
Help.ShowHelp(this, strHelpFilePath);
}
}
private void 關(guān)于CSharpNotepadToolStripMenuItem_Click(object sender, EventArgs e)
{
new aboutForm().Show();
}
#endregion
#endregion
#region 主窗口工具欄事件處理的方法
#region 填充字體和字號(hào)數(shù)據(jù)
private void GetFontFamilyNames()
{
Graphics graphics = this.CreateGraphics();
FontFamily[] fontFamilyNames = FontFamily.GetFamilies(graphics);
for (int i = 0; i < fontFamilyNames.Length; i++)
{
tscbFontFamilyName.Items.Add(fontFamilyNames[i].Name);
}
}
private void GetFontSize()
{
float[] fontSize = new float[] { 5f, 6, 7, 8, 9, 10, 11, 12, 14, 16, 18, 20, 22, 24, 26, 28, 36, 48, 72 };
for (int i = 0; i < fontSize.Length; i++)
tscbFontSize.Items.Add(fontSize[i].ToString());
}
#endregion
#region 設(shè)置文本的字體和字號(hào)
//單獨(dú)設(shè)置字體
private void tscbFontFamilyName_SelectedIndexChanged(object sender, EventArgs e)
{
string newFontFamilyName;
float FontSize;
newFontFamilyName = tscbFontFamilyName.SelectedItem.ToString();
if (tscbFontSize.SelectedIndex == -1)
{
FontSize = float.Parse(tscbFontSize.Items[6].ToString());
}
else
{
FontSize = float.Parse(tscbFontSize.SelectedItem.ToString());
}
currentForm.SetFontFamilyName(newFontFamilyName, FontSize);
currentForm.GetCurrentFontAndAlignment();
}
//單獨(dú)設(shè)置字號(hào)
private void tscbFontSize_SelectedIndexChanged(object sender, EventArgs e)
{
string FontFamilyName;
float newFontSize;
newFontSize = float.Parse(tscbFontSize.Text.ToString());
if (tscbFontFamilyName.SelectedIndex == -1)
{
FontFamilyName = tscbFontFamilyName.Items[1].ToString();
}
else
{
FontFamilyName = tscbFontFamilyName.SelectedItem.ToString();
}
currentForm.SetFontSize(FontFamilyName, newFontSize);
currentForm.GetCurrentFontAndAlignment();
}
private void tscbFontSize_KeyPress(object sender, KeyPressEventArgs e)
{
if (!(Char.IsNumber(e.KeyChar) || e.KeyChar == (char)8))
e.Handled = true;
}
private void tscbFontSize_TextChanged(object sender, System.EventArgs e)
{
if (this.MdiChildren.Length == 0 || tscbFontSize.Text == "")
return;
else
{
string FontFamilyName;
float newFontSize;
newFontSize = float.Parse(tscbFontSize.Text.ToString());
if (tscbFontFamilyName.SelectedIndex == -1)
{
FontFamilyName = tscbFontFamilyName.Items[1].ToString();
}
else
{
FontFamilyName = tscbFontFamilyName.SelectedItem.ToString();
}
currentForm.SetFontSize(FontFamilyName, newFontSize);
currentForm.GetCurrentFontAndAlignment();
}
}
#endregion
#region 設(shè)置文本的字形(粗體/斜體/下劃線)
private void tsbBold_Click(object sender, EventArgs e)
{
currentForm.SetBold();
currentForm.GetCurrentFontAndAlignment();
this.SetCurrentFont();
}
private void tsbItalic_Click(object sender, EventArgs e)
{
currentForm.SetItalic();
currentForm.GetCurrentFontAndAlignment();
this.SetCurrentFont();
}
private void tsbUnderLine_Click(object sender, EventArgs e)
{
currentForm.SetUnderLine();
currentForm.GetCurrentFontAndAlignment();
this.SetCurrentFont();
}
#endregion
#region 設(shè)置文本的對(duì)齊格式
private void LeftAlign_Click(object sender, EventArgs e) //左對(duì)齊
{
左對(duì)齊ToolStripMenuItem_Click(sender, e);
currentForm.GetCurrentFontAndAlignment();
this.SetCurrentAlignment();
}
private void MiddleAlign_Click(object sender, EventArgs e) //居中
{
居中ToolStripMenuItem_Click(sender, e);
currentForm.GetCurrentFontAndAlignment();
this.SetCurrentAlignment();
}
private void RightAlign_Click(object sender, EventArgs e) //右對(duì)齊
{
右對(duì)齊ToolStripMenuItem_Click(sender, e);
currentForm.GetCurrentFontAndAlignment();
this.SetCurrentAlignment();
}
#endregion
#region 設(shè)置文本的顏色
private void tssbFontColor_Click(object sender, EventArgs e)
{
顏色ToolStripMenuItem_Click(sender, e);
}
#endregion
#endregion
#region 主窗口格式欄事件處理的方法
private void 新建NToolStripButton_Click(object sender, EventArgs e)
{
新建ToolStripMenuItem_Click(sender, e);
}
private void 打開OToolStripButton_Click(object sender, EventArgs e)
{
打開ToolStripMenuItem_Click(sender, e);
}
private void 保存SToolStripButton_Click(object sender, EventArgs e)
{
保存ToolStripMenuItem_Click(sender, e);
}
private void 打印PToolStripButton_Click(object sender, EventArgs e)
{
打印ToolStripMenuItem_Click(sender, e);
}
private void 打印預(yù)覽VToolStripButton_Click(object sender, EventArgs e)
{
打印預(yù)覽ToolStripMenuItem_Click(sender, e);
}
private void 剪切UToolStripButton_Click(object sender, EventArgs e)
{
剪切ToolStripMenuItem_Click(sender, e);
}
private void 復(fù)制CToolStripButton_Click(object sender, EventArgs e)
{
復(fù)制ToolStripMenuItem_Click(sender, e);
}
private void 粘貼PToolStripButton_Click(object sender, EventArgs e)
{
粘貼ToolStripMenuItem_Click(sender, e);
}
private void 撤消UToolStripButton_Click(object sender, EventArgs e)
{
撤消ToolStripMenuItem_Click(sender, e);
}
private void 恢復(fù)RToolStripButton_Click(object sender, EventArgs e)
{
恢復(fù)ToolStripMenuItem_Click(sender, e);
}
private void 幫助LToolStripButton_Click(object sender, EventArgs e)
{
幫助主題ToolStripMenuItem_Click(sender, e);
}
private void tscbDisplayRatio_KeyPress(object sender, KeyPressEventArgs e)
{
if (e.KeyChar != (char)37)
{
if (!(Char.IsNumber(e.KeyChar) || e.KeyChar == (char)8))
e.Handled = true;
}
return;
}
private void tscbDisplayRatio_SelectedIndexChanged(object sender, System.EventArgs e)
{
if (this.MdiChildren.Length == 0)
return;
this.currentForm.richTextBox1.ZoomFactor = float.Parse(tscbDisplayRatio.Text.Remove(tscbDisplayRatio.Text.Length - 1, 1)) / 100.0f;
}
private void tscbDisplayRatio_TextChanged(object sender, System.EventArgs e)
{
string[] temp = this.tscbDisplayRatio.Text.Split('%');
if (this.MdiChildren.Length == 0 || temp[0] == "")
{
this.tscbDisplayRatio.Text = "10%";
return;
}
else
{
float ratio;
//if (tscbDisplayRatio.Text.EndsWith("%"))
//ratio = float.Parse(tscbDisplayRatio.Text.Remove(tscbDisplayRatio.Text.Length - 1, 1)) / 100.0f;
this.tscbDisplayRatio.Text = temp[0] + "%";
ratio = float.Parse(temp[0]) / 100.0f;
if (ratio <= 0.05)
{
this.currentForm.richTextBox1.ZoomFactor = 0.05f;
}
else if (ratio > 16.0)
{
this.currentForm.richTextBox1.ZoomFactor = 16.0f;
}
else
{
this.currentForm.richTextBox1.ZoomFactor = ratio;
}
}
}
private void tsbProject_Click(object sender, EventArgs e)
{
項(xiàng)目符號(hào)樣式ToolStripMenuItem_Click(sender, e);
}
#endregion
}
}
?? 快捷鍵說(shuō)明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -