diff options
| author | lempamo <[email protected]> | 2017-08-27 15:46:36 -0400 |
|---|---|---|
| committer | GitHub <[email protected]> | 2017-08-27 15:46:36 -0400 |
| commit | d2006a3cf629c0ac4ec020778604ae490b4981ec (patch) | |
| tree | 6306b7fdc0dbe4b42e27296d5d74e5787fbc8146 /Histacom2/GlobalPrograms/WinClassicNotepad.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/GlobalPrograms/WinClassicNotepad.cs')
| -rw-r--r-- | Histacom2/GlobalPrograms/WinClassicNotepad.cs | 34 |
1 files changed, 26 insertions, 8 deletions
diff --git a/Histacom2/GlobalPrograms/WinClassicNotepad.cs b/Histacom2/GlobalPrograms/WinClassicNotepad.cs index 0ed0bb7..e1a4019 100644 --- a/Histacom2/GlobalPrograms/WinClassicNotepad.cs +++ b/Histacom2/GlobalPrograms/WinClassicNotepad.cs @@ -15,6 +15,7 @@ namespace Histacom2.OS.Win95.Win95Apps { public partial class WinClassicNotepad : UserControl { + public string CurrentFilePath = ""; public WinClassicNotepad() { InitializeComponent(); @@ -84,10 +85,9 @@ namespace Histacom2.OS.Win95.Win95Apps { try { - ActivateSaveFileDialog(".txt"); + ActivateOpenFileDialog(".txt"); string selectedPath = Program.OpenFileExplorerAsDialogAndReturnGivenPath(); - MessageBox.Show(selectedPath); if (selectedPath != "") { mainText.Text = ReadTextFile(selectedPath); @@ -100,19 +100,37 @@ namespace Histacom2.OS.Win95.Win95Apps private void saveToolStripMenuItem_Click(object sender, EventArgs e) { + if (CurrentFilePath == "") + { + // We aren't in a file right now + + SaveAs(); + } else { + + File.Delete(CurrentFilePath); + SaveSystem.CreateWindowsFile(new FileInfo(CurrentFilePath).Directory.FullName, CurrentFilePath.Split('\\').Last(), mainText.Text, 12, mainText.Text.Length); + } + } + + void SaveAs() + { try { ActivateSaveFileDialog(".txt"); string selectedPath = Program.OpenFileExplorerAsDialogAndReturnGivenPath(); - List<string> pathList = selectedPath.Split('\\').ToList(); - pathList.RemoveAt(selectedPath.Split('\\').Count() - 1); if (selectedPath != "") { - SaveSystem.CreateWindowsFile(pathList.ToString(), selectedPath.Split('\\').Last(), mainText.Text, 12, mainText.Text.Length); - } - } catch { - } + SaveSystem.CreateWindowsFile(new FileInfo(selectedPath).Directory.FullName, selectedPath.Split('\\').Last(), mainText.Text, 12, mainText.Text.Length); + CurrentFilePath = selectedPath; + } + } + catch { } + } + + private void saveAsToolStripMenuItem_Click(object sender, EventArgs e) + { + SaveAs(); } } } |
