protected void NewImageSourceTask(Task <ImageSource> task, string errorMessage, ImageSource defaultValue) { ImageSource = new NotifyingTask <ImageSource>(task, e => Log.Error(errorMessage, e)) { Default = defaultValue }; }
public DownloadStashViewModel(IDialogCoordinator dialogCoordinator, IPersistentData persistentData, StashViewModel stash) { _stash = stash; _persistenData = persistentData; _dialogCoordinator = dialogCoordinator; DisplayName = L10n.Message("Download & Import Stash"); Build = persistentData.CurrentBuild; if (Build.League != null && _persistenData.LeagueStashes.ContainsKey(Build.League)) { _tabs = new List <StashBookmark>(_persistenData.LeagueStashes[Build.League]); } TabsView = new ListCollectionView(_tabs); TabsView.CurrentChanged += (sender, args) => UpdateTabLink(); Build.PropertyChanged += BuildOnPropertyChanged; BuildOnPropertyChanged(this, null); _viewLoadedCompletionSource = new TaskCompletionSource <object>(); if (CurrentLeagues == null) { CurrentLeagues = new NotifyingTask <IReadOnlyList <string> >(LoadCurrentLeaguesAsync(), async e => { await _viewLoadedCompletionSource.Task; await _dialogCoordinator.ShowWarningAsync(this, L10n.Message("Could not load the currently running leagues."), e.Message); }); } }
public void Calculate(ushort node, JewelRadius radius, IReadOnlyCollection <string> modifiers) { DisplayStrength = AnyModifierUsesAttributesInJewelRadius(modifiers, "Strength"); DisplayDexterity = AnyModifierUsesAttributesInJewelRadius(modifiers, "Dexterity"); DisplayIntelligence = AnyModifierUsesAttributesInJewelRadius(modifiers, "Intelligence"); if (!DisplayAttributes) { return; } var task = GetAttributesInRadiusAsync(node, radius); if (DisplayStrength) { Strength = new NotifyingTask <double>(GetStrengthAsync(task), e => Log.Error(e, "Calculating Strength in radius failed")); } if (DisplayDexterity) { Dexterity = new NotifyingTask <double>(GetDexterityAsync(task), e => Log.Error(e, "Calculating Dexterity in radius failed")); } if (DisplayIntelligence) { Intelligence = new NotifyingTask <double>(GetIntelligenceAsync(task), e => Log.Error(e, "Calculating Intelligence in radius failed")); }
protected ItemImage(ItemImage baseItemImage) { Options = baseItemImage.Options; _baseName = baseItemImage._baseName; _baseGroup = baseItemImage._baseGroup; _imageSource = baseItemImage._imageSource; _isDefaultImage = baseItemImage._isDefaultImage; _defaultImage = baseItemImage._defaultImage; }
/// <summary> /// Represents an image for an item base. First the classes's image will be loaded synchronously, /// which is then used as the image until the base item's image is loaded asynchronously. /// </summary> public ItemImage(ItemImageService itemImageService, string baseName, ItemClass baseClass) { var defaultImage = itemImageService.LoadDefaultImage(baseClass); ImageSource = NewImageSourceTask( itemImageService.LoadItemImageAsync(baseName, Task.FromResult(defaultImage)), "Loading of base item image failed", defaultImage ); }
/// <summary> /// Represents an image for an item class. The image will be loaded synchronously. /// </summary> public ItemImage(ItemImageService itemImageService, ItemClass baseClass) { var defaultImage = itemImageService.LoadDefaultImage(baseClass); ImageSource = NewImageSourceTask( Task.FromResult(defaultImage), "Exception in completed task", defaultImage ); }
/// <summary> /// Represents an image for an item base. First the group's image will be loaded synchronously, /// which is then used as the image until the base item's image is loaded asynchronously. /// </summary> public ItemImage(ItemImageService itemImageService, string baseName, ItemGroup baseGroup) { var defaultImage = itemImageService.LoadDefaultImage(baseGroup); ImageSource = NewImageSourceTask( itemImageService.LoadItemImageAsync(baseName, defaultImage), "Loading of base item image failed", defaultImage ); }
private void LoadImage() { var fileName = string.Format(AssetPathFormat, _baseName); if (File.Exists(fileName)) { _isDefaultImage = false; NewImageSourceTask(Task.Run(() => ImageSourceFromPath(fileName)), "Loading of base item image failed", _defaultImage); } else { ImageSource = new NotifyingTask <ImageSource>(Task.FromResult(_defaultImage)); } }
private ItemImage(ImageSource defaultImage, Task <ImageSource> imageTask, string errorMessage) { ImageSource = NewImageSourceTask(imageTask, errorMessage, defaultImage); }
private void LoadImage() { var fileName = string.Format(AssetPathFormat, _baseName); if (File.Exists(fileName)) { _isDefaultImage = false; NewImageSourceTask(Task.Run(() => ImageSourceFromPath(fileName)), "Loading of base item image failed", _defaultImage); } else { ImageSource = new NotifyingTask<ImageSource>(Task.FromResult(_defaultImage)); } }
protected void NewImageSourceTask(Task<ImageSource> task, string errorMessage, ImageSource defaultValue) { ImageSource = new NotifyingTask<ImageSource>(task, e => Log.Error(errorMessage, e)) { Default = defaultValue }; }
public DownloadStashViewModel(IDialogCoordinator dialogCoordinator, IPersistentData persistentData, Stash stash) { _stash = stash; _persistenData = persistentData; _dialogCoordinator = dialogCoordinator; DisplayName = L10n.Message("Download & Import Stash"); Build = persistentData.CurrentBuild; if (Build.League != null && _persistenData.LeagueStashes.ContainsKey(Build.League)) _tabs = new List<StashBookmark>(_persistenData.LeagueStashes[Build.League]); TabsView = new ListCollectionView(_tabs); TabsView.CurrentChanged += (sender, args) => UpdateTabLink(); Build.PropertyChanged += BuildOnPropertyChanged; BuildOnPropertyChanged(this, null); RequestsClose += _ => Build.PropertyChanged -= BuildOnPropertyChanged; _viewLoadedCompletionSource = new TaskCompletionSource<object>(); if (CurrentLeagues == null) { CurrentLeagues = new NotifyingTask<IReadOnlyList<string>>(LoadCurrentLeaguesAsync(), async e => { await _viewLoadedCompletionSource.Task; await _dialogCoordinator.ShowWarningAsync(this, L10n.Message("Could not load the currently running leagues."), e.Message); }); } }