internal SettingsWindow(ProgramSettings settings) { InitializeComponent(); CommandBindings.Add(new CommandBinding(ApplicationCommands.Close, (sender, e) => Close())); LoadTabs(settings); }
public ProgramSettingsCommandProvider(ProgramSettings programSettings, CompositionContainer compositionContainer) { this.programSettings = programSettings; this.compositionContainer = compositionContainer; Recompose(); this.compositionContainer.ExportsChanged += Recompose; }
private void LoadTabs(ProgramSettings settings) { var commandProvider = settings.CommandProvider; Resources["commandProvider"] = commandProvider; AddTab( new DefaultCommandsEditor(commandProvider, settings.FeatureRegistry, settings.DefaultCommands), "Defaults" ); foreach (var plugin in settings.Plugins) { var editor = plugin.GetEditor(commandProvider); if (editor == null) { continue; } AddTab(editor, plugin.Name); } }
private void Load() { var commandRunner = new CommandRunner(); Log.Info("Loading extension manager"); this.extensionManager = new ExtensionManager(Directory.CreateDirectory(Path.Combine(Directory.GetCurrentDirectory(), "Extensions"))); Log.Info("Loading application settings"); this.applicationSettings = new ApplicationSettings(new ProgramSettingsDataSerializer(this.extensionManager)); ProgramSettingsData settingsData = null; try { settingsData = this.applicationSettings.LoadSettingsData(); } catch (SerializationException e) { Log.Warn("Loading settings failed", e); if (this.guiMode) { MessageBox.Show( "An error occurred loading your NoCap settings. Settings will be restored to their defaults.", "Error loading settings", MessageBoxButton.OK, MessageBoxImage.Exclamation ); } } bool loadCommandDefaults = false; if (settingsData == null) { Log.Debug("Application settings not found; using defaults"); settingsData = new ProgramSettingsData(); loadCommandDefaults = true; } this.settings = ProgramSettings.Create(settingsData, commandRunner, this.extensionManager); var featureRegistry = this.settings.FeatureRegistry; // TODO Move elsewhere featureRegistry.Register(CommandFeatures.ImageUploader, "Image uploader"); featureRegistry.Register(CommandFeatures.UrlShortener, "Url shortener" ); featureRegistry.Register(CommandFeatures.FileUploader, "File uploader" ); featureRegistry.Register(CommandFeatures.TextUploader, "Text uploader" ); if (loadCommandDefaults) { this.settings.LoadCommandDefaults(); } }
public static ProgramSettings Create(ProgramSettingsData settingsData, CommandRunner commandRunner, ExtensionManager extensionManager) { var settings = new ProgramSettings(settingsData); settings.Initialize(commandRunner, extensionManager); return settings; }