Histacom2/Histacom2.Engine/FileDialogBoxManager.cs

56 lines
1.6 KiB
C#
Raw Normal View History

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
{
public static class FileDialogBoxManager
{
public static bool IsInOpenDialog = false;
public static bool IsInSaveDialog = false;
public static string OnlyViewExtension = "";
2017-08-18 09:56:56 -04:00
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 "";
}
}
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);
}
}
}