コード例 #1
0
        public void ShowImage(String imageURL)
        {
            try
            {
                LoadingAhihi.Visibility = Visibility.Visible;
                VideoFull.Close();

                VideoFull.Visibility = Visibility.Hidden;
                ImgFull.Visibility   = Visibility.Hidden;

                if (ImgCache.Contains(imageURL))
                {
                    ImgFull.Source = ImgCache.Get(imageURL);

                    ImgFull.MaxHeight = ImgFull.Source.Height;
                    ImgFull.MaxWidth  = ImgFull.Source.Width;

                    ImgFull.Visibility      = Visibility.Visible;
                    LoadingAhihi.Visibility = Visibility.Hidden;
                }
                else
                {
                    if (imgThread != null && imgThread.IsAlive)
                    {
                        imgThread.Abort();
                    }
                    imgThread = new Thread(() =>
                    {
                        try
                        {
                            WebClient wc       = new WebClient();
                            BitmapFrame bitmap = BitmapFrame.Create(new MemoryStream(wc.DownloadData(imageURL)));
                            wc.Dispose();
                            Application.Current.Dispatcher.Invoke(() =>
                            {
                                ImgCache.AddReplace(imageURL, bitmap);
                                ImgFull.Source = bitmap;

                                ImgFull.MaxHeight  = bitmap.PixelHeight;
                                ImgFull.MaxWidth   = bitmap.PixelWidth;
                                ImgFull.Visibility = Visibility.Visible;

                                LoadingAhihi.Visibility = Visibility.Hidden;
                            });
                        }
                        catch (Exception ex)
                        {
                            Console.WriteLine(ex);
                        }
                    });
                    imgThread.IsBackground = true;
                    imgThread.Start();
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }
        }
コード例 #2
0
        public void Clean(bool hard = true)
        {
            Gallery.Children.Clear();
            ImgCache.Clear();

            ImgFull.Source    = null;
            ImgFull.IsEnabled = false;

            VideoFull.Close();

            currentBtn = null;
        }
コード例 #3
0
        public void ShowVideo(String streamURL)
        {
            try
            {
                VideoFull.Close();

                VideoFull.Visibility = Visibility.Visible;
                ImgFull.Visibility   = Visibility.Hidden;

                LoadingAhihi.Visibility = Visibility.Visible;

                VideoFull.Source = new Uri(streamURL);
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }
        }