图形和文字编辑器面向对象程序设计实验报告Word格式.docx

上传人:b****2 文档编号:15386597 上传时间:2022-10-29 格式:DOCX 页数:11 大小:230.02KB
下载 相关 举报
图形和文字编辑器面向对象程序设计实验报告Word格式.docx_第1页
第1页 / 共11页
图形和文字编辑器面向对象程序设计实验报告Word格式.docx_第2页
第2页 / 共11页
图形和文字编辑器面向对象程序设计实验报告Word格式.docx_第3页
第3页 / 共11页
图形和文字编辑器面向对象程序设计实验报告Word格式.docx_第4页
第4页 / 共11页
图形和文字编辑器面向对象程序设计实验报告Word格式.docx_第5页
第5页 / 共11页
点击查看更多>>
下载资源
资源描述

图形和文字编辑器面向对象程序设计实验报告Word格式.docx

《图形和文字编辑器面向对象程序设计实验报告Word格式.docx》由会员分享,可在线阅读,更多相关《图形和文字编辑器面向对象程序设计实验报告Word格式.docx(11页珍藏版)》请在冰豆网上搜索。

图形和文字编辑器面向对象程序设计实验报告Word格式.docx

开发环境:

Windows7

开发工具:

MicrosoftVisualstudio2010C#

硬件环境:

CPU:

2.6GHz、内存:

4G、硬盘:

500G

运行环境:

Windows7/XP/2003

三、概要设计

3.1功能简要概述

文本编辑器的功能是对windows的记事本的精简版本,使用更方面快捷。

3.2系统框架设计

根据系统功能分析,经过模块化的分析得到如下图所示的系统功能模块结构图。

四、详细设计

4.1界面设计

1.程序运行主界面如下图:

2、文本编辑器界面如下图:

五、程序使用说明、测试分析及结果

5.1.使用说明

图片文本编辑器的使用说明:

打开程序主界面后,通过点击“图片编辑器”按钮或者“文本编辑器”

按钮可跳转到相应的视图界面。

1、图片编辑器的运行:

2、文本编辑器的运行:

打开文本编辑器的主界面后,可以直接编辑文本,也可以选择实现相应功能:

文件菜单中包括新建,打开,保存,另存为,和退出;

编辑菜单中包括剪切,粘贴,复制,全选,清空,显示时间;

格式;

查看等功能对编辑的进行编辑

5.2.分析与结果

(1)主界面的文本编辑器的标志图片变换:

每100MS执行一次

privatevoidbutton2_Click(objectsender,EventArgse)

{

frm_notePadfrmn=newfrm_notePad();

frmn.Show();

}

(2)文本编辑器按键出发的实现:

(3)窗体的初始化:

privatevoidfrm_notePad_Load(objectsender,System.EventArgse)//窗体加载时的初始化属性

{

//this.txt_notePad.Dock=DockStyle.Fill;

this.txt_notePad.WordWrap=true;

this.txt_notePad.ScrollBars=ScrollBars.Both;

this.txt_notePad.SelectedText="

"

;

this.stat_LnColShow.Visible=false;

stat_LnColShow_Resize(this,e);

this.open_FileName="

this.mnu_formatLineWrap.Checked=true;

//是否打钩

this.mnu_viewStateBar.Checked=false;

this.sfdlg.OverwritePrompt=true;

this.ofdlg.CheckFileExists=true;

this.ofdlg.CheckPathExists=true;

this.fontDlg.ShowColor=true;

this.fontDlg.ShowEffects=true;

this.mnu_editCut.Enabled=false;

//是否可选择(灰色还是黑色)

this.mnu_editCopy.Enabled=false;

this.mnu_editDelete.Enabled=false;

}

(4)开始选项的实现:

●新建:

privatevoidmnu_fileNew_Click(objectsender,System.EventArgse)

if(this.open_FileName!

="

{

StreamReadersr=newStreamReader(this.open_FileName);

//读入流

if(this.txt_notePad.Text==sr.ReadToEnd())this.txt_notePad.Clear();

//

else

{

DialogResultdlgResult=MessageBox.Show("

文件"

+this.open_FileName+"

的文字已经改变。

\r\n想保存文件吗?

"

记事本"

MessageBoxButtons.YesNoCancel,MessageBoxIcon.Warning);

if(dlgResult==DialogResult.Yes)

{

sr.Close();

mnu_fileSave_Click(this,e);

this.txt_notePad.Clear();

//清空当前文本文字

this.open_FileName="

}

if(dlgResult==DialogResult.No)

}

}

else

if(this.txt_notePad.Text!

文件无标题.txt的文字已经改变。

if(dlgResult==DialogResult.Yes)

mnu_fileSaveAs_Click(this,e);

if(this.dlg_result==DialogResult.OK)this.txt_notePad.Clear();

if(dlgResult==DialogResult.No)this.txt_notePad.Clear();

●打开:

privatevoidmnu_fileOpen_Click(objectsender,System.EventArgse)

this.ofdlg.InitialDirectory=@"

C:

\DocumentsandSettings\huahua\MyDocuments"

this.ofdlg.Filter="

文本文档(*.txt)|*.txt|所有文件|*.*"

this.ofdlg.FilterIndex=1;

if(this.ofdlg.ShowDialog()==DialogResult.OK)

StreamReadersr=newStreamReader(this.ofdlg.FileName);

this.txt_notePad.Text=sr.ReadToEnd();

sr.Close();

this.open_FileName=this.ofdlg.FileName;

●保存:

privatevoidmnu_fileSave_Click(objectsender,System.EventArgse)

stringfileName;

FileStreamfs=null;

if(this.open_FileName!

="

)fileName=this.open_FileName;

elsefileName=@"

\DocumentsandSettings\huahua\MyDocuments\无标题.txt"

try

fs=newFileStream(fileName,FileMode.Open);

UTF8Encodingtemp=newUTF8Encoding(true);

byte[]b=temp.GetBytes(this.txt_notePad.Text);

fs.Write(b,0,b.Length);

fs.Close();

catch

●另存为:

privatevoidmnu_fileSaveAs_Click(objectsender,System.EventArgse)

this.sfdlg.InitialDirectory=@"

\DocumentsandSettings\xiaojing\MyDocuments"

//获取或设置文件对话框显示的初始目录

this.sfdlg.Filter="

this.sfdlg.FilterIndex=1;

this.sfdlg.FileName="

无标题.txt"

this.dlg_result=this.sfdlg.ShowDialog();

if(this.dlg_result==DialogResult.OK)

StreamWritersw=newStreamWriter(this.sfdlg.FileName);

//从内存中写入到文件中

sw.Write(this.txt_notePad.Text);

sw.Close();

//关闭这个流

●退出:

1、退出主界面:

privatevoidmenuItem1_Click(objectsender,EventArgse)

this.Close();

2、退出程序:

privatevoidfrm_notePad_Closing(objectsender,System.ComponentModel.CancelEventArgse)

mnu_fileExit_Click(this,e);

privatevoidmnu_editCut_Click(objectsender,System.EventArgse)

//Clipbo

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 医药卫生 > 基础医学

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1