Example #1
0
        public FrmEditShowItem(ArtShowItem item, int artistAttendingID = -1)
        {
            InitializeComponent();
            TxtNotes.SetWatermark("Optional");
            TxtBid.SetWatermark("NFS If Blank");
            TxtPrintMax.SetWatermark("Optional");

            ShowItem = item ?? new ArtShowItem();
            if (artistAttendingID > -1)
            {
                ShowItem.ArtistAttendingID = artistAttendingID;
            }
            if (item == null)
            {
                return;
            }

            LblShowNumber.Text = ShowItem.ShowNumber != null?ShowItem.ShowNumber.ToString() : "TBD";

            TxtTitle.Text       = ShowItem.Title;
            ChkOriginal.Checked = ShowItem.IsOriginal;
            TxtMedia.Text       = ShowItem.Media;
            TxtPrintNum.Text    = ShowItem.PrintNumber ?? "";
            TxtPrintMax.Text    = ShowItem.PrintMaxNumber ?? "";
            TxtBid.Text         = ShowItem.MinimumBid != null?ShowItem.MinimumBid.ToString() : "";

            TxtNotes.Text             = ShowItem.Notes ?? "";
            TxtLocation.Text          = ShowItem.LocationCode ?? "";
            CmbCategory.SelectedIndex = ShowItem.Category != null?CmbCategory.FindString(ShowItem.Category) : 0;
        }
        private Bitmap DrawTag(ArtShowItem item, PrintPageEventArgs e)
        {
            var year             = (Program.Year - 1980).ToString();
            var fontHeader       = new Font("Lucida Sans", 18, FontStyle.Bold);
            var fontText         = new Font("Lucida Sans", 14);
            var fontTable        = new Font("Lucida Sans", 12);
            var fontFootnote     = new Font("Lucida Sans", 12);
            var fontFootnoteBold = new Font("Lucida Sans", 12, FontStyle.Bold);
            var centered         = new StringFormat {
                LineAlignment = StringAlignment.Center, Alignment = StringAlignment.Center
            };
            var leftButCentered = new StringFormat {
                LineAlignment = StringAlignment.Center, Alignment = StringAlignment.Near
            };

            var settings    = new PrinterSettings();
            var resX        = settings.DefaultPageSettings.PrinterResolution.X;
            var resY        = settings.DefaultPageSettings.PrinterResolution.Y;
            var imageWidth  = Convert.ToInt32(((float)e.PageBounds.Width / 200) * resX);
            var imageHeight = Convert.ToInt32((((float)e.PageBounds.Height + 375) / 200) * resY);

            var image = new Bitmap(imageWidth, imageHeight);

            image.SetResolution(resX, resY);
            var gfx      = Graphics.FromImage(image);
            var currentY = 0F;

            var text = "Capricon " + year + " Art Show";

            gfx.DrawString(text, fontHeader, Brushes.Black, new RectangleF(0, currentY, image.Width, fontHeader.GetHeight(gfx)), centered);
            currentY += (float)(fontHeader.GetHeight(gfx) * 1.5);

            text = "Artist #: " + Artist.ArtistNumber;
            gfx.DrawString(text, fontText, Brushes.Black, new RectangleF(0, currentY, image.Width, fontText.GetHeight(gfx)));
            text = "Piece #: " + item.ShowNumber;
            var textWidth = gfx.MeasureString(text, fontText).Width;

            gfx.DrawString(text, fontText, Brushes.Black, new RectangleF(image.Width - textWidth, currentY, textWidth, fontText.GetHeight(gfx)));
            currentY += (float)(fontText.GetHeight(gfx) * 1.5);

            text = "Artist: " + Artist.DisplayName;
            gfx.DrawString(text, fontText, Brushes.Black, new RectangleF(0, currentY, image.Width, fontText.GetHeight(gfx)));
            text      = Artist.IsPro ? "Pro" : "Fan";
            textWidth = gfx.MeasureString(text, fontText).Width;
            gfx.DrawString(text, fontText, Brushes.Black, new RectangleF(image.Width - textWidth, currentY, textWidth, fontText.GetHeight(gfx)));
            currentY += (float)(fontText.GetHeight(gfx) * 1.5);

            text = "Title: " + item.Title;
            gfx.DrawString(text, fontText, Brushes.Black, new RectangleF(0, currentY, image.Width, fontText.GetHeight(gfx)));
            currentY += (float)(fontText.GetHeight(gfx) * 1.5);

            text = "Medium: " + item.Media;
            gfx.DrawString(text, fontText, Brushes.Black, new RectangleF(0, currentY, image.Width, fontText.GetHeight(gfx)));
            currentY += (float)(fontText.GetHeight(gfx) * 1.5);

            text = "Print: " + (item.IsOriginal ? "No" : "Yes") + "     Number: ";
            if (item.PrintNumber != null)
            {
                text += item.PrintNumber;
                if (item.PrintMaxNumber != null)
                {
                    text += " of " + item.PrintMaxNumber;
                }
            }
            else
            {
                text += "N/A";
            }
            gfx.DrawString(text, fontText, Brushes.Black, new RectangleF(0, currentY, image.Width, fontText.GetHeight(gfx)));
            currentY += (float)(fontText.GetHeight(gfx) * 1.5);

            text = "Publishing Rights: Yes / No / Ask";
            gfx.DrawString(text, fontText, Brushes.Black, new RectangleF(0, currentY, image.Width, fontText.GetHeight(gfx)));
            currentY += (float)(fontText.GetHeight(gfx) * 1.5);

            text = "Minimum Bid: " + (item.MinimumBid != null ? Convert.ToDecimal(item.MinimumBid).ToString("C") : "Not For Sale");
            gfx.DrawString(text, fontText, Brushes.Black, new RectangleF(0, currentY, image.Width, fontText.GetHeight(gfx)));
            currentY += (float)(fontText.GetHeight(gfx) * 1.5);

            var rowHeight = fontTable.GetHeight(gfx) + 2;
            var row1      = (float)(image.Width * 0.08);
            var row2      = (float)(image.Width * 0.59);
            var row3      = (float)(image.Width * 0.79);

            var thickLine = new Pen(Color.Black, 6);

            gfx.DrawLine(thickLine, 0, currentY, image.Width - 1, currentY);
            gfx.DrawLine(thickLine, 0, currentY, 0, currentY + rowHeight * 2);
            gfx.DrawLine(thickLine, row1, currentY, row1, currentY + rowHeight * 2);
            gfx.DrawLine(thickLine, row2, currentY, row2, currentY + rowHeight * 2);
            gfx.DrawLine(thickLine, row3, currentY, row3, currentY + rowHeight * 2);
            gfx.DrawLine(thickLine, image.Width - 1, currentY, image.Width - 1, currentY + rowHeight * 2);
            gfx.DrawLine(thickLine, 0, currentY + (rowHeight * 2), image.Width - 1, currentY + (rowHeight * 2));
            gfx.DrawString("Name", fontTable, Brushes.Black, new RectangleF(row1 + 2, currentY + 1, row2 - row1, (rowHeight * 2) - 1), leftButCentered);
            gfx.DrawString("Badge #", fontTable, Brushes.Black, new RectangleF(row2, currentY + 1, row3 - row2, (rowHeight * 2) - 1), centered);
            gfx.DrawString("Bid Amount", fontTable, Brushes.Black, new RectangleF(row3, currentY + 1, image.Width - row3, (rowHeight * 2) - 1), centered);
            currentY += (rowHeight * 2) + 1;

            for (int rowNumber = 1; rowNumber <= 5; rowNumber++)
            {
                gfx.DrawLine(thickLine, 0, currentY, image.Width - 1, currentY);
                gfx.DrawLine(thickLine, 0, currentY, 0, (float)(currentY + rowHeight * 2));
                gfx.DrawLine(thickLine, row1, currentY, row1, (float)(currentY + rowHeight * 2));
                gfx.DrawLine(thickLine, row2, currentY, row2, (float)(currentY + rowHeight * 2));
                gfx.DrawLine(thickLine, row3, currentY, row3, (float)(currentY + rowHeight * 2));
                gfx.DrawLine(thickLine, image.Width - 1, currentY, image.Width - 1, (float)(currentY + rowHeight * 2));
                gfx.DrawLine(thickLine, 0, (float)(currentY + rowHeight * 2), image.Width - 1, (float)(currentY + rowHeight * 2));
                gfx.DrawString(rowNumber.ToString(), fontTable, Brushes.Black, new RectangleF(1, currentY + 1, row1 - 1, rowHeight * 2 - 1), centered);
                currentY += (float)(rowHeight * 2) + 1;
            }

            gfx.DrawLine(thickLine, 0, currentY, image.Width - 1, currentY);
            gfx.DrawLine(thickLine, 0, currentY, 0, currentY + rowHeight * 2);
            gfx.DrawLine(thickLine, row2, currentY, row2, currentY + rowHeight * 2);
            gfx.DrawLine(thickLine, row3, currentY, row3, currentY + rowHeight * 2);
            gfx.DrawLine(thickLine, image.Width - 1, currentY, image.Width - 1, currentY + rowHeight * 2);
            gfx.DrawLine(thickLine, 0, currentY + rowHeight * 2, image.Width - 1, currentY + rowHeight * 2);
            gfx.DrawString("Auction", fontTable, Brushes.Black, new RectangleF(1, currentY + 1, row2 - 1, rowHeight * 2 - 1), centered);
            currentY += (float)(rowHeight * 2) + 1;

            text = "Do not ";
            gfx.DrawString(text, fontFootnoteBold, Brushes.Black, new RectangleF(0, currentY, image.Width, fontText.GetHeight(gfx)));
            var text2 = "cross off bids! Ask for assistance.";

            gfx.DrawString(text2, fontFootnote, Brushes.Black,
                           new RectangleF(gfx.MeasureString(text, fontFootnoteBold).Width, currentY, image.Width, fontText.GetHeight(gfx)));
            currentY += (float)(rowHeight * 1.5);

            text = "Final Total: $";
            gfx.DrawString(text, fontTable, Brushes.Black, new RectangleF(0, currentY, image.Width, fontText.GetHeight(gfx)));
            text = "    Badge #:";
            gfx.DrawString(text, fontTable, Brushes.Black, new RectangleF((float)(image.Width / 2), currentY, (float)(image.Width / 2), fontText.GetHeight(gfx)));

            gfx.Dispose();

            var resized = new Bitmap(image, image.Width / 4, image.Height / 4);

            return(resized);
        }