public void AddDeck()
        {
            var deck = new DeckModel
            {
                Name   = "New deck",
                Server = SelectedServer.Name
            };

            deckManager.AddDeck(deck);

            RefreshDecks();
            SelectedDeck = Decks.FirstOrDefault(x => x.Id == deck.Id);
        }
        public void SaveAsNewDeck()
        {
            var deck = new DeckModel
            {
                Name   = DeckName,
                Server = SelectedServer.Name,
                Key    = DeckSlot,
                Notes  = DeckNotes
            };

            deckManager.AddDeck(deck);
            UpdateDeckImageFromBitmapImage(deck);

            RefreshDecks();
            SelectedDeck = Decks.FirstOrDefault(x => x.Id == deck.Id);
        }
        private void UpdateDeckImageFromBitmapImage(DeckModel deckModel)
        {
            if (DeckScreenshot == null)
            {
                return;
            }

            using (var ms = new MemoryStream())
            {
                BitmapEncoder enc = new BmpBitmapEncoder();
                enc.Frames.Add(BitmapFrame.Create(DeckScreenshot));
                enc.Save(ms);
                ms.Position = 0;
                deckManager.UpdateDeckImage(deckModel.Id, ms.ToArray());
            }
        }
Ejemplo n.º 4
0
        public void AddDeck(DeckModel deck)
        {
            using (var context = dbContext())
            {
                var newdeck = new Deck();
                newdeck.InjectFrom(deck);
                context.Decks.Add(newdeck);
                if (!String.IsNullOrEmpty(deck.Key))
                {
                    var existingSlots = context.Decks.Where(x => x.Key == deck.Key && x.Server == deck.Server && x.Id != deck.Id).ToList();
                    foreach (var existingSlot in existingSlots)
                    {
                        existingSlot.Key = null;
                    }
                }

                context.SaveChanges();
                deck.InjectFrom(newdeck);
                ClearCache();
                events.PublishOnBackgroundThread(new DeckUpdated(newdeck));
            }
        }
Ejemplo n.º 5
0
        public void UpdateDeck(DeckModel deck, bool suppressEvent = false)
        {
            using (var context = dbContext())
            {
                var newdeck = context.Decks.Query().FirstOrDefault(x => x.Id == deck.Id);
                if (newdeck == null)
                {
                    throw new ArgumentException("deck not found", "deck");
                }
                var oldName = newdeck.Name;
                context.Entry(newdeck).CurrentValues.SetValues(deck);

                if (!String.IsNullOrEmpty(deck.Key))
                {
                    var existingSlots = context.Decks.Where(x => x.Key == deck.Key && x.Server == deck.Server && x.Id != deck.Id).ToList();
                    foreach (var existingSlot in existingSlots)
                    {
                        existingSlot.Key = null;
                    }
                }

                context.SaveChanges();
                ClearCache();

                if (!suppressEvent)
                {
                    events.PublishOnBackgroundThread(new DeckUpdated(newdeck));
                }
            }
        }
Ejemplo n.º 6
0
        public void AddDeck(DeckModel deck)
        {
            using (var context = dbContext())
            {
                var newdeck = new Deck();
                newdeck.InjectFrom(deck);
                context.Decks.Add(newdeck);
                if (!String.IsNullOrEmpty(deck.Key))
                {
                    var existingSlots = context.Decks.Where(x => x.Key == deck.Key && x.Server == deck.Server && x.Id != deck.Id).ToList();
                    foreach (var existingSlot in existingSlots)
                    {
                        existingSlot.Key = null;
                    }
                }

                context.SaveChanges();
                deck.InjectFrom(newdeck);
                ClearCache();
                events.PublishOnBackgroundThread(new DeckUpdated(newdeck));
            }
        }
 public void Load(DeckModel deck)
 {
     this.selectedDeck = deck;
     this.DeckName     = deck.Name;
     this.DeckSlot     = deck.Key;
 }
 public void Load(DeckModel deck)
 {
     this.selectedDeck = deck;
     this.DeckName = deck.Name;
     this.DeckSlot = deck.Key;
 }
 public static void MapFrom(this Deck target, DeckModel source)
 {
     target.InjectFrom(source);
 }
Ejemplo n.º 10
0
 public void Load(DeckModel deck)
 {
     selectedDeck = deck;
     DeckName     = deck.Name;
     DeckSlot     = deck.Key;
 }
 public void Load(DeckModel deck)
 {
     selectedDeck = deck;
     DeckName = deck.Name;
     DeckSlot = deck.Key;
 }