public async Task TakePicture() { if (!CrossMedia.Current.IsCameraAvailable || !CrossMedia.Current.IsTakePhotoSupported) { await Application.Current.MainPage.DisplayAlert("No Camera", "Sorry! No camera available.", "OK"); return; } var file = await CrossMedia.Current.TakePhotoAsync(new Plugin.Media.Abstractions.StoreCameraMediaOptions { Directory = "TestPhotoFolder", SaveToAlbum = true, PhotoSize = PhotoSize.Medium, }); if (file == null) { IsVisible = false; return; } this.Source = ImageSource.FromStream(() => { var stream = file.GetStream(); return(stream); }); ListImage.Add(Source); }
private void DownloadImage(ListImage imageControl, string folderName, int index) { BitmapEncoder encoder = null; switch (imageControl.ImageType.ToUpper()) { case ".JPG": encoder = new JpegBitmapEncoder(); break; case ".PNG": encoder = new PngBitmapEncoder(); break; case ".BMP": encoder = new BmpBitmapEncoder(); break; } encoder.Frames.Add(BitmapFrame.Create((BitmapSource)imageControl.Image)); using (System.IO.FileStream stream = new System.IO.FileStream(index.ToString() + imageControl.ImageType, System.IO.FileMode.Create)) { encoder.Save(stream); } //这里因为已经显示在界面上了,所以直接拿控件内容保存 //对于直接下载的情况,可以使用这个函数 //WebUtil.DownloadFileAsync(); }
public ActionResult Detail(int?id) { ProductDetailViewModel model = new ProductDetailViewModel(); model.product = db.Products.Find(id); var cate = db.Categories.Find(model.product.CategoryID); model.CategoryName = cate.CategoryName; model.CategoryLink = "/san-pham/" + cate.SEOUrlRewrite + "-" + cate.CategoryID; model.listimage = db.ProductImages.Where(q => q.ProductID == id).Select(s => new ListImage { ImageURL = s.URLImage, URLThumb = s.ImagesThumb }).ToList(); model.relate = db.Products.Where(q => q.IsActive == true && q.ProductID != id && q.IsProduct == true && q.CategoryID == cate.CategoryID).ToList(); model.upsell = db.Products.Where(q => q.IsActive == true && q.ProductID != id && q.IsProduct == true).ToList(); ListImage l = new ListImage(); l.URLThumb = model.product.ImagesThumb; l.ImageURL = model.product.Images; model.listimage.Add(l); AddList(model.product); return(View(model)); }
private void AddReview() { ReviewItem = new Reviews(); ReviewItem.Rate = Rate; ReviewItem.Avatar = "dragonGray.png"; ReviewItem.Content = Content; var listItem = new List <ImageReview>(); foreach (var item in ListImage) { listItem.Add(new ImageReview() { ImageContent = item }); } ReviewItem.ListImage = listItem; var navigationParams = new DialogParameters(); navigationParams.Add("reviews", ReviewItem); RequestClose.Invoke(navigationParams); ListImage.Clear(); IsInvisible = false; IsVisible = false; }
public MainViewModel() { List <ListItem> items = new List <ListItem>(); ListImage listImage = new ListImage(); listImage.ImageUrls = new ObservableCollection <string>(); listImage.ImageUrls.Add("file://c1.jpg"); listImage.ImageUrls.Add("file://c2.jpg"); listImage.ImageUrls.Add("file://c3.jpg"); items.Add(listImage); initLabelText(20, items); ListItems = new ObservableCollection <ListItem>(items); }
// tao list ListImage public ActionResult List() { List <ListImage> list = new List <ListImage>(); for (int i = 0; i <= 10; i++) { ListImage ListImage = new ListImage(); ListImage.ID = i; ListImage.ID_CuonSach = i + 2; ListImage.link = " link" + i; list.Add(ListImage); } return(View(list)); }
public ActionResult Add(ImageAddViewModel model) { string path = Server.MapPath(ConfigurationManager.AppSettings["ImagesPath"]); var imageName = Guid.NewGuid().ToString() + ".jpg"; model.Image.SaveAs(path + imageName); ListImage image = new ListImage() { Name = imageName }; _context.ListImages.Add(image); _context.SaveChanges(); return(RedirectToAction("Index")); }
private void btn_Download_Click(object sender, RoutedEventArgs e) { System.Windows.Forms.FolderBrowserDialog folderDialog = new System.Windows.Forms.FolderBrowserDialog(); folderDialog.SelectedPath = Environment.CurrentDirectory; if (folderDialog.ShowDialog() == System.Windows.Forms.DialogResult.OK) { for (int i = 0; i < grid_Content.Children.Count; i++) { ListImage liImage = grid_Content.Children[i] as ListImage; if (liImage != null) { DownloadImage(liImage, folderDialog.SelectedPath, i); } } ShowStatusText("保存图像完成"); } }
private void btnSelectExam_Click(object sender, RoutedEventArgs e) { if (listPlace == null || listPlace.SelectedItem == null) { MessageBox.Show("请先选择活动区域", "消息提示", MessageBoxButton.OK, MessageBoxImage.Warning); return; } ActivityPlaceInfo place = listPlace.SelectedItem as ActivityPlaceInfo; string selectPlaceGuid = place.Guid; SelectExamPlaceDialog form = new SelectExamPlaceDialog(); form.OnGetDataEvent += (datas) => { ActivityPlaceLocation[] locations = dg_LocationList.ItemsSource as ActivityPlaceLocation[]; List <ActivityPlaceLocation> listLocation = locations.ToList(); for (int i = 0; i < datas.Count(); i++) { ActivityPlaceLocation newLocation = new ActivityPlaceLocation(); newLocation.GUID = datas[i].Guid; newLocation.ActivityPlaceGuid = place.Guid; newLocation.LocationName = datas[i].Name; newLocation.LocationLA = Convert.ToDouble(datas[i].Location_la); newLocation.LocationLG = Convert.ToDouble(datas[i].Location_lg); newLocation.Remark = datas[i].Phone; newLocation.activityPlaceLocationImage = datas[i].Images; listLocation.Add(newLocation); ListImage listImage = new ListImage(); listImage.locationGuid = datas[i].Guid; listImage.listAPLImage = datas[i].Images; //ActivityManageImage.listImage.Add(listImage); } locations = listLocation.ToArray(); this.dg_LocationList.ItemsSource = locations; }; form.ShowDialog(); }
public void ShowImage(ObservableCollection <UrlStruct> list) { int count = list.Count; this.Dispatcher.Invoke(() => { this.grid_Content.Children.Clear(); }); for (int i = 0; i < count; i++) { this.Dispatcher.Invoke(() => { ListImage image = new ListImage(); image.Width = 370; image.Height = 370; image.Margin = new Thickness(10); image.Text = ""; image.Image = new BitmapImage(new Uri(list[i].Url)); grid_Content.Children.Add(image); }); } }
private void DeleteImage(ImageSource obj) { var img = ListImage.Where(a => a == obj).FirstOrDefault(); ListImage.Remove(img); if (ListImage.Count == 0) { IsVisible = false; } if (ListImage.Count > 0) { IsVisible = true; } if (ListImage.Count > 1) { IsInvisible = false; } }
public override LearningImage BackProject(LearningImage i) { int Scale = this.Scale; ListImage li = new ListImage(i.Height * Scale + Height, i.Width * Scale + Width); for (int h = 0; h < i.Height; h++) { for (int w = 0; w < i.Width; w++) { LearningImage trimed = i.Trim(new Rectangle(w, h, 1, 1)); LearningImage pasting = base.BackProject(trimed); for (int hh = 0; hh < pasting.Height; hh++) for (int ww = 0; ww < pasting.Width; ww++) li.Add(h * Scale + hh, w * Scale + ww, pasting.GetPlane(hh, ww)); } } LearningImage o = new LearningImage(i.Height * Scale, i.Width * Scale, this.FrameIn.Plane); for (int h = 0; h < o.Height; h++) for (int w = 0; w < o.Width; w++) o.SetPlane(h, w, li.Median(h + Height / 2, w + Width / 2)); return o; }
public PartialViewResult GetQuickView(int?id) { QuickViewModel model = new QuickViewModel(); model.listimage = db.ProductImages.Where(q => q.ProductID == id).Select(s => new ListImage { ImageURL = s.URLImage, URLThumb = s.ImagesThumb }).ToList(); model.product = db.Products.Find(id); ListImage l = new ListImage(); l.URLThumb = model.product.ImagesThumb; l.ImageURL = model.product.Images; model.listimage.Add(l); return(PartialView("_quickview", model)); }
public async Task GetPhoto() { if (!CrossMedia.Current.IsTakePhotoSupported) { return; } var file = await CrossMedia.Current.PickPhotoAsync(new PickMediaOptions { PhotoSize = PhotoSize.Medium, }); if (file == null) { IsVisible = false; return; } this.Source = ImageSource.FromStream(() => { var stream = file.GetStream(); return(stream); }); ListImage.Add(Source); }
public ActionResult Create(ListImage _ListImage) { return(RedirectToAction("List")); }
// xoa ListImage duoc chon public ActionResult Delete(int id) { ListImage ListImage = new ListImage(id, 2, "link "); return(View(ListImage)); }
public ActionResult Delete(ListImage ListImage) { return(RedirectToAction("List")); }
private void btnSelectExam_Click(object sender, RoutedEventArgs e) { if (listPlace == null || listPlace.SelectedItem == null) { MessageBox.Show("请先选择区域", "消息提示", MessageBoxButton.OK, MessageBoxImage.Warning); return; } ActivityPlaceInfo _placeInfo = (ActivityPlaceInfo)grdPlace.DataContext; string guids = ""; if (_placeInfo != null) { foreach (ActivityPlaceLocation location in _placeInfo.Locations) { guids += "'" + location.RiasExamplaceGuid + "',"; } } if (guids.Length > 0) { guids = guids.Substring(0, guids.Length - 1); } ActivityPlaceInfo place = listPlace.SelectedItem as ActivityPlaceInfo; string selectPlaceGuid = place.Guid; SelectExamPlaceDialog form = new SelectExamPlaceDialog(guids); form.OnGetDataEvent += (datas) => { ActivityPlaceLocation[] locations = dg_LocationList.ItemsSource as ActivityPlaceLocation[]; List <ActivityPlaceLocation> listLocation = new List <ActivityPlaceLocation>(); if (locations != null) { listLocation = locations.ToList(); } for (int i = 0; i < datas.Count(); i++) { string locationGuid = Utility.NewGuid(); ActivityPlaceLocation newLocation = new ActivityPlaceLocation(); //newLocation.GUID = datas[i].Guid; newLocation.GUID = locationGuid; newLocation.ActivityPlaceGuid = place.Guid; newLocation.LocationName = datas[i].Name; newLocation.LocationLA = Convert.ToDouble(datas[i].Location_la); newLocation.LocationLG = Convert.ToDouble(datas[i].Location_lg); newLocation.Remark = datas[i].Phone; newLocation.activityPlaceLocationImage = datas[i].Images; newLocation.RiasExamplaceGuid = datas[i].Guid; listLocation.Add(newLocation); ListImage listImage = new ListImage(); //listImage.locationGuid = datas[i].Guid; listImage.locationGuid = locationGuid; //更换图片的guid,防止插入的逐渐冲突 for (int n = 0; n < datas[i].Images.Count(); n++) { datas[i].Images[n].ACTIVITY_PLACE_LOCATION_GUID = locationGuid; datas[i].Images[n].GUID = Utility.NewGuid(); } listImage.listAPLImage = datas[i].Images; //ActivityManageImage.listImage.Add(listImage); } locations = listLocation.ToArray(); this.dg_LocationList.ItemsSource = locations; }; form.ShowDialog(); }