• 大小: 4.56 MB
    文件类型: .rar
    金币: 1
    下载: 0 次
    发布日期: 2024-12-30
  • 语言: 其他
  • 标签: .net  写字板  

资源简介

1. 利用Windows Forms控件编制写字板;
2. 可以利用该软件进行文字的录入;
3. 可以对选中文字进行“加粗”、“倾斜”和“加下划线”处理;
4. 可以将录入信息存储在默认文件中;
5. 可以读取默认文件信息,如果该文件不存在则发出警告;
6. 使用C#语言,代码符合编码规范。
不好请要不下载

资源截图

代码片段和文件信息

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using  System.IO;
using System.Web;

namespace xieziban._
{
    public partial class Form1 : Form
    {
        string openFileName = String.Empty;
        string initialDir = Environment.CurrentDirectory + “C:“;
        public Form1()
        {
            InitializeComponent();
            fontsToolStripComboBox.SelectedIndex = 0;
        }

        private void fontsToolStripComboBox_SelectedIndexChanged(object sender EventArgs e)
        {
            string text = ((ToolStripComboBox)sender).SelectedItem.ToString();

            Font newFont = new Font(text richTextBoxText.SelectionFont.Size
                richTextBoxText.SelectionFont.style);
            richTextBoxText.SelectionFont = newFont;
        }
        private void newToolStripMenuItem_Click(object sender EventArgs e)
        {
            richTextBoxText.Text = ““;
        }

        private void openToolStripMenuItem_Click(object sender EventArgs e)
        {
            Stream myStream;
            OpenFileDialog openFileDialog1 = new OpenFileDialog();
            openFileDialog1.InitialDirectory = “c:\\“;
            openFileDialog1.Filter = “RTF文档|*.rtf|纯文本文档|*.txt|All Files|*.*“; 
            openFileDialog1.FilterIndex = 2;
            openFileDialog1.RestoreDirectory = true;

            if (openFileDialog1.ShowDialog() == DialogResult.OK)
            {
                try
                {
                    if (Path.GetExtension(openFileDialog1.FileName).ToLower() == “.rtf“)
                        richTextBoxText.LoadFile(openFileDialog1.FileName RichTextBoxStreamType.RichText);
                    else
                        richTextBoxText.LoadFile(openFileDialog1.FileName RichTextBoxStreamType.PlainText);
                    openFileName = openFileDialog1.FileName;

                }
                catch
                { }
            }
        }
        private void saveToolStripMenuItem_Click(object sender EventArgs e)
        {
            //try
            //{
            //    richTextBoxText.SaveFile(@“.Example.rtf“);
            //}
            //catch
            //{

            //}
            if (openFileName == String.Empty)
            {
                SaveFileDialog saveFileDialog = new SaveFileDialog();
                saveFileDialog.Filter = “*.rtf|*.rtf|*.txt|*.txt|All Files(*.*)|*.*“;
                saveFileDialog.InitialDirectory = initialDir;
                saveFileDialog.RestoreDirectory = true;
                saveFileDialog.FilterIndex = 2;
                if (saveFileDialog.ShowDialog() == DialogResult.OK)
                {
                    if (Path.GetExtension(saveFileDialog.FileName).ToLower() == “.rtf“)
                        richTextBoxText.SaveFile(saveFileDialog.FileName RichT

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----

     文件      14960  2009-05-10 19:54  写字板\xieziban.1\Form1.cs

     文件      30817  2009-05-10 19:27  写字板\xieziban.1\Form1.Designer.cs

     文件    6747632  2009-05-10 19:27  写字板\xieziban.1\Form1.resx

     文件        290  2009-05-10 19:51  写字板\xieziban.1\obj\xieziban.1.csproj.FileList.txt

     文件        469  2009-05-07 21:39  写字板\xieziban.1\Program.cs

     文件       1168  2009-05-07 21:39  写字板\xieziban.1\Properties\AssemblyInfo.cs

     文件       2885  2009-05-07 21:39  写字板\xieziban.1\Properties\Resources.Designer.cs

     文件       5612  2009-05-07 21:39  写字板\xieziban.1\Properties\Resources.resx

     文件       1111  2009-05-07 21:39  写字板\xieziban.1\Properties\Settings.Designer.cs

     文件        249  2009-05-07 21:39  写字板\xieziban.1\Properties\Settings.settings

     文件       3265  2009-05-07 21:46  写字板\xieziban.1\xieziban.1.csproj

     文件        919  2009-05-07 21:39  写字板\xieziban.1.sln

    ..A..H.     17920  2009-05-10 19:54  写字板\xieziban.1.suo

     目录          0  2009-07-26 21:47  写字板\xieziban.1\bin

     目录          0  2009-07-26 21:47  写字板\xieziban.1\obj

     目录          0  2009-07-26 21:47  写字板\xieziban.1\Properties

     目录          0  2009-07-26 21:47  写字板\xieziban.1

     目录          0  2009-07-26 21:47  写字板

----------- ---------  ---------- -----  ----

              6827297                    18


评论

共有 条评论