Esempio n. 1
0
        private void Form1_Load(object sender, EventArgs e)
        {
            GamesRepository mygame    = new Octgn.Data.GamesRepository();
            int             gamecount = mygame.Games.Count;

            if (gamecount > 1)
            {
                GameSelection chooserForm = new GameSelection();
                chooserForm.gameList = new string[gamecount];
                for (int i = 0; i < gamecount; i++)
                {
                    chooserForm.gameList[i] = mygame.Games[i].Name;
                }
                chooserForm.ShowDialog();
                gameindex = chooserForm.GameIndex;
            }

            Game octgnGame = proxy.Games[gameindex];

            try
            {
                // Retrieve Card Image
                System.Windows.Controls.Image CardImage = new System.Windows.Controls.Image();
                BitmapImage src = new BitmapImage();
                src.BeginInit();
                src.UriSource   = octgnGame.GetCardBackUri();
                src.CacheOption = BitmapCacheOption.OnLoad;
                src.EndInit();
                pictureBox1.Image = SourceConvert.BitmapSourceToBitmap(src);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            // Default Page Setups
            printDocument1.DefaultPageSettings.Landscape = true;
            Margins margins = new Margins(25, 25, 25, 25); // 100ths of an inch. Ex. 25 = 0.25, 150 = 1.5

            printDocument1.DefaultPageSettings.Margins = margins;
            groupBox2.Focus();
            txtSearch.Focus();
        }
Esempio n. 2
0
        private void listDeckList_Click(object sender, EventArgs e)
        {
            // Selected Card Image
            GamesRepository proxy  = new GamesRepository();
            Game            mygame = proxy.Games[GameIndex];
            Guid            card   = Guid.Empty;
            string          guid   = listDeckList.Items[listDeckList.SelectedItems[0].Index].SubItems[3].Text;

            Guid.TryParse(guid, out card);
            try
            {
                BitmapImage img = new BitmapImage();
                System.Windows.Controls.Image CardImage = new System.Windows.Controls.Image();
                mtgPicture1.Image = SourceConvert.BitmapFromUri(img != null ? CardModel.GetPictureUri(mygame,
                                                                                                      mygame.GetCardById(card).Set.Id, mygame.GetCardById(card).ImageUri) : mygame.GetCardBackUri());
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Esempio n. 3
0
        private void DeckLoader_Load(object sender, EventArgs e)
        {
            // Default Image
            GamesRepository proxy  = new GamesRepository();
            Game            mygame = proxy.Games[GameIndex];

            try
            {
                // Retrieve Card Image
                System.Windows.Controls.Image CardImage = new System.Windows.Controls.Image();
                BitmapImage src = new BitmapImage();
                src.BeginInit();
                src.UriSource   = mygame.GetCardBackUri();
                src.CacheOption = BitmapCacheOption.OnLoad;
                src.EndInit();
                mtgPicture1.Image = SourceConvert.BitmapSourceToBitmap(src);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Esempio n. 4
0
        private void comboChooser_SelectionChangeCommitted(object sender, EventArgs e)
        {
            // Look up picture for selected Set
            Guid   card = Guid.Empty;
            string name = comboChooser.Items[comboChooser.SelectedIndex].ToString();

            foreach (CardModel Card in SetList)
            {
                if (name == Card.Set.Name)
                {
                    card = Card.Id;
                }
            }
            GamesRepository proxy  = new GamesRepository();
            Game            mygame = proxy.Games[GameIndex];
            BitmapImage     img    = new BitmapImage();

            System.Windows.Controls.Image CardImage = new System.Windows.Controls.Image();
            mtgPicture1.Image = SourceConvert.BitmapFromUri(img != null ? CardModel.GetPictureUri(mygame,
                                                                                                  mygame.GetCardById(card).Set.Id, mygame.GetCardById(card).ImageUri) : mygame.GetCardBackUri());
            selectedCard = card;
        }
Esempio n. 5
0
        private void Chooser_Load(object sender, EventArgs e)
        {
            //label2.Text = CardName;
            Guid card = Guid.Empty;

            string[] list = new string[SetList.Count];
            int      i    = 0;

            foreach (CardModel Card in SetList)
            {
                Set CardSet = Card.Set;
                list[i] = CardSet.Name;
                i++;
            }
            List <string> unique = new List <string>();

            unique.AddRange(list.Distinct());
            comboChooser.Sorted = true;
            foreach (string setname in unique)
            {
                comboChooser.Items.Add(setname);
            }
            comboChooser.Text = comboChooser.Items[0].ToString();
            // Default Image
            GamesRepository proxy  = new GamesRepository();
            Game            mygame = proxy.Games[GameIndex];

            card        = SetList[0].Id;
            label2.Text = SetList[0].Name;
            BitmapImage img = new BitmapImage();

            System.Windows.Controls.Image CardImage = new System.Windows.Controls.Image();
            mtgPicture1.Image = SourceConvert.BitmapFromUri(img != null ? CardModel.GetPictureUri(mygame,
                                                                                                  mygame.GetCardById(card).Set.Id, mygame.GetCardById(card).ImageUri) : mygame.GetCardBackUri());
            selectedCard = card;
        }
Esempio n. 6
0
        private void btnSearch_Click(object sender, EventArgs e)
        {
            try
            {
                string CardName = txtSearch.Text.ToLower();
                Game   mygame   = proxy.Games[gameindex];

                // Search for Card
                Guid     card = Guid.Empty;
                string[] cond = new string[1];
                cond[0] = "name = '" + CardName.Trim().Replace("'", "''") + "'";       // Equals
                string[] cond2 = new string[1];
                cond2[0] = "name like '%" + CardName.Trim().Replace("'", "''") + "%'"; // Contains
                List <CardModel> SetsWhereCardAppear = new List <CardModel>();
                SetsWhereCardAppear.AddRange(mygame.SelectCardModels(cond));
                if (SetsWhereCardAppear.Count < 1)
                {
                    // If incorrectly typed name try a "name contains" statement
                    SetsWhereCardAppear.AddRange(mygame.SelectCardModels(cond2));
                    if (SetsWhereCardAppear.Count > 0)
                    {
                        CardSelection cardForm = new CardSelection();
                        cardForm.CardList = new string[SetsWhereCardAppear.Count];
                        for (int i = 0; i < SetsWhereCardAppear.Count; i++)
                        {
                            cardForm.CardList[i] = SetsWhereCardAppear[i].Name;
                        }
                        cardForm.ShowDialog();
                        string[] fixedSearch = new string[1];
                        fixedSearch[0] = "name = '" + cardForm.CardName.Trim().Replace("'", "''") + "'"; // Equals
                        SetsWhereCardAppear.Clear();
                        SetsWhereCardAppear.AddRange(mygame.SelectCardModels(fixedSearch));
                        txtSearch.Text = cardForm.CardName;
                    }
                    else
                    {
                        MessageBox.Show("Could not find any matching cards for search term: " + txtSearch.Text);
                        txtSearch.Focus();
                        txtSearch.SelectAll();
                    }
                }
                // If multiple cards returned.
                if (SetsWhereCardAppear.Count > 1)
                {
                    Chooser chooser = new Chooser();
                    chooser.SetList   = new List <CardModel>();
                    chooser.SetList   = SetsWhereCardAppear;
                    chooser.CardName  = CardName;
                    chooser.GameIndex = gameindex;
                    chooser.ShowDialog();
                    card = chooser.selectedCard;
                }
                else
                {
                    if (SetsWhereCardAppear.Count == 1)
                    {
                        card = SetsWhereCardAppear[0].Id;
                    }
                }
                if (SetsWhereCardAppear.Count != 0)
                {
                    // Retrieve Card Image
                    BitmapImage img = new BitmapImage();
                    System.Windows.Controls.Image CardImage = new System.Windows.Controls.Image();
                    Uri picture = CardModel.GetPictureUri(mygame, mygame.GetCardById(card).Set.Id,
                                                          mygame.GetCardById(card).ImageUri) ?? mygame.GetCardBackUri();
                    pictureBox1.Image = SourceConvert.BitmapFromUri(picture);
                    Uri alternate = new Uri(picture.ToString().Replace(".jpg", ".b.jpg"));
                    try
                    {
                        pictureBox2.Image = SourceConvert.BitmapFromUri(alternate);
                    }
                    catch
                    {
                        pictureBox2.Image = SourceConvert.BitmapFromUri(mygame.GetCardBackUri());
                    }
                }
            }
            catch (Exception ex) { MessageBox.Show(ex.Message); }
            txtSearch.Focus();
            txtSearch.SelectAll();
            pictureBox1.Visible = true;
            pictureBox2.Visible = false;
        }
Esempio n. 7
0
        private void btnLoadDeck_Click(object sender, EventArgs e)
        {
            DeckLoader LoadDeck = new DeckLoader();

            LoadDeck.GameIndex = gameindex;
            LoadDeck.ShowDialog();

            if (LoadDeck.cancelled == false)
            {
                richTextBox1.ReadOnly = false;
                PictureBox ProxyImage = new PictureBox();


                // Open database for image retrieval
                GamesRepository proxy  = new GamesRepository();
                Game            mygame = proxy.Games[gameindex];

                foreach (ProxyList myList in LoadDeck.guidList)
                {
                    // Resize image for mock layout
                    Size mockSize = new Size();
                    mockSize.Width  = 384 / 3;
                    mockSize.Height = 544 / 3;
                    // Resize image for real layout
                    Size realSize = new Size();
                    realSize.Width  = 240;
                    realSize.Height = 335; // 340

                    // Load Image
                    Guid CardID = Guid.Empty;
                    Guid.TryParse(myList.GUID, out CardID);
                    try
                    {
                        // Retrieve Card Image
                        BitmapImage img = new BitmapImage();
                        System.Windows.Controls.Image CardImage = new System.Windows.Controls.Image();
                        ProxyImage.Image = SourceConvert.BitmapFromUri(CardModel.GetPictureUri(mygame,
                                                                                               mygame.GetCardById(CardID).Set.Id, mygame.GetCardById(CardID).ImageUri)
                                                                       ?? mygame.GetCardBackUri());
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(ex.Message);
                    }

                    for (int I = 0; I < Convert.ToInt16(myList.Quantity); I++)
                    {
                        // Mock Page
                        Clipboard.SetImage(resizeImage(ProxyImage.Image, mockSize));
                        richTextBox1.Paste();
                        // Real Page
                        Clipboard.SetImage(resizeImage(ProxyImage.Image, realSize));
                        richTextBox2.Paste();
                        // Add spacing
                        richTextBox1.AppendText(" "); // Mock
                        richTextBox2.AppendText(" "); // Real
                    }
                }
                // Center all images
                richTextBox1.SelectAll();
                richTextBox1.SelectionAlignment = HorizontalAlignment.Center;
                richTextBox1.Select(0, 0);
                richTextBox2.SelectAll();
                richTextBox2.SelectionAlignment = HorizontalAlignment.Center;
                richTextBox2.Select(0, 0);

                Clipboard.Clear();
                txtSearch.Focus();
                txtSearch.SelectAll();

                //mygame.CloseDatabase();
                richTextBox1.ReadOnly = true;
            }
            // End
        }