private void ParseInformation(UserInformation currentUser) { string icon = null; try { icon = currentUser.Icon; if (string.IsNullOrEmpty(icon) || icon == "default.jpg" || icon == "default") { icon = "http://qc.cdorey.net/default.jpg"; } Icon = new BitmapImage(new Uri(icon)); } catch (UriFormatException ex) { //检查导致解析头像崩溃的原因 ex.ToExceptionless().AddObject(icon).AddObject(currentUser).Submit(); } try { AvailableRate = currentUser.SpaceUsed * 100 / currentUser.SpaceCapacity; } catch (Exception) { AvailableRate = 100; } FrendlySpaceCapacity = $"总计:{Calculators.SizeCalculator(currentUser.SpaceCapacity)}{Environment.NewLine}已用:{Calculators.SizeCalculator(currentUser.SpaceUsed)}"; Name = currentUser.Name; OnPropertyChanged(nameof(Icon)); OnPropertyChanged(nameof(AvailableRate)); OnPropertyChanged(nameof(FrendlySpaceCapacity)); OnPropertyChanged(nameof(Name)); }
public object Convert(object value, Type targetType, object parameter, CultureInfo culture) { if (value is long size) { return(Calculators.SizeCalculator(size)); } return("未知"); }