Exemple #1
0
        public void UpdateFile(MessageViewModel message, File file)
        {
            var videoNote = GetContent(message.Content);

            if (videoNote == null)
            {
                return;
            }

            if (videoNote.Thumbnail != null && videoNote.Thumbnail.Photo.Id == file.Id)
            {
                UpdateThumbnail(message, file);
                return;
            }
            else if (videoNote.Video.Id != file.Id)
            {
                return;
            }

            var size = Math.Max(file.Size, file.ExpectedSize);

            if (file.Local.IsDownloadingActive)
            {
                Button.Glyph    = "\uE10A";
                Button.Progress = (double)file.Local.DownloadedSize / size;
            }
            else if (file.Remote.IsUploadingActive)
            {
                Button.Glyph    = "\uE10A";
                Button.Progress = (double)file.Remote.UploadedSize / size;
            }
            else if (file.Local.CanBeDownloaded && !file.Local.IsDownloadingCompleted)
            {
                Button.Glyph    = "\uE118";
                Button.Progress = 0;

                if (message.Delegate.CanBeDownloaded(message))
                {
                    _message.ProtoService.Send(new DownloadFile(file.Id, 32));
                }
            }
            else
            {
                if (message.IsBlurred())
                {
                    Button.Glyph    = "\uE60D";
                    Button.Progress = 1;
                }
                else
                {
                    Button.Glyph    = "\uE102";
                    Button.Progress = 1;
                }
            }
        }
Exemple #2
0
        public void UpdateFile(MessageViewModel message, File file)
        {
            var photo = GetContent(message.Content);

            if (photo == null)
            {
                return;
            }

            var small = photo.GetSmall();
            var big   = photo.GetBig();

            if (small != null && small.Photo.Id != big.Photo.Id && small.Photo.Id == file.Id)
            {
                UpdateThumbnail(message, file);
                return;
            }
            else if (big == null || big.Photo.Id != file.Id)
            {
                return;
            }

            var size = Math.Max(file.Size, file.ExpectedSize);

            if (file.Local.IsDownloadingActive)
            {
                Button.Glyph    = "\uE10A";
                Button.Progress = (double)file.Local.DownloadedSize / size;

                Button.Opacity  = 1;
                Overlay.Opacity = 0;
            }
            else if (file.Remote.IsUploadingActive)
            {
                Button.Glyph    = "\uE10A";
                Button.Progress = (double)file.Remote.UploadedSize / size;

                Button.Opacity  = 1;
                Overlay.Opacity = 0;
            }
            else if (file.Local.CanBeDownloaded && !file.Local.IsDownloadingCompleted)
            {
                Button.Glyph    = "\uE118";
                Button.Progress = 0;

                Button.Opacity  = 1;
                Overlay.Opacity = 0;

                if (message.Delegate.CanBeDownloaded(message))
                {
                    _message.ProtoService.Send(new DownloadFile(file.Id, 32));
                }
            }
            else
            {
                if (message.IsBlurred())
                {
                    Button.Glyph    = "\uE60D";
                    Button.Progress = 1;

                    Button.Opacity  = 1;
                    Overlay.Opacity = 1;

                    Subtitle.Text = Locale.FormatTTLString(message.Ttl, true);
                }
                else
                {
                    Button.Glyph    = "\uE102";
                    Button.Progress = 1;

                    Button.Opacity  = 0;
                    Overlay.Opacity = 0;

                    Texture.Source = new BitmapImage(new Uri("file:///" + file.Local.Path));
                }
            }
        }
Exemple #3
0
        public void UpdateFile(MessageViewModel message, File file)
        {
            var video = GetContent(message.Content);

            if (video == null)
            {
                return;
            }

            if (video.Thumbnail != null && video.Thumbnail.Photo.Id == file.Id)
            {
                UpdateThumbnail(message, file);
                return;
            }
            else if (video.VideoData.Id != file.Id)
            {
                return;
            }

            var size = Math.Max(file.Size, file.ExpectedSize);

            if (file.Local.IsDownloadingActive)
            {
                Button.Glyph    = "\uE10A";
                Button.Progress = (double)file.Local.DownloadedSize / size;

                Subtitle.Text = string.Format("{0} / {1}", FileSizeConverter.Convert(file.Local.DownloadedSize, size), FileSizeConverter.Convert(size));
            }
            else if (file.Remote.IsUploadingActive)
            {
                Button.Glyph    = "\uE10A";
                Button.Progress = (double)file.Remote.UploadedSize / size;

                Subtitle.Text = string.Format("{0} / {1}", FileSizeConverter.Convert(file.Remote.UploadedSize, size), FileSizeConverter.Convert(size));
            }
            else if (file.Local.CanBeDownloaded && !file.Local.IsDownloadingCompleted)
            {
                Button.Glyph    = "\uE118";
                Button.Progress = 0;

                Subtitle.Text = video.GetDuration() + ", " + FileSizeConverter.Convert(size);

                if (message.Delegate.CanBeDownloaded(message))
                {
                    _message.ProtoService.Send(new DownloadFile(file.Id, 32));
                }
            }
            else
            {
                if (message.IsBlurred())
                {
                    Button.Glyph    = "\uE60D";
                    Button.Progress = 1;

                    Subtitle.Text = Locale.FormatTTLString(Math.Max(message.Ttl, video.Duration), true);
                }
                else
                {
                    Button.Glyph    = "\uE102";
                    Button.Progress = 1;

                    Subtitle.Text = video.GetDuration();
                }
            }
        }