Esempio n. 1
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
        }
Esempio n. 2
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
        }