mirror of
https://github.com/abrendan/smolEdit.git
synced 2025-08-25 22:12:03 +02:00
Projektdateien hinzufügen.
This commit is contained in:
71
V_EditorPro/MainForm.cs
Normal file
71
V_EditorPro/MainForm.cs
Normal file
@@ -0,0 +1,71 @@
|
||||
using System;
|
||||
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);
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user