到现在大二了,学习专业基础两年了,做网络编程一个学期了,对于开发工具的使用,从微软的vs2005-vs2008-vs2010,还有adobe的,还有苹果mic,现在每天打开的是vs2010,前几天培训的时候,多下了个silverlight_tool的组件,微软庞大的软件开发.net平台给it人员更多的选择
有点winform的基础,把以前刚刚接触c#时候,很久以前做个一个winform的记事本,现在拿出来玩下,这里多了几个协助工具,主要主要是调用系统自带的游戏...便携打开...上层是记事本,下层是博客链接...
截图:
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Data;
- using System.Drawing;
- using System.Linq;
- using System.Text;
- using System.Windows.Forms;
- using System.IO;
- namespace notebook
- {
- public partial class Form1 : Form
- {
- public Form1()
- {
- InitializeComponent();
- }
- //打开
- private void 打开ToolStripMenuItem_Click(object sender, EventArgs e)
- {
- openFileDialog1.Filter = "所有文件(*.*)|*.*|记事本(*.txt)|*.txt";
- if (openFileDialog1.ShowDialog() == DialogResult.OK)
- {
- StreamReader sr = new StreamReader(openFileDialog1.FileName, Encoding.Default);
- richTextBox1.Text = sr.ReadToEnd();
- sr.Close();
- }
- }
- //保存
- private void 保存ToolStripMenuItem_Click(object sender, EventArgs e)
- {
- SaveFileDialog saveFile1 = new SaveFileDialog();
- saveFile1.InitialDirectory = "C://";
- saveFile1.Filter = "txt files(*.txt)|*.txt|RTF Files|*.rtf|DOC Files|*.doc|All files(*.*)|*.*";
- saveFile1.FilterIndex = 2; saveFile1.RestoreDirectory = true;
- if (saveFile1.ShowDialog() == DialogResult.OK)
- {
- richTextBox1.SaveFile(saveFile1.FileName, RichTextBoxStreamType.PlainText);
- }
- }
- //另存为
- private void 另存为ToolStripMenuItem_Click(object sender, EventArgs e)
- {
- saveFileDialog1.Filter = "所有文件(*.*)|*.*|记事本(*.txt)|*.txt";
- if (saveFileDialog1.ShowDialog() == DialogResult.OK)
- {
- StreamWriter sw = new StreamWriter(saveFileDialog1.FileName, true);
- sw.Write(richTextBox1.Text);
- sw.Close();
- }
- }
- //退出
- private void 退出ToolStripMenuItem_Click(object sender, EventArgs e)
- {
- if (richTextBox1.Text == "")
- {
- Application.Exit();
- }
- else
- {
- DialogResult dr = MessageBox.Show("你是否要保存记事本", "记事本", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Information);
- if (dr == DialogResult.Yes)
- {
- if (saveFileDialog1.ShowDialog() == DialogResult.OK)
- File.WriteAllText(saveFileDialog1.FileName, richTextBox1.Text);
- }
- else
- {
- if (dr == DialogResult.No)
- Application.Exit();
- }
- }
- }
- //撤销
- private void 撤销ToolStripMenuItem_Click(object sender, EventArgs e)
- {
- richTextBox1.Undo();
- }
- //剪切
- private void 剪切ToolStripMenuItem_Click(object sender, EventArgs e)
- {
- if (richTextBox1.SelectedText != "")
- {
- richTextBox1.Cut();
- 剪切ToolStripMenuItem.Enabled = false;
- 复制ToolStripMenuItem.Enabled = false;
- }
- }
- //复制
- private void 复制ToolStripMenuItem_Click(object sender, EventArgs e)
- {
- if (richTextBox1.SelectedText != "")
- {
- richTextBox1.Copy();
- 剪切ToolStripMenuItem.Enabled = false;
- 复制ToolStripMenuItem.Enabled = false;
- }
- }
- //粘贴
- private void 粘贴ToolStripMenuItem_Click(object sender, EventArgs e)
- {
- richTextBox1.Paste();
- }
- //删除
- private void 删除ToolStripMenuItem_Click(object sender, EventArgs e)
- {
- richTextBox1.SelectedText = "";
- }
- //全选
- private void 全选ToolStripMenuItem_Click(object sender, EventArgs e)
- {
- richTextBox1.SelectAll();
- }
- //时间日期
- private void 时间日期DToolStripMenuItem_Click(object sender, EventArgs e)
- {
- richTextBox1.AppendText(DateTime.Now.ToString());
- }
- //自动换行
- private void ToolStripMenuItem123_Click(object sender, EventArgs e)
- {
- if (ToolStripMenuItem123.Checked == true)
- {
- ToolStripMenuItem123.Checked = false;
- richTextBox1.WordWrap = false;
- }
- else
- {
- ToolStripMenuItem123.Checked = true;
- richTextBox1.WordWrap = true;
- }
- }
- //设置字体
- private void 字体FToolStripMenuItem_Click(object sender, EventArgs e)
- {
- fontDialog1.ShowDialog();
- richTextBox1.Font = fontDialog1.Font;
- if (richTextBox1.SelectedText != "")
- {
- fontDialog1.ShowDialog();
- richTextBox1.Font = fontDialog1.Font;
- }
- }
- //调用windows自带的计算器
- private void 计算器ToolStripMenuItem_Click(object sender, EventArgs e)
- {
- System.Diagnostics.Process.Start(@"C:/WINDOWS/system32/calc");
- }
- //调用画图工具
- private void 画图ToolStripMenuItem_Click(object sender, EventArgs e)
- {
- System.Diagnostics.Process.Start(@"C:/WINDOWS/system32/mspaint");
- }
- //调用命令提示符
- private void 命令提示符ToolStripMenuItem_Click(object sender, EventArgs e)
- {
- System.Diagnostics.Process.Start(@"C:/WINDOWS/system32/cmd");
- }
- //友谊链接
- private void 百度ToolStripMenuItem_Click(object sender, EventArgs e)
- {
- System.Diagnostics.Process.Start("IExplore", "http://www.baidu.com");
- }
- private void 关于记事本ToolStripMenuItem_Click(object sender, EventArgs e)
- {
- MessageBox.Show("该记事本是我2010年清明时制作的/r/n所有权归新竹所有 ");
- }
- //设置颜色
- private void 颜色ToolStripMenuItem_Click(object sender, EventArgs e)
- {
- ColorDialog ColorDialog1 = new ColorDialog();
- ColorDialog1.AllowFullOpen = false;
- ColorDialog1.FullOpen = true;
- ColorDialog1.AnyColor = true;
- ColorDialog1.Color = richTextBox1.ForeColor;
- ColorDialog1.ShowDialog();
- //richTextBox1.ForeColor=ColorDialog1.Color;
- richTextBox1.SelectionColor = ColorDialog1.Color;
- }
- private void 小新ToolStripMenuItem_Click(object sender, EventArgs e)
- {
- System.Diagnostics.Process.Start("IExplore", "http://hshichu.blog.51cto.com/");
- }
- private void 记事本ToolStripMenuItem_Click(object sender, EventArgs e)
- {
- System.Diagnostics.Process.Start(@"C:/WINDOWS/system32/notepad");
- }
- //游戏
- //纸牌
- private void 纸牌ToolStripMenuItem_Click(object sender, EventArgs e)
- {
- System.Diagnostics.Process.Start(@"C:/WINDOWS/system32/sol.exe ");
- }
- private void 扫雷ToolStripMenuItem_Click(object sender, EventArgs e)
- {
- System.Diagnostics.Process.Start(@"C:/WINDOWS/system32/winmine.exe");
- }
- private void 清空ToolStripMenuItem_Click(object sender, EventArgs e)
- {
- this.richTextBox1.Clear();
- }
- private void 放大镜ToolStripMenuItem_Click(object sender, EventArgs e)
- {
- System.Diagnostics.Process.Start(@"C:/WINDOWS/system32/magnify");
- }
- private void 蜘蛛纸牌ToolStripMenuItem_Click(object sender, EventArgs e)
- {
- System.Diagnostics.Process.Start(@"C:/WINDOWS/system32/spider.exe ");
- }
- private void 空当接龙ToolStripMenuItem_Click(object sender, EventArgs e)
- {
- System.Diagnostics.Process.Start(@"C:/WINDOWS/system32/freecell.exe ");
- }
- private void 红心大战ToolStripMenuItem_Click(object sender, EventArgs e)
- {
- System.Diagnostics.Process.Start(@"C:/WINDOWS/system32/mshearts.exe ");
- }
- private void 左对齐ToolStripMenuItem_Click(object sender, EventArgs e)
- {
- richTextBox1.SelectionAlignment =
- (System.Windows.Forms.HorizontalAlignment)0;
- }
- private void 右对齐ToolStripMenuItem_Click(object sender, EventArgs e)
- {
- richTextBox1.SelectionAlignment =
- (System.Windows.Forms.HorizontalAlignment)1;
- }
- private void 居中对齐ToolStripMenuItem_Click(object sender, EventArgs e)
- {
- richTextBox1.SelectionAlignment =
- (System.Windows.Forms.HorizontalAlignment)2;
- }
- private void 打印预览ToolStripMenuItem_Click(object sender, EventArgs e)
- {
- PrintPreviewDialog printpreviewDialog = new PrintPreviewDialog();
- printpreviewDialog.Document = printDocument1;
- //lineReader = new System.IO.StringReader(richTextBox1.Text);
- try
- {
- printpreviewDialog.ShowDialog();
- }
- catch (Exception excep)
- {
- MessageBox.Show(excep.Message, "打印出错 ",
- MessageBoxButtons.OK, MessageBoxIcon.Error);
- }
- }
- private void 查找ToolStripMenuItem_Click(object sender, EventArgs e)
- {
- //FindandReplace findandReplace = new FindandReplace();
- //findandReplace.Show();
- }
- private void button1_Click(object sender, EventArgs e)
- {
- Refresh();
- }
- private static void rRefresh()
- {
- //throw new NotImplementedException();
- }
- }
- }