资源简介
通过c#实现写字板页面的编辑。并实现调整写字板中所输入的文字大小、字体、文字居中、保存文件、新建文件、打印文件等基本功能。

代码片段和文件信息
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;
namespace 写字板
{
public partial class Form1 : Form
{
private bool textChange = false;
public Form1()
{
InitializeComponent();
}
private void menuItemNewFile_Click(object sender EventArgs e)
{
createNewFile();
}
private void Form1_Load(object sender EventArgs e)
{
initFortName(); // 将系统字体添加到字体列表
statusLabelFileName.Text = “NoName“; //设置状态栏文件名
statusLabelFileName.Tag = ““;
timer1.Interval = 60000; // 计时器每分钟发生一次事件
timer1.Enabled = true; // 启动计时器
this.ShowInTaskbar = false;
}
private void initFortName()
{
// 枚举计算机上安装的字体
System.Drawing.Text.InstalledFontCollection installedFontCollection = new System.Drawing.Text.InstalledFontCollection();
FontFamily[] fontFamilies;
// Get the array of FontFamily objects.
fontFamilies = installedFontCollection.Families;
int count = fontFamilies.Length;
foreach (FontFamily fontFamily in fontFamilies)
this.comBoxFontName.Items.Add(fontFamily.Name);
}
private void createNewFile()
{
richTextBox1.Clear();
}
private void openFile()
{
openFileDialog1.title = “请选择一个文件“;
openFileDialog1.Filter = “RTF格式文件(*.rtf)|*.rtf|文本文件(*.txt)|*.txt|所有文件(*.*)|*.*“; //打开文件格式
openFileDialog1.RestoreDirectory = true; // 关闭前还原当前目录
//显示对话框,直到用户关闭它。在退出对话框时如果选择了确定按钮表示有效
statusLabelMsg.Text = “请选择要编辑的文件“;
string MyFileName;
if (openFileDialog1.ShowDialog() == DialogResult.OK)
{
MyFileName = openFileDialog1.FileName; // 返回选取的文件名
//string MyShortFileName = MyFileName.Substring(MyFileName.LastIndexOf(“\\“) + 1);
if (richTextBox1.Text != ““)
{
if (MessageBox.Show(“是否保存当前文件?“ “提示“ MessageBoxButtons.YesNo) == DialogResult.Yes)
saveFile();
}
if (openFileDialog1.FilterIndex == 1)
{ // 如果是*.rtf格式,则用RichText(RTF格式文件)方式打开
richTextBox1.LoadFile(MyFileName RichTextBoxStreamType.RichText);
}
else
{ // 如果是其它格式,则用PlainText(文本文件)方式打开
richTextBox1.LoadFile(MyFileName RichTextBoxStreamType.PlainText);
}
// 将文件名显示在状态栏(不含路径)
statusLabelFileName.Text = openFileDialog1.SafeFileName;
statusLabel
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
目录 0 2018-10-21 20:09 写字板\
文件 869 2018-10-21 16:34 写字板.sln
目录 0 2018-10-21 16:34 写字板\bin\
目录 0 2018-10-21 19:43 写字板\bin\Debug\
文件 71168 2018-10-21 20:12 写字板\bin\Debug\写字板.exe
文件 62976 2018-10-21 20:12 写字板\bin\Debug\写字板.pdb
文件 11600 2018-10-21 21:53 写字板\bin\Debug\写字板.vshost.exe
文件 490 2018-04-12 07:35 写字板\bin\Debug\写字板.vshost.exe.manifest
文件 26522 2018-10-21 20:09 写字板\Form1.cs
文件 50177 2018-10-21 20:08 写字板\Form1.Designer.cs
文件 50829 2018-10-21 20:08 写字板\Form1.resx
文件 446 2018-10-21 20:05 写字板\Form2.cs
文件 5292 2018-10-21 20:05 写字板\Form2.Designer.cs
文件 8211 2018-10-21 20:05 写字板\Form2.resx
文件 275 2018-10-21 20:09 写字板\FrmAbout.cs
文件 22358 2018-10-13 19:26 写字板\Icon1.ico
目录 0 2018-10-21 16:34 写字板\obj\
目录 0 2018-10-21 16:34 写字板\obj\x86\
目录 0 2018-10-21 20:12 写字板\obj\x86\Debug\
文件 5420 2018-10-21 18:05 写字板\obj\x86\Debug\DesignTimeResolveAssemblyReferences.cache
文件 6379 2018-10-21 21:53 写字板\obj\x86\Debug\DesignTimeResolveAssemblyReferencesInput.cache
目录 0 2018-10-21 16:34 写字板\obj\x86\Debug\TempPE\
文件 860 2018-10-21 21:53 写字板\obj\x86\Debug\写字板.csproj.FileListAbsolute.txt
文件 1033 2018-10-21 20:08 写字板\obj\x86\Debug\写字板.csproj.GenerateResource.Cache
文件 9214 2018-10-21 20:12 写字板\obj\x86\Debug\写字板.csprojResolveAssemblyReference.cache
文件 71168 2018-10-21 20:12 写字板\obj\x86\Debug\写字板.exe
文件 31380 2018-10-21 20:09 写字板\obj\x86\Debug\写字板.Form1.resources
文件 1970 2018-10-21 20:09 写字板\obj\x86\Debug\写字板.Form2.resources
文件 62976 2018-10-21 20:12 写字板\obj\x86\Debug\写字板.pdb
文件 180 2018-10-21 20:09 写字板\obj\x86\Debug\写字板.Properties.Resources.resources
文件 533 2018-10-21 20:12 写字板\Program.cs
............此处省略7个文件信息
- 上一篇:c#绘图板源码直线,矩形,圆形,填充
- 下一篇:随机点名程序.zip
相关资源
- C#解析HL7消息的库135797
- C# OCR数字识别实例,采用TessnetOcr,对
- 考试管理系统 - C#源码
- asp.net C#购物车源代码
- C#实时网络流量监听源码
- C#百度地图源码
- Visual C#.2010从入门到精通配套源程序
- C# 软件版本更新
- C#屏幕软键盘源码,可以自己定制界面
- 智慧城市 智能家居 C# 源代码
- c#获取mobile手机的IMEI和IMSI
- C#实现简单QQ聊天程序
- 操作系统 模拟的 欢迎下载 C#版
- C#写的计算机性能监控程序
- 用C#实现邮件发送,有点类似于outlo
- MVC model层代码生成器 C#
- c#小型图书销售系统
- C# Socket Server Client 通讯应用 完整的服
- c# winform 自动登录 百度账户 源代码
- C#编写的16进制计算器
- C#TCP通信协议
- C# 数据表(Dataset)操作 合并 查询一
- C#语音识别系统speechsdk51,SpeechSDK51L
- 数据库备份还原工具1.0 C# 源码
-
[免费]xm
lDocument 节点遍历C# - EQ2008LEDc#开发实例
- DirectX.Capturec# winform 操作摄像头录像附
- c# 实现的最大最小距离方法对鸢尾花
- C#版保龄球记分代码
- C#自定义控件
评论
共有 条评论