aboutsummaryrefslogtreecommitdiff
path: root/Histacom2.Engine/FileDialogBoxManager.cs
diff options
context:
space:
mode:
authorAlex-TIMEHACK <[email protected]>2017-08-27 11:32:44 +0100
committerAlex-TIMEHACK <[email protected]>2017-08-27 11:32:44 +0100
commitf8f3bd0b1eb57c5a289513200b192e1d54d58292 (patch)
treec9b79515fb81d90320ef386a522a5830875f6d49 /Histacom2.Engine/FileDialogBoxManager.cs
parentbffcb720f811623015ed4795032e5c57d1064c8a (diff)
parentcd6273d7c95098e0e0dd9948c6b5cec1c5f9cd3f (diff)
downloadhistacom2-f8f3bd0b1eb57c5a289513200b192e1d54d58292.tar.gz
histacom2-f8f3bd0b1eb57c5a289513200b192e1d54d58292.tar.bz2
histacom2-f8f3bd0b1eb57c5a289513200b192e1d54d58292.zip
Updated my fork!
Diffstat (limited to 'Histacom2.Engine/FileDialogBoxManager.cs')
-rw-r--r--Histacom2.Engine/FileDialogBoxManager.cs55
1 files changed, 55 insertions, 0 deletions
diff --git a/Histacom2.Engine/FileDialogBoxManager.cs b/Histacom2.Engine/FileDialogBoxManager.cs
new file mode 100644
index 0000000..c3a2372
--- /dev/null
+++ b/Histacom2.Engine/FileDialogBoxManager.cs
@@ -0,0 +1,55 @@
+using System;
+using System.Collections.Generic;
+using System.IO;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows.Forms;
+
+namespace Histacom2.Engine
+{
+ public static class FileDialogBoxManager
+ {
+ public static bool IsInOpenDialog = false;
+ public static bool IsInSaveDialog = false;
+ public static string OnlyViewExtension = "";
+
+ public static void ActivateOpenFileDialog(string ExtensionToView)
+ {
+ IsInOpenDialog = true;
+ IsInSaveDialog = false;
+ OnlyViewExtension = ExtensionToView;
+ }
+
+ public static void ActivateSaveFileDialog(string ExtensionToView)
+ {
+ IsInOpenDialog = false;
+ IsInSaveDialog = true;
+ OnlyViewExtension = ExtensionToView;
+ }
+
+ public static string ReadTextFile(string path)
+ {
+ try
+ {
+ return File.ReadAllText(path);
+ } catch {
+ return "";
+ }
+ }
+
+ public static void SaveRtfDocument(RichTextBox tbox, string path)
+ {
+ int fileBytes = 0;
+ tbox.SaveFile(path);
+ fileBytes = File.ReadAllText(path).Length;
+
+ THFileInfo info = new THFileInfo();
+ info.Name = Path.GetFileName(path);
+ info.FileIcon = 17;
+ info.ByteSize = fileBytes;
+ SaveSystem.CurrentSave.BytesLeft -= fileBytes;
+ SaveSystem.UpdateDirectoryInfo(new FileInfo(path).Directory.FullName, info);
+ }
+ }
+}