2017-05-24 16:42:48 -04:00
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.IO;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Text;
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
using System.Windows.Forms;
|
|
|
|
|
|
2017-08-23 13:38:40 -04:00
|
|
|
|
namespace Histacom2.Engine
|
2017-05-24 16:42:48 -04:00
|
|
|
|
{
|
|
|
|
|
public static class FileDialogBoxManager
|
|
|
|
|
{
|
2017-07-13 10:46:24 -04:00
|
|
|
|
public static bool IsInOpenDialog = false;
|
|
|
|
|
public static bool IsInSaveDialog = false;
|
|
|
|
|
public static string OnlyViewExtension = "";
|
2017-08-18 09:56:56 -04:00
|
|
|
|
|
2017-07-13 10:46:24 -04:00
|
|
|
|
public static void ActivateOpenFileDialog(string ExtensionToView)
|
2017-05-24 16:42:48 -04:00
|
|
|
|
{
|
|
|
|
|
IsInOpenDialog = true;
|
|
|
|
|
IsInSaveDialog = false;
|
|
|
|
|
OnlyViewExtension = ExtensionToView;
|
|
|
|
|
}
|
|
|
|
|
|
2017-07-13 10:46:24 -04:00
|
|
|
|
public static void ActivateSaveFileDialog(string ExtensionToView)
|
2017-05-24 16:42:48 -04:00
|
|
|
|
{
|
|
|
|
|
IsInOpenDialog = false;
|
|
|
|
|
IsInSaveDialog = true;
|
|
|
|
|
OnlyViewExtension = ExtensionToView;
|
|
|
|
|
}
|
|
|
|
|
|
2017-07-13 10:46:24 -04:00
|
|
|
|
public static string ReadTextFile(string path)
|
2017-05-24 16:42:48 -04:00
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
return File.ReadAllText(path);
|
|
|
|
|
} catch {
|
|
|
|
|
return "";
|
|
|
|
|
}
|
|
|
|
|
}
|
2017-08-18 09:56:56 -04:00
|
|
|
|
|
2017-08-18 15:41:45 -04:00
|
|
|
|
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);
|
2017-08-27 10:48:28 -04:00
|
|
|
|
info.FileIcon = 20;
|
2017-08-18 15:41:45 -04:00
|
|
|
|
info.ByteSize = fileBytes;
|
|
|
|
|
SaveSystem.CurrentSave.BytesLeft -= fileBytes;
|
|
|
|
|
SaveSystem.UpdateDirectoryInfo(new FileInfo(path).Directory.FullName, info);
|
|
|
|
|
}
|
2017-05-24 16:42:48 -04:00
|
|
|
|
}
|
|
|
|
|
}
|