记事本源码



源码:


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 NotepadProgram
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }


        List<string> listPath = new List<string>();


        private void btnShowHidden_Click(object sender, EventArgs e)
        {
            this.panel1.Visible = false;
        }


        private void Form1_Load(object sender, EventArgs e)
        {
            this.panel1.Visible = false;
            this.txtContent.WordWrap = false;
        }


        private void menuHidden_Click(object sender, EventArgs e)
        {
            this.panel1.Visible = false;
        }


        private void menuOpen_Click(object sender, EventArgs e)
        {
            OpenFileDialog ofd = new OpenFileDialog();
            ofd.Title = "请选择要打开的文件...";
            ofd.InitialDirectory = @"C:\Users\Administrator\Desktop";
            ofd.Filter = "文本文件|*.txt|所有文件|*.*";
            ofd.ShowDialog();


            string path = ofd.FileName;
            listPath.Add(path);


            if (path == "")
            {
                return;
            }


            using (FileStream fsRead = new FileStream(path, FileMode.OpenOrCreate, FileAccess.Read))
            {
                byte[] buffer = new byte[1024 * 1024 * 5];
                int r = fsRead.Read(buffer, 0, buffer.Length);
                this.txtContent.Text = Encoding.Default.GetString(buffer, 0, r);
            }
        }


        private void menuSave_Click(object sender, EventArgs e)
        {
            SaveFileDialog sfd = new SaveFileDialog();
            sfd.Title = "请选择保存的路径";
            sfd.Filter = "文本文件|*.txt|所有文件|*.*";
            sfd.InitialDirectory = @"C:\Users\Administrator\Desktop";
            sfd.ShowDialog();
            string path = sfd.FileName;
            if (path == "")
            {
                return;
            }


            using (FileStream fsWrite = new FileStream(path, FileMode.OpenOrCreate, FileAccess.Write))
            {
                byte[] buffer = Encoding.Default.GetBytes(this.txtContent.Text);
                fsWrite.Write(buffer, 0, buffer.Length);
            }
            MessageBox.Show("保存成功!");
        }


        private void menuFont_Click(object sender, EventArgs e)
        {
            FontDialog fd = new FontDialog();
            fd.ShowDialog();
            this.txtContent.Font = fd.Font;
        }


        private void menuColor_Click(object sender, EventArgs e)
        {
            ColorDialog cd = new ColorDialog();
            cd.ShowDialog();
            this.txtContent.ForeColor = cd.Color;
        }


        private void menuWordWrap_Click(object sender, EventArgs e)
        {
            if (menuWordWrap.Text == "☆自动换行")
            {
                this.menuWordWrap.Text = "★取消自动换行";
                this.txtContent.WordWrap = true;
            }
            else if (menuWordWrap.Text == "★取消自动换行")
            {
                this.menuWordWrap.Text = "☆自动换行";
                this.txtContent.WordWrap = false;
            }
        }


        private void menuShow_Click(object sender, EventArgs e)
        {
            LoadHistory();
        }


        /// <summary>
        /// 加载已经打开的历史记录
        /// </summary>
        public void LoadHistory()
        {
            listBox1.Items.Clear();
            this.panel1.Visible = true;
            for (int i = 0; i < listPath.Count; i++)
            {
                listBox1.Items.Add(listPath[i]);
            }
        }


        private void listBox1_DoubleClick(object sender, EventArgs e)
        {
            string filepath = listPath[listBox1.SelectedIndex];
            if (filepath == "")
            {
                return;
            }
            using (FileStream fsRead = new FileStream(filepath, FileMode.OpenOrCreate, FileAccess.Read))
            {
                byte[] buffer = new byte[1024 * 1024 * 5];
                int r = fsRead.Read(buffer, 0, buffer.Length);
                this.txtContent.Text = Encoding.Default.GetString(buffer, 0, r);
            }
        }
    }
}

记事本资讯网站源码简介 记事本资讯网站源码采用织梦discuz基于php mysql制作,功能是毋庸置疑的,强大至极。源码完整无错,本站修复源码的大量模板错位问题,现已完美分享,需要的朋友请拿走! 记事本资讯网站源码安装教程: 一、将整站解压后,将文件夹内的所有文件上传到网站根目录(西部数码的根目录是:wwwroot,不同网站的根目录名称不同,请咨询空间提供商,不要来问我) 注意:如果您的空间支持在线解压的话,建议您直接将压缩文件上传解压,因为这样速度会很快,也很少会出错。 二、打开浏览器,在地址栏里输入http://网址/install/index.php 点击安装 至此Discuz x3.x程序安装完成。 三、登录Discuz后台(http://域名/admin.php) 选择 "站长—数据库—恢复—导入" 或者 http://您的域名/data/restore.php 四、检查UCenter能否登陆 1、检查UCenter 访问地址设置是否正确(一般不会出错) 2、创始人密码和admin管理员密码有可能不是同一个,创始人密码是上面第二步重新安装discuz程序时设置的密码。 3、检查UCenter应用是否通讯成功 五、在后台:工具 更新缓存 完毕。 六、恢复完的后台 管理员帐号:admin 密码:1 如果不清楚可以下载后看里面具体的安装教程 记事本资讯网站源码前台页面 记事本资讯网站源码后台管理 后台路径:http://域名/admin.php 用户名与密码:安装时可设置 后台页面 相关阅读 同类推荐:站长常用源码
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值