Esempio n. 1
0
        private void ShowMarkPicturesButton_Click(object sender, RoutedEventArgs e)
        {
            if (GridViewer.ViewType == GalleryViewType.Marked)
            {
                return;
            }

            var galleries = (CurrentGallery != null ? new[] { CurrentGallery } : Container.Default.GetExportedValues <Gallery>()).Select(x => x.GalleryName).ToArray();

            var online_mark_feature = CurrentGallery?.Feature <IGalleryMark>();

            var source = new Func <IEnumerable <GalleryItem> >(() => (online_mark_feature?.GetMarkedGalleryItem()) ?? LocalDBContext.Instance.ItemMarks
                                                               .Select(x => new { gallery = galleries.FirstOrDefault(y => y == x.Item.GalleryName), gallery_item = x })
                                                               .Where(x => x.gallery != null)
                                                               .ToArray()//avoid SQL.
                                                               .Select(x => x.gallery_item.Item.ConvertToNormalModel()));


            GalleryTitle        = (CurrentGallery != null ? $"{CurrentGallery.GalleryName}的" : "") + (online_mark_feature != null?"在线":"本地") + "收藏列表";
            GridViewer.ViewType = GalleryViewType.Marked;
            GridViewer.ClearGallery();
            GridViewer.Gallery = null;
            GridViewer.LoadableSourceFactory = source;

            CloseLeftPanel();
        }
Esempio n. 2
0
        public void ApplyGallery(Gallery gallery, IEnumerable <string> keywords = null)
        {
            Func <IEnumerable <GalleryItem> > items_source_creator;

            if (keywords?.Any() ?? false)
            {
                GridViewer.ViewType  = GalleryViewType.SearchResult;
                items_source_creator = new Func <IEnumerable <GalleryItem> >(() => gallery.TryFilterIfNSFWEnable(gallery.Feature <IGallerySearchImage>().SearchImages(keywords).MakeMultiThreadable()));
                GalleryTitle         = $"{gallery.GalleryName} ({string.Join(" ", keywords)})";
                ShowReturnButton     = true;
            }
            else
            {
                GridViewer.ViewType  = GalleryViewType.Main;
                items_source_creator = new Func <IEnumerable <GalleryItem> >(() => gallery.TryFilterIfNSFWEnable(gallery.GetMainPostedImages().MakeMultiThreadable()));
                GalleryTitle         = gallery.GalleryName;
                ShowReturnButton     = false;
            }

            CurrentGallery = gallery;

            GridViewer.ClearGallery();
            GridViewer.Gallery = gallery;
            GridViewer.LoadableSourceFactory = items_source_creator;

            UpdateAccountButtonText();
        }
Esempio n. 3
0
        public async void ApplyGallery(Gallery gallery, IEnumerable <string> keywords = null)
        {
            Func <IEnumerable <GalleryItem> > items_source_creator;

            if (keywords?.Any() ?? false)
            {
                GridViewer.ViewType  = GalleryViewType.SearchResult;
                items_source_creator = new Func <IEnumerable <GalleryItem> >(() => gallery.TryFilterIfNSFWEnable(gallery.Feature <IGallerySearchImage>().SearchImages(keywords).MakeMultiThreadable()));
                GalleryTitle         = $"{gallery.GalleryName} ({string.Join(" ", keywords)})";
                ShowReturnButton     = true;
            }
            else
            {
                GridViewer.ViewType  = GalleryViewType.Main;
                items_source_creator = new Func <IEnumerable <GalleryItem> >(() => gallery.TryFilterIfNSFWEnable(gallery.GetMainPostedImages().MakeMultiThreadable()));
                GalleryTitle         = gallery.GalleryName;
                ShowReturnButton     = false;
            }

            CurrentGallery = gallery;
            SettingManager.LoadSetting <GlobalSetting>().RememberLastViewedGalleryName = gallery.GalleryName;

            GridViewer.ClearGallery();
            GridViewer.Gallery = gallery;
            GridViewer.LoadableSourceFactory = items_source_creator;

            if (gallery.SupportFeatures.HasFlag(GallerySupportFeature.Account))
            {
                await TryAutoLogin(gallery);
            }

            UpdateAccountButtonText();

            Log.Info($"Switch main page gallery:{gallery.GalleryName}");
        }
Esempio n. 4
0
        private void ShowHistoryButton_Click(object sender, RoutedEventArgs e)
        {
            if (GridViewer.ViewType == GalleryViewType.History)
            {
                return;
            }

            var galleries = (CurrentGallery != null ? new[] { CurrentGallery } : Container.Default.GetExportedValues <Gallery>()).Select(x => x.GalleryName).ToArray();

            var source = new Func <IEnumerable <GalleryItem> >(() => LocalDBContext.Instance.VisitRecords.OrderByDescending(x => x.LastVisitTime).Select(x => x.GalleryItem)
                                                               .Select(x => new { gallery = galleries.FirstOrDefault(y => y == x.GalleryName), gallery_item = x })
                                                               .Where(x => x.gallery != null)
                                                               .ToArray()//avoid SQL.
                                                               .Select(x => x.gallery_item.ConvertToNormalModel()));


            GalleryTitle        = "历史浏览记录";
            GridViewer.ViewType = GalleryViewType.History;
            GridViewer.ClearGallery();
            GridViewer.Gallery = null;
            GridViewer.LoadableSourceFactory = source;

            CloseLeftPanel();
        }