Ejemplo n.º 1
0
        public void AddMediaItem(String conversationID, String fileID, String fileName, int position, bool reachedRight = false)
        {
            Console.WriteLine("reached right: " + reachedRight);
            foreach (var uiElement in Gallery.Children)
            {
                if (!(uiElement is ThumbnailButton))
                {
                    continue;
                }
                ThumbnailButton btn = uiElement as ThumbnailButton;
                if (btn.FileID.Equals(fileID, StringComparison.OrdinalIgnoreCase))
                {
                    return;
                }
            }

            String thumbUrl  = StreamAPI.GetMediaThumbnailURL(fileID, conversationID);
            String streamUrl = StreamAPI.GetMediaURL(fileID, conversationID);

            MediaInfo media = new MediaInfo(thumbUrl, streamUrl, fileName, fileID);

            LoadThumbnail(media, int.MaxValue);

            IsReachedRight = reachedRight;
            borderRight    = Math.Min(position, borderRight);
        }
Ejemplo n.º 2
0
        private void BtnClick(object sender, EventArgs e)
        {
            ThumbnailButton thumbnail = sender as ThumbnailButton;

            thumbnail.StreamURL = StreamAPI.GetMediaURL(thumbnail.FileID, ConversationID);
            SwapToBtn(thumbnail);
        }
Ejemplo n.º 3
0
        private void SwapToBtn(ThumbnailButton btn)
        {
            if (btn == currentBtn)
            {
                return;
            }

            if (currentBtn != null)
            {
                currentBtn.IsActive = false;
            }
            currentBtn = btn;

            if (currentBtn.Image != null)
            {
                SetBackground(currentBtn.Image);
            }
            else
            {
                String url = currentBtn.ThumbnailUrl;
                if (thumbThread != null && thumbThread.IsAlive)
                {
                    thumbThread.Abort();
                }
                thumbThread = new Thread(() =>
                {
                    try
                    {
                        WebClient wc       = new WebClient();
                        BitmapFrame bitmap = BitmapFrame.Create(new MemoryStream(wc.DownloadData(url)));
                        wc.Dispose();
                        Application.Current.Dispatcher.Invoke(() =>
                        {
                            SetBackground(bitmap);
                        });
                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine(ex);
                    }
                });
                thumbThread.IsBackground = true;
                thumbThread.Start();
            }

            if (PacPlayer.IsSupport(currentBtn.FileName))
            {
                ShowVideo(currentBtn.StreamURL);
            }
            else
            {
                ShowImage(currentBtn.StreamURL);
            }
            currentBtn.IsActive = true;
        }
Ejemplo n.º 4
0
        public void Clean(bool hard = true)
        {
            Gallery.Children.Clear();
            ImgCache.Clear();

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

            VideoFull.Close();

            currentBtn = null;
        }
Ejemplo n.º 5
0
        public void Demo()
        {
            ThumbnailButton btn = new ThumbnailButton()
            {
                ThumbnailUrl = StreamAPI.GetMediaThumbnailURL("7ca94feb-4f57-4beb-8b6a-fe9225337794", "7516cdee-0971-472c-9a01-b2804dcedd9f"),
                StreamURL    = StreamAPI.GetMediaURL("7ca94feb-4f57-4beb-8b6a-fe9225337794", "7516cdee-0971-472c-9a01-b2804dcedd9f"),
                FileName     = "dreamstime_xxl_65780868_small.jpg",
                FileID       = "7ca94feb-4f57-4beb-8b6a-fe9225337794"
            };

            btn.Click += BtnClick;
            Gallery.Children.Add(btn);
        }
Ejemplo n.º 6
0
 public void ShowMedia(String fileID)
 {
     foreach (var uiElement in Gallery.Children)
     {
         if (!(uiElement is ThumbnailButton))
         {
             continue;
         }
         ThumbnailButton btn = uiElement as ThumbnailButton;
         if (btn.FileID.Equals(fileID, StringComparison.OrdinalIgnoreCase))
         {
             SwapToBtn(btn);
             break;
         }
     }
     FillGallery();
 }
Ejemplo n.º 7
0
        private void LoadThumbnail(MediaInfo media, int index, bool swapTo = false)
        {
            ThumbnailButton btn = new ThumbnailButton(media);

            btn.Click += BtnClick;
            if (index > Gallery.Children.Count - 1)
            {
                Gallery.Children.Add(btn);
            }
            else
            {
                Gallery.Children.Insert(index, btn);
            }

            if (swapTo)
            {
                SwapToBtn(btn);
            }
        }
Ejemplo n.º 8
0
        public void AddMediaItemToFirst(String conversationID, String fileID, String fileName, int position, bool reachedLeft = true)
        {
            foreach (var uiElement in Gallery.Children)
            {
                if (!(uiElement is ThumbnailButton))
                {
                    continue;
                }
                ThumbnailButton btn = uiElement as ThumbnailButton;
                if (btn.FileID.Equals(fileID, StringComparison.OrdinalIgnoreCase))
                {
                    return;
                }
            }

            String thumbUrl  = StreamAPI.GetMediaThumbnailURL(fileID, conversationID);
            String streamUrl = StreamAPI.GetMediaURL(fileID, conversationID);

            MediaInfo media = new MediaInfo(thumbUrl, streamUrl, fileName, fileID);

            LoadThumbnail(media, 0);
        }