Exemple #1
0
        private List <CardHolder> GetCardHolders(PrintModes pm)
        {
            int failcount       = 0;
            int failmax         = 10;
            List <CardHolder> i = null;

tryagain:
            try
            {
                var op = new MinimalOptions()
                {
                    Expansion = newestExpansionToolStripMenuItem.Checked,
                    Flavour   = flavourTextToolStripMenuItem.Checked,
                    Rarity    = newestExpansionRarityToolStripMenuItem.Checked
                };

                i = EnteredCards.Items.Cast <ListViewItem>().Select(s => s.Tag).Cast <CardHolder>().ToList();
                i.AsParallel().ForAll(s => s.GetAndSetImages(pm, op));
                return(i);
            }
            catch (Exception ex)
            {
                if (failcount < failmax)
                {
                    failcount++;
                    Thread.Sleep(100);
                    goto tryagain;
                }
                MessageBox.Show("an error has occured. try again:" + ex);
            }
            return(null);
        }
        public static MinimalCardControl Show(Card c, MinimalOptions mo)
        {
            var cc = new MinimalCardControl();

            try
            {
                cc.CardName.Text  = c.Name;
                cc.cardMana.Text  = "Cost:" + c.Cost;
                cc.cardTypes.Text = c.Types;
                cc.expansion.Text = mo.Expansion ? c.NewestExpansion : "";
                cc.rarity.Text    = mo.Rarity ? c.Rarity : "";
                cc.textTB.Text    = c.Text;
                cc.flavourTB.Text = mo.Flavour ? c.FlavourText : "";
                cc.ptTB.Text      = c.PT;
            }
            catch (Exception)
            {
            }
            return(cc);
        }
Exemple #3
0
        public void GetAndSetImages(PrintModes pm, MinimalOptions mo)
        {
            //download first if necessary
            //colour
            var pathColour = GetImageFilename(C, PrintModes.Colour);

            if (File.Exists(pathColour) == false)
            {
                NetExtras.DownloadFile(C.ImgURL, pathColour);
            }

            //black and white
            var pathBw = GetImageFilename(C, PrintModes.BlackAndWhite);

            if (File.Exists(pathBw) == false)
            {
                Bitmap bw;
                using (var i = (Bitmap)Image.FromFile(pathColour))
                {
                    bw = BitmapExtras.ApplyGrayscale(new Bitmap(i));
                }

                bw.Save(pathBw);
            }

            //minimal - always generate in case options have changed - todo - do properly
            var minpath = GetImageFilename(C, PrintModes.Minimal);

            if (File.Exists(minpath))
            {
                File.Delete(minpath);
            }

            var m   = MinimalCardControl.Show(C, mo);
            var min = new Bitmap(m.Width, m.Height);

            m.DrawToBitmap(min, new Rectangle(0, 0, m.Width, m.Height));
            min.Save(minpath);

            SetImage(pm);
        }