Beispiel #1
0
        private async void Button_Click(object sender, RoutedEventArgs e)
        {
            var file = _message.GetFile();

            if (file == null)
            {
                return;
            }

            if (file.Local.IsDownloadingActive)
            {
                if (_delegate != null)
                {
                    _message.ProtoService.CancelDownloadFile(file.Id);
                }
                else
                {
                    _message.ProtoService.Send(new ToggleDownloadIsPaused(file.Id, true));
                }
            }
            else if (file.Local.CanBeDownloaded && !file.Local.IsDownloadingActive && !file.Local.IsFileExisting())
            {
                if (_delegate != null)
                {
                    _message.ProtoService.AddFileToDownloads(file.Id, _message.ChatId, _message.Id);
                }
                else
                {
                    _message.ProtoService.Send(new ToggleDownloadIsPaused(file.Id, false));
                }
            }
            else if (_delegate == null)
            {
                var temp = await _message.ProtoService.GetFileAsync(file);

                if (temp != null)
                {
                    await Windows.System.Launcher.LaunchFileAsync(temp);
                }
            }
            else
            {
                _delegate.OpenFile(file);
            }
        }
Beispiel #2
0
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            var file = _message.GetFile();

            if (file == null)
            {
                return;
            }

            if (file.Local.IsDownloadingActive)
            {
                _protoService.Send(new CancelDownloadFile(file.Id, false));
            }
            else if (file.Local.CanBeDownloaded && !file.Local.IsDownloadingActive && !file.Local.IsDownloadingCompleted)
            {
                _protoService.DownloadFile(file.Id, 32);
            }
            else
            {
                _delegate.OpenFile(file);
            }
        }
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            var document = _message?.Content as MessageDocument;

            if (document == null)
            {
                return;
            }

            var file = document.Document.DocumentValue;

            if (file.Local.IsDownloadingActive)
            {
                _protoService.Send(new CancelDownloadFile(file.Id, false));
            }
            else if (file.Local.CanBeDownloaded && !file.Local.IsDownloadingActive && !file.Local.IsDownloadingCompleted)
            {
                _protoService.Send(new DownloadFile(file.Id, 1));
            }
            else
            {
                _delegate.OpenFile(file);
            }
        }