예제 #1
0
        public void WriteManifest()
        {
            var pack = ViewModel.SelectedPack;

            if (pack == null)
            {
                _logger.LogError("Attempting to write manifest with no pack select");
                return;
            }

            var manifestPath = pack.Directory + "\\Manifest.json";

            _logger.LogMessage($"Writing manifest {manifestPath}.");
            try {
                var manifest = new LocalPackManifest {
                    Name  = pack.Name,
                    Cards = new List <LocalManifestCard>()
                };

                foreach (var card in pack.Cards)
                {
                    var localManifestCard = new LocalManifestCard();
                    card.CopyTo(localManifestCard);
                    manifest.Cards.Add(localManifestCard);
                }

                File.WriteAllText(manifestPath, JsonConvert.SerializeObject(manifest));
            } catch (Exception e) {
                _logger.LogException(e, "Error writing manifest");
            }
        }
        internal void ReadManifest(LocalPackManifest manifest, LocalPack pack)
        {
            pack.Name = manifest.Name;
            var localCards = new ObservableCollection <LocalCard>();

            foreach (var card in manifest.Cards)
            {
                if (File.Exists(card.FilePath))
                {
                    var localCard = new LocalCard(card.FilePath)
                    {
                        CardType = card.CardType,
                        Name     = card.Name,
                        HasBack  = card.HasBack
                    };

                    localCard.PropertyChanged += (s, e) => {
                        WriteManifest();
                    };

                    localCards.Add(localCard);
                }
            }
            pack.Cards = localCards;
        }
예제 #3
0
 public SelectableLocalPackManifest(LocalPackManifest localPackManifest)
 {
     Manifest = localPackManifest;
 }