コード例 #1
0
        public static CollectionViewForm LoadCollection(CardCollection collection, DockState dockState = DockState.Document)
        {
            var document = new CollectionViewForm {
                Collection = collection, Text = collection.CollectionName
            };

            document.LoadCollection();
            document.CardsDropped += EventManager.CollectionViewFormCardsDropped;
            document.CardsUpdated += EventManager.CollectionViewFormCardsUpdated;
            document.CardSelected += EventManager.CardSelected;
            document.cardListView.SmallImageList = Globals.ImageLists.SmallIconList;
            document.Show(Globals.Forms.DockPanel, dockState);
            Globals.Forms.DockPanel.ActiveDocumentPane.SetDoubleBuffered();
            return(document);
        }
コード例 #2
0
        public static CollectionViewForm LoadCollection(int id, DockState dockState = DockState.Document)
        {
            CollectionViewForm document = null;
            CardCollection     collection;

            using (var context = new MyDbContext())
            {
                collection = (from c in context.Collections
                              where c.Id == id
                              select c).FirstOrDefault();
            }
            if (collection != null)
            {
                document = LoadCollection(collection, dockState);
            }

            return(document);
        }
コード例 #3
0
        public static void MoveFullInventoryCardsToCollection(ArrayList fullInventoryCards, CollectionViewForm sourceCVForm, CardCollection collection)
        {
            var cardsList = new List <FullInventoryCard>();

            try
            {
                using (var context = new MyDbContext())
                {
                    foreach (FullInventoryCard fullInventoryCard in fullInventoryCards)
                    {
                        fullInventoryCard.CollectionId = collection.Id;
                        if (fullInventoryCard.Virtual != collection.Virtual)
                        {
                            fullInventoryCard.TimeAdded = DateTime.Now;
                        }
                        fullInventoryCard.Virtual = collection.Virtual;
                        context.Update(fullInventoryCard.InventoryCard);
                        cardsList.Add(fullInventoryCard);
                    }
                    context.SaveChanges();
                }
                sourceCVForm.RemoveFullInventoryCards(cardsList);
                Globals.Forms.OpenCollectionForms.FirstOrDefault(x => x.Collection.Id == collection.Id)?.AddFullInventoryCards(cardsList);
            }
            catch (Exception ex)
            {
                DebugOutput.WriteLine(ex.ToString());
                MessageBox.Show("Could not move cards to collection.");
            }
        }