aboutsummaryrefslogtreecommitdiff
path: root/Histacom2/OS/Win95/Win95Apps/WinClassicWordPad.cs
diff options
context:
space:
mode:
Diffstat (limited to 'Histacom2/OS/Win95/Win95Apps/WinClassicWordPad.cs')
-rw-r--r--Histacom2/OS/Win95/Win95Apps/WinClassicWordPad.cs110
1 files changed, 110 insertions, 0 deletions
diff --git a/Histacom2/OS/Win95/Win95Apps/WinClassicWordPad.cs b/Histacom2/OS/Win95/Win95Apps/WinClassicWordPad.cs
index f1f5245..91d9368 100644
--- a/Histacom2/OS/Win95/Win95Apps/WinClassicWordPad.cs
+++ b/Histacom2/OS/Win95/Win95Apps/WinClassicWordPad.cs
@@ -8,6 +8,8 @@ using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Drawing.Text;
+using static Histacom2.Engine.FileDialogBoxManager;
+using System.IO;
using Histacom2.Engine;
namespace Histacom2.OS.Win95.Win95Apps
@@ -20,6 +22,8 @@ namespace Histacom2.OS.Win95.Win95Apps
bool doItalic = false;
bool doUnderline = false;
+ public string CurrentFilePath = "";
+
public WinClassicWordPad()
{
InitializeComponent();
@@ -169,5 +173,111 @@ namespace Histacom2.OS.Win95.Win95Apps
if (doUnderline) Underline = FontStyle.Underline;
mainText.SelectionFont = new Font(mainText.SelectionFont.FontFamily, mainText.SelectionFont.Size, Bold | Italic | Underline);
}
+
+ private void openToolStripMenuItem1_Click(object sender, EventArgs e)
+ {
+ try
+ {
+ ActivateOpenFileDialog(".rtf");
+ string selectedPath = Program.OpenFileExplorerAsDialogAndReturnGivenPath();
+
+ if (selectedPath != null)
+ {
+ try
+ {
+ mainText.LoadFile(selectedPath);
+ CurrentFilePath = selectedPath;
+ } catch
+ {
+ (new WindowManager()).StartInfobox95("Wordpad", "An error occured opening the file.", Engine.Template.InfoboxType.Error, Engine.Template.InfoboxButtons.OK);
+ }
+
+ }
+ }
+ catch
+ {
+ }
+ }
+
+ private void saveAsToolStripMenuItem_Click(object sender, EventArgs e)
+ {
+ SaveAs();
+ }
+
+ private void saveToolStripMenuItem_Click(object sender, EventArgs e)
+ {
+ if (CurrentFilePath == "")
+ {
+ // We aren't in a file right now
+
+ SaveAs();
+ }
+ else
+ {
+ File.Delete(CurrentFilePath);
+ SaveRtfDocument(mainText, CurrentFilePath);
+ }
+ }
+
+ void SaveAs()
+ {
+ try
+ {
+ ActivateSaveFileDialog(".rtf");
+ string selectedPath = Program.OpenFileExplorerAsDialogAndReturnGivenPath();
+
+ if (selectedPath != "")
+ {
+ SaveRtfDocument(mainText, selectedPath);
+ CurrentFilePath = selectedPath;
+ }
+ }
+ catch (Exception ex) { MessageBox.Show(ex.Message); }
+ }
+
+ private void btnNew_Click(object sender, EventArgs e)
+ {
+
+ }
+
+ private void btnOpen_Click(object sender, EventArgs e)
+ {
+ try
+ {
+ ActivateOpenFileDialog(".rtf");
+ string selectedPath = Program.OpenFileExplorerAsDialogAndReturnGivenPath();
+
+ if (selectedPath != null)
+ {
+ try
+ {
+ mainText.LoadFile(selectedPath);
+ }
+ catch
+ {
+ (new WindowManager()).StartInfobox95("Wordpad", "An error occured opening the file.", Engine.Template.InfoboxType.Error, Engine.Template.InfoboxButtons.OK);
+ }
+
+ }
+ }
+ catch
+ {
+ }
+ }
+
+ private void btnSave_Click(object sender, EventArgs e)
+ {
+ if (CurrentFilePath == "")
+ {
+ // We aren't in a file right now
+
+ SaveAs();
+ }
+ else
+ {
+ File.Delete(CurrentFilePath);
+ SaveRtfDocument(mainText, CurrentFilePath);
+ }
+ }
}
} \ No newline at end of file