private void UpdateCardDetails(MabelCard card)
        {
            if (tbStatusBar.InvokeRequired == false)
            {
                if (card != null)
                {
                    Image frontImage = card.GetCardFrontImage();
                    Image backImage  = card.GetCardBackImage();
                    if (Properties.Settings.Default.Orientation.Equals("Portrait"))
                    {
                        frontImage.RotateFlip(RotateFlipType.Rotate90FlipNone);
                        backImage.RotateFlip(RotateFlipType.Rotate270FlipNone);
                    }
                    pbCardFront.Image = frontImage;
                    pbCardBack.Image  = backImage;

                    tbMemberId.Text = card.member_id;
                    tbMagId.Text    = card.mag_token;
                    tbCardId.Text   = card.card_id.ToString();
                }
            }
            else
            {
                UpdateCardDetailsDelegate updateCard = new UpdateCardDetailsDelegate(UpdateCardDetails);
                this.BeginInvoke(updateCard, new object[] { card });
            }
        }
        public void PrintMabelCard(MabelCard card)
        {
            if ((card.GetCardBackImage() == null) || (card.GetCardFrontImage() == null))
            {
                //throw new Exception("IMAGE_NULL"); //
            }
            PrintDocument printDoc = new PrintDocument();

            this.pages_printed = 0;
            printDoc.PrinterSettings.PrinterName   = Properties.Settings.Default.LocalPrinter;
            printDoc.PrinterSettings.Duplex        = Duplex.Default;
            printDoc.DefaultPageSettings.PaperSize = new PaperSize("CR80", 213, 337);
            printDoc.DefaultPageSettings.Landscape = true;
            printDoc.DocumentName = "Card-" + card.card_id;

            PrinterResolution pkResolution;
            PrinterResolution targetRes = null;

            for (int i = 0; i < printDoc.PrinterSettings.PrinterResolutions.Count; i++)
            {
                pkResolution = printDoc.PrinterSettings.PrinterResolutions[i];
                //System.Console.Out.WriteLine("Resolution : " + pkResolution.Kind + " X : " + pkResolution.X + " Y: " + pkResolution.Y);
                if (pkResolution.Kind.Equals("Custom"))
                {
                    targetRes = pkResolution;
                }
            }

            if (targetRes != null)
            {
                printDoc.DefaultPageSettings.PrinterResolution = targetRes;
            }
            else
            {
                targetRes = printDoc.DefaultPageSettings.PrinterResolution;
            }

            printDoc.PrintPage += new PrintPageEventHandler(printDoc_PrintPage);
            if (printDoc.PrinterSettings.IsValid)
            {
                try
                {
                    printDoc.Print();
                } catch (Exception ex)
                {
                    lastError = "Printing Error: " + ex.Message;
                    // something went wrong.
                }
            }
        }
        private void UpdateCardDetails(MabelCard card)
        {
            if (tbStatusBar.InvokeRequired == false)
            {
                if (card != null)
                {
                    Image frontImage = card.GetCardFrontImage();
                    Image backImage = card.GetCardBackImage();
                    if (Properties.Settings.Default.Orientation.Equals("Portrait"))
                    {
                        frontImage.RotateFlip(RotateFlipType.Rotate90FlipNone);
                        backImage.RotateFlip(RotateFlipType.Rotate270FlipNone);
                    }
                    pbCardFront.Image = frontImage;
                    pbCardBack.Image = backImage;

                    tbMemberId.Text = card.member_id;
                    tbMagId.Text = card.mag_token;
                    tbCardId.Text = card.card_id.ToString();
                }
            }
            else
            {
                UpdateCardDetailsDelegate updateCard = new UpdateCardDetailsDelegate(UpdateCardDetails);
                this.BeginInvoke(updateCard, new object[] { card });
            }
        }