Ejemplo n.º 1
0
 public void ResetVisual()
 {
     ImageItemsWrapPanel.Children.Clear();
     ImageLoadingPool.Clear();
     ImageWaitForLoadingPool.Clear();
     SelectedImageControls.Clear();
     ImageItemsScrollViewer.ScrollToTop();
 }
Ejemplo n.º 2
0
 private void ItemOnImageLoaded(ImageControl obj)
 {
     ImageLoadingPool.Remove(obj);
     if (ImageWaitForLoadingPool.Any())
     {
         var item = ImageWaitForLoadingPool[0];
         ImageWaitForLoadingPool.Remove(item);
         ImageLoadingPool.Add(item);
         item.ImageLoadEnd += ItemOnImageLoaded;
         var unused = item.LoadImageAndDetailTask();
     }
 }
Ejemplo n.º 3
0
        private void ItemOnImageLoaded(ImageControl obj)
        {
            ImageLoadingPool.Remove(obj);
            if (ImageLoadingPool.Count == 0) // all image loaded
            {
                App.ShowMessage("图片加载完毕", 1);
            }
            else
            {
                var remain = ImageLoadingPool.Count + ImageWaitForLoadingPool.Count;
                App.ShowMessage($"剩余 {remain} 张图片等待加载", 1);
            }

            if (ImageWaitForLoadingPool.Count > 0)
            {
                var item = ImageWaitForLoadingPool[0];
                ImageWaitForLoadingPool.Remove(item);
                ImageLoadingPool.Add(item);
                item.ImageLoadEnd += ItemOnImageLoaded;
                var unused = item.LoadImageAsync();
            }
        }
Ejemplo n.º 4
0
        public void LoadImages(ImageItems items)
        {
            ResetVisual();
            foreach (var item in items)
            {
                var itemctrl = new ImageControl(Settings, item);

                itemctrl.DownloadButton.Click += (sender, args)
                                                 => ImageItemDownloadButtonClicked?.Invoke(itemctrl.ImageItem, itemctrl.PreviewImage.Source);
                itemctrl.MouseEnter              += (sender, args) => MouseOnImageControl = itemctrl;
                itemctrl.ImageCheckBox.Checked   += (sender, args) => SelectedImageControls.Add(itemctrl);
                itemctrl.ImageCheckBox.Unchecked += (sender, args) => SelectedImageControls.Remove(itemctrl);
                ImageItemsWrapPanel.Children.Add(itemctrl);
                if (ImageLoadingPool.Count < Settings.MaxOnLoadingImageCount)
                {
                    ImageLoadingPool.Add(itemctrl);
                }
                else
                {
                    ImageWaitForLoadingPool.Add(itemctrl);
                }
            }
        }
Ejemplo n.º 5
0
 public void AddImages(MoeItems imgs)
 {
     foreach (var img in imgs)
     {
         var itemCtrl = new ImageControl(Settings, img);
         itemCtrl.DownloadButton.Click    += (sender, args) => { ImageItemDownloadButtonClicked?.Invoke(itemCtrl.ImageItem, itemCtrl.PreviewImage.Source); };
         itemCtrl.PreviewButton.Click     += (sender, args) => { MoeItemPreviewButtonClicked?.Invoke(itemCtrl.ImageItem, itemCtrl.PreviewImage.Source); };
         itemCtrl.MouseEnter              += (sender, args) => MouseOnImageControl = itemCtrl;
         itemCtrl.ImageCheckBox.Checked   += (sender, args) => SelectedImageControls.Add(itemCtrl);
         itemCtrl.ImageCheckBox.Unchecked += (sender, args) => SelectedImageControls.Remove(itemCtrl);
         ImageItemsWrapPanel.Children.Add(itemCtrl);
         itemCtrl.Sb("ShowSb").Begin();
         if (ImageLoadingPool.Count < Settings.MaxOnLoadingImageCount)
         {
             ImageLoadingPool.Add(itemCtrl);
         }
         else
         {
             ImageWaitForLoadingPool.Add(itemCtrl);
         }
         itemCtrl.MouseRightButtonUp += ItemCtrlOnMouseRightButtonUp;
     }
 }