Archived
1
0
This repository has been archived on 2026-03-24. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
SomeLab/CS/lab15/15_5/Form1.cs
2026-03-19 19:39:01 +08:00

59 lines
1.7 KiB
C#

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace _15_5
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void buttonOpen_Click(object sender, EventArgs e)
{
OpenFileDialog ofd = new OpenFileDialog();
ofd.Filter = "文本文件(RTF)|*.rtf";
ofd.FilterIndex = 2;
ofd.RestoreDirectory = true;
if (ofd.ShowDialog() == DialogResult.OK)
richTextBox1.LoadFile(ofd.FileName);
}
private void buttonSave_Click(object sender, EventArgs e)
{
SaveFileDialog sfd = new SaveFileDialog();
sfd.Filter = "文本文件(RTF)|*.rtf";
sfd.FilterIndex = 2;
sfd.RestoreDirectory = true;
if (sfd.ShowDialog() == DialogResult.OK)
richTextBox1.SaveFile(sfd.FileName);
}
private void buttonFonts_Click(object sender, EventArgs e)
{
FontDialog fontDialog = new FontDialog();
fontDialog.ShowDialog();
fontDialog.Font = richTextBox1.SelectionFont;
fontDialog.Color = richTextBox1.SelectionColor;
if (fontDialog.ShowDialog() == DialogResult.OK)
{
richTextBox1.SelectionFont = fontDialog.Font;
richTextBox1.SelectionColor = fontDialog.Color;
}
}
private void buttonExit_Click(object sender, EventArgs e)
{
this.Close();
}
}
}