// METHODS private void GetViewerCarouselImageList(string path) { try { ImageList ilist = new ImageList(); CarouselImageCollection icollect = ViewerCarousel.ImageListCollection; ViewerCarousel.ImageSlides = true; ViewerCarousel.UseOriginalImageinPreview = true; string[] images = Directory.GetFiles(path); FilePath = path; foreach (string i in images) { string p = Path.GetFileNameWithoutExtension(i); Bitmap b = new Bitmap(i); b.Tag = p; CarouselImage c = new CarouselImage(); c.ItemImage = b; ilist.Images.Add(b); icollect.Add(c); } ViewerCarousel.ImageList = ilist; } catch (Exception ex) { new Error(ex).ShowDialog(); } }
private void GetAppropriationCarouselImageList(string path) { try { ImageList ilist = new ImageList(); CarouselImageCollection icollect = AppropriationCarousel.ImageListCollection; AppropriationCarousel.ImageSlides = true; AppropriationCarousel.UseOriginalImageinPreview = true; string[] images = Directory.GetFiles(path); foreach (string i in images) { Bitmap b = new Bitmap(i); b.Tag = i; CarouselImage c = new CarouselImage(); c.ItemImage = b; ilist.Images.Add(b); icollect.Add(c); } AppropriationCarousel.ImageList = ilist; } catch (Exception e) { new Error(e).ShowDialog(); } }
public override ActionResult Index(CarouselBlock currentBlock) { var model = new CarouselBlockViewModel(currentBlock); foreach (var item in _contentLoader.GetItems(currentBlock.CarouselItems, _languageResolver.GetPreferredCulture())) { if (item.GetOriginalType().Equals(typeof(ImageMediaData))) { var image = _contentLoader.Get <ImageMediaData>(item.ContentLink); var carouselImage = new CarouselImage() { Heading = image.Title, Description = image.Description, Image = image.ContentLink }; model.Items.Add(new CarouselItem() { CarouselImage = carouselImage }); } else if (item.GetOriginalType().Equals(typeof(HeroBlock))) { var heroBlock = _contentLoader.Get <HeroBlock>(item.ContentLink); model.Items.Add(new CarouselItem() { HeroBlock = new BlockViewModel <HeroBlock>(heroBlock) }); } } return(PartialView("~/Features/Blocks/Views/CarouselBlock.cshtml", model)); }
private async void Convert_Click(object sender, RoutedEventArgs e) { FileOpenPicker fileOpenPicker = new FileOpenPicker(); fileOpenPicker.SuggestedStartLocation = PickerLocationId.PicturesLibrary; fileOpenPicker.FileTypeFilter.Add(".jpg"); fileOpenPicker.ViewMode = PickerViewMode.Thumbnail; StorageFile inputFile = await fileOpenPicker.PickSingleFileAsync(); if (inputFile == null) { // The user cancelled the picking operation return; } SoftwareBitmap softwareBitmap; using (IRandomAccessStream stream = await inputFile.OpenAsync(FileAccessMode.Read)) { // Create the decoder from the stream BitmapDecoder decoder = await BitmapDecoder.CreateAsync(stream); // Get the SoftwareBitmap representation of the file softwareBitmap = await decoder.GetSoftwareBitmapAsync(); } var bitmap = softwareBitmap; var imgSource = new WriteableBitmap(bitmap.PixelWidth, bitmap.PixelHeight); bitmap.CopyToBuffer(imgSource.PixelBuffer); byte[] dataArrayTobeSent = await ConvertImageToByte(inputFile); imageName = Guid.NewGuid() + inputFile.FileType; imageData = dataArrayTobeSent; TravelListItemImage liImage = new TravelListItemImage() { ImageData = imageData, ImageName = imageName, }; CarouselImage cImage = await ViewModel.ConvertImageTask(liImage); cImage.IsNew = true; ViewModel.imageChanges.Add(cImage); ViewModel.ImageChangesCheck = new List <CarouselImage>(ViewModel.imageChanges); cImages.Add(cImage); }
// METHODS private void GetFunctionCarouselImageList(string path) { ImageList ilist = new ImageList(); CarouselImageCollection icollect = FunctionCarousel.ImageListCollection; FunctionCarousel.ImageSlides = true; FunctionCarousel.UseOriginalImageinPreview = true; string[] images = Directory.GetFiles(path); foreach (string i in images) { string p = Path.GetFileNameWithoutExtension(i); Bitmap b = new Bitmap(i); b.Tag = p; CarouselImage c = new CarouselImage(); c.ItemImage = b; ilist.Images.Add(b); icollect.Add(c); } FunctionCarousel.ImageList = ilist; }
private void DeleteImageAppBar_Click(object sender, Windows.UI.Xaml.RoutedEventArgs e) { var button = sender as Button; var ImageName = button.Tag; CarouselImage imageToDelete = cImages.First(image => image.ImageName.Equals(ImageName)); if (imageToDelete != null) { imageToDelete.ToRemove = true; if (imageToDelete.IsNew) { ViewModel.imageChanges.Remove(imageToDelete); } else if (imageToDelete.TravelListItemImageID > 0) { ViewModel.imageChanges.Add(imageToDelete); } ViewModel.ImageChangesCheck = new List <CarouselImage>(ViewModel.imageChanges); cImages.Remove(imageToDelete); } }
public override ActionResult Index(CarouselBlock currentBlock) { var model = new CarouselBlockViewModel(currentBlock); if (currentBlock.CarouselItems != null) { foreach (var contentAreaItem in currentBlock.CarouselItems.FilteredItems) { var carouselItem = _contentLoader.Get <IContentData>(contentAreaItem.ContentLink); if (carouselItem is ImageMediaData) { var carouselImage = new CarouselImage() { Heading = ((ImageMediaData)carouselItem).Title, Description = ((ImageMediaData)carouselItem).Description, Image = ((ImageMediaData)carouselItem).ContentLink }; model.Items.Add(new CarouselItem() { CarouselImage = carouselImage }); } else if (carouselItem is HeroBlock) { model.Items.Add(new CarouselItem() { HeroBlock = new BlockViewModel <HeroBlock>((HeroBlock)carouselItem) }); } } } return(PartialView("~/Features/Blocks/Views/CarouselBlock.cshtml", model)); }
public IEnumerator NewSearch(string query) { //remove the old images Carousel.GetComponent <Carousel>().Clear(); //get the data from the api query = query.Replace(' ', '+'); string url = "https://maps.googleapis.com/maps/api/place/textsearch/json?query=" + query + "&key=AIzaSyAYQhMIz-fDmymfvuez8xpwDPgNN7e7xw8"; WWW response = new WWW(url); yield return(response); //print(response.text); //create json object from the response json text JObject JsonResponse = JObject.Parse(response.text); //continue if we got good data if (JsonResponse["status"] != null && JsonResponse["status"].Value <string>() == "OK") { //find out how many images we will show in the carousel int counter = 0; int imageCount = Carousel.GetComponent <Carousel>().MaxImages; if (JsonResponse["results"].HasValues) { int count = JsonResponse["results"].Count(); if (count < imageCount) { imageCount = count; } } //fill the carousel with the results foreach (JToken result in JsonResponse["results"]) { counter++; if (counter <= imageCount) { //create carousel image object GameObject newObj = GameObject.Instantiate(CarouselImagePrefab); CarouselImage carouselImageScript = newObj.GetComponent <CarouselImage>(); newObj.GetComponent <LookAtTargetAxis>().SetTarget(Carousel.transform); newObj.GetComponent <LookAtTargetAxis>().SetOverwriteTarget(LookAtOverwriteTarget.transform); string title = ""; string description = ""; string photo = ""; int height = 0; int width = 0; //get the title if (result["name"] != null) { title = result["name"].Value <string>(); } //get some description if (result["formatted_address"] != null) { description += "Adress:\n\n" + result["formatted_address"].Value <string>() + "\n\n"; } if (result["opening_hours"] != null && result["opening_hours"].HasValues) { description += "Open?\n\n"; if (result["opening_hours"]["open_now"].Value <bool>()) { description += "Yes"; } else { description += "No"; } description += "\n\n"; } if (result["rating"] != null) { description += "Rating:\n\n" + result["rating"].Value <float>(); } //get the reference string of the first photo if (result["photos"] != null && result["photos"].HasValues) { JToken jsonPhoto = result["photos"].First; photo = jsonPhoto["photo_reference"].Value <string>(); height = jsonPhoto["height"].Value <int>(); width = jsonPhoto["width"].Value <int>(); } //send the data to the carousel image object carouselImageScript.SetVariables(title, description, photo, height, width); //set it at the correct position in the carousel newObj.transform.parent = Carousel.transform; double distanceFromCenter = 2.3; double angle = (Math.PI * 2 / imageCount) * (counter - 1); double x = Math.Cos(angle) * distanceFromCenter; double y = Math.Sin(angle) * distanceFromCenter; newObj.transform.localPosition = new Vector3((float)x, 0, (float)y); //add the image object to the carousel Carousel.GetComponent <Carousel>().CarouselImages.Add(newObj); } } } }