Exemplo n.º 1
0
        private void Init()
        {
            Timetable.DefaultLinearVersion = Settings.GetEnum("core.default-file-format", Timetable.DefaultLinearVersion);
            FontCollection.InitAsync();     // Asynchron Liste von verfügbaren Schriftarten laden
            EtoExtensions.Initialize(this); // UI-Erweiterungen initialiseren
            this.AddSizeStateHandler();

            // Extensions laden & initialisieren (=> Initialisiert Importer/Exporter)
            extensionManager.LoadExtensions();
            extensionManager.InitActivatedExtensions();

            InitializeExportImport();
            InitializeMenus();

            // Vorlagen laden
            templatePath    = Settings.Get("tmpl.root", templatePath);
            templateManager = new TemplateManager(registry, Logger, Settings);
            templateManager.LoadTemplates(templatePath);
            if (OptionsParser.TemplateDebug)
            {
                Task.Run(() => Application.Instance.Invoke(() => templateManager.DebugCompileAll()));
            }

            ExtensionsLoaded?.Invoke(this, new EventArgs());

            Shown += (s, e) => LoadStartFile();
            Shown += (s, e) => update.AutoUpdateCheck(Logger);

            checkRunner = new TimetableChecks.TimetableCheckRunner(this); // CheckRunner initialisieren

            // Hatten wir einen Crash beim letzten Mal?
            if (crashReporter.HasCurrentReport)
            {
                Shown += (s, e) =>
                {
                    try
                    {
                        var cf = new CrashReporting.CrashForm(crashReporter);
                        if (cf.ShowModal(this) == DialogResult.Ok)
                        {
                            crashReporter.Restore(fileHandler);
                        }
                        crashReporter.RemoveCrashFlag();
                    }
                    catch (Exception ex)
                    {
                        Logger.Error("Fehlermeldung des letzten Absturzes konnte nicht angezeigt werden: " + ex.Message);
                        crashReporter.RemoveCrashFlag(); // Der Crash crasht sogar noch die Fehlerbehandlung...
                    }
                };
            }
        }
Exemplo n.º 2
0
        private static (LastFileHandler, Bootstrapper) InitializeMainComponents()
        {
            var lfh = new LastFileHandler();

            // Bootstrap the first main components
            var bootstrapper = new Bootstrapper(lfh);

            // Initialize CrashReporter, so it can be used early
            crashReporter = new CrashReporter(bootstrapper);

            // Wire up missin pieces in file handling
            lfh.Initialize(bootstrapper);

            // Initailize some loosely coupled UI components, so that extensions can use them
            EtoExtensions.Initialize(bootstrapper);                                   // Initialize Eto extensions
            FontCollection.InitAsync();                                               // Load list of available fonts, async, as this should not be needed by any extension.
#pragma warning disable CA2000
            TemplateDebugger.GetInstance().AttachDebugger(new GuiTemplateDebugger()); // Attach javascript debugger form
#pragma warning restore CA2000

            // Reset default file format versions on first run.
            var lastRunVersion = bootstrapper.FullSettings.Get <string>("updater.lastrun-version");
            if (!string.IsNullOrEmpty(lastRunVersion) && lastRunVersion != VersionInformation.Current.DisplayVersion)
            {
                bootstrapper.FullSettings.SetEnum("core.default-network-file-format", Timetable.PRESET_NETWORK_VERSION);
                bootstrapper.FullSettings.SetEnum("core.default-file-format", Timetable.PRESET_LINEAR_VERSION);
                bootstrapper.PreBootstrapWarnings.Add(T._("Die Standard-Dateiformatversionen wurden zurückgesetzt, da Sie die Version von FPLedit aktualisiert haben. Diese Einstellung kann unter Einstellungen > Dateiversionen geändert werden."));
            }
            bootstrapper.FullSettings.Set("updater.lastrun-version", VersionInformation.Current.DisplayVersion);

            // Load default versions for new timetable files from config.
            var linearDefaultVersion = bootstrapper.FullSettings.GetEnum("core.default-file-format", Timetable.DefaultLinearVersion);
            var linCompat            = linearDefaultVersion.GetVersionCompat();
            if (linCompat.Compatibility == TtVersionCompatType.ReadWrite && linCompat.Type == TimetableType.Linear)
            {
                Timetable.DefaultLinearVersion = linearDefaultVersion;
            }
            else
            {
                bootstrapper.PreBootstrapWarnings.Add(T._("Gewählte lineare Standardversion ist nicht R/W-kompatibel!"));
            }

            var networkDefaultVersion = bootstrapper.FullSettings.GetEnum("core.default-network-file-format", Timetable.DefaultNetworkVersion);
            var netCompat             = networkDefaultVersion.GetVersionCompat();
            if (netCompat.Compatibility == TtVersionCompatType.ReadWrite && netCompat.Type == TimetableType.Network)
            {
                Timetable.DefaultNetworkVersion = networkDefaultVersion;
            }
            else
            {
                bootstrapper.PreBootstrapWarnings.Add(T._("Gewählte Netzwerk-Standardversion ist nicht R/W-kompatibel!"));
            }

            // Load logger before extensions
            var logger = new MultipleLogger();
            if (bootstrapper.FullSettings.Get("log.enable-file", false))
            {
                logger.AttachLogger(new TempLogger(bootstrapper));
            }
            if (OptionsParser.ConsoleLog)
            {
                logger.AttachLogger(new ConsoleLogger());
            }
            bootstrapper.InjectLogger(logger);

            // Output some version stats
            bootstrapper.Logger.Debug("Current version: " + VersionInformation.Current.DisplayVersion);
            bootstrapper.Logger.Debug("Runtime version: " + VersionInformation.Current.RuntimeVersion);
            bootstrapper.Logger.Debug("OS version: " + VersionInformation.Current.OsVersion);

            // Init feature flags
            FeatureFlags.Initialize(((IReducedPluginInterface)bootstrapper).Settings);

            var restartable = new RestartHandler(bootstrapper);

            // Add default plugins
            bootstrapper.ExtensionManager.InjectPlugin(new CorePlugins.MenuPlugin(), 0);
            bootstrapper.ExtensionManager.InjectPlugin(new Editor.EditorPlugin(), 0);
            bootstrapper.ExtensionManager.InjectPlugin(new CorePlugins.DefaultPlugin(restartable, bootstrapper), 0);

            return(lfh, bootstrapper);
        }