Exemplo n.º 1
0
        private void SearchCardView_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (SearchCardView.SelectedIndices.Count > 0)
            {
                //Console.WriteLine();
                int i = SearchCardView.SelectedIndices[0];
                //var card = CardDatabaseManagement.GetCard(SearchCardView.SelectedItems[0].Text, (string)SearchCardView.SelectedItems[0].Tag);

                Console.WriteLine((string)SearchCardView.SelectedItems[0].Tag + ", " + SearchCardView.SelectedItems[0].Text);
                //type slot page
                var card = CardDatabaseManagement.GetCard((string)SearchCardView.SelectedItems[0].Tag, SearchCardView.SelectedItems[0].Text);
                if (card.Slot != "NA")
                {
                    Console.WriteLine(card.Type + ", " + card.Slot + ", PAGE: " + card.Page + ", NAME: " + card.Name);
                    //currentPage = card.Page;
                }
                currentType.SelectedItem = (string)SearchCardView.SelectedItems[0].Tag;
                currentPage = card.Page;
                PopulateDisplay();
                foreach (Panel c in cardCollectionView.Controls.OfType <Panel>())
                {
                    foreach (PictureBox pb in c.Controls.OfType <PictureBox>())
                    {
                        if (pb.Name == card.Slot)
                        {
                            Card_Click(pb, null);
                        }
                    }
                }
            }



            SearchCardView.Clear();
        }
Exemplo n.º 2
0
 private void UpdateDisplay(PictureBox p)
 {
     if (p != null)
     {
         SelectedCard          = CardDatabaseManagement.GetCard((string)currentType.SelectedItem, p.Name, currentPage + "");
         seeCardNameLabel.Text = SelectedCard.Name;
     }
     else
     {
         seeCard.Image   = null;
         seeCard.Visible = false;
     }
 }
Exemplo n.º 3
0
        private async Task InitializeGhostCard(CancellationToken cancellationToken)
        {
            await Task.Delay(TimeSpan.FromSeconds(1));

            cancellationToken.ThrowIfCancellationRequested();

            if (!ghostCardMove)
            {
                ghostCard = Create_GhostCard(SelectedSlot);
                UpdateGhostCardLocation(SelectedSlot.Parent);
                ghostCardMove    = true;
                ghostCard.Parent = SelectedSlot.Parent;
                ghostCard.BringToFront();

                Card t = CardDatabaseManagement.GetCard((string)currentType.SelectedItem, SelectedSlot.Name, currentPage + "");
                if (t.Count != 0)
                {
                    swapCard = t;
                }
            }
        }
Exemplo n.º 4
0
 private void PopulateDisplay()
 {
     foreach (Panel c in cardCollectionView.Controls.OfType <Panel>())
     {
         foreach (PictureBox pb in c.Controls.OfType <PictureBox>())
         {
             Card s = CardDatabaseManagement.GetCard((string)currentType.SelectedItem, pb.Name, currentPage + "");
             if (s.Count > 2)
             {
                 pb.Load("database/" + (string)currentType.SelectedItem + "/images/" + s.Picture);
             }
             else
             {
                 pb.Image = null;
             }
         }
     }
     MAX_PAGE_LABEL.Text   = "" + PageDatabaseManagement.GetPageNum((string)currentType.SelectedItem);
     currentPageLabel.Text = "Page: " + currentPage;
     GC.Collect();
 }
Exemplo n.º 5
0
        //Method for card area click response
        private void AddCardButton_Click(object sender, EventArgs e)
        {
            //Console.WriteLine("TEMPLATE: " + template.Picture + " " + template.PictureLink);
            if (SelectedSlot != null)
            {
                Card template;
                if (addCardNameIn.Text != "")
                {
                    template = new Card((string)currentType.SelectedItem,
                                        "" + currentPage,
                                        SelectedSlot.Name,
                                        addCardNameIn.Text,
                                        CardDatabaseManagement.Simplify(addCardNameIn.Text) + ".jpeg",
                                        addCardCopiesIn.Text,
                                        addCardPicIn.Text);
                }
                else
                {
                    template = new Card(0, SelectedSlot.Name, "" + currentPage);
                }
                //Console.WriteLine("BEG" + CardDatabaseManagement.Simplify(addCardNameIn.Text) + ".jpeg");
                if (!CardDatabaseManagement.CardExists(template))
                {
                    if (!CardDatabaseManagement.CardExistsInSlot(SelectedSlot.Name, (string)currentType.SelectedItem, currentPage))
                    {
                        try
                        {
                            CardDatabaseManagement.AddCard(template);
                        }
                        catch (Exception ex)
                        {
                            ex.ToString();
                            Console.WriteLine("weird");
                            //Form f = new Dialog("Error: \n[Not connected to the internet]\nor\n[Spelled the name incorrectly]\nor\n[Card does not exist]");
                            //DialogResult dr = new DialogResult();
                            //f.ShowDialog();
                            return;
                        }

                        Card cc = CardDatabaseManagement.GetCard((string)currentType.SelectedItem, SelectedSlot.Name, currentPage + "");
                        //Console.WriteLine(cc.Count);
                        if (cc.Count != 1)
                        {
                            foreach (Panel c in cardCollectionView.Controls.OfType <Panel>())
                            {
                                foreach (PictureBox pb in c.Controls.OfType <PictureBox>())
                                {
                                    if (pb.Name == cc.Slot)
                                    {
                                        pb.Load("database/" + (string)currentType.SelectedItem + "/images/" + cc.Picture);
                                    }
                                }
                            }

                            seeCard.Visible = true;
                            seeCard.Load("database/" + (string)currentType.SelectedItem + "/images/" + cc.Picture);
                        }
                    }
                    else
                    {
                        Console.WriteLine("EXISTS IN SLOT");
                        //Form f = new Dialog("Error: \n[Card Exists in Slot]");
                        //f.ShowDialog();
                    }
                }
                else
                {
                    Console.WriteLine("EXIST SAME");
                    //Error Dialog for Card already Existing
                    //Thus press goto to goto the card

                    //Form f = new Dialog("Error: \n[Card Already Exists]");
                    //f.ShowDialog();
                }
            }
            else
            {
                Console.WriteLine("SLECT SLOT");
                //Form f = new Dialog("Error: \n[Select a Slot]");
                //f.ShowDialog();
            }

            addCardPicIn.Text = "";
        }
Exemplo n.º 6
0
        private void GhostCard_Click(object sender, EventArgs e)
        {
            PictureBox pb = (PictureBox)sender;
            var        mx = pb.Parent.PointToClient(Cursor.Position).X;
            var        my = pb.Parent.PointToClient(Cursor.Position).Y;

            //if GhostCard is clicked on the right component, erase it and fill it
            try
            {
                if (panelHandler.GetComponent(pb, mx, my) == turnPageR)
                {
                    //Console.WriteLine(panelHandler.getComponent(pb, mx, my).Name);
                    TurnPageR_Click(null, null);
                }
                else if (panelHandler.GetComponent(pb, mx, my) == turnPageL)
                {
                    //Console.WriteLine(panelHandler.getComponent(pb, mx, my).Name);
                    TurnPageL_Click(null, null);
                }
                else if (panelHandler.GetComponent(pb, mx, my) == trashIcon)
                {
                    //Console.WriteLine("BOORYT;JKF;D");
                    if (trashIcon.Visible == true)
                    {
                        CardDatabaseManagement.RemoveCard(swapCard, (string)currentType.SelectedItem);
                        DisposeGhostCard();
                        PopulateDisplay();
                    }
                    else
                    {
                        DisposeGhostCard();
                    }
                }
                else if (panelHandler.GetComponent(pb, mx, my) == changePictureIcon)
                {
                    Console.WriteLine("database\\" + swapCard.Type + "\\images\\" + swapCard.Picture);
                    if (changePictureIcon.Visible == true)
                    {
                        //CardDatabaseManagement.RemoveCard(swapCard, (string)currentType.SelectedItem);
                        Process.Start("database\\" + swapCard.Type + "\\images\\");
                        //CardDatabaseManagement.RemoveCard(swapCard, (string)currentType.SelectedItem);
                        DisposeGhostCard();
                        PopulateDisplay();
                    }
                    else
                    {
                        DisposeGhostCard();
                    }
                }
                else if (panelHandler.GetComponent(pb, mx, my).GetType() == typeof(PictureBox))
                {
                    Control c = panelHandler.GetComponent(pb, mx, my);
                    //Console.WriteLine("Slot: " + c.Name + ", Page: " + currentPage);
                    Card destinationCard = CardDatabaseManagement.GetCard((string)currentType.SelectedItem, c.Name, currentPage + "");
                    //Console.WriteLine("c1: " + swapCard.Count + ", c2: " + destinationCard.Count);
                    //swap card
                    CardDatabaseManagement.SwapCard(ref swapCard, ref destinationCard);
                    PopulateDisplay();
                    DisposeGhostCard();
                }
            }
            catch (Exception ex)
            {
                ex.ToString();
                DisposeGhostCard();
            }
        }