Files
UseCase_Designer/UseCases/Program.cs
2018-02-21 09:40:31 +01:00

58 lines
2.0 KiB
C#

using System;
using System.IO;
using System.Runtime.InteropServices;
using System.Windows.Forms;
using Newtonsoft.Json;
namespace UseCases
{
static class Program
{
[DllImport("kernel32")]
static extern bool AllocConsole();
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
var frm = new FrmMain();
try
{
Application.Run(frm);
}
catch (Exception ex)
{
if(MessageBox.Show(
@"Fatal error occured and the application cannot continue
A memmory dump will be generated to minimize lost data
Nerds may check console for the exception, press yes to show console"
, @"Error occured, show console?", MessageBoxButtons.YesNo) ==
DialogResult.Yes) AllocConsole();
Console.Error.WriteLine(ex.ToString());
Console.WriteLine(ex.ToString());
var tosave = JsonConvert.SerializeObject(frm.Diagram, Utils.SerializerSettings);
//dump know data before exiting, may contain errors
// var saveObj = new JObject
// {
// {"version", 2},
// {"actors", JToken.FromObject(frm.actors)},
// {"useCases", JToken.FromObject(frm.useCases)},
// {"size", JToken.FromObject(frm.Size)},
// {"maximized",JToken.FromObject(frm.WindowState==FormWindowState.Maximized)}
// };
//dump to file
File.WriteAllText(Application.StartupPath+"\\DUMP-"+DateTime.Now.ToString().Replace(':','.')+".ucd",tosave);
Console.ReadLine();
throw;
}
}
}
}