Пример #1
0
        public MainForm()
        {
            InitializeComponent();
            ProcessCommandLine();

            staticHttpClient = new StaticHttpClient(Settings.Network);

            pathFormatter = new PathFormatter(Program.ApplicationPath, Program.SourcePath, Settings.PathFormatter.Custom, Settings.PathFormatter, Settings.Lists.Tags.LanguageNames, Settings.PathFormatter.IsEnabled);

            tagsModel         = new TagsModel();
            tokenModifiers    = TokenModifiers.All.Concat(new ITokenModifier[] { new TagTokenModifier(tagsModel) }).ToArray();
            bookmarkFormatter = new BookmarkFormatter(Settings.Lists.Bookmarks, Settings.Lists.Tags, tagsModel, pathFormatter, tokenModifiers);
            bookmarksModel    = new BookmarksModel(tagsModel, bookmarkFormatter);
            libraryModel      = new LibraryModel(pathFormatter.GetCacheDirectory(), new WinformsTimer(0, Settings.Polling.LibraryRefreshInterval));
            browsingModel     = new BrowsingModel();
            galleryModel      = new GalleryModel(tagsModel);
            detailsModel      = new DetailsModel();

            metadataKeywordLists = new MetadataKeywordLists();
            metadataProcessors   = new List <IMetadataProcessor>();
            metadataConverters   = new List <IMetadataConverter>();
            archiveWriters       = new List <IArchiveWriter>();
            queryParser          = new QueryParser(tagsModel);

            coreTextFormatter     = new CoreTextFormatter(pathFormatter, tokenModifiers);
            aboutTextFormatter    = new AboutTextFormatter(pathFormatter);
            tagTextFormatter      = new TagTextFormatter();
            metadataTextFormatter = new MetadataTextFormatter(pathFormatter, Settings.Lists.Tags.LanguageNames, metadataKeywordLists, tokenModifiers);

            documentTemplates                      = new DocumentTemplates();
            documentTemplates.About                = new DocumentTemplate <object>("about", Settings.Cache.Templates, pathFormatter, (x, context) => aboutTextFormatter.Format(x));
            documentTemplates.Details              = new DocumentTemplate <Metadata>("details", Settings.Cache.Templates, pathFormatter, (text, context) => metadataTextFormatter.Format(text, context));
            documentTemplates.DetailsPreload       = new DocumentTemplate <Metadata>("details-preload", Settings.Cache.Templates, pathFormatter, (text, context) => metadataTextFormatter.Format(text, context));
            documentTemplates.Download             = new DocumentTemplate <Metadata>("download", Settings.Cache.Templates, pathFormatter, (text, context) => metadataTextFormatter.Format(text, context));
            documentTemplates.GalleryTooltip       = new DocumentTemplate <Metadata>("gallery-tooltip", Settings.Cache.Templates, pathFormatter, (text, context) => metadataTextFormatter.Format(text, context));
            documentTemplates.LibraryCovergrid     = new DocumentTemplate <ISearchProgressArg>("library-covergrid", Settings.Cache.Templates, pathFormatter, (text, context) => searchProgressArgTextFormatter.Format(text, context, "library"));
            documentTemplates.LibraryCovergridItem = new DocumentTemplate <Metadata>("library-covergrid-item", Settings.Cache.Templates, pathFormatter, (text, context) => metadataTextFormatter.Format(text, context));
            documentTemplates.SearchCovergrid      = new DocumentTemplate <ISearchProgressArg>("search-covergrid", Settings.Cache.Templates, pathFormatter, (text, context) => searchProgressArgTextFormatter.Format(text, context, "search"));
            documentTemplates.SearchCovergridItem  = new DocumentTemplate <Metadata>("search-covergrid-item", Settings.Cache.Templates, pathFormatter, (text, context) => metadataTextFormatter.Format(text, context));
            documentTemplates.SearchPreload        = new DocumentTemplate <ISearchArg>("search-preload", Settings.Cache.Templates, pathFormatter, (text, context) => searchArgTextFormatter.Format(text, context));
            documentTemplates.Startup              = new DocumentTemplate <object>("startup", Settings.Cache.Templates, pathFormatter, (text, context) => coreTextFormatter.Format(text, context));

            searchArgTextFormatter         = new SearchArgTextFormatter(pathFormatter, metadataKeywordLists, tagsModel, tokenModifiers);
            searchProgressArgTextFormatter = new SearchProgressArgTextFormatter(pathFormatter, metadataKeywordLists, tagsModel, metadataTextFormatter, tokenModifiers, documentTemplates.SearchCovergridItem, documentTemplates.LibraryCovergridItem);

            metadataCache     = new MetadataCache();
            searchResultCache = new SearchResultCache(metadataCache);
            sessionManager    = new SessionManager(pathFormatter, searchResultCache, Settings.Cache.Session.RecentLifeSpan, Settings.Cache.Session.SearchLifeSpan, Settings.Cache.Session.TaggedLifeSpan, Settings.Network);
            cacheFileSystem   = new CacheFileSystem(pathFormatter, searchResultCache, archiveWriters);
            pluginSystem      = new PluginSystem(Logger, pathFormatter, cacheFileSystem, archiveWriters, metadataConverters, metadataProcessors);

            backgroundTaskWorker = new BackgroundTaskWorker()
            {
                IdleWaitTime = Settings.BackgroundWorkers.BackgroundTaskWorker.IdleWaitTime, MaxConcurrentJobCount = Settings.BackgroundWorkers.BackgroundTaskWorker.MaxConcurrentJobCount
            };
            pageDownloader = new PageDownloader(staticHttpClient.Client, pathFormatter, searchResultCache, cacheFileSystem)
            {
                IdleWaitTime = Settings.BackgroundWorkers.PageDownloader.IdleWaitTime, MaxConcurrentJobCount = Settings.BackgroundWorkers.PageDownloader.MaxConcurrentJobCount
            };
            coverDownloader = new CoverDownloader(staticHttpClient.Client, pathFormatter, metadataKeywordLists)
            {
                IdleWaitTime = Settings.BackgroundWorkers.CoverDownloader.IdleWaitTime, MaxConcurrentJobCount = Settings.BackgroundWorkers.CoverDownloader.MaxConcurrentJobCount
            };
            coverLoader = new CoverDownloader(staticHttpClient.Client, pathFormatter, metadataKeywordLists)
            {
                IdleWaitTime = Settings.BackgroundWorkers.CoverLoader.IdleWaitTime, MaxConcurrentJobCount = Settings.BackgroundWorkers.CoverLoader.MaxConcurrentJobCount
            };
            galleryDownloader = new GalleryDownloader(staticHttpClient.Client, pathFormatter, searchResultCache)
            {
                IdleWaitTime = Settings.BackgroundWorkers.GalleryDownloader.IdleWaitTime, MaxConcurrentJobCount = Settings.BackgroundWorkers.GalleryDownloader.MaxConcurrentJobCount
            };

            detailsTabControl         = new TabControlEx();
            detailsTabPage            = new TabPage();
            downloadTabPage           = new TabPage();
            listsTabControl           = new TabControlEx();
            tagsTabPage               = new TabPage();
            bookmarksTabPage          = new TabPage();
            libraryTabPage            = new TabPage();
            browsingTabPage           = new TabPage();
            mainViewTabControl        = new TabControlEx();
            galleryBrowserViewTabPage = new TabPage();
            libraryBrowserViewTabPage = new TabPage();
            downloadsListViewTabPage  = new TabPage();
            webBrowserToolTip         = new WebBrowserTreeNodeToolTip(pathFormatter, documentTemplates.GalleryTooltip);
            loadTimer = new Timer(components);

            searchHandler = new SearchHandler(
                libraryModel
                , mainViewTabControl
                , libraryBrowserViewTabPage
                , galleryBrowserViewTabPage
                , Settings.Cache
                , searchResultCache
                , Logger
                , browsingModel
                , pathFormatter
                , staticHttpClient.Client
                , queryParser
                , galleryModel
                , detailsModel
                , galleryDownloader
                , sessionManager
                , Settings.Network);

            bookmarkPromptUtility = new BookmarkPromptUtility(bookmarksModel, Settings.Lists.Bookmarks);

            tagsFilter           = new TagsFilter(Settings.Lists.Tags, metadataKeywordLists);
            bookmarksFilter      = new BookmarksFilter(Settings.Lists.Bookmarks);
            libraryFilter        = new LibraryFilter(Settings.Lists.Library);
            browsingFilter       = new BrowsingFilter(Settings.Lists.Browsing);
            libraryBrowserFilter = new LibraryBrowserFilter(Settings.Library.Browser);
            galleryBrowserFilter = new GalleryBrowserFilter(Settings.Gallery.Browser);
            detailsBrowserFilter = new DetailsBrowserFilter(Settings.Details.Browser);

            tagsTreeView       = new TagsTreeView(tagsFilter, tagsModel, tagTextFormatter, Settings.Lists.Tags, metadataKeywordLists, searchHandler, bookmarkPromptUtility, staticHttpClient.Client);
            tagsToolStrip      = new TagsToolStrip(tagsFilter, tagsModel, Settings.Lists.Tags, metadataKeywordLists, Settings.Polling.FilterDelay);
            bookmarksTreeView  = new BookmarksTreeView(bookmarksFilter, bookmarksModel, Settings.Lists.Bookmarks, webBrowserToolTip, queryParser, cacheFileSystem, searchHandler);
            bookmarksToolStrip = new BookmarksToolStrip(bookmarksFilter, bookmarksModel, Settings.Lists.Bookmarks, Settings.Polling.FilterDelay);
            libraryTreeView    = new LibraryTreeView(libraryFilter, libraryModel, archiveWriters, webBrowserToolTip, searchHandler, cacheFileSystem);
            libraryToolStrip   = new LibraryToolStrip(libraryFilter, libraryModel, Settings.Lists.Library, Settings.Polling.FilterDelay);
            browsingTreeView   = new BrowsingTreeView(browsingFilter, browsingModel, Settings.Lists.Browsing, searchHandler, sessionManager, queryParser);
            browsingToolStrip  = new BrowsingToolStrip(browsingFilter, browsingModel, Settings.Lists.Browsing, Settings.Polling.FilterDelay);

            galleryBrowserView      = new GalleryBrowserView(galleryBrowserFilter, galleryModel, documentTemplates.SearchCovergrid, documentTemplates.SearchPreload, pathFormatter, Settings.Gallery.Browser, pageDownloader, coverDownloader, metadataKeywordLists, tagsModel, searchHandler);
            galleryToolStrip        = new GalleryBrowserToolStrip(galleryBrowserFilter, galleryModel, Settings.Gallery.Browser, searchHandler);
            libraryBrowserView      = new LibraryBrowserView(libraryBrowserFilter, libraryModel, documentTemplates.LibraryCovergrid, documentTemplates.SearchPreload, documentTemplates.LibraryCovergridItem, pathFormatter, pageDownloader, coverLoader, metadataKeywordLists, Settings.Library.Browser, searchResultCache);
            libraryBrowserToolStrip = new LibraryBrowserToolStrip(libraryBrowserFilter, libraryModel, Settings.Library.Browser, searchHandler);
            detailsToolStrip        = new DetailsBrowserToolStrip(detailsBrowserFilter, detailsModel, searchHandler);
            detailsBrowserView      = new DetailsBrowserView(detailsBrowserFilter, detailsModel, documentTemplates.Details, documentTemplates.Download, documentTemplates.DetailsPreload, galleryDownloader, pageDownloader, coverDownloader, metadataKeywordLists, Settings.Details.Browser, searchResultCache, cacheFileSystem);
            theme                  = new Theme();
            applicationLoader      = new ApplicationLoader();
            fullScreenRestoreState = new FullScreenRestoreState();
            mainMenuStrip          = new MainMenuStrip(Settings);
            startupSpecialHandler  = new StartupSpecialHandler(Settings.Gallery, tagsModel, metadataKeywordLists, searchHandler);
            taskbar                = new Taskbar(coverDownloader, galleryDownloader, pageDownloader, searchResultCache, cacheFileSystem);

            publicApi = new PublicApi(staticHttpClient.Client
                                      , pathFormatter
                                      , cacheFileSystem
                                      , searchResultCache
                                      , searchHandler
                                      , bookmarkPromptUtility
                                      , pluginSystem
                                      , libraryBrowserToolStrip
                                      , Settings.Library
                                      , galleryToolStrip
                                      , Settings.Gallery
                                      , Settings.Details
                                      , galleryDownloader
                                      , coverDownloader
                                      , pageDownloader
                                      , Settings.Notifications
                                      , metadataKeywordLists
                                      , Settings
                                      );

            splitContainer1 = new SplitContainerEx();
            splitContainer2 = new SplitContainerEx();
            splitContainer3 = new SplitContainerEx();

            splitContainer1.BeginInit();
            splitContainer1.Panel2.SuspendLayout();
            splitContainer1.SuspendLayout();

            splitContainer2.BeginInit();
            splitContainer2.Panel1.SuspendLayout();
            splitContainer2.SuspendLayout();

            splitContainer3.BeginInit();
            splitContainer3.SuspendLayout();

            SuspendLayout();

            //
            //
            //
            loadTimer.Interval = 100;
            loadTimer.Tick    += LoadTimer_Tick;

            //
            //
            //
            tagsTabPage.Name     = "tagsTabPage";
            tagsTabPage.TabIndex = 0;
            tagsTabPage.Tag      = "tags";
            tagsTabPage.Text     = "Tags";
            tagsTabPage.UseVisualStyleBackColor = true;

            bookmarksTabPage.Name     = "bookmarksTabPage";
            bookmarksTabPage.TabIndex = 1;
            bookmarksTabPage.Tag      = "bookmarks";
            bookmarksTabPage.Text     = "Bookmarks";
            bookmarksTabPage.UseVisualStyleBackColor = true;

            libraryTabPage.Name     = "libraryTabPage";
            libraryTabPage.TabIndex = 2;
            libraryTabPage.Tag      = "library";
            libraryTabPage.Text     = "Library";
            libraryTabPage.UseVisualStyleBackColor = true;

            browsingTabPage.Name     = "browsingTabPage";
            browsingTabPage.TabIndex = 4;
            browsingTabPage.Tag      = "browsing";
            browsingTabPage.Text     = "Browsing";
            browsingTabPage.UseVisualStyleBackColor = true;

            //
            //
            //
            listsTabControl.Dock          = DockStyle.Fill;
            listsTabControl.Name          = "treeViewTabControl";
            listsTabControl.SelectedIndex = -1;
            listsTabControl.TabIndex      = 2;
            listsTabControl.TabPages.Add(tagsTabPage);
            listsTabControl.TabPages.Add(bookmarksTabPage);
            listsTabControl.TabPages.Add(libraryTabPage);
            listsTabControl.TabPages.Add(browsingTabPage);
            listsTabControl.Selected += TreeViewTabControl_Selected;

            splitContainer3.Panel1.Controls.Add(listsTabControl);

            //
            //
            //
            tagsTreeView.Dock = DockStyle.Fill;

            //
            //
            //
            tagsToolStrip.Dock         = DockStyle.Top;
            tagsToolStrip.AutoSizeMode = AutoSizeMode.GrowAndShrink;
            tagsToolStrip.AutoSize     = true;

            //
            //
            //
            tagsTabPage.Controls.Add(tagsTreeView);
            tagsTabPage.Controls.Add(tagsToolStrip);

            //
            //
            //
            bookmarksModel.ItemAdded   += BookmarksModel_ItemAdded;
            bookmarksModel.ItemChanged += BookmarksModel_ItemChanged;

            //
            //
            //
            bookmarksTreeView.Dock = DockStyle.Fill;

            //
            //
            //
            bookmarksToolStrip.Dock         = DockStyle.Top;
            bookmarksToolStrip.AutoSizeMode = AutoSizeMode.GrowAndShrink;
            bookmarksToolStrip.AutoSize     = true;

            //
            //
            //
            bookmarksTabPage.Controls.Add(bookmarksTreeView);
            bookmarksTabPage.Controls.Add(bookmarksToolStrip);

            //
            //
            //
            libraryTreeView.Dock = DockStyle.Fill;

            //
            //
            //
            libraryToolStrip.Dock         = DockStyle.Top;
            libraryToolStrip.AutoSizeMode = AutoSizeMode.GrowAndShrink;
            libraryToolStrip.AutoSize     = true;

            //
            //
            //
            libraryTabPage.Controls.Add(libraryTreeView);
            libraryTabPage.Controls.Add(libraryToolStrip);

            //
            //
            //
            browsingModel.ItemAdded   += BrowsingModel_ItemAdded;
            browsingModel.ItemChanged += BrowsingModel_ItemChanged;

            //
            //
            //
            browsingToolStrip.Dock         = DockStyle.Top;
            browsingToolStrip.AutoSizeMode = AutoSizeMode.GrowAndShrink;
            browsingToolStrip.AutoSize     = true;

            //
            //
            //
            browsingTreeView.Dock = DockStyle.Fill;

            //
            //
            //
            browsingTabPage.Controls.Add(browsingTreeView);
            browsingTabPage.Controls.Add(browsingToolStrip);

            //
            //
            //
            galleryBrowserViewTabPage.Name     = "galleryBrowserViewTabPage";
            galleryBrowserViewTabPage.Padding  = Padding.Empty;
            galleryBrowserViewTabPage.TabIndex = 0;
            galleryBrowserViewTabPage.Text     = "Search";
            galleryBrowserViewTabPage.UseVisualStyleBackColor = true;

            //
            //
            //
            libraryBrowserViewTabPage.Name     = "libraryBrowserViewTabPage";
            libraryBrowserViewTabPage.TabIndex = 1;
            libraryBrowserViewTabPage.Text     = "Library";
            libraryBrowserViewTabPage.UseVisualStyleBackColor = true;

            //
            //
            //
            downloadsListViewTabPage.Name     = "downloadsListViewTabPage";
            downloadsListViewTabPage.TabIndex = 2;
            downloadsListViewTabPage.Text     = "Downloads";
            downloadsListViewTabPage.UseVisualStyleBackColor = true;

            //
            //
            //
            mainViewTabControl.Controls.Add(galleryBrowserViewTabPage);
            mainViewTabControl.Controls.Add(libraryBrowserViewTabPage);
            mainViewTabControl.Controls.Add(downloadsListViewTabPage);
            mainViewTabControl.Dock          = DockStyle.Fill;
            mainViewTabControl.Name          = "mainViewTabControl";
            mainViewTabControl.SelectedIndex = 0;
            mainViewTabControl.TabIndex      = 2;
            mainViewTabControl.Selected     += MainViewTabControl_Selected;

            splitContainer3.Panel2.Controls.Add(mainViewTabControl);
            splitContainer2.Panel2.Controls.Add(detailsTabControl);

            //
            // detailsTabControl
            //
            detailsTabControl.Controls.Add(detailsTabPage);
            detailsTabControl.Controls.Add(downloadTabPage);
            detailsTabControl.Dock          = DockStyle.Fill;
            detailsTabControl.Name          = "detailsTabControl";
            detailsTabControl.SelectedIndex = 0;
            detailsTabControl.TabIndex      = 2;

            //
            // detailsTabPage
            //
            detailsTabPage.Name     = "detailsTabPage";
            detailsTabPage.TabIndex = 0;
            detailsTabPage.Text     = "Details";
            detailsTabPage.UseVisualStyleBackColor = true;

            //
            // downloadTabPage
            //
            downloadTabPage.Name     = "downloadTabPage";
            downloadTabPage.TabIndex = 1;
            downloadTabPage.Text     = "Download";
            downloadTabPage.UseVisualStyleBackColor = true;

            //
            //
            //
            galleryBrowserView.Dock = DockStyle.Fill;
            galleryBrowserView.WebBrowser.ObjectForScripting = publicApi;

            //
            //
            //
            galleryToolStrip.AutoSizeMode = AutoSizeMode.GrowAndShrink;
            galleryToolStrip.AutoSize     = true;
            galleryToolStrip.Dock         = DockStyle.Top;

            //
            //
            //
            galleryBrowserViewTabPage.Controls.Add(galleryBrowserView);
            galleryBrowserViewTabPage.Controls.Add(galleryToolStrip);

            //
            //
            //
            libraryBrowserView.Dock = DockStyle.Fill;
            libraryBrowserView.WebBrowser.ObjectForScripting = publicApi;

            //
            //
            //
            libraryBrowserToolStrip.AutoSizeMode = AutoSizeMode.GrowAndShrink;
            libraryBrowserToolStrip.AutoSize     = true;
            libraryBrowserToolStrip.Dock         = DockStyle.Top;

            //
            //
            //
            libraryBrowserViewTabPage.Controls.Add(libraryBrowserView);
            libraryBrowserViewTabPage.Controls.Add(libraryBrowserToolStrip);

            //
            //
            //
            detailsToolStrip.AutoSizeMode = AutoSizeMode.GrowAndShrink;
            detailsToolStrip.AutoSize     = true;
            detailsToolStrip.Dock         = DockStyle.Top;

            //
            //
            //
            detailsBrowserView.Dock = DockStyle.Fill;
            detailsBrowserView.WebBrowser.ObjectForScripting = publicApi;

            //
            //
            //
            detailsTabPage.Controls.Add(detailsBrowserView);
            detailsTabPage.Controls.Add(detailsToolStrip);

            //
            // splitContainer1
            //
            splitContainer1.Dock          = DockStyle.Fill;
            splitContainer1.FixedPanel    = FixedPanel.Panel1;
            splitContainer1.Margin        = new Padding(0);
            splitContainer1.Name          = "splitContainer1";
            splitContainer1.Orientation   = Orientation.Horizontal;
            splitContainer1.Panel1MinSize = 22;

            //
            // splitContainer1.Panel2
            //
            splitContainer1.Panel2.Controls.Add(splitContainer2);
            splitContainer1.Size              = new Size(1364, 637);
            splitContainer1.SplitterDistance  = 25;
            splitContainer1.SplitterIncrement = 22;
            splitContainer1.SplitterWidth     = 7;
            splitContainer1.TabIndex          = 2;

            //
            // splitContainer2
            //
            splitContainer2.Dock       = DockStyle.Fill;
            splitContainer2.FixedPanel = FixedPanel.Panel2;
            splitContainer2.Margin     = new Padding(0);
            splitContainer2.Name       = "splitContainer2";

            //
            // splitContainer2.Panel1
            //
            splitContainer2.Panel1.Controls.Add(splitContainer3);
            splitContainer2.Size             = new Size(1364, 605);
            splitContainer2.SplitterDistance = 1214;
            splitContainer2.SplitterWidth    = 7;
            splitContainer2.TabIndex         = 1;

            //
            // splitContainer3
            //
            splitContainer3.Dock             = DockStyle.Fill;
            splitContainer3.FixedPanel       = FixedPanel.Panel1;
            splitContainer3.Margin           = new Padding(0);
            splitContainer3.Name             = "splitContainer3";
            splitContainer3.Size             = new Size(1214, 605);
            splitContainer3.SplitterDistance = 200;
            splitContainer3.SplitterWidth    = 7;
            splitContainer3.TabIndex         = 0;

            //
            // applicationMenuStrip
            //
            mainMenuStrip.Exit               += MainMenuStrip_Exit;
            mainMenuStrip.ToggleListsPanel   += MainMenuStrip_ToggleListsPanel;
            mainMenuStrip.ToggleDetailsPanel += MainMenuStrip_ToggleDetailsPanel;
            mainMenuStrip.ToggleFullScreen   += MainMenuStrip_ToggleFullScreen;
            mainMenuStrip.ShowAbout          += MainMenuStrip_ShowAbout;
            mainMenuStrip.ShowPlugins        += MainMenuStrip_ShowPlugins;

            //
            // this
            //
            Controls.Add(splitContainer1);
            Controls.Add(mainMenuStrip);
            Controls.Add(webBrowserToolTip);
            webBrowserToolTip.BringToFront();
            MainMenuStrip = mainMenuStrip;
            Padding       = new Padding(0);
            Text          = aboutTextFormatter.Format(Settings.Window.TextFormat);
            if (Settings.Network.Offline)
            {
                Text += " [OFFLINE]";
            }
            Enabled = false;

            //
            // splash screen
            //
            if (Settings.SplashScreen.IsVisible)
            {
                startupWebBrowser      = new StartupWebBrowserView(coreTextFormatter, documentTemplates.Startup, applicationLoader);
                startupWebBrowser.Name = "startupWebBrowserView";
                startupWebBrowser.Dock = DockStyle.Fill;
                startupWebBrowser.WebBrowser.DocumentCompleted += WebBrowser_DocumentCompleted;

                Controls.Add(startupWebBrowser);
                startupWebBrowser.BringToFront();

                // avoid flickering
                listsTabControl.Visible    = false;
                mainViewTabControl.Visible = false;
                detailsTabControl.Visible  = false;
            }

            backgroundTaskWorker.ProgressChanged += TaskBackgroundWorker_ProgressChanged;

            pageDownloader.PagesDownloadCompleted += PageDownloader_PagesDownloadCompleted;

            ReadTheme();
            ApplyTheme();
            ApplyVisualStyles();

            splitContainer1.Panel2.ResumeLayout(false);
            splitContainer1.EndInit();
            splitContainer1.ResumeLayout(false);

            splitContainer2.Panel1.ResumeLayout(false);
            splitContainer2.EndInit();
            splitContainer2.ResumeLayout(false);

            splitContainer3.EndInit();
            splitContainer3.ResumeLayout(false);

            ResumeLayout(false);
            PerformLayout();
        }
Пример #2
0
        public LibraryBrowserToolStrip(LibraryBrowserFilter libraryBrowserFilter, LibraryModel libraryModel, Configuration.ConfigLibraryBrowserView libraryBrowserSettings, SearchHandler searchHandler)
        {
            InitializeComponent();

            LibraryBrowserFilter   = libraryBrowserFilter;
            LibraryModel           = libraryModel;
            LibraryBrowserSettings = libraryBrowserSettings;
            SearchHandler          = searchHandler;

            toolStrip               = new ToolStrip();
            filterComboBox          = new ToolStripSpringComboBox();
            sortTypeComboBox        = new ToolStripComboBox();
            sortOrderComboBox       = new ToolStripComboBox();
            globalSortTypeComboBox  = new ToolStripComboBox();
            globalSortOrderComboBox = new ToolStripComboBox();

            SuspendLayout();

            filterComboBox.AutoCompleteMode   = AutoCompleteMode.SuggestAppend;
            filterComboBox.AutoCompleteSource = AutoCompleteSource.ListItems;
            filterComboBox.DropDownStyle      = ComboBoxStyle.DropDown;
            filterComboBox.Dock     = DockStyle.Fill;
            filterComboBox.Margin   = new Padding(0, 0, 6, 0);
            filterComboBox.KeyDown += FilterComboBox_KeyDown;
            filterComboBox.ComboBox.SelectedIndexChanged     += ComboBox_SelectedIndexChanged;
            filterComboBox.ComboBox.SelectionChangeCommitted += FilterComboBox_SelectionChangeCommitted;
            // WORKAROUND: bug since win7 - selectedindex is wrong when a datasource is bound
            //searchComboBox.ComboBox.DataSource = galleryModel.Searches;
            //galleryModel.Searches.ListChanged += Searches_ListChanged;
            filterComboBox.ComboBox.OverrideMouseWheelBehaviour();
            filterComboBox.EnableMiddleClickToClear();
            filterComboBox.OverrideUpDownKeys();

            sortTypeComboBox.Text          = "&Sort";
            sortTypeComboBox.FlatStyle     = FlatStyle.Flat;
            sortTypeComboBox.DropDownStyle = ComboBoxStyle.DropDownList;
            List <ComboBoxItem> sortTypeItems = new List <ComboBoxItem>
            {
                new ComboBoxItem("orderByNone", "None", SortTypeComboBox_None, GallerySortType.None),
                new ComboBoxItem("orderByTitle", "Title", SortTypeComboBox_Title, GallerySortType.Title),
                new ComboBoxItem("orderByLanguage", "Language", SortTypeComboBox_Language, GallerySortType.Language),
                new ComboBoxItem("orderByArtist", "Artist", SortTypeComboBox_Artist, GallerySortType.Artist),
                new ComboBoxItem("orderByGroup", "Group", SortTypeComboBox_Group, GallerySortType.Group),
                new ComboBoxItem("orderByTag", "Tag", SortTypeComboBox_Tag, GallerySortType.Tag),
                new ComboBoxItem("orderByParody", "Parody", SortTypeComboBox_Parody, Tag = GallerySortType.Parody),
                new ComboBoxItem("orderByCharacter", "Character", SortTypeComboBox_Character, GallerySortType.Character),
                new ComboBoxItem("orderByCategory", "Category", SortTypeComboBox_Category, GallerySortType.Category),
                new ComboBoxItem("orderByScanlator", "Scanlator", SortTypeComboBox_Scanlator, GallerySortType.Scanlator),
                new ComboBoxItem("orderByUploadDate", "Upload Date", SortTypeComboBox_UploadDate, GallerySortType.UploadDate),
                new ComboBoxItem("orderByNumPages", "Num Pages", SortTypeComboBox_NumPages, GallerySortType.NumPages),
                new ComboBoxItem("orderByNumFavorites", "Num Favorites", SortTypeComboBox_NumFavorites, GallerySortType.NumFavorites),
                new ComboBoxItem("orderById", "Id", SortTypeComboBox_Id, GallerySortType.Id),
                //new SortItem("orderByComiket", "Comiket", SortTypeComboBox_Comiket, GallerySortType.Comiket),
                //new SortItem("orderByVersion", "Version", SortTypeComboBox_Version, GallerySortType.Version),
                //new SortItem("orderByCensorship", "Censorship", SortTypeComboBox_Censorship, GallerySortType.Censorship),
            };

            sortTypeComboBox.Items.AddRange(sortTypeItems.Cast <object>().ToArray());
            sortTypeComboBox.ComboBox.SelectionChangeCommitted += SortTypeComboBox_SelectionChangeCommitted;
            sortTypeComboBox.SelectedItem = sortTypeItems.First(x => (GallerySortType)x.Tag == LibraryBrowserFilter.SortType);
            sortTypeComboBox.ComboBox.OverrideMouseWheelBehaviour();
            sortTypeComboBox.OverrideUpDownKeys();

            sortOrderComboBox.Text          = "&Sort";
            sortOrderComboBox.FlatStyle     = FlatStyle.Flat;
            sortOrderComboBox.DropDownStyle = ComboBoxStyle.DropDownList;
            List <ComboBoxItem> sortOrderItems = new List <ComboBoxItem>
            {
                new ComboBoxItem("orderByAscending", "Ascending", SortOrderComboBox_Ascending, SortOrder.Ascending),
                new ComboBoxItem("orderByDescending", "Descending", SortOrderComboBox_Descending, SortOrder.Descending)
            };

            sortOrderComboBox.Items.AddRange(sortOrderItems.Cast <object>().ToArray());
            sortOrderComboBox.ComboBox.SelectionChangeCommitted += SortOrderComboBox_SelectionChangeCommitted;
            sortOrderComboBox.SelectedItem = sortOrderItems.First(x => (SortOrder)x.Tag == LibraryBrowserFilter.SortOrder);
            sortOrderComboBox.ComboBox.OverrideMouseWheelBehaviour();
            sortOrderComboBox.Enabled = LibraryBrowserFilter.SortType != GallerySortType.None;
            sortOrderComboBox.OverrideUpDownKeys();


            globalSortTypeComboBox.Text          = "&Sort";
            globalSortTypeComboBox.FlatStyle     = FlatStyle.Flat;
            globalSortTypeComboBox.DropDownStyle = ComboBoxStyle.DropDownList;
            List <ComboBoxItem> globalSortTypeItems = new List <ComboBoxItem>
            {
                new ComboBoxItem("orderByNone", "None", GlobalSortTypeComboBox_None, LibrarySortType.None),
                new ComboBoxItem("orderByCreationTime", "Creation time", GlobalSortTypeComboBox_CreationTime, LibrarySortType.CreationTime),
                new ComboBoxItem("orderByLastAccessTime", "Last access time", GlobalSortTypeComboBox_LastAccessTime, LibrarySortType.LastAccessTime),
                new ComboBoxItem("orderByLastWriteTime", "Last write time", GlobalSortTypeComboBox_LastWriteTime, LibrarySortType.LastWriteTime),
            };

            globalSortTypeComboBox.Items.AddRange(globalSortTypeItems.Cast <object>().ToArray());
            globalSortTypeComboBox.ComboBox.SelectionChangeCommitted += GlobalSortTypeComboBox_SelectionChangeCommitted;
            globalSortTypeComboBox.SelectedItem = globalSortTypeItems.First(x => (LibrarySortType)x.Tag == LibraryBrowserFilter.GlobalSortType);
            globalSortTypeComboBox.ComboBox.OverrideMouseWheelBehaviour();
            globalSortTypeComboBox.OverrideUpDownKeys();

            globalSortOrderComboBox.Text          = "&Sort";
            globalSortOrderComboBox.FlatStyle     = FlatStyle.Flat;
            globalSortOrderComboBox.DropDownStyle = ComboBoxStyle.DropDownList;
            List <ComboBoxItem> globalSortOrderItems = new List <ComboBoxItem>
            {
                new ComboBoxItem("orderByAscending", "Ascending", GlobalSortOrderComboBox_Ascending, SortOrder.Ascending),
                new ComboBoxItem("orderByDescending", "Descending", GlobalSortOrderComboBox_Descending, SortOrder.Descending)
            };

            globalSortOrderComboBox.Items.AddRange(globalSortOrderItems.Cast <object>().ToArray());
            globalSortOrderComboBox.ComboBox.SelectionChangeCommitted += SortOrderComboBox_SelectionChangeCommitted;
            globalSortOrderComboBox.SelectedItem = globalSortOrderItems.First(x => (SortOrder)x.Tag == LibraryBrowserFilter.GlobalSortOrder);
            globalSortOrderComboBox.ComboBox.OverrideMouseWheelBehaviour();
            globalSortOrderComboBox.Enabled = LibraryBrowserFilter.GlobalSortType != LibrarySortType.None;
            globalSortOrderComboBox.OverrideUpDownKeys();

            toolStrip.Dock        = DockStyle.Fill;
            toolStrip.CanOverflow = false;
            toolStrip.Items.Add(filterComboBox);
            toolStrip.Items.Add(sortTypeComboBox);
            toolStrip.Items.Add(sortOrderComboBox);
            toolStrip.Items.Add(globalSortTypeComboBox);
            toolStrip.Items.Add(globalSortOrderComboBox);

            //
            // this
            //
            Controls.Add(toolStrip);

            //LibraryModel.SearchesChanged += LibraryModel_SearchesChanged;
            LibraryModel.FiltersChanged += LibraryModel_FiltersChanged;

            libraryBrowserFilter.SortTypeChanged        += LibraryBrowserFilter_SortTypeChanged;
            libraryBrowserFilter.SortOrderChanged       += LibraryBrowserFilter_SortOrderChanged;
            libraryBrowserFilter.GlobalSortTypeChanged  += LibraryBrowserFilter_GlobalSortTypeChanged;
            libraryBrowserFilter.GlobalSortOrderChanged += LibraryBrowserFilter_GlobalSortOrderChanged;

            ResumeLayout(false);
        }
Пример #3
0
        public LibraryBrowserView(LibraryBrowserFilter libraryBrowserFilter, LibraryModel libraryModel, DocumentTemplate <ISearchProgressArg> libraryCovergridTemplate, DocumentTemplate <ISearchArg> libraryPreloadTemplate, DocumentTemplate <Metadata> libraryCovergridItemTemplate
                                  , IPathFormatter pathFormatter
                                  , PageDownloader pageDownloader
                                  , CoverDownloader coverLoader
                                  , MetadataKeywordLists metadataKeywordLists
                                  , Configuration.ConfigLibraryBrowserView libraryBrowserSettings
                                  , ISearchResultCache searchResultCache)
        {
            InitializeComponent();

            LibraryBrowserFilter         = libraryBrowserFilter;
            LibraryModel                 = libraryModel;
            PathFormatter                = pathFormatter;
            SearchResultCache            = searchResultCache;
            LibraryCovergridTemplate     = libraryCovergridTemplate;
            LibraryPreloadTemplate       = libraryPreloadTemplate;
            LibraryCovergridItemTemplate = libraryCovergridItemTemplate;
            PageDownloader               = pageDownloader;
            CoverLoader            = coverLoader;
            MetadataKeywordLists   = metadataKeywordLists;
            LibraryBrowserSettings = libraryBrowserSettings;

            webBrowser       = new WebBrowserEx();
            backgroundWorker = new BackgroundWorker();

            SuspendLayout();

            webBrowser.AllowWebBrowserDrop = false;
            webBrowser.Dock = DockStyle.Fill;
            webBrowser.Name = "libraryWebBrowser";
            webBrowser.BeforeDocumentCompleted += WebBrowser_BeforeDocumentCompleted;
            webBrowser.DocumentCompleted       += WebBrowser_DocumentCompleted;

            backgroundWorker.WorkerReportsProgress      = true;
            backgroundWorker.WorkerSupportsCancellation = true;

            backgroundWorker.DoWork             += BackgroundWorker_DoWork;
            backgroundWorker.ProgressChanged    += BackgroundWorker_ProgressChanged;
            backgroundWorker.RunWorkerCompleted += BackgroundWorker_RunWorkerCompleted;

            PageDownloader.PageDownloadReportProgress += PageDownloader_PageDownloadReportProgress;
            PageDownloader.PagesDownloadStarted       += PageDownloader_PagesDownloadStarted;
            PageDownloader.PagesDownloadCancelled     += PageDownloader_PagesDownloadCancelled;
            PageDownloader.PagesDownloadCompleted     += PageDownloader_PagesDownloadCompleted;

            CoverLoader.CoverDownloadReportProgress += CoverLoader_CoverDownloadReportProgress;
            CoverLoader.CoversDownloadStarted       += CoverLoader_CoversDownloadStarted;
            CoverLoader.CoversDownloadCancelled     += CoverLoader_CoversDownloadCancelled;
            CoverLoader.CoversDownloadCompleted     += CoverLoader_CoversDownloadCompleted;

            MetadataKeywordLists.WhitelistChanged  += Form_WhiteListChanged;
            MetadataKeywordLists.BlacklistChanged  += Form_BlackListChanged;
            MetadataKeywordLists.IgnorelistChanged += Form_IgnoreListChanged;
            MetadataKeywordLists.HidelistChanged   += Form_HideListChanged;

            //libraryModel.Poll += LibraryModel_Poll;

            libraryBrowserFilter.TextChanged += LibraryBrowserFilter_TextChanged;

            LibraryModel.PageIndexChanged         += LibraryModel_PageIndexChanged;
            LibraryModel.SearchProgressArgChanged += LibraryModel_SearchProgressArgChanged;

            Controls.Add(webBrowser);

            ResumeLayout(false);
        }