📄 jsb.cs
字号:
this.menuItem23.Index = 3;
this.menuItem23.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
this.menuItem24});
this.menuItem23.Text = "帮助(&H)";
//
// menuItem24
//
this.menuItem24.Index = 0;
this.menuItem24.Text = "关于无聊记事本";
this.menuItem24.Click += new System.EventHandler(this.menuItem24_Click);
//
// openFileDialog1
//
this.openFileDialog1.DefaultExt = "txt";
this.openFileDialog1.Filter = "文本文件(*.txt)|*.txt|所有文件(*.*)|(*.*)\"";
//
// saveFileDialog1
//
this.saveFileDialog1.Filter = "文本文件(*.txt)|*.txt|所有文件(*.*)|(*.*)\"";
//
// fontDialog1
//
this.fontDialog1.ShowColor = true;
//
// colorDialog1
//
this.colorDialog1.AnyColor = true;
this.colorDialog1.Color = System.Drawing.Color.Transparent;
//
// printDialog1
//
this.printDialog1.Document = this.printDocument1;
//
// printDocument1
//
this.printDocument1.PrintPage += new System.Drawing.Printing.PrintPageEventHandler(this.printDocument1_PrintPage);
//
// printPreviewDialog1
//
this.printPreviewDialog1.AutoScrollMargin = new System.Drawing.Size(0, 0);
this.printPreviewDialog1.AutoScrollMinSize = new System.Drawing.Size(0, 0);
this.printPreviewDialog1.ClientSize = new System.Drawing.Size(400, 300);
this.printPreviewDialog1.Document = this.printDocument1;
this.printPreviewDialog1.Enabled = true;
this.printPreviewDialog1.Icon = ((System.Drawing.Icon)(resources.GetObject("printPreviewDialog1.Icon")));
this.printPreviewDialog1.Location = new System.Drawing.Point(360, 75);
this.printPreviewDialog1.MinimumSize = new System.Drawing.Size(375, 250);
this.printPreviewDialog1.Name = "printPreviewDialog1";
this.printPreviewDialog1.TransparencyKey = System.Drawing.Color.Empty;
this.printPreviewDialog1.Visible = false;
//
// richText
//
this.richText.Dock = System.Windows.Forms.DockStyle.Fill;
this.richText.Location = new System.Drawing.Point(0, 0);
this.richText.Name = "richText";
this.richText.Size = new System.Drawing.Size(672, 305);
this.richText.TabIndex = 0;
this.richText.Text = "";
this.richText.WordWrap = false;
this.richText.KeyPress += new System.Windows.Forms.KeyPressEventHandler(this.richText_KeyPress);
//
// Form1
//
this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
this.ClientSize = new System.Drawing.Size(672, 305);
this.Controls.Add(this.richText);
this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
this.Menu = this.mainMenu1;
this.Name = "Form1";
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
this.Text = "无聊记事本1.0版";
this.Closing += new System.ComponentModel.CancelEventHandler(this.Form1_Closing);
this.Load += new System.EventHandler(this.Form1_Load);
this.ResumeLayout(false);
}
#endregion
/// <summary>
/// 应用程序的主入口点。
/// </summary>
[STAThread]
static void Main()
{
Application.Run(new Form1());
}
private bool bc = false;
private string filelj = "z:\\aa.aa";
private void savefile()
{
if (bc)
{
if(File.Exists(@filelj))
{
bc = false;
StreamWriter tmp = new StreamWriter(filelj);
tmp.Write(richText.Text);
tmp.Flush();
tmp.Close();
}
else
{
if (saveFileDialog1.ShowDialog() == DialogResult.OK)
{
bc = false;
filelj = saveFileDialog1.FileName;
StreamWriter tmp = new StreamWriter(filelj);
tmp.Write(richText.Text);
tmp.Flush();
tmp.Close();
}
}
}
}
private void Form1_Load(object sender, System.EventArgs e)
{
}
private void menuItem3_Click(object sender, System.EventArgs e)
{
if (bc)
{
if (MessageBox.Show("文件已更,改是否保存!","提示框",MessageBoxButtons.YesNo,MessageBoxIcon.Exclamation) == DialogResult.Yes)
{
savefile();
}
}
filelj = "z:\\aa.aa";
richText.Text = "";
}
private void menuItem2_Click(object sender, System.EventArgs e)
{
if (openFileDialog1.ShowDialog() == DialogResult.OK)
{
savefile();
bc = false;
filelj = openFileDialog1.FileName;
StreamReader rtmp = new StreamReader(filelj,System.Text.Encoding.ASCII);
richText.Text = rtmp.ReadToEnd();
rtmp.Close();
}
}
private void menuItem4_Click(object sender, System.EventArgs e)
{
saveFileDialog1.Title = "保存";
savefile();
}
private void menuItem5_Click(object sender, System.EventArgs e)
{
saveFileDialog1.Title = "另存为";
filelj = "z:\\aa.aa";
bc = true;
savefile();
}
private void menuItem7_Click(object sender, System.EventArgs e)
{
if (printDialog1.ShowDialog() == DialogResult.OK)
{
printDocument1.Print();
}
}
private void menuItem9_Click(object sender, System.EventArgs e)
{
printPreviewDialog1.ShowDialog();
}
private void menuItem11_Click(object sender, System.EventArgs e)
{
if (bc)
{
if (MessageBox.Show("文件已更,改是否保存!","提示框",MessageBoxButtons.YesNo,MessageBoxIcon.Exclamation) == DialogResult.Yes)
{
savefile();
}
this.Close();
}
}
private void printDocument1_PrintPage(object sender, System.Drawing.Printing.PrintPageEventArgs e)
{
Font ff = new Font("",30,FontStyle.Regular);
int x = 0;
int y = 30;
int i = 0;
for (i=0;i<richText.Lines.Length;i++)
{
e.Graphics.DrawString(richText.Lines[i].ToString(),ff,Brushes.Black,x,y);
y += ff.Height + 20;
}
}
private void richText_KeyPress(object sender, System.Windows.Forms.KeyPressEventArgs e)
{
bc = true;
}
private void Form1_Closing(object sender, System.ComponentModel.CancelEventArgs e)
{
this.TopMost = true;
if (bc)
{
if (MessageBox.Show("文件已更,改是否保存!","提示框",MessageBoxButtons.YesNo,MessageBoxIcon.Exclamation) == DialogResult.Yes)
{
savefile();
}
}
}
private void menuItem21_Click(object sender, System.EventArgs e)
{
if (richText.WordWrap == true)
{
richText.WordWrap = false;
mainMenu1.MenuItems[2].MenuItems[0].Checked = false;
}
else
{
richText.WordWrap = true;
mainMenu1.MenuItems[2].MenuItems[0].Checked = true;
}
}
private void menuItem22_Click(object sender, System.EventArgs e)
{
if (fontDialog1.ShowDialog() == DialogResult.OK)
{
richText.Font = fontDialog1.Font;
richText.ForeColor = fontDialog1.Color;
}
}
private void menuItem26_Click(object sender, System.EventArgs e)
{
if (colorDialog1.ShowDialog() == DialogResult.OK)
{
richText.BackColor=colorDialog1.Color;
}
}
private void menuItem24_Click(object sender, System.EventArgs e)
{
MessageBox.Show("无聊记事本1.0版本,版权所有:王旸","关于无聊记事本",MessageBoxButtons.OK,MessageBoxIcon.Information);
}
private void menuItem14_Click(object sender, System.EventArgs e)
{
IDataObject data = Clipboard.GetDataObject();
if (data.GetDataPresent(DataFormats.Text))
{
richText.SelectedText = data.GetData(DataFormats.Text).ToString();
}
}
private void menuItem13_Click(object sender, System.EventArgs e)
{
if (richText.SelectedText != "")
{
Clipboard.SetDataObject(richText.SelectedText);
}
}
private void menuItem12_Click(object sender, System.EventArgs e)
{
if (richText.SelectedText != "")
{
Clipboard.SetDataObject(richText.SelectedText);
richText.SelectedText = "";
}
}
private void menuItem19_Click(object sender, System.EventArgs e)
{
richText.SelectAll();
}
private void menuItem16_Click(object sender, System.EventArgs e)
{
Form3 f3 = new Form3(this);
f3.Show();
}
private void menuItem17_Click(object sender, System.EventArgs e)
{
Form2 f2 = new Form2(this);
f2.Show();
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -