Пример #1
0
        private async void GetUserInformation()
        {
            var client = await ClientService.GetClient();

            if (client == null)
            {
                return;
            }

            var username = SettingsService.Default.Value.LocalSettings.Username;

            if (string.IsNullOrEmpty(username))
            {
                return;
            }

            try {
                User = await client.GetUserAttributes(username);

                var converter = new BytesToHumanReadableConverter();
                QuotaUsedOfTotalString = LocalizationService.Instance.GetString(
                    "QuotaUsedOfTotal",
                    converter.Convert(User.Quota.Used, typeof(string), null, CultureInfo.CurrentCulture.ToString()),
                    converter.Convert(User.Quota.Total, typeof(string), null, CultureInfo.CurrentCulture.ToString())
                    );

                switch (SettingsService.Default.Value.LocalSettings.PreviewImageDownloadMode)
                {
                case PreviewImageDownloadMode.Always:
                    UserAvatarUrl = await client.GetUserAvatarUrl(username, 120);

                    break;

                case PreviewImageDownloadMode.WiFiOnly:
                    var connectionProfile = NetworkInformation.GetInternetConnectionProfile();
                    // connectionProfile can be null (e.g. airplane mode)
                    if (connectionProfile != null && connectionProfile.IsWlanConnectionProfile)
                    {
                        UserAvatarUrl = await client.GetUserAvatarUrl(username, 120);
                    }
                    break;

                case PreviewImageDownloadMode.Never:
                    break;

                default:
                    throw new ArgumentOutOfRangeException();
                }
            }
            catch (ResponseError e)
            {
                ResponseErrorHandlerService.HandleException(e);
            }
        }
Пример #2
0
        private void Update()
        {
            var percentage = (double)BytesSend / BytesTotal;

            PercentageUploaded = (int)(percentage * 100);

            UploadingFileProgressText = string.Format(
                _resourceLoader.GetString("UploadingFileProgress"),
                _converter.Convert((long)BytesSend, typeof(string), null,
                                   CultureInfo.CurrentCulture.ToString()),
                _converter.Convert(BytesTotal, typeof(string), null,
                                   CultureInfo.CurrentCulture.ToString())
                );
        }
Пример #3
0
        public override void OnNavigatedTo(NavigatedToEventArgs e, Dictionary <string, object> viewModelState)
        {
            base.OnNavigatedTo(e, viewModelState);
            foreach (var path in Directory.PathStack)
            {
                PathStack.Add(path);
            }
            var parameters   = FileInfoPageParameters.Deserialize(e.Parameter);
            var resourceInfo = parameters?.ResourceInfo;

            if (resourceInfo == null)
            {
                return;
            }
            PathStack.Add(new PathInfo
            {
                ResourceInfo = resourceInfo
            });
            ResourceInfo  = resourceInfo;
            FileExtension = Path.GetExtension(ResourceInfo.Name);
            FileName      = Path.GetFileNameWithoutExtension(ResourceInfo.Name);
            var converter = new BytesToHumanReadableConverter();

            FileSizeString = LocalizationService.Instance.GetString(
                "FileSizeString",
                converter.Convert(ResourceInfo.Size, typeof(string), null, CultureInfo.CurrentCulture.ToString()),
                ResourceInfo.Size
                );
            DownloadPreviewImages();
        }
        private void Update()
        {
            if (BytesTotal == 0)
            {
                IsIndeterminate             = true;
                DownloadingFileProgressText = string.Format(
                    _resourceLoader.GetString("DownloadingFileProgressIndeterminate"),
                    _converter.Convert((long)BytesDownloaded, typeof(string), null, CultureInfo.CurrentCulture.ToString())
                    );
                return;
            }

            var percentage = (double)BytesDownloaded / BytesTotal;

            PercentageDownloaded = (int)(percentage * 100);

            IsIndeterminate             = false;
            DownloadingFileProgressText = string.Format(
                _resourceLoader.GetString("DownloadingFileProgress"),
                _converter.Convert((long)BytesDownloaded, typeof(string), null, CultureInfo.CurrentCulture.ToString()),
                _converter.Convert(BytesTotal, typeof(string), null, CultureInfo.CurrentCulture.ToString())
                );
        }