Ejemplo n.º 1
0
        public void Register()
        {
            _bookmarkService = new BookmarkService();

            RegisterTypes();

            IUIManager uiMgr = Core.UIManager;

            uiMgr.RegisterWizardPane("Import Bookmarks", ImportBookmarksOptionsPane.StartupWizardPaneCreator, 1);
            uiMgr.RegisterOptionsGroup("Internet", "The Internet options enable you to control how [product name] works with several types of online content.");
            OptionsPaneCreator favoritesPaneCreator = FavoritesOptionsPane.FavoritesOptionsPaneCreator;

            uiMgr.RegisterOptionsPane("Internet", "Favorites", favoritesPaneCreator,
                                      "The Favorites options enable you to control how your Internet Explorer Favorites are imported and synchronized with Internet Explorer.");
            ImportBookmarksOptionsPane.AddPane(favoritesPaneCreator);

            if (OperaBookmarkProfile.OperaBookmarksPath().Length > 0)
            {
                OptionsPaneCreator operaPaneCreator = OperaOptionsPane.CreatePane;
                uiMgr.RegisterOptionsPane("Internet", "Opera Bookmarks", operaPaneCreator,
                                          "The Opera Bookmarks options enable you to control how your Opera Bookmarks are imported.");
                ImportBookmarksOptionsPane.AddPane(operaPaneCreator);
            }

            OptionsPaneCreator downloadOptionsPaneCreator = DownloadOptionsPane.DownloadOptionsPaneCreator;

            uiMgr.RegisterOptionsPane("Internet", "Web Pages", downloadOptionsPaneCreator,
                                      "The Web Pages options enable you to control how your bookmarked Web pages are downloaded.");
            IPropTypeCollection propTypes = Core.ResourceStore.PropTypes;
            int sourceId = propTypes["Source"].Id;

            propTypes.RegisterDisplayName(sourceId, "Web Bookmark");
            Core.TabManager.RegisterResourceTypeTab("Web", "Web", new[] { "Weblink", "Folder" }, sourceId, 4);
            uiMgr.RegisterResourceLocationLink("Weblink", _propParent, "Folder");
            uiMgr.RegisterResourceLocationLink("Folder", _propParent, "Folder");
            uiMgr.RegisterResourceSelectPane("Weblink", typeof(ResourceTreeSelectPane));
            Core.WorkspaceManager.RegisterWorkspaceType("Weblink",
                                                        new[] { Core.ResourceStore.PropTypes["Source"].Id }, WorkspaceResourceType.Container);
            Core.WorkspaceManager.RegisterWorkspaceFolderType("Folder", "Weblink", new[] { _propParent });
            IPluginLoader loader = Core.PluginLoader;

            loader.RegisterResourceDisplayer("Weblink", this);
            loader.RegisterStreamProvider("Weblink", this);
            loader.RegisterResourceUIHandler("Folder", this);
            loader.RegisterResourceUIHandler("Weblink", this);
            loader.RegisterResourceTextProvider(null, this);
            _favIconManager = (FavIconManager)Core.GetComponentImplementation(typeof(FavIconManager));

            Image img = Utils.TryGetEmbeddedResourceImageFromAssembly(Assembly.GetExecutingAssembly(), "Favorites.Icons.Favorites24.png");

            _favoritesTreePane = Core.LeftSidebar.RegisterResourceStructureTreePane("Favorites", "Web", "Bookmarks", img, "Weblink");
            _favoritesTreePane.WorkspaceFilterTypes = new[] { "Weblink", "Folder" };
            _favoritesTreePane.EnableDropOnEmpty(this);
            JetResourceTreePane realPane = (JetResourceTreePane)_favoritesTreePane;

            realPane.AddNodeDecorator(new WeblinkNodeDecorator());
            realPane.AddNodeFilter(new BookmarkProfileFilter());
            _favoritesTreePane.ToolTipCallback = DisplayWeblinkError;
            Core.LeftSidebar.RegisterViewPaneShortcut("Favorites", Keys.Control | Keys.Alt | Keys.B);

            Core.ResourceIconManager.RegisterResourceIconProvider("Weblink", this);
            Core.ResourceIconManager.RegisterPropTypeIcon(Core.ResourceStore.PropTypes["Source"].Id, LoadIconFromAssembly("favorites1.ico"));
            _emptyWeblinkIcon = LoadIconFromAssembly("weblink_empty.ico");
            _errorWeblinkIcon = LoadIconFromAssembly("weblink_error.ico");
            WebLinksPaneFilter filter = new WebLinksPaneFilter();

            Core.ResourceBrowser.RegisterLinksPaneFilter("Weblink", filter);
            Core.ResourceBrowser.RegisterLinksPaneFilter("Folder", filter);
            Core.ResourceBrowser.RegisterResourceDisplayForwarder("Weblink", ForwardWeblinkDisplay);
            Core.FilterEngine.RegisterRuleApplicableResourceType("Weblink");

            Core.RemoteControllerManager.AddRemoteCall("Favorites.ExportMozillaBookmarkChanges.1",
                                                       new RemoteExportMozillaBookmarkChangesDelegate(RemoteExportMozillaBookmarkChanges));
            Core.RemoteControllerManager.AddRemoteCall("Favorites.SetMozillaBookmarkId.1",
                                                       new RemoteSetMozillaBookmarkIdDelegate(RemoteSetMozillaBookmarkId));
            Core.RemoteControllerManager.AddRemoteCall("Favorites.RefreshMozillaBookmarks.1",
                                                       new RemoteRefreshBookmarksDelegate(RemoteRefreshBookmarks));
            Core.RemoteControllerManager.AddRemoteCall("Favorites.AnnotateWeblink.1",
                                                       new RemoteAnnotateWeblinkDelegate(RemoteAnnotateWeblink));

            Core.DisplayColumnManager.RegisterDisplayColumn("Weblink", 0,
                                                            new ColumnDescriptor(new[] { "Name", "DisplayName" }, 300, ColumnDescriptorFlags.AutoSize));
            Core.DisplayColumnManager.RegisterDisplayColumn("Weblink", 1, new ColumnDescriptor("LastUpdated", 120));

            /**
             * bookmark profiles
             */
            Core.PluginLoader.RegisterPluginService(_bookmarkService);
            _favoritesProfile = new IEFavoritesBookmarkProfile(_bookmarkService);
            _bookmarkService.RegisterProfile(_favoritesProfile);
            if (OperaBookmarkProfile.OperaBookmarksPath().Length > 0)
            {
                _operaProfile = new OperaBookmarkProfile(_bookmarkService);
                _bookmarkService.RegisterProfile(_operaProfile);
            }
            if (MozillaProfiles.PresentOnComputer)
            {
                OptionsPaneCreator mozillaPaneCreator = MozillaOptionsPane.MozillaOptionsPaneCreator;
                uiMgr.RegisterOptionsPane("Internet", "Mozilla Bookmarks", mozillaPaneCreator,
                                          "The Mozilla Bookmarks options enable you to select Mozilla or Firefox profile which bookmarks are imported.");
                ImportBookmarksOptionsPane.AddPane(mozillaPaneCreator);
                RegisterMozillaProfiles(MozillaProfiles.GetMozillaProfiles());
                RegisterMozillaProfiles(MozillaProfiles.GetFirefoxProfiles());
                RegisterMozillaProfiles(MozillaProfiles.GetFirefox09Profiles());
                RegisterMozillaProfiles(MozillaProfiles.GetAbsoluteFirefoxProfiles());
                MozillaBookmarkProfile.SetImportPropertiesOfProfiles();
            }
        }