private void _ReportException(object sender, Exception exc)
        {
            string msg = "Catched an unhandled exception raised from: " + sender.ToString();

            _logger.Error(msg, exc);

            // Try to close splash
            bool has_splash = Splashscreen.IsSplashAvail;

            try
            {
                if (has_splash)
                {
                    Splashscreen.HideSplash();
                }
            }
            catch { }

            // Not sure which state we're in, so better be careful with creating this dialog
            try
            {
                Dialogs.ErrorReportingDialog.Show(msg, exc);
                return;
            }
            catch { }

            // So showing error reporting dialog didn't work, uhhh ... last report: traditional message box
            msg += string.Format("\n\nThe latest log file located at\n\n{0}\n\nmight contain further details on its cause.\n", Settings.LOGPATH);
            MessageBox.Show(msg, "Fatal error occured", MessageBoxButton.OK, MessageBoxImage.Error);
        }
        private void _ShutdownErrorReporting()
        {
            // Remove event handlers first!
            AppDomain.CurrentDomain.UnhandledException -= _AppDomainUnhandledException;
            DispatcherUnhandledException          -= _DispatcherUnhandledException;
            TaskScheduler.UnobservedTaskException -= _TaskSchedulerUnobservedTaskException;

            if (_uploader != null)
            {
                if (_uploader.HasPendingWork)
                {
                    Splashscreen.ShowSplash("Waiting for uploader to finish ...");

                    string msg = "";
                    while (_uploader.HasPendingWork)
                    {
                        msg += ".";
                        Splashscreen.SetMessage(msg);
                        Thread.Sleep(250);
                    }

                    Splashscreen.HideSplash();
                }

                _uploader.Close();
            }
            _uploader = null;
        }
        protected void _Init()
        {
            Splashscreen.SetMessage("Creating main window");

            // Load options
            // - Position window
            if (Config.Root.HasSection("window"))
            {
                if (Config.Root.window.HasItem("state") &&
                    Config.Root.window.state == WindowState.Maximized.ToString())
                {
                    WindowState = WindowState.Maximized;
                }
                else
                {
                    if (Config.Root.window.HasItem("pos_x") && Config.Root.window.pos_x != -1)
                    {
                        Left   = Config.Root.window.pos_x;
                        Top    = Config.Root.window.pos_y;
                        Width  = Config.Root.window.size_x;
                        Height = Config.Root.window.size_y;
                    }
                    else
                    {
                        WindowStartupLocation = WindowStartupLocation.CenterScreen;
                    }
                }

                // - Position splitter
                if (Config.Root.window.HasItem("splitter"))
                {
                    if (Config.Root.window.splitter != -1)
                    {
                        MainGrid.ColumnDefinitions[0].Width = new GridLength(Config.Root.window.splitter);
                    }
                }
            }

#if !DEVENV
            if (Config.Root.HasSection("update_check") &&
                Config.Root.update_check.HasItem("check_for_updates") &&
                Config.Root.update_check.check_for_updates)
            {
                Splashscreen.SetMessage("Checking for updates");
                _RunUpdateChecker(true);
            }
#endif

            _SetupMRU();

            Splashscreen.SetMessage("Registering plugins");
            ActionFactory.AddToMenu(actions_menu, Actions_Click);

            _SetStatusbar();

            Details.Modified += Details_Modified;

            // Finally, update menu states
            _UpdateUIState();

            // Close splash
            Splashscreen.HideSplash();
        }