diff options
| author | lempamo <lempamo@users.noreply.github.com> | 2017-08-27 15:46:36 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2017-08-27 15:46:36 -0400 |
| commit | d2006a3cf629c0ac4ec020778604ae490b4981ec (patch) | |
| tree | 6306b7fdc0dbe4b42e27296d5d74e5787fbc8146 /Histacom2/OS/Win95/Win95Apps/WinClassicWordPad.cs | |
| parent | e5f6f8ddc11ac1a17abc98b006ddff5860e0e805 (diff) | |
| parent | 805a238822d3fdca7b75f63e622d93cba421755a (diff) | |
| download | histacom2-d2006a3cf629c0ac4ec020778604ae490b4981ec.tar.gz histacom2-d2006a3cf629c0ac4ec020778604ae490b4981ec.tar.bz2 histacom2-d2006a3cf629c0ac4ec020778604ae490b4981ec.zip | |
Merge pull request #152 from Alex-TIMEHACK/master
Wordpad saves files + Windows Explorer overhawl
Diffstat (limited to 'Histacom2/OS/Win95/Win95Apps/WinClassicWordPad.cs')
| -rw-r--r-- | Histacom2/OS/Win95/Win95Apps/WinClassicWordPad.cs | 110 |
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 |
