示例#1
0
文件: AboutForm.cs 项目: NHxD/NHxD
        private static void BackgoundWorker_DoWork(object sender, DoWorkEventArgs e)
        {
            BackgroundWorker backgroundWorker = sender as BackgroundWorker;
            IPathFormatter   pathFormatter    = e.Argument as IPathFormatter;
            string           cacheDirectory   = pathFormatter.GetCacheDirectory();

            if (Directory.Exists(cacheDirectory))
            {
                DirectoryInfo dirInfo     = new DirectoryInfo(cacheDirectory);
                FileInfo[]    coverFiles  = dirInfo.GetFiles("*.jpg", SearchOption.TopDirectoryOnly);
                Random        rand        = new Random();
                int           randomIndex = rand.Next(coverFiles.Length);

                if (backgroundWorker.CancellationPending)
                {
                    e.Cancel = true;
                }
                else
                {
                    e.Result = coverFiles[randomIndex].FullName.Replace('\\', '/');
                }
            }
            else
            {
                e.Cancel = true;
            }
        }
示例#2
0
 public SearchHandler(
     LibraryModel libraryModel
     , TabControlEx mainViewTabControl
     , TabPage libraryBrowserViewTabPage
     , TabPage galleryBrowserViewTabPage
     , Configuration.ConfigCache cacheSettings
     , ISearchResultCache searchResultCache
     , ILogger logger
     , BrowsingModel browsingModel
     , IPathFormatter pathFormatter
     , HttpClient httpClient
     , IQueryParser queryParser
     , GalleryModel galleryModel
     , DetailsModel detailsModel
     , GalleryDownloader galleryDownloader)
 {
     LibraryModel              = libraryModel;
     MainViewTabControl        = mainViewTabControl;
     LibraryBrowserViewTabPage = libraryBrowserViewTabPage;
     GalleryBrowserViewTabPage = galleryBrowserViewTabPage;
     CacheSettings             = cacheSettings;
     SearchResultCache         = searchResultCache;
     Logger            = logger;
     BrowsingModel     = browsingModel;
     PathFormatter     = pathFormatter;
     HttpClient        = httpClient;
     QueryParser       = queryParser;
     GalleryModel      = galleryModel;
     DetailsModel      = detailsModel;
     GalleryDownloader = galleryDownloader;
 }
示例#3
0
 public SearchArgTextFormatter(IPathFormatter pathFormatter, MetadataKeywordLists metadataKeywordLists, TagsModel tagsModel, ITokenModifier[] tokenModifiers)
 {
     PathFormatter        = pathFormatter;
     MetadataKeywordLists = metadataKeywordLists;
     TagsModel            = tagsModel;
     TokenModifiers       = tokenModifiers;
 }
示例#4
0
        public WebBrowserToolTip(IPathFormatter pathFormatter, DocumentTemplate <Metadata> galleryTooltipTemplate)
        {
            InitializeComponent();

            Visible = false;

            PathFormatter          = pathFormatter;
            GalleryTooltipTemplate = galleryTooltipTemplate;
            webBrowser             = new WebBrowserEx();
            associatedControls     = new Dictionary <Control, int>();

            SuspendLayout();

            //
            //
            //
            webBrowser.AllowWebBrowserDrop    = false;
            webBrowser.AllowNavigation        = false;
            webBrowser.ScriptErrorsSuppressed = true;
            webBrowser.DocumentCompleted     += WebBrowser_DocumentCompleted;

            //
            //
            //
            Controls.Add(webBrowser);

            ResumeLayout(false);
        }
示例#5
0
 public PageDownloader(HttpClient httpClient, IPathFormatter pathFormatter, ISearchResultCache searchResultCache, ICacheFileSystem cacheFileSystem)
 {
     HttpClient        = httpClient;
     SearchResultCache = searchResultCache;
     PathFormatter     = pathFormatter;
     CacheFileSystem   = cacheFileSystem;
 }
示例#6
0
 public MutatorsTree(ModelConfigurationNode tree, IPathFormatter pathFormatter, IPathFormatterCollection pathFormatterCollection, int priority)
 {
     this.tree = tree;
     this.pathFormatterCollection = pathFormatterCollection;
     this.pathFormatter           = pathFormatter;
     this.priority = priority;
 }
示例#7
0
        public WebBrowserTreeNodeToolTip(IPathFormatter pathFormatter, DocumentTemplate <Metadata> galleryTooltipTemplate)
        {
            InitializeComponent();

            Visible = false;

            PathFormatter          = pathFormatter;
            GalleryTooltipTemplate = galleryTooltipTemplate;
            associatedControls     = new Dictionary <TreeNode, int>();
            observedTreeViews      = new List <TreeView>();
            webBrowser             = new WebBrowserEx();

            SuspendLayout();

            //
            //
            //
            webBrowser.AllowWebBrowserDrop = false;
            //webBrowser.AllowNavigation = false;
            webBrowser.ScriptErrorsSuppressed     = true;
            webBrowser.WebBrowserShortcutsEnabled = false;
            webBrowser.Dock               = DockStyle.Fill;
            webBrowser.Name               = "tooltipWebBrowser";
            webBrowser.TabIndex           = 0;
            webBrowser.DocumentCompleted += WebBrowser_DocumentCompleted;

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

            ResumeLayout(false);
        }
示例#8
0
 public DownloadGalleryRunArg(int galleryId, HttpClient httpClient, IPathFormatter pathFormatter, ISearchResultCache searchResultCache)
 {
     Id                = galleryId;
     HttpClient        = httpClient;
     PathFormatter     = pathFormatter;
     SearchResultCache = searchResultCache;
 }
示例#9
0
 public MetadataTextFormatter(IPathFormatter pathFormatter, string[] languageNames, MetadataKeywordLists metadataKeywordLists, ITokenModifier[] tokenModifiers)
 {
     PathFormatter        = pathFormatter;
     LanguageNames        = languageNames;
     MetadataKeywordLists = metadataKeywordLists;
     TokenModifiers       = tokenModifiers;
 }
示例#10
0
 public DocumentTemplate(string name, bool cacheEnabled, IPathFormatter pathFormatter, Func <string, T, string> formatText)
 {
     Name          = name;
     CacheEnabled  = cacheEnabled;
     PathFormatter = pathFormatter;
     FormatText    = formatText;
 }
示例#11
0
        private AbsolutePath([NotNull][ItemNotNull] IReadOnlyList <string> components, bool isExtended)
        {
            Components      = components;
            this.isExtended = isExtended;

            Formatter = new AbsolutePathFormatter(this);
        }
示例#12
0
        public static AssetResolver BuildTestResolver(
            IBundleLookup bundleLookup   = null,
            IPathFormatter pathFormatter = null,
            IBunderCache cache           = null,
            BunderSettings settings      = null)
        {
            if (bundleLookup == null)
            {
                bundleLookup = new Mock <IBundleLookup>().Object;
            }

            if (pathFormatter == null)
            {
                pathFormatter = new MockPathFormatter();
            }

            if (settings == null)
            {
                settings = new BunderSettings();
            }

            if (cache == null)
            {
                cache = new Mock <IBunderCache>().Object;
            }

            return(new AssetResolver(bundleLookup, pathFormatter, cache, settings));
        }
示例#13
0
 public SessionManager(IPathFormatter pathFormatter, ISearchResultCache searchResultCache, int recentSearchLifeSpan, int querySearchLifeSpan, int taggedSearchLifeSpan)
 {
     PathFormatter        = pathFormatter;
     SearchResultCache    = searchResultCache;
     RecentSearchLifeSpan = recentSearchLifeSpan;
     QuerySearchLifeSpan  = querySearchLifeSpan;
     TaggedSearchLifeSpan = taggedSearchLifeSpan;
 }
 public PathFormatterWrapper(IPathFormatter pathFormatter, IPathFormatter basePathFormatter, ModelConfigurationNode converterTree, CompositionPerformer performer, AliasesResolver resolver)
 {
     this.pathFormatter     = pathFormatter;
     this.basePathFormatter = basePathFormatter;
     this.converterTree     = converterTree;
     this.performer         = performer;
     this.resolver          = resolver;
 }
示例#15
0
 public DownloadCoversRunArg(HttpClient httpClient, IPathFormatter pathFormatter, SearchResult searchResult, MetadataKeywordLists metadataKeywordLists, CoverDownloaderFilters filters)
 {
     HttpClient           = httpClient;
     PathFormatter        = pathFormatter;
     SearchResult         = searchResult;
     MetadataKeywordLists = metadataKeywordLists;
     Filters = filters;
 }
示例#16
0
 public SessionManager(IPathFormatter pathFormatter, ISearchResultCache searchResultCache, int recentSearchLifeSpan, int querySearchLifeSpan, int taggedSearchLifeSpan, ConfigNetwork networkSettings)
 {
     PathFormatter        = pathFormatter;
     SearchResultCache    = searchResultCache;
     RecentSearchLifeSpan = recentSearchLifeSpan;
     QuerySearchLifeSpan  = querySearchLifeSpan;
     TaggedSearchLifeSpan = taggedSearchLifeSpan;
     NetworkSettings      = networkSettings;
 }
示例#17
0
 public SearchProgressArgTextFormatter(IPathFormatter pathFormatter, MetadataKeywordLists metadataKeywordLists, TagsModel tagsModel, MetadataTextFormatter metadataTextFormatter, ITokenModifier[] searchTokenModifiers, DocumentTemplate <Metadata> searchCoverGridItemDocumentTemplate, DocumentTemplate <Metadata> libraryCoverGridItemDocumentTemplate)
 {
     PathFormatter         = pathFormatter;
     MetadataKeywordLists  = metadataKeywordLists;
     TagsModel             = tagsModel;
     MetadataTextFormatter = metadataTextFormatter;
     SearchTokenModifiers  = searchTokenModifiers;
     SearchCoverGridItemDocumentTemplate  = searchCoverGridItemDocumentTemplate;
     LibraryCoverGridItemDocumentTemplate = libraryCoverGridItemDocumentTemplate;
 }
        public FakeSystemChangeEventArgs(WatcherChangeTypes changeType, NotifyFilters filters,
                                         [NotNull] IPathFormatter pathFormatter, [CanBeNull] IPathFormatter previousPathInRenameFormatter)
        {
            Guard.NotNull(pathFormatter, nameof(pathFormatter));

            ChangeType    = changeType;
            Filters       = filters;
            PathFormatter = pathFormatter;
            PreviousPathInRenameFormatter = previousPathInRenameFormatter;
        }
示例#19
0
 public AssetResolver(
     IBundleLookup bundleLookup,
     IPathFormatter pathFormatter,
     IBunderCache cache,
     BunderSettings settings)
 {
     BundleLookup  = bundleLookup;
     PathFormatter = pathFormatter;
     Cache         = cache;
     Settings      = settings;
 }
示例#20
0
        public AbsolutePath([NotNull] string path)
        {
            Guard.NotNull(path, nameof(path));

            var parser = new Parser(path);

            Components           = parser.GetComponents();
            isExtended           = parser.IsExtended;
            HasTrailingSeparator = parser.HasTrailingSeparator;

            Formatter = new AbsolutePathFormatter(this);
        }
示例#21
0
 public BookmarkFormatter(Configuration.ConfigBookmarksList bookmarkListSettings, Configuration.ConfigTagsList tagsListSettings
                          , TagsModel tagsModel
                          , IPathFormatter pathFormatter
                          , ITokenModifier[] tokenModifiers
                          )
 {
     BookmarkListSettings = bookmarkListSettings;
     TagsListSettings     = tagsListSettings;
     TagsModel            = tagsModel;
     PathFormatter        = pathFormatter;
     TokenModifiers       = tokenModifiers;
 }
示例#22
0
 public DownloadPagesRunArg(int galleryId, int[] pageIndices
                            , HttpClient httpClient
                            , IPathFormatter pathFormatter
                            , ISearchResultCache searchResultCache
                            , ICacheFileSystem cacheFileSystem)
 {
     Id                = galleryId;
     PageIndices       = pageIndices;
     HttpClient        = httpClient;
     PathFormatter     = pathFormatter;
     SearchResultCache = searchResultCache;
     CacheFileSystem   = cacheFileSystem;
 }
示例#23
0
 public LibraryLoadRunArg(IPathFormatter pathFormatter, ISearchResultCache searchResultCache, SearchArg searchArg, int numItemsPerPage, string libraryPath
                          , GallerySortType sortType, LibrarySortType globalSortType
                          , SortOrder sortOrder, SortOrder globalSortOrder)
 {
     PathFormatter     = pathFormatter;
     SearchResultCache = searchResultCache;
     SearchArg         = searchArg;
     NumItemsPerPage   = numItemsPerPage;
     LibraryPath       = libraryPath;
     SortType          = sortType;
     GlobalSortType    = globalSortType;
     SortOrder         = sortOrder;
     GlobalSortOrder   = globalSortOrder;
 }
示例#24
0
文件: PluginSystem.cs 项目: NHxD/NHxD
 public PluginSystem(ILogger logger
                     , IPathFormatter pathFormatter
                     , ICacheFileSystem cacheFileSystem
                     , List <IArchiveWriter> archiveWriters
                     , List <IMetadataConverter> metadataConverters
                     , List <IMetadataProcessor> metadataProcessors)
 {
     Logger             = logger;
     PathFormatter      = pathFormatter;
     CacheFileSystem    = cacheFileSystem;
     ArchiveWriters     = archiveWriters;
     MetadataConverters = metadataConverters;
     MetadataProcessors = metadataProcessors;
 }
示例#25
0
        public GalleryDownloaderJob(HttpClient httpClient, IPathFormatter pathFormatter, ISearchResultCache searchResultCache, int galleryId)
        {
            GalleryId         = galleryId;
            HttpClient        = httpClient;
            PathFormatter     = pathFormatter;
            SearchResultCache = searchResultCache;

            BackgroundWorker.WorkerReportsProgress      = true;
            BackgroundWorker.WorkerSupportsCancellation = true;

            BackgroundWorker.DoWork             += DownloadGalleryBackgroundWorker_DoWork;
            BackgroundWorker.ProgressChanged    += DownloadGalleryBackgroundWorker_ProgressChanged;
            BackgroundWorker.RunWorkerCompleted += DownloadGalleryBackgroundWorker_RunWorkerCompleted;
        }
示例#26
0
 private void MoveSingleFile([NotNull] FileEntry sourceFile, [NotNull] DirectoryEntry destinationDirectory,
                             [NotNull] string destinationFileName, [NotNull] IPathFormatter sourcePathFormatter, bool skipNotifyLastAccess)
 {
     if (sourceFile.Parent == destinationDirectory)
     {
         IPathFormatter sourcePathFormatterNonLazy = sourcePathFormatter.GetPath().Formatter;
         sourceFile.Parent.RenameFile(sourceFile.Name, destinationFileName, sourcePathFormatterNonLazy,
                                      skipNotifyLastAccess, true);
     }
     else
     {
         sourceFile.Parent.DeleteFile(sourceFile.Name, true);
         destinationDirectory.MoveFileToHere(sourceFile, destinationFileName, skipNotifyLastAccess, true);
     }
 }
        private void MoveDirectory([NotNull] DirectoryEntry sourceDirectory, [NotNull] DirectoryEntry destinationDirectory,
                                   [NotNull] string destinationDirectoryName, [NotNull] IPathFormatter sourcePathFormatter)
        {
            if (sourceDirectory.Parent == destinationDirectory)
            {
                sourceDirectory.Parent.RenameDirectory(sourceDirectory.Name, destinationDirectoryName, sourcePathFormatter);
            }
            else
            {
                Container.ChangeTracker.NotifyContentsAccessed(destinationDirectory.PathFormatter, FileAccessKinds.Read);

                sourceDirectory.Parent?.DeleteDirectory(sourceDirectory.Name);
                destinationDirectory.MoveDirectoryToHere(sourceDirectory, destinationDirectoryName);
            }
        }
示例#28
0
        public CoverDownloaderJob(HttpClient httpClient, IPathFormatter pathFormatter, MetadataKeywordLists metadataKeywordLists, SearchResult searchResult, CoverDownloaderFilters filters)
        {
            HttpClient           = httpClient;
            PathFormatter        = pathFormatter;
            SearchResult         = searchResult;
            MetadataKeywordLists = metadataKeywordLists;
            Filters = filters;

            BackgroundWorker.WorkerReportsProgress      = true;
            BackgroundWorker.WorkerSupportsCancellation = true;

            BackgroundWorker.DoWork             += DownloadCoverBackgroundWorker_DoWork;
            BackgroundWorker.ProgressChanged    += DownloadCoverBackgroundWorker_ProgressChanged;
            BackgroundWorker.RunWorkerCompleted += DownloadCoverBackgroundWorker_RunWorkerCompleted;
        }
示例#29
0
        public void RenameDirectory([NotNull] string sourceDirectoryName, [NotNull] string destinationDirectoryName,
                                    [NotNull] IPathFormatter sourcePathFormatter)
        {
            Guard.NotNullNorWhiteSpace(sourceDirectoryName, nameof(sourceDirectoryName));
            Guard.NotNullNorWhiteSpace(destinationDirectoryName, nameof(destinationDirectoryName));
            Guard.NotNull(sourcePathFormatter, nameof(sourcePathFormatter));

            DirectoryEntry directory = contents.RemoveDirectory(sourceDirectoryName);

            directory.Name = destinationDirectoryName;
            contents.Add(directory);

            HandleDirectoryContentsAccessed();
            ChangeTracker.NotifyDirectoryRenamed(sourcePathFormatter, directory.PathFormatter);
            HandleDirectoryContentsChanged(false);
        }
示例#30
0
        public PageDownloaderJob(HttpClient httpClient, IPathFormatter pathFormatter, ISearchResultCache searchResultCache, ICacheFileSystem cacheFileSystem, int galleryId, int[] pageIndices)
        {
            HttpClient        = httpClient;
            PathFormatter     = pathFormatter;
            SearchResultCache = searchResultCache;
            CacheFileSystem   = cacheFileSystem;
            GalleryId         = galleryId;
            PageIndices       = pageIndices;

            BackgroundWorker.WorkerReportsProgress      = true;
            BackgroundWorker.WorkerSupportsCancellation = true;

            BackgroundWorker.DoWork             += DownloadPagesBackgroundWorker_DoWork;
            BackgroundWorker.ProgressChanged    += DownloadPagesBackgroundWorker_ProgressChanged;
            BackgroundWorker.RunWorkerCompleted += DownloadPagesBackgroundWorker_RunWorkerCompleted;
        }
示例#31
0
 public Aria2cFinder(Aria2cConfig config, IPathFormatter formatter = null)
 {
     _config = config;
     _formatter = formatter ?? new DefaultPathFormatter();
 }