Пример #1
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();
        }
Пример #2
0
 public FileUploadPageViewModel(INavigationService navigationService, IResourceLoader resourceLoader, DialogService dialogService)
 {
     _navigationService = navigationService;
     _resourceLoader    = resourceLoader;
     _dialogService     = dialogService;
     _converter         = new BytesToHumanReadableConverter();
 }
Пример #3
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);
            }
        }
        public FileUploadPageViewModel(INavigationService navigationService, IResourceLoader resourceLoader, DialogService dialogService)
        {
            _navigationService = navigationService;
            _resourceLoader    = resourceLoader;
            _dialogService     = dialogService;
            _converter         = new BytesToHumanReadableConverter();

            // See: http://csharperimage.jeremylikness.com/2013/06/mvvm-and-accessing-ui-thread-in-windows.html
            if (Windows.ApplicationModel.DesignMode.DesignModeEnabled)
            {
                return;
            }
            _dispatcher = CoreWindow.GetForCurrentThread().Dispatcher;
        }
 public void OnProgressChanged(ProgressDescription progress, WuStateId currentState)
 {
     lock (EndpointLock)
     {
         if (Endpoint == null)
         {
             return;
         }
         Log.Debug($"Progress changed callback from {Endpoint.FQDN}. Percent: {progress.Percent} Indeterminate: {progress.IsIndeterminate}.");
         lock (Endpoint.StateLock)
         {
             if (progress.CurrentUpdate != null)
             {
                 Endpoint.State.Description = progress.CurrentUpdate.Title;
                 if (currentState == WuStateId.Downloading)
                 {
                     Endpoint.State.Description += $" ({BytesToHumanReadableConverter.GetBytesReadable(progress.CurrentUpdate.MaxByteSize)})";
                 }
                 Endpoint.State.Progress = progress;
             }
         }
         Endpoint.OnPropertyChanged("State");
     }
 }
 public SingleFileDownloadPageViewModel(INavigationService navigationService, IResourceLoader resourceLoader)
 {
     _navigationService = navigationService;
     _resourceLoader    = resourceLoader;
     _converter         = new BytesToHumanReadableConverter();
 }