protected override void Initialize()
        {
            base.Initialize();

            var mcs = GetService(typeof(IMenuCommandService)) as OleMenuCommandService;

            if (null != mcs)
            {
                // The ToolWindow menu command.
                var toolWindowCommandId = new CommandID(GuidList.guidTwainsoft_StudioStyler_VSPackageCmdSet, CommandIds.ShowStudioStylesId);
                var menuToolWin         = new MenuCommand(OnShowToolWindow, toolWindowCommandId);
                mcs.AddCommand(menuToolWin);

                // The search combobox command.
                var searchStringCommandId = new CommandID(GuidList.GuidSchemesToolbarCmdSet, CommandIds.SearchStringComboId);
                var searchStringCommand   = new OleMenuCommand(OnSearchString, searchStringCommandId);
                mcs.AddCommand(searchStringCommand);

                // The search combobox value list command.
                var searchStringValuesCommandId = new CommandID(GuidList.GuidSchemesToolbarCmdSet, CommandIds.SearchStringValuesId);
                var searchSTringValuesCommand   = new OleMenuCommand(OnSearchStringValues, searchStringValuesCommandId);
                mcs.AddCommand(searchSTringValuesCommand);

                // The clear search command.
                var clearSearchCommandId = new CommandID(GuidList.GuidSchemesToolbarCmdSet, CommandIds.ClearSearch);
                var clearSearchCommand   = new OleMenuCommand(OnClearSearch, clearSearchCommandId);
                mcs.AddCommand(clearSearchCommand);

                // The refresh schemes cache command.
                var refreshSchemesCacheCommandId = new CommandID(GuidList.GuidSchemesToolbarCmdSet, CommandIds.RefreshSchemesCache);
                var refreshSchemesCacheCommand   = new OleMenuCommand(OnRefreshSchemesCache, refreshSchemesCacheCommandId);
                mcs.AddCommand(refreshSchemesCacheCommand);

                // The activate scheme command.
                var activateSchemeCommandId = new CommandID(GuidList.GuidSchemesToolbarCmdSet, CommandIds.ActivateScheme);
                var activateSchemeCommand   = new OleMenuCommand(OnActivateScheme, activateSchemeCommandId);
                mcs.AddCommand(activateSchemeCommand);

                // The history command.
                var historyCommandId = new CommandID(GuidList.GuidSchemesToolbarCmdSet, CommandIds.SchemesHistory);
                var historyCommand   = new OleMenuCommand(OnHistory, historyCommandId);
                historyCommand.BeforeQueryStatus += HistoryCommandOnBeforeQueryStatus;
                mcs.AddCommand(historyCommand);

                // The first page command.
                var firstPageCommandId = new CommandID(GuidList.GuidSchemesToolbarCmdSet, CommandIds.FirstPageNavigation);
                var firstPageCommand   = new OleMenuCommand(OnFirstPage, firstPageCommandId);
                mcs.AddCommand(firstPageCommand);

                // The previous page command.
                var previousPageCommandId = new CommandID(GuidList.GuidSchemesToolbarCmdSet, CommandIds.PreviousPageNavigation);
                var previousPageCommand   = new OleMenuCommand(OnPreviousPage, previousPageCommandId);
                mcs.AddCommand(previousPageCommand);

                // The next page command.
                var nextPageCommandId = new CommandID(GuidList.GuidSchemesToolbarCmdSet, CommandIds.NextPageNavigation);
                var nextPageCommand   = new OleMenuCommand(OnNextPage, nextPageCommandId);
                mcs.AddCommand(nextPageCommand);

                // The last page command.
                var lastPageCommandId = new CommandID(GuidList.GuidSchemesToolbarCmdSet, CommandIds.LastPageNavigation);
                var lastPageCommand   = new OleMenuCommand(OnLastPage, lastPageCommandId);
                mcs.AddCommand(lastPageCommand);
            }

            // The general options for this package.
            var optionsStore = GetDialogPage(typeof(OptionsStore)) as OptionsStore;

            // Some services that provides important functionalities.
            StudioStylesService = new StudioStylesService();
            SettingsActivator   = new SettingsActivator();

            // The cache holds all studio styles (called schemes) that are available.
            SchemeCache   = new SchemeCache(StudioStylesService);
            SchemeHistory = new SchemeHistory(SchemeCache);

            // Instantiate the models. They are the main classes to interact with the ui and the data.
            SchemeModel  = new SchemeModel(SchemeCache, SchemeHistory, optionsStore, StudioStylesService, SettingsActivator);
            HistoryModel = new HistoryModel(SchemeHistory, optionsStore, StudioStylesService, SettingsActivator);

            // Instantiate the views. This are the WPF controls that visualize the styles and the history.
            SchemeView  = new SchemeView(SchemeModel);
            HistoryView = new HistoryView(HistoryModel);

            // Some Visual Studio visuals can fire some events so that the model is need very early.
            Model = SchemeModel;

            // Save those objects. We need them more than once!
            Window = FindToolWindow(typeof(SchemeToolWindow), 0, true);

            if (Window == null || Window.Frame == null)
            {
                throw new NotSupportedException(Resources.Resources.CanNotCreateWindow);
            }

            var schemesOverview = Window as SchemeToolWindow;

            if (schemesOverview == null)
            {
                throw new InvalidOperationException("Cannot find the SchemesOverviewWindow!");
            }

            SchemeToolWindowView = schemesOverview.Content as SchemeToolWindowView;

            if (SchemeToolWindowView == null)
            {
                throw new InvalidOperationException("Cannot find the StudioStylesView!");
            }

            SchemeToolWindowView.Dock.Children.Add(SchemeView);

            // Check both model caches (Styles and History) so that saved data is present.
            SchemeModel.CheckCache();
            HistoryModel.CheckCache();
        }