-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMainWindow.xaml.cs
95 lines (76 loc) · 3.28 KB
/
MainWindow.xaml.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
using MahApps.Metro.Controls;
using Microsoft.Win32;
using System.IO;
using System.Windows;
using System.Windows.Documents;
namespace Notepad
{
public partial class MainWindow : MetroWindow
{
public MainWindow()
{
InitializeComponent();
richtextbox.SetValue(Paragraph.LineHeightProperty, 1.0);
}
private void MenuItem_Click(object sender, RoutedEventArgs e)
{
// Method to save stuff in your text editor
var saveFileDialog = new SaveFileDialog();
saveFileDialog.Filter = "Text Files (*.txt)|*.txt";
if (saveFileDialog.ShowDialog() == true)
{
richtextbox.Save(saveFileDialog.FileName);
}
}
private void MenuItem_Click_1(object sender, RoutedEventArgs e) { /* cut */ richtextbox.Cut(); }
private void MenuItem_Click_2(object sender, RoutedEventArgs e) { /*copy*/ richtextbox.Copy(); }
private void MenuItem_Click_3(object sender, RoutedEventArgs e) { /*paste*/ richtextbox.Paste(); }
private void MenuItem_Click_4(object sender, RoutedEventArgs e) { /* Exit */ Application.Current.Shutdown(); }
private void MenuItem_Click_5(object sender, RoutedEventArgs e)
{ /* open */
var openFileDialog = new OpenFileDialog();
openFileDialog.DefaultExt = "*.*";
openFileDialog.Multiselect = false;
if (openFileDialog.ShowDialog() == true)
{
richtextbox.Text = File.ReadAllText(openFileDialog.FileName);
}
}
private void MenuItem_Click_6(object sender, RoutedEventArgs e)
{ /*AboutMe Notepad*/
var aboutWindow = new MoreAboutUs();
aboutWindow.Show();
}
private void ChangeFont_Click(object sender, RoutedEventArgs e)
{
var changeFontWindow = new ChangeFont();
changeFontWindow.Show();
}
private void CommandBinding_Executed(object sender, System.Windows.Input.ExecutedRoutedEventArgs e) { MenuItem_Click(sender, e); }
private void cSharp_Click(object sender, RoutedEventArgs e)
{
richtextbox.SyntaxHighlighting = ICSharpCode.AvalonEdit.Highlighting.HighlightingManager.Instance.GetDefinition("C#");
}
private void php_Click(object sender, RoutedEventArgs e)
{
richtextbox.SyntaxHighlighting = ICSharpCode.AvalonEdit.Highlighting.HighlightingManager.Instance.GetDefinition("PHP");
}
private void cpp_Click(object sender, RoutedEventArgs e)
{
richtextbox.SyntaxHighlighting = ICSharpCode.AvalonEdit.Highlighting.HighlightingManager.Instance.GetDefinition("C++");
}
private void compileAndRun_Click(object sender, RoutedEventArgs e)
{
var fileSystem = new FileSystem();
fileSystem.SaveAndRun();
}
private void IncreaseFontSize_Click_1(object sender, RoutedEventArgs e)
{
richtextbox.FontSize += 1;
}
private void DecreaseFontSize_Click(object sender, RoutedEventArgs e)
{
richtextbox.FontSize -= 1;
}
}
}