/// <summary> /// 展示图片 /// </summary> /// <param name="goodsNo"></param> private void ShowImages(int goodsNo) { //清空控件 //LvImg.Items.Clear(); LvImg.ItemsSource = null; //清空绑定 //图片文件夹不存在 var path = Path.Combine("Goods", goodsNo + ""); if (!Directory.Exists(path)) { return; } //TODO 判断文件的扩展名 //获取图片列表 var files = Directory.GetFiles(path); var imgList = new ObservableCollection <ImgShow>(); foreach (var file in files) { var ext = Path.GetExtension(file); if (ext != ".jpg" && ext != ".png") { continue; } var fs = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, file); var bytes = File.ReadAllBytes(fs); var mem = new MemoryStream(bytes); var bmp = new BitmapImage() { }; bmp.BeginInit(); bmp.StreamSource = mem; bmp.EndInit(); var dt = new ImgShow { Image = bmp, Title = file }; imgList.Add(dt); } LvImg.ItemsSource = imgList; }
/// <summary> /// 初始化页面 /// </summary> /// <param name="site"></param> /// <returns></returns> public async void InitiallyImgs() { MainWindow.dataLib.IsLoadingProgressBar = Visibility.Visible; List <Post> posts = new List <Post>(); await Task.Run(() => { posts = booruClient.GetPost(); }); //CommonData.CurrentPreImgDownloadCount = posts.Count; for (int i = 0; i < posts.Count; i++) { await Task.Run(() => { Application.Current.Dispatcher.Invoke(new Action(() => { ImgShow imgShow = new ImgShow(posts[i].preview_url, posts[i].id, posts[i].preview_width, posts[i].preview_height); })); }); } MainWindow.dataLib.IsLoadingProgressBar = Visibility.Collapsed; }
public async void SearchPost(int page, string tags) { List <string> tagsList = new List <string>(); foreach (var item in tags.Split(' ')) { tagsList.Add(item); } List <Post> posts = new List <Post>(); await Task.Run(() => { posts = booruClient.GetPost(page, tagsList); //CommonData.PostCount = booruClient.GetPageCount(tagsList); //while (true) //{ // if (CommonData.CurrentPreImgDownloadCount == 0) // { // CommonData.CurrentPreImgDownloadCount = posts.Count; // break; // } // else // { // Thread.Sleep(1000); // } //} }); for (int i = 0; i < posts.Count; i++) { await Task.Run(() => { Application.Current.Dispatcher.Invoke(new Action(() => { ImgShow imgShow = new ImgShow(posts[i].preview_url, posts[i].id, posts[i].preview_width, posts[i].preview_height); })); }); } MainWindow.dataLib.IsLoadingProgressBar = Visibility.Collapsed; }
public static Panel GetEditColumn(string ShowType, Column c, string v) { if (ShowType == EditShowType.picUpload.ToString()) { ImgShow show = new ImgShow(c, v); return(show.Panel); } else if (ShowType == EditShowType.CheckList.ToString() || ShowType == EditShowType.DropDownList.ToString() || ShowType == EditShowType.RadioList.ToString()) { FkShow show = new FkShow(c, v); return(show.Panel); } else if (ShowType == EditShowType.Hidden.ToString()) { HideFK show = new HideFK(c, v); return(show.Panel); } else { TextShow show = new TextShow(c, v); return(show.Panel); } }