Ejemplo n.º 1
0
    public static void LoadPage(int nPage)
    {
        MediaList.Clear();
        UIMgr.clearLayer();

        XmlStage.LoadPage(nPage);
    }
Ejemplo n.º 2
0
        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);
        }
Ejemplo n.º 3
0
        private void Upload(object sender, RoutedEventArgs e)
        {
            if (ShoppingCart.Count > 0)
            {
                TimeSpan scaleDuration = new TimeSpan(0, 0, 0, 0, ShoppingCart.Count * 200);
                DoubleAnimation ProgressAnimation = new DoubleAnimation(0, 100, scaleDuration, FillBehavior.Stop);
                UploadProgressBar.BeginAnimation(ProgressBar.ValueProperty, ProgressAnimation);
               // MessageBox.Show(ShoppingCart.Count.ToString());

                foreach (var imageCart in ShoppingCart)
                {
                    BitmapSource imageForCust = imageCart.Photo;
                    CurrentPhoto.Source = imageForCust;
                    MessageBox.Show(imageForCust.ToString());

                    using (var fileStream = new FileStream("..\\..\\photosCust", FileMode.Create))
                    {
                        BitmapEncoder encoder = new PngBitmapEncoder();
                        encoder.Frames.Add(BitmapFrame.Create(imageForCust));
                        encoder.Save(fileStream);
                    }
                  
                }
                ShoppingCart.Clear();
                UploadButton.IsEnabled = false;
                if (true == RemoveButton.IsEnabled)
                    RemoveButton.IsEnabled = false;
            }
        }
        private async void GraphTypeCombo_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            RatingCategory Selection = GraphTypeCombo.SelectedItem as RatingCategory;

            if (Selection != null && Selection.Name != "" && Selection.Name[0] != '-')
            {
                List <int> GraphData = await business.LoadGraphAsync(MediaType.Video, Selection, 0);

                DisplayGraph(GraphData);
            }
            else
            {
                DisplayGraph(null);
            }
            MediaList.Clear();
        }
Ejemplo n.º 5
0
        public void UpdateFiles()
        {
            MediaList.Clear();

            foreach (var filePath in Directory.GetFiles(SourcePath).Where(item => !item.Contains(".ini")))
            {
                var fileName  = filePath.Split('\\').LastOrDefault();
                var extension = filePath.Split('.').LastOrDefault();

                if (SupportedVideoExtensions.Contains(extension))
                {
                    var tempFolder        = Path.GetTempPath();
                    var tempThumbnailPath = string.Format("{0}{1}.jpg", tempFolder, fileName);

                    var ffMpeg = new NReco.VideoConverter.FFMpegConverter();

                    CreateThumbnailForVideo(filePath, tempThumbnailPath, ffMpeg);

                    ffMpeg.Stop();

                    if (extension.Contains("webm"))
                    {
                        var newFilePath = string.Format("{0}{1}.mp4", tempFolder, fileName);

                        if (!File.Exists(newFilePath))
                        {
                            var tempffMpeg = new NReco.VideoConverter.FFMpegConverter();

                            tempffMpeg.ConvertMedia(filePath, newFilePath, "mp4");

                            tempffMpeg.Stop();
                        }

                        AddMediaToList(extension, tempThumbnailPath, newFilePath);
                    }
                    else
                    {
                        AddMediaToList(extension, tempThumbnailPath, filePath);
                    }
                }
                else
                {
                    AddMediaToList(extension, filePath, filePath);
                }
            }
        }
Ejemplo n.º 6
0
        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
            });
        }
Ejemplo n.º 7
0
 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);
         }
     }
 }
Ejemplo n.º 8
0
        void FillMediaList(MediaList list, CssTokenType end, ref CssToken token)
        {
            _nodes.Push(list);

            if (token.Type != end)
            {
                while (token.Type != CssTokenType.EndOfFile)
                {
                    var medium = CreateMedium(ref token);

                    if (medium != null)
                    {
                        list.AppendChild(medium);
                    }

                    if (token.Type != CssTokenType.Comma)
                    {
                        break;
                    }

                    token = NextToken();
                    CollectTrivia(ref token);
                }

                if (token.Type != end || list.Length == 0)
                {
                    list.Clear();
                    list.AppendChild(new CssMedium
                    {
                        IsInverse = true,
                        Type      = Keywords.All
                    });
                }
            }

            _nodes.Pop();
        }
Ejemplo n.º 9
0
        /// <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
            });
        }
Ejemplo n.º 10
0
        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())
                    });
                }
            }
        }