aboutsummaryrefslogtreecommitdiff
path: root/Histacom2/GlobalPrograms/WinClassicNotepad.cs
diff options
context:
space:
mode:
authorAShifter <[email protected]>2017-08-29 12:34:00 -0600
committerAShifter <[email protected]>2017-08-29 12:34:00 -0600
commitb1689dea36e46933280bfcc0d186746dd6210c0f (patch)
tree3644ac63218378082e0afa90d4c42d73d6d3980c /Histacom2/GlobalPrograms/WinClassicNotepad.cs
parentf8e657ddbaf3654f102676a0b51e424c005218c3 (diff)
parentd4d94f85a6424e4d21cecccec21b0e78860431d6 (diff)
downloadhistacom2-b1689dea36e46933280bfcc0d186746dd6210c0f.tar.gz
histacom2-b1689dea36e46933280bfcc0d186746dd6210c0f.tar.bz2
histacom2-b1689dea36e46933280bfcc0d186746dd6210c0f.zip
Merge remote-tracking branch 'refs/remotes/Histacom2-Devs/master'
Diffstat (limited to 'Histacom2/GlobalPrograms/WinClassicNotepad.cs')
-rw-r--r--Histacom2/GlobalPrograms/WinClassicNotepad.cs34
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();
}
}
}