public MainForm(LastFileHandler lfh, CrashReporting.CrashReporter crashReporter, Bootstrapper bootstrapper) { Eto.Serialization.Xaml.XamlReader.Load(this); Icon = new Icon(this.GetResource("Resources.programm.ico")); this.lfh = lfh; Bootstrapper = bootstrapper; CrashReporter = crashReporter; lfh.LastFilesUpdates += UpdateLastFilesMenu; UpdateLastFilesMenu(null, null); Bootstrapper.Logger.AttachLogger(logTextBox); Bootstrapper.InitializeUi(this); Bootstrapper.FileStateChanged += FileStateChanged; Bootstrapper.FileHandler.AsyncOperationStateChanged += FileHandlerOnAsyncOperationStateChanged; this.AddSizeStateHandler(); }
public Bootstrapper(LastFileHandler lfh) { timetableBackup = new Dictionary <object, Timetable>(); var configPath = Path.Combine(PathManager.Instance.SettingsDirectory, "fpledit.conf"); #pragma warning disable CA2000 settings = new Settings(GetConfigStream(configPath)); #pragma warning restore CA2000 var lang = settings.Get("lang", "de-DE"); T.SetLocale(Path.Combine(PathManager.Instance.AppDirectory, "Languages"), lang); registry = new RegisterStore(); Update = new UpdateManager(settings); undo = new UndoManager(); ExtensionManager = new ExtensionManager(this); FileHandler = new FileHandler(this, lfh, undo); FileHandler.FileOpened += (o, args) => FileOpened?.Invoke(o, args); FileHandler.FileStateChanged += (o, args) => FileStateChanged?.Invoke(o, args); }
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); }