Beispiel #1
0
        public void addToInventory(cardWrapper newEntry)
        {
            Card_Table_Panel.RowCount++;

            Card_Table_Panel.Controls.Add(new Label()
            {
                Text = newEntry.card.name, AutoEllipsis = true
            }, 1, Card_Table_Panel.RowCount - 1);
            Card_Table_Panel.Controls.Add(new Label()
            {
                Text = newEntry.card.type, AutoEllipsis = true
            }, 2, Card_Table_Panel.RowCount - 1);
            Card_Table_Panel.Controls.Add(new Label()
            {
                Text = newEntry.card.setCode, AutoEllipsis = true
            }, 3, Card_Table_Panel.RowCount - 1);
            Card_Table_Panel.Controls.Add(new Label()
            {
                Text = newEntry.card.multiverseId.ToString(), AutoEllipsis = true
            }, 4, Card_Table_Panel.RowCount - 1);
            Card_Table_Panel.Controls.Add(new Label()
            {
                Text = newEntry.card.manaCost, AutoEllipsis = true
            }, 5, Card_Table_Panel.RowCount - 1);
            Card_Table_Panel.Controls.Add(new Label()
            {
                Text = "N/A", AutoEllipsis = true
            }, 6, Card_Table_Panel.RowCount - 1);
        }
Beispiel #2
0
        private void Label_Clicked(Object sender, EventArgs eventArgs)
        {
            var returnCard = (sender as Label).Tag as cardWrapper;

            currentCard = returnCard;

            CardName.Text          = returnCard.card.name;
            Card_Set_Combobox.Text = returnCard.card.setCode;
            Card_Type_TextBox.Text = returnCard.card.type;
            if (returnCard.card.text != "n/a" && returnCard.card.text != null)
            {
                cardTextTextbox.Visible = true;
                cardTextLabel.Visible   = true;
                cardTextTextbox.Text    = returnCard.card.text;
            }
            else
            {
                cardTextLabel.Visible   = false;
                cardTextTextbox.Visible = false;
            }

            if (returnCard.card.flavorText != "n/a" && returnCard.card.flavorText != null)
            {
                cardFlavorLabel.Visible   = true;
                cardFlavorTextbox.Visible = true;
                cardFlavorTextbox.Text    = returnCard.card.flavorText;
            }
            else
            {
                cardFlavorLabel.Visible   = false;
                cardFlavorTextbox.Visible = false;
            }

            if (returnCard.card.loyalty != "n/a" && returnCard.card.loyalty != null)
            {
                cardLoyaltyLabel.Visible = true;
                cardPTLabel.Visible      = false;
                cardPTLTextbox.Visible   = true;
                cardPTLTextbox.Text      = returnCard.card.loyalty;
            }
            else if (returnCard.card.power != "n/a" && returnCard.card.power != null)
            {
                cardPTLabel.Visible      = true;
                cardPTLTextbox.Visible   = true;
                cardLoyaltyLabel.Visible = false;
                cardPTLTextbox.Text      = returnCard.card.power + "/" + returnCard.card.toughness;
            }
            else
            {
                cardPTLabel.Visible      = false;
                cardPTLTextbox.Visible   = false;
                cardLoyaltyLabel.Visible = false;
            }
        }
Beispiel #3
0
        private List <cardWrapper> findCardsWithName(string cardName)
        {
            List <cardWrapper> returnList = new List <cardWrapper>();

            List <int> tempIDs = new List <int>();

            connection.Open();

            using (var cmd = new NpgsqlCommand("get_cards_containing_name", connection))
            {
                cmd.CommandType = CommandType.StoredProcedure;

                cmd.Parameters.AddWithValue("in_name", cardName);

                //tempID =
                var reader = cmd.ExecuteReader();

                //if(reader.HasRows)

                while (reader.Read())
                {
                    string      temp;
                    cardWrapper tempWrapper = new cardWrapper();
                    CardObject  tempCard    = new CardObject();
                    tempCard.cardID       = Convert.ToInt32(reader[0].ToString());
                    tempCard.name         = reader[2].ToString();
                    tempCard.type         = reader[3].ToString();
                    tempCard.manaCost     = reader[4].ToString();
                    tempCard.setCode      = reader[5].ToString();
                    tempCard.multiverseId = Convert.ToInt32(reader[9].ToString());
                    tempCard.power        = reader[10].ToString();
                    tempCard.toughness    = reader[11].ToString();

                    temp            = reader[13].ToString().TrimEnd('}');
                    temp            = temp.TrimStart('{');
                    tempCard.colors = temp.Split(',').ToList <string>();

                    temp = reader[14].ToString().TrimEnd('}');
                    temp = temp.TrimStart('{');
                    tempCard.colorIdentity = temp.Split(',').ToList <string>();

                    tempCard.text = reader[15].ToString();
                    tempCard.convertedManaCost = float.Parse(reader[16].ToString());

                    tempCard.flavorText  = reader[17].ToString();
                    tempCard.rarity      = reader[18].ToString();
                    tempCard.borderColor = reader[19].ToString();
                    tempCard.loyalty     = reader[20].ToString();
                    tempCard.artist      = reader[21].ToString();
                    tempCard.number      = reader[24].ToString();

                    tempWrapper.card = tempCard;

                    returnList.Add(tempWrapper);
                }
            }

            connection.Close();

            return(returnList);
        }
Beispiel #4
0
        private cardWrapper findCardWithName(string cardName)
        {
            cardWrapper returnCard  = new cardWrapper();
            cardWrapper tempWrapper = new cardWrapper();

            connection.Open();

            using (var cmd = new NpgsqlCommand("get_cards_containing_name", connection))
            {
                cmd.CommandType = CommandType.StoredProcedure;

                cmd.Parameters.AddWithValue("in_name", cardName);
                var reader       = cmd.ExecuteReader();
                int rowsAffected = 0;

                while (reader.Read())
                {
                    if (reader[2].ToString().Contains("FOIL") || reader[2].ToString().Contains("PRERELEASE"))
                    {
                        rowsAffected++;
                    }
                }

                if (rowsAffected > 1)
                {
                    tempWrapper.cardStatus = Color.Gold;
                }
                else
                {
                    tempWrapper.cardStatus = this.BackColor;
                }
            }

            connection.Close();

            connection.Open();

            using (var cmd = new NpgsqlCommand("get_card_with_name", connection))
            {
                cmd.CommandType = CommandType.StoredProcedure;

                cmd.Parameters.AddWithValue("in_name", cardName);

                CardObject tempCard = new CardObject();

                tempCard.cardID = Convert.ToInt32(cmd.ExecuteScalar());
                returnCard.card = tempCard;
            }

            connection.Close();

            connection.Open();

            using (var cmd = new NpgsqlCommand("SELECT * FROM public.card WHERE card_id = " + returnCard.card.cardID, connection))
            {
                NpgsqlDataReader reader = cmd.ExecuteReader();
                while (reader.Read())
                {
                    string     temp;
                    CardObject tempCard = new CardObject();
                    tempCard.cardID       = Convert.ToInt32(reader[0].ToString());
                    tempCard.name         = reader[2].ToString();
                    tempCard.type         = reader[3].ToString();
                    tempCard.manaCost     = reader[4].ToString();
                    tempCard.setCode      = reader[5].ToString();
                    tempCard.multiverseId = Convert.ToInt32(reader[9].ToString());
                    tempCard.power        = reader[10].ToString();
                    tempCard.toughness    = reader[11].ToString();

                    temp            = reader[13].ToString().TrimEnd('}');
                    temp            = temp.TrimStart('{');
                    tempCard.colors = temp.Split(',').ToList <string>();

                    temp = reader[14].ToString().TrimEnd('}');
                    temp = temp.TrimStart('{');
                    tempCard.colorIdentity = temp.Split(',').ToList <string>();

                    tempCard.text = reader[15].ToString();
                    tempCard.convertedManaCost = float.Parse(reader[16].ToString());

                    tempCard.flavorText  = reader[17].ToString();
                    tempCard.rarity      = reader[18].ToString();
                    tempCard.borderColor = reader[19].ToString();
                    tempCard.loyalty     = reader[20].ToString();
                    tempCard.artist      = reader[21].ToString();
                    tempCard.number      = reader[24].ToString();

                    tempWrapper.card = tempCard;

                    returnCard = tempWrapper;
                    Card_Set_Combobox.Items.Add(tempCard.setCode);
                    CardName.Items.Add(tempCard.name);
                }
            }
            connection.Close();

            if (returnCard.card != null)
            {
                textBox1.Text += " Success!";
            }
            else
            {
                textBox1.Text += " Failed!";
            }

            CardName.Text          = returnCard.card.name;
            Card_Set_Combobox.Text = returnCard.card.setCode;
            Card_Type_TextBox.Text = returnCard.card.type;
            if (returnCard.card.text != "n/a")
            {
                cardTextTextbox.Visible = true;
                cardTextLabel.Visible   = true;
                cardTextTextbox.Text    = returnCard.card.text;
            }
            else
            {
                cardTextLabel.Visible   = false;
                cardTextTextbox.Visible = false;
            }

            if (returnCard.card.flavorText != "n/a")
            {
                cardFlavorLabel.Visible   = true;
                cardFlavorTextbox.Visible = true;
                cardFlavorTextbox.Text    = returnCard.card.flavorText;
            }
            else
            {
                cardFlavorLabel.Visible   = false;
                cardFlavorTextbox.Visible = false;
            }

            if (returnCard.card.loyalty != "n/a")
            {
                cardLoyaltyLabel.Visible = true;
                cardPTLabel.Visible      = false;
                cardPTLTextbox.Visible   = true;
                cardPTLTextbox.Text      = returnCard.card.loyalty;
            }
            else if (returnCard.card.power != "n/a")
            {
                cardPTLabel.Visible      = true;
                cardPTLTextbox.Visible   = true;
                cardLoyaltyLabel.Visible = false;
                cardPTLTextbox.Text      = returnCard.card.power + "/" + returnCard.card.toughness;
            }
            else
            {
                cardPTLabel.Visible      = false;
                cardPTLTextbox.Visible   = false;
                cardLoyaltyLabel.Visible = false;
            }

            currentCard = returnCard;

            return(returnCard);
        }
Beispiel #5
0
        public void addToList(cardWrapper sentCard)
        {
            tableLayoutPanel5.Visible = false;
            int rowOffset = tableLayoutPanel5.RowCount;

            tableLayoutPanel5.RowCount++;
            tableLayoutPanel5.RowStyles.Add(new RowStyle()
            {
                SizeType = SizeType.Absolute, Height = 50
            });
            //if (!Card_Table_Panel.AutoScroll) Card_Table_Panel.AutoScroll = true;
            if (!cards.Contains(sentCard))
            {
                cards.Add(sentCard);
            }


            // begin popluating rows with cards
            // populate each row with a checkbox

            var tempCheck = new CheckBox()
            {
                CheckAlign = ContentAlignment.MiddleCenter, Dock = DockStyle.Fill, BackColor = sentCard.cardStatus, Tag = sentCard
            };

            tempCheck.CheckStateChanged += new EventHandler(cardCheckChanged);
            tableLayoutPanel5.Controls.Add(tempCheck, 0, tableLayoutPanel5.RowCount - 1);

            var tempLabel = new Label()
            {
                Text = sentCard.card.name, AutoEllipsis = true, AutoSize = true, Anchor = AnchorStyles.None, BackColor = sentCard.cardStatus, Tag = sentCard
            };

            tempLabel.Click += new EventHandler(Label_Clicked);
            tableLayoutPanel5.Controls.Add(tempLabel, 1, rowOffset);

            tempLabel = new Label()
            {
                Text = sentCard.card.type, AutoEllipsis = true, AutoSize = true, Anchor = AnchorStyles.None, BackColor = sentCard.cardStatus, Tag = sentCard
            };
            tempLabel.Click += new EventHandler(Label_Clicked);
            tableLayoutPanel5.Controls.Add(tempLabel, 2, rowOffset);

            tempLabel = new Label()
            {
                Text = sentCard.card.setCode, AutoEllipsis = true, AutoSize = true, Anchor = AnchorStyles.None, BackColor = sentCard.cardStatus, Tag = sentCard
            };
            tempLabel.Click += new EventHandler(Label_Clicked);
            tableLayoutPanel5.Controls.Add(tempLabel, 3, rowOffset);


            tempLabel = new Label()
            {
                Text = sentCard.card.number, AutoEllipsis = true, AutoSize = true, Anchor = AnchorStyles.None, BackColor = sentCard.cardStatus, Tag = sentCard
            };
            tempLabel.Click += new EventHandler(Label_Clicked);
            tableLayoutPanel5.Controls.Add(tempLabel, 4, rowOffset);

            tempLabel = new Label()
            {
                Text = sentCard.card.manaCost, AutoEllipsis = true, AutoSize = true, Anchor = AnchorStyles.None, BackColor = sentCard.cardStatus, Tag = sentCard
            };
            tempLabel.Click += new EventHandler(Label_Clicked);
            tableLayoutPanel5.Controls.Add(tempLabel, 5, rowOffset);

            tableLayoutPanel5.Visible = true;
        }
Beispiel #6
0
        private void Take_Picture_Button_Click(object sender, EventArgs e)
        {
            if (Photo_Filepath != null && Cam_Picture_Box.Image != null)
            {
                try
                {
                    //picture from web cam
                    Bitmap originalImg = (Bitmap)Cam_Picture_Box.Image.Clone();
                    //rotate 90 degrees
                    originalImg.RotateFlip(RotateFlipType.Rotate90FlipNone);

                    //Dim of saved image
                    int xStart  = 1;
                    int yStart  = 1;
                    int xEnd    = originalImg.Width - xStart;
                    int yEnd    = originalImg.Height - yStart;
                    int xWidth  = (xEnd - xStart);
                    int yHeight = (yEnd - yStart);

                    //Establishing size of crop area based off original image (x,y,width,height)
                    //All percents are measured/calulated ratios based off card dimensions
                    Rectangle nameHeaderCropRect = new Rectangle(Convert.ToInt32((xWidth * 0.08 /*0.063786008*/) + xStart), Convert.ToInt32((yHeight * 0.055 /*0.040481481*/) + yStart), Convert.ToInt32(xWidth * 0.69753086), Convert.ToInt32(yHeight * 0.06 /*0.05037037*/));

                    //Bitmap that will store altered image (width,height)
                    Bitmap nameHeaderBitmap = new Bitmap(nameHeaderCropRect.Width, nameHeaderCropRect.Height);

                    //blank bitmap to graphics object. ready for changes
                    Graphics nameHeadGraphics = Graphics.FromImage(nameHeaderBitmap);

                    //original image cropped to two different images
                    nameHeadGraphics.DrawImage(originalImg, 0, 0, nameHeaderCropRect, GraphicsUnit.Pixel);

                    //calls picture alteration function to increase contrast and adjust image color
                    Adjust_Tesseract_Img(15, nameHeaderBitmap);

                    //displays original image in picture preview box
                    Display_Picture_Box.Image = originalImg;
                    //displays name header image in name header picture box
                    Name_Header_Pic_Box.Image = nameHeaderBitmap;

                    //will hold tesseract return string
                    string textBoxString;
                    var    ocr  = new TesseractEngine("./tessdata", "eng", EngineMode.TesseractAndCube);
                    var    page = ocr.Process(nameHeaderBitmap);                            //sends name header bitmap to tesseract
                    textBoxString = page.GetText();                                         //gets tesseract text
                    textBox1.Text = textBoxString;
                    textBoxString = textBoxString.Replace("—", "-");                      //removes endline characters
                    textBoxString = textBoxString.TrimStart(' ', '-', '_', '.', ',', '\''); //removes spaces
                    textBoxString = textBoxString.TrimEnd('\n', '.', ',', '-', '_');        //removes endline characters
                    textBoxString = textBoxString.Trim(' ');                                //removes spaces
                    textBox1.Text = textBoxString;
                    CardName.Text = textBoxString;

                    addToList(findCardWithName(textBoxString));
                    currentCard.tempImg = originalImg;
                }
                catch (Exception ex)
                {
                    cardWrapper tempCard = new cardWrapper();
                    if (CardName.Text != "Name" && CardName.Text != "")
                    {
                        tempCard.card = new CardObject {
                            name = CardName.Text,
                        };
                    }
                    else
                    {
                        tempCard.card = new CardObject {
                            name = "Unknown Card"
                        };
                    }
                    tempCard.cardStatus = Color.Red;
                    tempCard.tempImg    = (Bitmap)Display_Picture_Box.Image.Clone();
                    addToList(tempCard);
                    if (connection.State == ConnectionState.Open)
                    {
                        connection.Close();
                    }
                }//need to add exception functionality
            }
        }
Beispiel #7
0
        public void populate(cardWrapper input)
        {
            currentCard = input;

            Name_Textbox.Text           = currentCard.card.name;
            Card_Mana_Cost_TextBox.Text = currentCard.card.manaCost;
            Card_Type_TextBox.Text      = currentCard.card.type;
            Card_Expansion_TextBox.Text = currentCard.card.setCode;
            textBox2.Text = currentCard.card.number;

            if (currentCard.card.subtypes != null)
            {
                Card_Additional_Label.Visible   = true;
                Card_Additional_TextBox.Visible = true;
                for (int i = 0; i < currentCard.card.subtypes.Count; i++)
                {
                    Card_Additional_TextBox.Text += currentCard.card.subtypes[i] + " ";
                }
            }
            else
            {
                Card_Additional_Label.Visible   = false;
                Card_Additional_TextBox.Visible = false;
            }

            if (currentCard.card.power != null)
            {
                Card_Power_Label.Visible   = true;
                Card_Power_TextBox.Visible = true;
                Card_Power_TextBox.Text    = currentCard.card.power;
            }
            else
            {
                Card_Power_Label.Visible   = false;
                Card_Power_TextBox.Visible = false;
            }

            if (currentCard.card.toughness != null)
            {
                Card_Toughness_Label.Visible   = true;
                Card_Toughness_TextBox.Visible = true;
                Card_Toughness_TextBox.Text    = currentCard.card.toughness;
            }
            else
            {
                Card_Toughness_Label.Visible   = false;
                Card_Toughness_TextBox.Visible = false;
            }

            if (currentCard.card.text != null)
            {
                Card_Description_Label.Visible   = true;
                Card_Description_TextBox.Visible = true;
                Card_Description_TextBox.Text    = currentCard.card.text;
            }
            else
            {
                Card_Description_Label.Visible   = false;
                Card_Description_TextBox.Visible = false;
            }

            if (currentCard.card.flavorText != null)
            {
                Card_Flavor_Text_Label.Visible   = true;
                Card_Flavor_Text_TextBox.Visible = true;
                Card_Flavor_Text_TextBox.Text    = currentCard.card.flavorText;
            }
            else
            {
                Card_Flavor_Text_Label.Visible   = false;
                Card_Flavor_Text_TextBox.Visible = false;
            }

            //pictureBox1.Image = newForm.Display_Picture_Box.Image;

            /*if (currentCard.card.ImageUrl.OriginalString != null)
             * {
             *  pictureBox1.Load(currentCard.card.ImageUrl.OriginalString);
             * }*/
        }
Beispiel #8
0
        public bool addToInventory()
        {
            if (CurrentUser.prvlg_lvl > 0 && CurrentUser.prvlg_lvl < 5)
            {
                cardWrapper card   = databaseList[0];
                bool        exists = false;
                int         inv_id;

                connection.Open();

                using (var cmd = new NpgsqlCommand("new_trans_event", connection))
                {
                    cmd.CommandType = System.Data.CommandType.StoredProcedure;

                    cmd.Parameters.AddWithValue("in_foreign_card_id", card.card.cardID);
                    cmd.Parameters.AddWithValue("in_foreign_user_id", CurrentUser.user_ID);
                    cmd.Parameters.AddWithValue("in_datetime", DateTime.Now);
                    cmd.Parameters.AddWithValue("in_trans_type", 1);

                    cmd.ExecuteScalar();
                }

                connection.Close();


                connection.Open();
                using (var cmd = new NpgsqlCommand("SELECT * FROM public.inventory WHERE card_id = " + card.card.cardID, connection))
                {
                    NpgsqlDataReader reader = cmd.ExecuteReader();


                    if (reader.HasRows)
                    {
                        exists = true;
                    }
                }
                connection.Close();

                if (exists)
                {
                    connection.Open();
                    using (var cmd = new NpgsqlCommand("update_inv_count", connection))
                    {
                        cmd.CommandType = System.Data.CommandType.StoredProcedure;

                        cmd.Parameters.AddWithValue("in_foreign_card_id", card.card.cardID);
                        cmd.Parameters.AddWithValue("in_new_count", 1);

                        cmd.ExecuteScalar();
                    }
                    connection.Close();
                }
                else
                {
                    connection.Open();
                    using (var cmd = new NpgsqlCommand("new_inv_event", connection))
                    {
                        cmd.CommandType = System.Data.CommandType.StoredProcedure;

                        cmd.Parameters.AddWithValue("in_foreign_card_id", card.card.cardID);
                        cmd.Parameters.AddWithValue("in_new_count", 1);

                        cmd.ExecuteScalar();
                    }
                    connection.Close();
                }
                return(true);
            }
            else
            {
                return(false);
            }
        }
Beispiel #9
0
        private void Enter()
        {
            databaseList.Clear();
            if (Name_Textbox.Text.Length != 0)
            {
                connection.Open();

                var str = "SELECT * FROM public.card WHERE card_name ILIKE '%" + Name_Textbox.Text + "%'";

                /*if(Card_Type_TextBox.Text != null)
                 * {
                 *  str += "AND card_type ILIKE '%" + Card_Type_TextBox.Text + "%'";
                 * }*/

                var cmd = new NpgsqlCommand("SELECT * FROM public.card WHERE card_name ILIKE '%" + Name_Textbox.Text + "%'", connection);

                NpgsqlDataReader reader = cmd.ExecuteReader();

                while (reader.Read())
                {
                    string      temp;
                    cardWrapper tempWrapper = new cardWrapper();
                    CardObject  tempCard    = new CardObject();
                    tempCard.cardID       = System.Convert.ToInt32(reader[0].ToString());
                    tempCard.name         = reader[2].ToString();
                    tempCard.type         = reader[3].ToString();
                    tempCard.manaCost     = reader[4].ToString();
                    tempCard.setCode      = reader[5].ToString();
                    tempCard.multiverseId = System.Convert.ToInt32(reader[9].ToString());
                    tempCard.power        = reader[10].ToString();
                    tempCard.toughness    = reader[11].ToString();

                    temp            = reader[13].ToString().TrimEnd('}');
                    temp            = temp.TrimStart('{');
                    tempCard.colors = temp.Split(',').ToList <string>();

                    temp = reader[14].ToString().TrimEnd('}');
                    temp = temp.TrimStart('{');
                    tempCard.colorIdentity = temp.Split(',').ToList <string>();

                    tempCard.text = reader[15].ToString();
                    tempCard.convertedManaCost = float.Parse(reader[16].ToString());

                    tempCard.flavorText  = reader[17].ToString();
                    tempCard.rarity      = reader[18].ToString();
                    tempCard.borderColor = reader[19].ToString();
                    tempCard.loyalty     = reader[20].ToString();
                    tempCard.artist      = reader[21].ToString();
                    tempCard.number      = reader[24].ToString();

                    tempWrapper.card = tempCard;

                    databaseList.Add(tempWrapper);
                }


                connection.Close();
            }
            else
            {
                cardExists = false;
            }

            if (databaseList.Count != 0)
            {
                cardExists            = true;
                button2.Enabled       = true;
                textBox1.Text         = "";
                Name_Textbox.ReadOnly = true;
                populate(databaseList[0]);
            }
            else
            {
                Name_Textbox.Text = "Card not valid";
            }
        }
Beispiel #10
0
        /*
         * List of variables returned:
         *
         */
        private List <cardWrapper> Get_Inventory()
        {
            // create list of cards
            List <cardWrapper> cards = new List <cardWrapper>();

            // open connection to server
            connection.Open();

            // return entire inventory table, go through it,
            // populate cards inside list with their card IDs,
            // check for duplicates
            // query the database again, looking for those same card IDs within the database
            // go back to the system so it can read all the return data from the database so
            // it can be returned to the calling function
            using (var cmd = new NpgsqlCommand("SELECT * FROM public.inventory", connection))
            {
                NpgsqlDataReader reader = cmd.ExecuteReader();

                while (reader.Read())
                {
                    cardWrapper card = new cardWrapper();
                    card.card_ID = System.Convert.ToInt32(reader[1].ToString());
                    card.count   = System.Convert.ToInt32(reader[2].ToString());

                    cards.Add(card);
                }
            }
            connection.Close();

            string cmdhold = "";

            for (int i = 0; i < cards.Count; i++)
            {
                if (cards[i].count <= 0)
                {
                    cards.RemoveAt(i);
                    i--;
                }
                else if (i != 0)
                {
                    cmdhold += "OR card_id = " + cards[i].card_ID;
                }
                else
                {
                    cmdhold = "card_id = " + cards[i].card_ID;
                }
            }


            // TO DO:
            // add ability to grab card expansion
            if (cards.Count != 0)
            {
                connection.Open();

                using (var cmd = new NpgsqlCommand("SELECT * FROM public.card WHERE " + cmdhold, connection))
                {
                    NpgsqlDataReader reader = cmd.ExecuteReader();

                    while (reader.Read())
                    {
                        string     temp;
                        CardObject tempCard = new CardObject();
                        tempCard.cardID       = System.Convert.ToInt32(reader[0].ToString());
                        tempCard.name         = reader[2].ToString();
                        tempCard.type         = reader[3].ToString();
                        tempCard.manaCost     = reader[4].ToString();
                        tempCard.setCode      = reader[5].ToString();
                        tempCard.multiverseId = System.Convert.ToInt32(reader[9].ToString());
                        tempCard.power        = reader[10].ToString();
                        tempCard.toughness    = reader[11].ToString();

                        temp            = reader[13].ToString().TrimEnd('}');
                        temp            = temp.TrimStart('{');
                        tempCard.colors = temp.Split(',').ToList <string>();

                        temp = reader[14].ToString().TrimEnd('}');
                        temp = temp.TrimStart('{');
                        tempCard.colorIdentity = temp.Split(',').ToList <string>();

                        tempCard.text = reader[15].ToString();
                        tempCard.convertedManaCost = float.Parse(reader[16].ToString());

                        tempCard.flavorText  = reader[17].ToString();
                        tempCard.rarity      = reader[18].ToString();
                        tempCard.borderColor = reader[19].ToString();
                        tempCard.loyalty     = reader[20].ToString();
                        tempCard.artist      = reader[21].ToString();
                        tempCard.number      = reader[24].ToString();

                        for (int i = 0; i < cards.Count; i++)
                        {
                            if (cards[i].card_ID == tempCard.cardID)
                            {
                                cards[i].card = tempCard;
                            }
                        }
                    }
                }
                connection.Close();
            }


            return(cards);
        }
Beispiel #11
0
        public void populate(cardWrapper input)
        {
            cardWrapper currentCard = input;

            pictureBox1.Image = null;

            try
            {
                var image = service.Where(x => x.Set, currentCard.card.setCode).Where(y => y.Number, currentCard.card.number).All().Value[0].ImageUrl.OriginalString;
                System.Net.WebRequest  req      = System.Net.WebRequest.Create(image);
                System.Net.WebResponse response = req.GetResponse();
                var stream = response.GetResponseStream();
                pictureBox1.Image = Image.FromStream(stream);
                stream.Close();
            }
            catch
            {
            }

            Name_Textbox.Text           = currentCard.card.name;
            Card_Mana_Cost_TextBox.Text = currentCard.card.manaCost;
            Card_Type_TextBox.Text      = currentCard.card.type;
            Card_Expansion_TextBox.Text = currentCard.card.setCode;
            textBox2.Text = currentCard.card.number;

            if (currentCard.card.subtypes != null)
            {
                Card_Additional_Label.Visible   = true;
                Card_Additional_TextBox.Visible = true;
                for (int i = 0; i < currentCard.card.subtypes.Count; i++)
                {
                    Card_Additional_TextBox.Text += currentCard.card.subtypes[i] + " ";
                }
            }
            else
            {
                Card_Additional_Label.Visible   = false;
                Card_Additional_TextBox.Visible = false;
            }

            if (currentCard.card.power != null)
            {
                Card_Power_Label.Visible   = true;
                Card_Power_TextBox.Visible = true;
                Card_Power_TextBox.Text    = currentCard.card.power;
            }
            else
            {
                Card_Power_Label.Visible   = false;
                Card_Power_TextBox.Visible = false;
            }

            if (currentCard.card.toughness != null)
            {
                Card_Toughness_Label.Visible   = true;
                Card_Toughness_TextBox.Visible = true;
                Card_Toughness_TextBox.Text    = currentCard.card.toughness;
            }
            else
            {
                Card_Toughness_Label.Visible   = false;
                Card_Toughness_TextBox.Visible = false;
            }

            if (currentCard.card.text != null)
            {
                Card_Description_Label.Visible   = true;
                Card_Description_TextBox.Visible = true;
                Card_Description_TextBox.Text    = currentCard.card.text;
            }
            else
            {
                Card_Description_Label.Visible   = false;
                Card_Description_TextBox.Visible = false;
            }

            if (currentCard.card.flavorText != null)
            {
                Card_Flavor_Text_Label.Visible   = true;
                Card_Flavor_Text_TextBox.Visible = true;
                Card_Flavor_Text_TextBox.Text    = currentCard.card.flavorText;
            }
            else
            {
                Card_Flavor_Text_Label.Visible   = false;
                Card_Flavor_Text_TextBox.Visible = false;
            }
        }