public async Task SaveCard(InkCard card) { try { await this.EnsureInitialized(); if (savesInProgress.TryGetValue(card.CardId, out var saveInProgress)) { await saveInProgress; } var taskCompletionSource = new TaskCompletionSource <bool>(); savesInProgress.TryAdd(card.CardId, taskCompletionSource.Task); var targetFolder = await this.GetCollectionFolder(card.CardCollectionId); var result = await Task.WhenAll( this.SaveInkFile(card.CardFrontInk, targetFolder, this.GetCardFrontFileName(card)), this.SaveInkFile(card.CardBackInk, targetFolder, this.GetCardBackFileName(card))); taskCompletionSource.SetResult(true); savesInProgress.TryRemove(card.CardId, out var _); card.CardFrontUri = new Uri(result[0].Path, UriKind.Absolute); card.CardBackUri = new Uri(result[1].Path, UriKind.Absolute); } catch (Exception ex) { } }
public void DeleteCard(InkCard card) { var currentlyEditedCardIndex = this.Cards.IndexOf(card); this.Cards.Remove(card); this.cardStorageService.DeleteCard(card); this.CurrentlyEditedCard = this.Cards.GetPreviousItemToSelect(currentlyEditedCardIndex); }
public void HideCards() { cards.SetActive(false); InkCard longestGazeCard = GetCardWithLongestGaze(); longestGazeCard.transform.SetParent(null, true); longestGazeCard.gameObject.SetActive(true); Debug.LogFormat("Card with longest gaze: {0}", GetCardWithLongestGaze()?.name); endcription.Perform(); }
public async Task SaveCard( InkCard card, IRandomAccessStream cardFront, IRandomAccessStream cardBack) { this.CurrentlyEditedCard.CardFrontInk = cardFront; this.CurrentlyEditedCard.CardBackInk = cardBack; await this.cardStorageService.SaveCard(card); }
public void AddCard() { var newCard = new InkCard { CardId = Guid.NewGuid(), CardCollectionId = this.currentCardCollectionId }; this.Cards.Insert(0, newCard); this.CurrentlyEditedCard = newCard; }
public InkCard GetCardWithLongestGaze() { InkCard mostWatched = null; foreach (InkCard card in cards.GetComponentsInChildren <InkCard>()) { if (mostWatched == null || card.gazeSeconds > mostWatched.gazeSeconds) { mostWatched = card; } } return(mostWatched); }
public async Task DeleteCard(InkCard card) { await this.EnsureInitialized(); if (savesInProgress.TryGetValue(card.CardId, out var saveInProgress)) { await saveInProgress; } var folder = await this.GetCollectionFolder(card.CardCollectionId); var filesToDelete = (await Task.WhenAll( folder.TryGetItemAsync(this.GetCardFrontFileName(card)).AsTask(), folder.TryGetItemAsync(this.GetCardBackFileName(card)).AsTask())) .Where(x => x != null); await Task.WhenAll(filesToDelete.Select(x => x.DeleteAsync().AsTask())); }
public async Task LoadCard(InkCard card) { await this.EnsureInitialized(); if (savesInProgress.TryGetValue(card.CardId, out var saveInProgress)) { await saveInProgress; } var targetFolder = await this.GetCollectionFolder(card.CardCollectionId); var result = await Task.WhenAll( this.LoadInkFile(targetFolder, this.GetCardFrontFileName(card)), this.LoadInkFile(targetFolder, this.GetCardBackFileName(card))); card.CardFrontInk = result[0]; card.CardBackInk = result[1]; }
private string GetCardFrontFileName(InkCard card) => $"{card.CardId}.front.gif";
private string GetCardBackFileName(InkCard card) => $"{card.CardId}.back.gif";
private async void LoadStrokeSteams(InkCard card) { await this.cardStorageService.LoadCard(card); this.StrokesForCurrentlyEditedCardLoaded?.Invoke(); }