Exemplo n.º 1
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();
            }
        }
Exemplo n.º 2
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);
                }
            }
        }