private void Files_CollectionChanged(object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e) { if (Media.Count == 0) { MediaList.Clear(); return; } if (e.NewItems.Count == 0) { return; } var file = e.NewItems[0] as MediaFile; var image = new CachedImage { WidthRequest = 300, HeightRequest = 300, Aspect = Aspect.AspectFit }; //image.Source = ImageSource.FromFile(file.Path); image.Source = ImageSource.FromStream(() => { var stream = file.GetStream(); return(stream); }); var imgBytes = ImageSourceToByteArray(image.Source); MediaList.Add(new Photo() { FilePath = file.Path, ImageSrc = image.Source, ImageBytes = imgBytes, ImageBase64 = Convert.ToBase64String(imgBytes) }); //var image2 = new CachedImage { WidthRequest = 300, HeightRequest = 300, Aspect = Aspect.AspectFit }; //image2.Source = ImageSource.FromFile(file.Path); //ImageList.Children.Add(image2); }
public Entry(XmlElement element) { Id = Util.ChildValue(element, "id"); Title = Util.ChildValue(element, "title"); Link = Util.ChildValue(element, "link"); Published = DateTime.Parse(Util.ChildValue(element, "published")); Updated = DateTime.Parse(Util.ChildValue(element, "updated")); User = new User(Util.ChildElement(element, "user")); Service = new Service(Util.ChildElement(element, "service")); Comments = new CommentList(); foreach (XmlElement child in element.GetElementsByTagName("comment")) { Comments.Add(new Comment(child)); } Likes = new LikeList(); foreach (XmlElement child in element.GetElementsByTagName("like")) { Likes.Add(new Like(child)); } Media = new MediaList(); foreach (XmlElement child in element.GetElementsByTagName("media")) { Media.Add(new Media(child)); } }
private void AddToShoppingCart(object sender, RoutedEventArgs e) { if (PackageAddTypeComboBox.SelectedItem != null) { PackageBase item; switch (PackageAddTypeComboBox.SelectedIndex) { case 0: item = new Package1(CurrentPhoto.Source as BitmapSource); break; case 1: item = new Package2(CurrentPhoto.Source as BitmapSource); break; case 2: item = new Package3(CurrentPhoto.Source as BitmapSource); break; default: return; } ShoppingCart.Add(item); ShoppingCartListBox.ScrollIntoView(item); ShoppingCartListBox.SelectedItem = item; if (false == UploadButton.IsEnabled) UploadButton.IsEnabled = true; if (false == RemoveButton.IsEnabled) RemoveButton.IsEnabled = true; } }
private void AddMediaToList(string extension, string thumbnailPath, string filePath) { MediaList.Add(new Media() { Path = filePath, ThumbnailPath = thumbnailPath, Extension = extension }); }
public void CssMediaListApiWithAppendDeleteAndTextShouldWork() { var media = new [] { "handheld", "screen", "only screen and (max-device-width: 480px)" }; var p = new CssParser(); var m = new MediaList(p); Assert.AreEqual(0, m.Length); m.Add(media[0]); m.Add(media[1]); m.Add(media[2]); m.Remove(media[1]); Assert.AreEqual(2, m.Length); Assert.AreEqual(media[0], m[0]); Assert.AreEqual(media[2], m[1]); Assert.AreEqual(String.Concat(media[0], ", ", media[2]), m.MediaText); }
public void CssMediaListApiWithAppendDeleteAndTextShouldWork() { var media = new [] { "handheld", "screen", "only screen and (max-device-width: 480px)" }; var context = BrowsingContext.New(Configuration.Default.WithCss()); var list = new MediaList(context); Assert.AreEqual(0, list.Length); list.Add(media[0]); list.Add(media[1]); list.Add(media[2]); list.Remove(media[1]); Assert.AreEqual(2, list.Length); Assert.AreEqual(media[0], list[0]); Assert.AreEqual(media[2], list[1]); Assert.AreEqual(String.Concat(media[0], ", ", media[2]), list.MediaText); }
void FillMediaList(MediaList list, CssTokenType end, ref CssToken token) { if (token.Type == end) { return; } while (token.Type != CssTokenType.Eof) { CreateNewNode(); var medium = CloseNode(CreateMedium(ref token)); if (medium != null) { list.Add(medium); } if (token.Type != CssTokenType.Comma) { break; } token = NextToken(); CollectTrivia(ref token); } if (token.Type == end && list.Length > 0) { return; } list.Clear(); list.Add(new CssMedium { IsInverse = true, Type = Keywords.All }); }
/// <summary> /// Before any medium has been found for the @media or @import rule. /// </summary> void FillMediaList(MediaList list, CssTokenType end, ref CssToken token) { if (token.Type == end) { return; } while (token.Type != CssTokenType.Eof) { var medium = CreateMedium(ref token); if (medium != null) { list.Add(medium); } if (token.Type != CssTokenType.Comma) { break; } token = _tokenizer.Get(); } if (token.Type == end && list.Length > 0) { return; } list.Clear(); list.Add(new CssMedium { IsInverse = true, Type = Keywords.All }); }
public void Refresh() { displayList = new MediaList(); string filter = MainWindow.MyMainwindow.MyTypeString[MainWindow.MyMainwindow.MySelectedTypeIndex]; foreach (var item in MainWindow.MyMainwindow.MyMediaList) { if (filter == "" || item.MyType.MyValue == filter) { displayList.Add(item); } } List_Media.ItemsSource = displayList; List_Media.Items.Refresh(); }
/*void returns need to change of course * public virtual void GetMesh() * { * }*/ public PrimitiveBaseShape Copy() { PrimitiveBaseShape copy = (PrimitiveBaseShape)MemberwiseClone(); if (Media != null) { MediaList dupeMedia = new MediaList(); lock (Media) { foreach (MediaEntry me in Media) { dupeMedia.Add(me != null ? MediaEntry.FromOSD(me.GetOSD()) : null); } } copy.Media = dupeMedia; } return(copy); }
public void Refresh() { displayList = new MediaList(); string filter = MainWindow.MyMainwindow.MyTypeString[MainWindow.MyMainwindow.MySelectedTypeIndex]; if (filter != null) { stack1.Children.Clear(); stack2.Children.Clear(); tiles.Clear(); } foreach (var item in MainWindow.MyMainwindow.MyMediaList) { if (filter == "" || item.MyType.MyValue == filter) { Frame frame = new Frame() { }; Tile tile = new Tile(item) { }; frame.Content = tile; tiles.Add(tile); displayList.Add(item); if (stack1.Children.Count <= stack2.Children.Count) { stack1.Children.Add(frame); } else { stack2.Children.Add(frame); } } } }
public void Load(string filePath) { MediaList.Clear(); using (StreamReader Stream1 = new StreamReader(filePath)) { try { while (Stream1.EndOfStream != true) { string line = Stream1.ReadLine(); if (String.IsNullOrEmpty(line) == false) { Song S = new Song(line); MediaList.Add(S); } } } catch (Exception ex) { throw new Exception("Error Opening File", ex); } } }
public async Task Init() { try { if (Year == "") { Year = "0"; } int.Parse(Year); } catch { await Application.Current.MainPage.DisplayAlert("Error", "The year must be a number!", "OK"); return; } if (MovieGenres.Count == 0) { MovieGenres.Add(new Genre { GenreID = 0, Name = "None" }); var serviceReturns = await _genreService.Get <List <Genre> >(null); foreach (var item in serviceReturns) { MovieGenres.Add(item); } } MediaList.Clear(); int GenreID = 0; try { GenreID = SelectedGenre.GenreID; } catch { GenreID = 0; } MediaSearchRequest request = new MediaSearchRequest { GenreID = GenreID, Title = MovieTitle, Year = int.Parse(Year) }; string query = await request.ToQueryString(); var list = await $"{APIService._apiUrl}/MediaSearch?{query}".GetJsonAsync <IEnumerable <Media> >(); foreach (var item in list) { if (item.MediaID != 1) { MediaList.Add(new ListItem { Id = item.MediaID, Title = item.Title, Description = item.Synopsis, Image = $"{APIService._apiUrl}/images/covers/{item.MediaID}", Rating = int.Parse(await $"{APIService._apiUrl}/MediaRatings?id={item.MediaID}&username={APIService.Username}".GetStringAsync()) }); } } }