Ejemplo n.º 1
0
        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)
            {
            }
        }
Ejemplo n.º 2
0
        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);
        }
Ejemplo n.º 3
0
    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();
    }
Ejemplo n.º 4
0
        public async Task SaveCard(
            InkCard card,
            IRandomAccessStream cardFront,
            IRandomAccessStream cardBack)
        {
            this.CurrentlyEditedCard.CardFrontInk = cardFront;
            this.CurrentlyEditedCard.CardBackInk  = cardBack;

            await this.cardStorageService.SaveCard(card);
        }
Ejemplo n.º 5
0
        public void AddCard()
        {
            var newCard = new InkCard
            {
                CardId           = Guid.NewGuid(),
                CardCollectionId = this.currentCardCollectionId
            };

            this.Cards.Insert(0, newCard);
            this.CurrentlyEditedCard = newCard;
        }
Ejemplo n.º 6
0
    public InkCard GetCardWithLongestGaze()
    {
        InkCard mostWatched = null;

        foreach (InkCard card in cards.GetComponentsInChildren <InkCard>())
        {
            if (mostWatched == null || card.gazeSeconds > mostWatched.gazeSeconds)
            {
                mostWatched = card;
            }
        }
        return(mostWatched);
    }
Ejemplo n.º 7
0
        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()));
        }
Ejemplo n.º 8
0
        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];
        }
Ejemplo n.º 9
0
 private string GetCardFrontFileName(InkCard card) => $"{card.CardId}.front.gif";
Ejemplo n.º 10
0
 private string GetCardBackFileName(InkCard card) => $"{card.CardId}.back.gif";
Ejemplo n.º 11
0
        private async void LoadStrokeSteams(InkCard card)
        {
            await this.cardStorageService.LoadCard(card);

            this.StrokesForCurrentlyEditedCardLoaded?.Invoke();
        }