Beispiel #1
0
        private static void Main(string[] args)
        {
            Application.ThreadException += (s, e) => UnhandledException(e.Exception);
            AppDomain.CurrentDomain.UnhandledException += (s, e) => UnhandledException((Exception)e.ExceptionObject);
            var fileName = string.Empty;

#if NETCORE
            Application.SetHighDpiMode(HighDpiMode.SystemAware);
#endif
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            Logger.Debug("Application started {@args}", args);

            // read the command line parameter
            if (args.Length == 1)
            {
                fileName = args[0];
            }

            // in case we have multiple arguments assume the path was split at space
            else if (args.Length > 1)
            {
                fileName = args.Join(" ");
            }

            var m_ViewSettings = ViewSettingHelper.LoadViewSettings();
            FunctionalDI.SignalBackground = Application.DoEvents;

            var frm = new FormMain(m_ViewSettings);
            frm.Show();
#pragma warning disable 4014
            if (string.IsNullOrEmpty(fileName))
            {
                frm.SelectFile("No startup file provided");
            }
            else if (!FileSystemUtils.FileExists(fileName))
            {
                frm.SelectFile($"File '{fileName}' not found");
            }
            else
            {
                frm.LoadCsvFile(FileSystemUtils.GetFullPath(fileName));
            }
#pragma warning restore 4014
            Application.Run(frm);
        }