mirror of
https://github.com/abrendan/smolEdit.git
synced 2025-06-16 12:45:02 +02:00
73 lines
2.1 KiB
C#
73 lines
2.1 KiB
C#
using System;
|
|
using System.Drawing;
|
|
using System.IO;
|
|
using System.Runtime.InteropServices;
|
|
using System.Windows.Forms;
|
|
|
|
namespace V_EditorPro
|
|
{
|
|
public partial class MainForm : Form
|
|
{
|
|
public MainForm()
|
|
{
|
|
InitializeComponent();
|
|
this.KeyPreview = true;
|
|
this.KeyDown += new KeyEventHandler(MainForm_KeyDown);
|
|
this.Icon = new Icon("..\\..\\Veditorproicon.ico");
|
|
}
|
|
|
|
private void MainForm_KeyDown(object sender, KeyEventArgs e)
|
|
{
|
|
if (e.Control && e.KeyCode == Keys.O)
|
|
{
|
|
OpenFile();
|
|
}
|
|
if (e.Control && e.KeyCode == Keys.S)
|
|
{
|
|
SaveFile();
|
|
}
|
|
}
|
|
|
|
private void openToolStripMenuItem_Click(object sender, EventArgs e)
|
|
{
|
|
OpenFile();
|
|
}
|
|
|
|
private void saveToolStripMenuItem_Click(object sender, EventArgs e)
|
|
{
|
|
SaveFile();
|
|
}
|
|
|
|
private void searchReplaceToolStripMenuItem_Click(object sender, EventArgs e)
|
|
{
|
|
using (SearchReplaceDialog searchReplaceDialog = new SearchReplaceDialog(richTextBox1))
|
|
{
|
|
searchReplaceDialog.ShowDialog();
|
|
}
|
|
}
|
|
|
|
private void aboutToolStripMenuItem_Click(object sender, EventArgs e)
|
|
{
|
|
MessageBox.Show($"V_EditorPro\nVersion 1.0\nOS: {RuntimeInformation.OSDescription}", "About");
|
|
}
|
|
|
|
private void OpenFile()
|
|
{
|
|
OpenFileDialog openFileDialog = new OpenFileDialog();
|
|
if (openFileDialog.ShowDialog() == DialogResult.OK)
|
|
{
|
|
richTextBox1.Text = File.ReadAllText(openFileDialog.FileName);
|
|
}
|
|
}
|
|
|
|
private void SaveFile()
|
|
{
|
|
SaveFileDialog saveFileDialog = new SaveFileDialog();
|
|
saveFileDialog.FileName = $"{DateTime.Now.ToString("yyyy-MM-dd")}.txt";
|
|
if (saveFileDialog.ShowDialog() == DialogResult.OK)
|
|
{
|
|
File.WriteAllText(saveFileDialog.FileName, richTextBox1.Text);
|
|
}
|
|
}
|
|
}
|
|
} |