Exemple #1
0
        public void UpdateItem(IGalleryDelegate delegato, GalleryItem item)
        {
            _delegate = delegato;
            _item     = item;

            Tag = item;

            Panel.Background = null;
            Texture.Source   = null;

            if (item == null)
            {
                return;
            }

            var data  = item.GetFile();
            var thumb = item.GetThumbnail();

            Panel.Constraint = item.Constraint;
            Panel.InvalidateMeasure();

            if (thumb != null && (item.IsVideo || (item.IsPhoto && !data.Local.IsDownloadingCompleted)))
            {
                UpdateThumbnail(item, thumb);
            }

            UpdateFile(item, data);
        }
Exemple #2
0
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            if (_item == null)
            {
                return;
            }

            var file = _item.GetFile();

            if (file.Local.IsDownloadingActive)
            {
                _item.ProtoService.Send(new CancelDownloadFile(file.Id, false));
            }
            else if (file.Local.CanBeDownloaded && !file.Local.IsDownloadingActive && !file.Local.IsDownloadingCompleted)
            {
                _item.ProtoService.Send(new DownloadFile(file.Id, 1));
            }
            else
            {
                if (_item.IsVideo)
                {
                    _delegate?.OpenFile(_item, file);
                }
            }
        }
Exemple #3
0
        public void UpdateFile(GalleryItem item, File file)
        {
            var data  = item.GetFile();
            var thumb = item.GetThumbnail();

            if (thumb != null && thumb.Id == file.Id)
            {
                UpdateThumbnail(item, file);
                return;
            }
            else if (data.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;
            }
            else if (file.Remote.IsUploadingActive)
            {
                Button.Glyph    = "\uE10A";
                Button.Progress = (double)file.Remote.UploadedSize / size;
                Button.Opacity  = 1;
            }
            else if (file.Local.CanBeDownloaded && !file.Local.IsDownloadingCompleted)
            {
                Button.Glyph    = "\uE118";
                Button.Progress = 0;
                Button.Opacity  = 1;

                if (item.IsPhoto)
                {
                    item.ProtoService.Send(new DownloadFile(file.Id, 1));
                }
            }
            else
            {
                if (item.IsVideo)
                {
                    Button.Glyph    = "\uE102";
                    Button.Progress = 1;
                    Button.Opacity  = 1;
                }
                else if (item.IsPhoto)
                {
                    Button.Opacity = 0;
                    Texture.Source = new BitmapImage(new Uri("file:///" + file.Local.Path));
                }
            }
        }