Example #1
1
 private static void DrawStringML(this Graphics G, string Text, Font font, Brush brush, float x, ref float y, float mX)
 {
     string[] words = Text.Split(' ');
     float tempX = x;
     float totalSpace = mX - x;
     SizeF measureWord = new SizeF(0, font.GetHeight());
     float tempWordWidth = 0;
     foreach (string word in words)
     {
         //measure word width (based in font size)
         tempWordWidth = G.MeasureString(word + " ", font).Width;
         measureWord.Width += tempWordWidth;
         //check if the word fits in free line space
         //if not then change line
         if (measureWord.Width > totalSpace)
         {
             y += font.GetHeight();
             tempX = x;
             measureWord.Width = tempWordWidth;
         }
         G.DrawString(word + " ", font, brush, tempX, y);
         tempX += tempWordWidth;
     }
     y += font.GetHeight();
 }
Example #2
0
        /// <summary>
        /// Print from the stream.
        /// </summary>
        /// <param name="e"></param>
        private void PrintFromStream(PrintPageEventArgs e)
        {
            float  yPos         = 0f;
            int    count        = 0;
            float  leftMargin   = e.MarginBounds.Left;
            float  topMargin    = e.MarginBounds.Top;
            string line         = null;
            float  linesPerPage = e.MarginBounds.Height / _font.GetHeight(e.Graphics);

            // While lines exist.
            while (count < linesPerPage)
            {
                line = _reader.ReadLine();
                if (line == null)
                {
                    break;
                }

                // Draw each line in the stream.
                yPos = topMargin + count * _font.GetHeight(e.Graphics);
                e.Graphics.DrawString(line, _font, _brush, leftMargin, yPos, new StringFormat());
                count++;
            }

            // More lines exist.
            if (line != null)
            {
                e.HasMorePages = true;
            }
        }
Example #3
0
        public void pd_PrintPage(object sender, PrintPageEventArgs e)
        {
            int    count      = 0;
            float  leftMargin = 0;
            float  topMargin  = 0;
            String line       = null;

            float linesPerPage = e.MarginBounds.Height / printFont.GetHeight(e.Graphics);

            while (count < linesPerPage && ((line = streamToPrint.ReadLine()) != null))
            {
                float yPos = topMargin + (count * printFont.GetHeight(e.Graphics));
                e.Graphics.DrawString(line, printFont, Brushes.Black, leftMargin, yPos, new StringFormat());
                count++;
            }

            if (line != null)
            {
                e.HasMorePages = true;
            }
            else
            {
                e.HasMorePages = false;
            }
        }
        private void printDocument1_PrintPage(object sender, System.Drawing.Printing.PrintPageEventArgs e)
        {
            float  yPos         = 0f;
            int    count        = 0;
            float  leftMargin   = e.MarginBounds.Left;
            float  topMargin    = e.MarginBounds.Top;
            string line         = null;
            float  linesPerPage = e.MarginBounds.Height / printFont.GetHeight(e.Graphics);

            while (count < linesPerPage)
            {
                line = fileToPrint.ReadLine();
                if (line == null)
                {
                    break;
                }
                yPos = topMargin + count * printFont.GetHeight(e.Graphics);
                e.Graphics.DrawString(line, printFont, Brushes.Black, leftMargin, yPos, new StringFormat());
                count++;
            }
            if (line != null)
            {
                e.HasMorePages = true;
            }
        }
Example #5
0
        // The PrintPage event is raised for each page to be printed.
        private void pd_PrintPage(object sender, PrintPageEventArgs ev)
        {
            float  linesPerPage = 0;
            float  yPos         = 0;
            int    count        = 0;
            float  leftMargin   = ev.MarginBounds.Left;
            float  topMargin    = ev.MarginBounds.Top;
            String line         = null;

            // Calculate the number of lines per page.
            linesPerPage = ev.MarginBounds.Height /
                           printFont.GetHeight(ev.Graphics);

            // Iterate over the file, printing each line.
            while (count < linesPerPage &&
                   ((line = streamToPrint.ReadLine()) != null))
            {
                yPos = topMargin + (count * printFont.GetHeight(ev.Graphics));
                ev.Graphics.DrawString(line, printFont, System.Drawing.Brushes.Black,
                                       leftMargin, yPos, new System.Drawing.StringFormat());
                count++;
            }

            // If more lines exist, print another page.
            if (line != null)
            {
                ev.HasMorePages = true;
            }
            else
            {
                ev.HasMorePages = false;
            }
        }
Example #6
0
 /// <summary>
 /// Set the space that is required by the page footer.
 /// ValidYPos will consider this value.
 ///
 /// </summary>
 /// <returns>void</returns>
 public override void SetPageFooterSpace(System.Int32 ANumberOfLines, eFont AFont)
 {
     // half a line for the drawn line, to separate the report body from the footer
     if (ANumberOfLines != 0)
     {
         FPageFooterSpace = ((float)Convert.ToDouble(ANumberOfLines) + 0.5f) * GetFont(AFont).GetHeight(FEv.Graphics) * CurrentLineHeight +
                            FDefaultFont.GetHeight(FEv.Graphics);
     }
 }
Example #7
0
        /// <summary>
        /// 打印彩票
        /// </summary>
        public void PrintLottery(System.Drawing.Printing.PrintPageEventArgs e, string serialNum, List <string> numList)
        {
            //生成条形码
            barCode.Text      = serialNum;                                  //条码数据
            barCode.Symbology = Fath.bcType.Code128;                        //设置条码格式
            barCode.ShowText  = true;                                       //同时显示文本
            e.Graphics.DrawImage(barCode.Image(240, 50), new Point(20, 5)); //画条形码

            //生成彩票信息
            float left      = 2;                                                                              //打印区域的左边界
            float top       = 70;                                                                             //打印区域的上边界
            Font  titlefont = new System.Drawing.Font("仿宋", 10);                                              //标题字体
            Font  font      = new Font("仿宋", 8);                                                              //内容字体

            e.Graphics.DrawString("激情包赚不赔彩票中心", titlefont, Brushes.Blue, left + 20, top, new StringFormat()); //打印标题
            //画一条分界线
            Pen pen = new Pen(Color.Green, 1);

            e.Graphics.DrawLine(pen, new Point((int)left - 2, (int)top + 20), new Point((int)left + (int)180, (int)top + 20));

            //循环打印选号
            for (int i = 0; i < numList.Count; i++)
            {
                e.Graphics.DrawString(numList[i], font, Brushes.Blue, left,
                                      top + titlefont.GetHeight(e.Graphics) + font.GetHeight(e.Graphics) * i + 12, new StringFormat());
            }

            //画一条分界线
            float topPoint = titlefont.GetHeight(e.Graphics) + font.GetHeight(e.Graphics) * (numList.Count) + 22;

            e.Graphics.DrawLine(pen, new Point((int)left - 2, (int)top + (int)topPoint),
                                new Point((int)left + (int)180, (int)top + (int)topPoint));

            //打印时间
            string time = "购买时间:" + DateTime.Now.ToString("yyy-MM-dd  HH:mm:ss");

            e.Graphics.DrawString(time, font, Brushes.Blue, left, top + titlefont.GetHeight(e.Graphics)
                                  + font.GetHeight(e.Graphics) * (numList.Count + 1) + 12, new StringFormat());

            //二维码图片left和top坐标
            int qrcodetop  = (int)(top + titlefont.GetHeight(e.Graphics) + font.GetHeight(e.Graphics) * (numList.Count + 3) + 12);
            int qrcodeleft = (int)left + 32;

            //生成二维码图片
            // Image bmp = QRcodeCreator.GetQRCodeBmp("http://www.xiketang.com/duijiang/query?id=" + serialNum);//直接添加流水号,将来从网站直接查询
            Image bmp = QRcodeCreator.GetQRCodeBmp("http://www.xiketang.com");

            //打印
            e.Graphics.DrawImage(bmp, new Point(qrcodeleft, qrcodetop));//不同的URL图片大小不同,可以根据需要调整left坐标
            e.Graphics.DrawString("扫描二维码可直接查询兑奖结果", font, Brushes.Blue, left, qrcodetop + bmp.Height + 10, new StringFormat());
        }
Example #8
0
        private static void DoTest(int res, GraphicsUnit unit)
        {
            using Bitmap bitmap = new Bitmap(1, 1);
            bitmap.SetResolution(res, res);
            var g = Graphics.FromImage(bitmap);

            g.PageUnit = unit;

            Console.WriteLine($"Graphics: PageUnit = {g.PageUnit}, PageScale = {g.PageScale}, DPI = {g.DpiX} x {g.DpiY}");

            // Calculate the number of lines per page.
            var font = new System.Drawing.Font(fontFamily, fontSize, fontStyle, GraphicsUnit.Point);

            //var font = new System.Drawing.Font(fontFamily, fontSize / 72F * 96F, fontStyle, GraphicsUnit.Pixel);
            Console.WriteLine($"Font: {font.Name}, {font.Size} in {font.Unit}s ({font.SizeInPoints}pts), {font.Style}.");

            var fi = new FontInfo(g, font);

            fi.Dump();

            // Font.GetHeight() assumes 96dpi
            Console.WriteLine($"  Height: GetHeight() = {font.GetHeight()}");

            // Font.GetHeight(res) should use res (and does on both Windows and libgdiplus 6.1)
            float fExpectedHeight = font.GetHeight(res);

            Console.WriteLine($"          GetHeight({res}) = {fExpectedHeight}");

            // Font.GetHeight(Graphics) honors Graphics.DpiY on Windows, but with libgdiplus 6.1 uses 96
            Console.WriteLine($"          GetHeight(g) = {font.GetHeight(g)}" + (fExpectedHeight == font.GetHeight(g) ? "" : " --- FAIL!"));

            var lineSize = g.MeasureString(font.Name, font);

            Console.WriteLine($"Size of \"{font.Name}\": {lineSize.Width} x {lineSize.Height}");

            // Set character ranges to "First" and "Second".
            CharacterRange[] characterRanges = { new CharacterRange(0, 6) };

            // Set string format.
            StringFormat stringFormat = new StringFormat();

            stringFormat.SetMeasurableCharacterRanges(characterRanges);

            Region[] rg = g.MeasureCharacterRanges(font.Name, font, new RectangleF(0, 0, 1000, 1000), stringFormat);
            Console.WriteLine($"rg.Size = {rg.Length}");
            for (int i = 0; i < rg.Length; i++)
            {
                Console.WriteLine($"{font.Name.Substring(0, 6)} - {rg[i].GetBounds(g).Width} x {rg[i].GetBounds(g).Height}");
            }
        }
Example #9
0
        private void printDocument1_PrintPage(object sender, System.Drawing.Printing.PrintPageEventArgs e)
        {
            System.Drawing.Font printFont;
            printFont = new System.Drawing.Font("Courier New", 9, FontStyle.Bold);

            float  yPos         = 0f;
            int    count        = 0;
            float  leftMargin   = 1; // e.MarginBounds.Left;
            float  topMargin    = 0; // e.MarginBounds.Top;
            string line         = null;
            float  linesPerPage = e.MarginBounds.Height / printFont.GetHeight(e.Graphics);

            yPos = topMargin + count * printFont.GetHeight(e.Graphics);
            e.Graphics.DrawString(rtbPrintBuffer.Text, printFont, Brushes.Black, leftMargin, yPos, new StringFormat());
        }
        public void GetCommonPrintValues(System.Drawing.Printing.PrintPageEventArgs ev)
        {
            printFont = new Font("Arial", 18, FontStyle.Bold);
            yPos = 0;
            leftMargin = ev.MarginBounds.Left;
            topMargin = ev.MarginBounds.Top;
            ev.PageSettings.Landscape = true;


            try
            {
                line = "Bally One Void Treasury Report" + "  - " + DateTime.Now.ToString("ddd dd mm yyyy hh:nn");
                   
                yPos = topMargin + (printFont.GetHeight(ev.Graphics));
                ev.Graphics.DrawString(line, printFont, Brushes.Black, leftMargin, yPos, new StringFormat());

                printFont = new Font("Arial", 10, FontStyle.Regular);

                line = "Page " + Environment.NewLine + PageNo + Environment.NewLine;
                yPos = topMargin + (4 * printFont.GetHeight(ev.Graphics));
                ev.Graphics.DrawString(line, printFont, Brushes.Black, leftMargin, yPos, new StringFormat());

                //line = "Date/Time".PadRight(number, ctab) + System.DateTime.Now.ToShortDateString() + " " + System.DateTime.Now.ToShortTimeString();
                //yPos = topMargin + (10 * printFont.GetHeight(ev.Graphics));
                //ev.Graphics.DrawString(line, printFont, Brushes.Black, leftMargin, yPos, new StringFormat());

                //line = "Workstation".PadRight(number, ctab) + System.Environment.MachineName.ToString();
                //yPos = topMargin + (11 * printFont.GetHeight(ev.Graphics));
                //ev.Graphics.DrawString(line, printFont, Brushes.Black, leftMargin, yPos, new StringFormat());

                foreach (TicketExceptions item in lstPrintItems)
                {
                    foreach (PropertyInfo info in item.GetType().GetProperties())
                    {
                        line = info.Name + " : " + info.GetValue(item, null).ToString();
                        yPos = topMargin + (11 * printFont.GetHeight(ev.Graphics));
                        ev.Graphics.DrawString(line, printFont, Brushes.Black, leftMargin, yPos, new StringFormat());
                    }
                }

            }
            catch (Exception Ex)
            {
                ExceptionManager.Publish(Ex);
            }

            //return ev;
        }
        public static void CreateFont(string fontName, float fontSize, string outputDirectory)
        {
            fontSize *= 96.0f / 72.0f;  // Converts points to pixels

            using (var font = new Font(fontName, fontSize, FontStyle.Regular, GraphicsUnit.Pixel))
            {
                Console.WriteLine("Loading font {0}. Loaded font name: {1}.", fontName, font.FontFamily.Name);

                using (var bitmap = new Bitmap(BitmapSize, BitmapSize, PixelFormat.Format32bppArgb))
                {
                    using (var graphics = Graphics.FromImage(bitmap))
                    {
                        graphics.PixelOffsetMode = PixelOffsetMode.HighQuality;
                        graphics.InterpolationMode = InterpolationMode.HighQualityBicubic;

                        if (fontSize > 60.0f)
                        {
                            graphics.TextRenderingHint = TextRenderingHint.AntiAliasGridFit;
                        }
                        else
                        {
                            graphics.TextRenderingHint = TextRenderingHint.ClearTypeGridFit;
                        }

                        var characters = ImportFont(font, bitmap, graphics);
                        var lineSpace = font.GetHeight();

                        int fontBitmapWidth, fontBitmapHeight;
                        var fontBitmap = PackCharacters(characters, (int)lineSpace, out fontBitmapWidth, out fontBitmapHeight);
                        SaveFont(characters, lineSpace, fontBitmapWidth, fontBitmapHeight, fontBitmap, Path.Combine(outputDirectory, fontName + ".font"));
                    }
                }
            }
        }
Example #12
0
        protected override void OnPaint(PaintEventArgs e)
        {
            if (VisibleTimeStart <= audio.MediaDuration)
            {
                if (samples.Count > 0 && !_creatingSamples)
                {
                    //Draws the Mark throught the waveform if Mark is being moved.
                    if (waveFormMark)
                    {
                        Pen p;
                        p = new Pen(Brushes.Yellow)
                        {
                            DashPattern = new float[] { 2, 2 }
                        };
                        Single x1 = timeToPixels(selectedTime - VisibleTimeStart);
                        e.Graphics.DrawLine(p, x1, 0, x1, Height);
                        p.Dispose();
                    }

                    //Draws Waveform
                    e.Graphics.TranslateTransform(-timeToPixels(VisibleTimeStart), 0);
                    float maxSample     = Math.Max(Math.Abs(ClampValue(samples.Low)), samples.High);
                    int   workingHeight = Height - (int)(Height * .1);                  //Leave a little margin
                    float factor        = workingHeight / maxSample;

                    float maxValue = 2 * maxSample * factor;
                    float minValue = -maxSample * factor;
                    int   start    = (int)timeToPixels(VisibleTimeStart);
                    int   end      = (int)timeToPixels(VisibleTimeEnd <= audio.MediaDuration ? VisibleTimeEnd : audio.MediaDuration);

                    for (int x = start; x < end; x += 1)
                    {
                        if (samples.Count <= x)
                        {
                            break;
                        }
                        {
                            float lowPercent  = (((samples[x].Low * factor) - minValue) / maxValue);
                            float highPercent = (((samples[x].High * factor) - minValue) / maxValue);
                            e.Graphics.DrawLine(Pens.Black, x, workingHeight * lowPercent, x, workingHeight * highPercent);
                        }
                    }
                }
                else
                {
                    using (Font f = new Font(Font.FontFamily, 10f, FontStyle.Regular))
                    {
                        e.Graphics.DrawString("Building waveform.....", f, Brushes.Black,
                                              new Point((int)timeToPixels(VisibleTimeStart) + 15,
                                                        (int)(Height - f.GetHeight(e.Graphics)) / 2),
                                              new StringFormat {
                            Alignment = StringAlignment.Near
                        });
                    }
                }
            }

            base.OnPaint(e);
        }
Example #13
0
        private void setOrderData(Graphics g)
        {
            // Set Invoice
            string FieldValue = "";

            invoiceFontHeight = (int)(invoiceFont.GetHeight(g));

            // Set Invoice Value:
            currentX   = leftMargin;
            currentY   = currentY + 8;
            FieldValue = "Invoice ID: " + invoiceID.ToString();
            g.DrawString(FieldValue, invoiceFont, blackBrush, currentX, currentY);

            // Draw line:
            currentY = currentY + invoiceFontHeight + 8;
            g.DrawLine(new Pen(Brushes.Black), leftMargin, currentY, rightMargin, currentY);
        }
 public clsToolList()
 {
     this.DrawMode    = DrawMode.OwnerDrawFixed;
     this.BackColor   = System.Drawing.Color.FromArgb(-1250856);
     this.BorderStyle = 0;
     this.Sorted      = true;
     m_font           = new System.Drawing.Font("Times New Roman", 8);
     if (nIconSize < (int)m_font.GetHeight() + 3)
     {
         nIconSize = (int)m_font.GetHeight() + 3;
     }
     ItemHeight    = nIconSize;
     nDrawTop      = (nIconSize - (int)(m_font.GetHeight())) / 2;
     m_brushBK     = new System.Drawing.SolidBrush(this.BackColor);
     m_penWhite    = new System.Drawing.Pen(System.Drawing.Color.White, 1);
     m_penDarkGray = new System.Drawing.Pen(System.Drawing.Brushes.DarkGray, 1);
 }
Example #15
0
 public void Init(Font f)
 {
     m_blockSize = 16;
     m_Font = f;
     m_HeaderHeight = (int) m_Font.GetHeight() * 3;
     m_FooterHeight = 100;
     m_tileRend = new TileRenderer(m_blockSize, m_HeaderHeight);
     m_charRend = new CharacterRenderer(m_blockSize, m_HeaderHeight);
 }
Example #16
0
        /// <summary>
        /// update the biggest last used font for the next line feed
        /// </summary>
        /// <param name="AFont"></param>
        protected virtual bool UpdateBiggestLastUsedFont(eFont AFont)
        {
            if ((FBiggestLastUsedFont == null) || (GetFont(AFont).GetHeight(FEv.Graphics) > FBiggestLastUsedFont.GetHeight(FEv.Graphics)))
            {
                FBiggestLastUsedFont = GetFont(AFont);
                return(true);
            }

            return(false);
        }
Example #17
0
        /// <summary>
        /// 刷新字符宽度
        /// </summary>
        /// <returns></returns>
        public override bool RefreshSize()
        {
            if (myMeasureFormat == null)
            {
                myMeasureFormat             = new System.Drawing.StringFormat(System.Drawing.StringFormat.GenericTypographic);
                myMeasureFormat.FormatFlags = System.Drawing.StringFormatFlags.FitBlackBox | System.Drawing.StringFormatFlags.MeasureTrailingSpaces;
            }

            bool bolSup = this.Sup;
            bool bolSub = this.Sub;

            //圈字 Add by wwj 2012-05-31
            bool bolCircleFont = this.CircleFont;

            if (myFont == null)
            {
                myFont = myOwnerDocument.View._CreateFont
                             (this.FontName,
                             (bolSub || bolSup ? (int)(this.FontSize * 0.6) : this.FontSize),//0.6
                             this.FontBold,
                             this.FontItalic,
                             this.FontUnderLine);
            }
            else
            {
                //Add by wwj 2013-04-19
                RefreshMyFont();
            }

            System.Drawing.SizeF CharSize = myOwnerDocument.View.Graph.MeasureString(myChar.ToString(), myFont, 10000, myMeasureFormat);

            //圈字 Add by wwj 2012-05-31 由于使用圆圈将字符括起来,所以要保证宽度适度
            if (bolCircleFont)
            {
                CharSize        = myOwnerDocument.View.MeasureChar('院', this.Font);
                CharSize.Width += 4;
            }

            if (myChar == '\t')
            {
                intWidth = myOwnerDocument.View.GetTabWidth(this.RealLeft);
            }
            else
            {
                intWidth = (int)CharSize.Width;
            }
            intHeight = (int)Math.Ceiling(myFont.GetHeight(myOwnerDocument.View.Graph));

            if (bolSub || bolSup)
            {
                this.Height = (int)(intHeight * 1.9);
            }

            return(true);
        }
Example #18
0
        private void Doc_PrintPage(object sender, PrintPageEventArgs e)
        {
            try
            {
                int printReportLogoType = 1;
                TextDocument doc = (TextDocument)sender;

                Font font = new Font("Lucida Console", 7);

                float lineHeight = font.GetHeight(e.Graphics);

                float x = e.MarginBounds.Left;
                float y = e.MarginBounds.Top + 3;

                if (printReportLogoType == 1)
                {

                    e.Graphics.DrawImage(Image.FromFile("C:\\Program Files\\Ibacs Ltd\\RMS Client\\IZUMI.jpg"), 400, 0);

                }
                else if (printReportLogoType == 2)
                {

                    e.Graphics.DrawImage(Image.FromFile("C:\\Program Files\\Ibacs Ltd\\RMS Client\\IZUMI.jpg"), 50, 0);

                }
                else if (printReportLogoType == 3)
                {
                    e.Graphics.DrawImage(Image.FromFile("C:\\Program Files\\Ibacs Ltd\\RMS Client\\SKYSHEEP.png"), 50, 40);

                }

                doc.PageNumber += 1;

                while ((y + lineHeight) < e.MarginBounds.Bottom && doc.Offset <= doc.Text.GetUpperBound(0))
                {
                    e.Graphics.DrawString(doc.Text[doc.Offset], font, Brushes.Black, 0, y);
                    doc.Offset += 1;
                    y += lineHeight;
                }

                if (doc.Offset < doc.Text.GetUpperBound(0))
                {
                    e.HasMorePages = true;
                }
                else
                {
                    doc.Offset = 0;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Sorry! Problem occured." + ex.ToString());
            }
        }
Example #19
0
        // Metodo para a impressao do recibo
        private void printDocument1_PrintPage(object sender, System.Drawing.Printing.PrintPageEventArgs e)
        {
            //variaveis usadas para definir as configurações da impressão
            float  linhasPorPagina = 0;
            float  yPosicao        = 0;
            int    contador        = 0;
            float  margemEsquerda  = e.MarginBounds.Left;
            float  margemSuperior  = e.MarginBounds.Top;
            string linha           = null;

            System.Drawing.Font fonteImpressao = this.labelImprimir.Font;
            SolidBrush          mCaneta        = new SolidBrush(Color.Black);

            // Imagem colocada no recibo no ponto (140,10)
            e.Graphics.DrawImage(System.Drawing.Image.FromFile(Application.StartupPath + @"\imagens\recibo.png"), new Point(140, 10));
            // Define o numero de linhas por pagina, usando MarginBounds.
            linhasPorPagina = e.MarginBounds.Height / fonteImpressao.GetHeight(e.Graphics);

            // Itera sobre a string usando StringReader, imprimindo cada linha
            while (contador < linhasPorPagina && ((linha = leitor.ReadLine()) != null))
            {
                // calcula a posicao da proxima linha baseada
                // na altura da fonte de acordo com o dispositivo de impressão
                yPosicao = margemSuperior + (contador * fonteImpressao.GetHeight(e.Graphics));

                // desenha a proxima linha
                e.Graphics.DrawString(linha, fonteImpressao, mCaneta, margemEsquerda, yPosicao, new StringFormat());
                contador++;
            }
            // Verifica se existe mais linhas para imprimir
            if (linha != null)
            {
                e.HasMorePages = true;
            }
            else
            {
                e.HasMorePages = false;
            }

            //libera recursos
            mCaneta.Dispose();
        }
Example #20
0
        public void drawItem(DrawItemEventArgs e, Padding margin, 
                             Font titleFont, Font detailsFont, StringFormat aligment, 
                             Size imageSize)
        {            

            // if selected, mark the background differently
            if ((e.State & DrawItemState.Selected) == DrawItemState.Selected)
            {
                e.Graphics.FillRectangle(Brushes.CornflowerBlue, e.Bounds);
            }
            else
            {
                e.Graphics.FillRectangle(Brushes.Beige, e.Bounds);
            }

            // draw some item separator
            e.Graphics.DrawLine(Pens.DarkGray, e.Bounds.X, e.Bounds.Y, e.Bounds.X + e.Bounds.Width, e.Bounds.Y);

            // draw item image
            e.Graphics.DrawImage(this.ItemImage, e.Bounds.X + margin.Left, e.Bounds.Y + margin.Top, imageSize.Width, imageSize.Height);

            // calculate bounds for title text drawing
            Rectangle titleBounds = new Rectangle(e.Bounds.X + margin.Horizontal + imageSize.Width,
                                                  e.Bounds.Y + margin.Top,
                                                  e.Bounds.Width - margin.Right - imageSize.Width - margin.Horizontal,
                                                  (int)titleFont.GetHeight() + 2);
            
            // calculate bounds for details text drawing
            Rectangle detailBounds = new Rectangle(e.Bounds.X + margin.Horizontal + imageSize.Width,
                                                   e.Bounds.Y + (int)titleFont.GetHeight() + 2 + margin.Vertical + margin.Top,
                                                   e.Bounds.Width - margin.Right - imageSize.Width - margin.Horizontal,
                                                   e.Bounds.Height - margin.Bottom - (int)titleFont.GetHeight() - 2 - margin.Vertical - margin.Top);

            // draw the text within the bounds
            e.Graphics.DrawString(this.Title, titleFont, Brushes.Black, titleBounds, aligment);
            e.Graphics.DrawString(this.Details, detailsFont, Brushes.DarkGray, detailBounds, aligment);            
            
            // put some focus rectangle
            e.DrawFocusRectangle();
        
        }
        /// <summary>
        /// Returns the height difference you need to add to the other font's Y location to make its baseline align with the standard font's baseline.
        /// </summary>
        /// <param name="standard">The font whose baseline you want to align with.</param>
        /// <param name="std_g">The graphics object for the standard font.</param>
        /// <param name="other">The font whose baseline you want to align to standard's baseline.</param>
        /// <param name="other_g">The graphics object for the other font.</param>
        /// <returns>The height difference you need to add to the other font's Y location to make its baseline align with the standard font's baseline.</returns>
        public static int calculate_height_difference_for_font_baseline_match(Font standard, Graphics std_g, Font other, Graphics other_g)
        {
            float std_ascent = standard.FontFamily.GetCellAscent(standard.Style);
             float std_linespace = standard.FontFamily.GetLineSpacing(standard.Style);
             float std_baseline = standard.GetHeight(std_g) * std_ascent / std_linespace;

             float other_ascent = other.FontFamily.GetCellAscent(other.Style);
             float other_linespace = other.FontFamily.GetLineSpacing(other.Style);
             float other_baseline = other.GetHeight(other_g) * other_ascent / other_linespace;

             return (int)(std_baseline - other_baseline);
        }
Example #22
0
 /// <summary>
 /// 获得指定分辨率的字体的高度
 /// </summary>
 /// <param name="dpi">分辨率</param>
 /// <returns>字体高度</returns>
 public float GetHeight(float dpi)
 {
     System.Drawing.Font f = this.Value;
     if (f == null)
     {
         return(0);
     }
     else
     {
         return(f.GetHeight(dpi));
     }
 }
Example #23
0
 /// <summary>
 /// 获得字体的高度
 /// </summary>
 /// <param name="g">绘图对象</param>
 /// <returns>字体高度</returns>
 public float GetHeight(System.Drawing.Graphics g)
 {
     System.Drawing.Font f = this.Value;
     if (f == null)
     {
         return(0);
     }
     else
     {
         return(f.GetHeight(g));
     }
 }
Example #24
0
        private void pd_PrintPage(object sender, PrintPageEventArgs e)
        {
            string strLine;//用于存放当前行打印的信息
            float leftMargin = (e.MarginBounds.Left) * 3 / 4;   //左边距
            float topMargin = e.MarginBounds.Top * 2 / 3;       //顶边距
            float verticalPosition = topMargin;                 //初始化垂直位置,设为顶边距

            Font mainFont = new Font("Courier New", 10);//打印的字体
            //每页的行数,当打印行数超过这个时,要换页(1.05这个值是根据实际情况中设定的,可以不要)
            int linesPerPage = (int)(e.MarginBounds.Height * 1.05 / mainFont.GetHeight(e.Graphics));
            e.Graphics.DrawImage(b, new Point());
        }
Example #25
0
 /// <summary>
 /// Create a banner image of the specified size, outputting the input text on it
 /// </summary>
 /// <param name="sizeImage">Size of the image to be generated</param>
 /// <param name="label">Text to be output on the image</param>
 /// <returns>a bitmap object</returns>
 private static Bitmap drawSimpleBanner(Size sizeImage, string label)
 {
     Bitmap image = new Bitmap(sizeImage.Width, sizeImage.Height);
     Graphics gph = Graphics.FromImage(image);
     //gph.FillRectangle(new SolidBrush(Color.FromArgb(50, Color.White)), new Rectangle(0, 0, sizeImage.Width, sizeImage.Height));
     GUIFont fontList = GUIFontManager.GetFont(s_sFontName);
     Font font = new Font(fontList.FontName, 36);
     gph.TextRenderingHint = System.Drawing.Text.TextRenderingHint.AntiAlias;
     gph.DrawString(label, font, new SolidBrush(Color.FromArgb(200, Color.White)), 5, (sizeImage.Height - font.GetHeight()) / 2);
     gph.Dispose();
     return image;
 }
        public void SetFont(Font zFont, Graphics zGraphics)
        {
            Font = zFont;
            FontHeight = zFont.GetHeight(zGraphics);

            var rectWithSpace = TextMarkup.MeasureDisplayStringWidth(zGraphics, " " + FontStringToTest, zFont);
            var rectWithoutSpace = TextMarkup.MeasureDisplayStringWidth(zGraphics, FontStringToTest, zFont);

            // NOTE the element word space is ignored! (is that a problem?)
            FontSpaceWidth = rectWithSpace.Width - rectWithoutSpace.Width;
            FontSpaceHeight = rectWithSpace.Height;
        }
Example #27
0
        private void pdc001_PrintPage(object sender, System.Drawing.Printing.PrintPageEventArgs e)
        {
            //列印圖片
            string strDir;

            strDir  = System.Windows.Forms.Application.StartupPath;
            strDir += "\\temp01.png";
            Image temp = Image.FromFile(strDir);//圖片檔案

            //設定圖片列印的x,y座標
            int x = e.MarginBounds.X;
            int y = e.MarginBounds.Y;

            //圖片列印的大小
            int       width    = temp.Width;  //temp.Width;
            int       height   = temp.Height; //temp.Height;
            Rectangle destRect = new Rectangle(x, y, width, height);

            // public void DrawImage (
            // Image image, 要繪製的 Image。
            // Rectangle destRect, Rectangle 結構,指定繪製影像的位置和大小。縮放影像來符合矩形
            // int srcX, 要繪製之來源影像部分左上角的 X 座標
            // int srcY, 要繪製之來源影像部分左上角的 Y 座標。
            // int srcWidth, 要繪製之來源影像部分的寬度。
            // int srcHeight, 要繪製之來源影像部分的高度。
            // GraphicsUnit srcUnit, GraphicsUnit 列舉型別的成員,指定用來判斷來源矩形的測量單位。
            // ImageAttributes imageAttr ImageAttributes,指定 image 物件的重新著色和 Gamma 資訊。
            //)
            //將圖片放入要列印的文件中
            e.Graphics.DrawImage(temp, destRect, 10, 10, temp.Width, temp.Height, System.Drawing.GraphicsUnit.Pixel);

            //列印文字
            System.Drawing.Font printFont = new System.Drawing.Font("Arial", 10); //設定字型與大小
            float leftMargin = e.MarginBounds.Left;                               //取得文件左邊界
            float topMargin  = e.MarginBounds.Top;                                //取得文件上邊界
            int   count      = 10;                                                //起始列印的行數
            float yPos       = 0f;                                                //收集成列印起始點的參數

            yPos = topMargin + count * printFont.GetHeight(e.Graphics);

            // public void DrawString (
            // string s, 要繪製的字串。
            // Font font, Font,定義字串的文字格式。
            // Brush brush, Brush,決定所繪製文字的色彩和紋理。
            // float x, 繪製文字左上角的 X 座標。
            // float y, 繪製文字左上角的 Y 座標。
            // StringFormat format StringFormat,指定套用到所繪製文字的格式化屬性,例如,行距和對齊。
            //)
            //將要列印的文字放入要列印的文件中

            //jash 停用 e.Graphics.DrawString("C#有夠讚", printFont, Brushes.Black, 100, yPos, new StringFormat());
        }
Example #28
0
        //You can have your way of decoration </strong></em>
        void CPrintPage(object sender, PrintPageEventArgs ev)
        {
            float linesPerPage = 0;
            float yPos = 0;
            int count = 0;
            float leftMargin = ev.MarginBounds.Left;
            float topMargin = ev.MarginBounds.Top;

            var font = new Font("Arial", 10);

            // Calculate the number of lines per page.
            linesPerPage = ev.MarginBounds.Height / font.GetHeight(ev.Graphics);

            // Print each line of the file.
            foreach (ListViewItem item in ListView.Items)
            {
                yPos = topMargin + (count * font.GetHeight(ev.Graphics));
                ev.Graphics.DrawString(item.Text, font, Brushes.Black, leftMargin, yPos, new StringFormat());
                count++;
            }
            ev.HasMorePages = false;
        }
Example #29
0
        public HttpResponseMessage GetPicture()
        {
            var filepath = @"C:\Users\Bezaleel\Source\Repos\Water_mark\Water_mark\Images\IMG_20150510_170224 - Copy (3).jpg";
            var result = new HttpResponseMessage(HttpStatusCode.OK);
            //var stream = new FileStream(path, FileMode.Open);
            FileStream fs = new FileStream(filepath, FileMode.Open, FileAccess.Read);
            //result.Content.Headers.ContentDisposition =
            //    new System.Net.Http.Headers.ContentDispositionHeaderValue("attachment")
            //    {
            //       fs.Dispose();
            //    };
            //fs.Close();
            //return result;

            string text = "Bad Ass";
            //var result = new HttpResponseMessage(HttpStatusCode.OK);
            Image image = Image.FromStream(fs);
            Font font = new Font("BankGothic Md BT", 17f, FontStyle.Bold);

            var imgheight = image.Height - 2 * font.GetHeight();
            var imgWidth = image.Width - font.GetHeight() * (5 * text.Length / 10);
            Bitmap b = new Bitmap(image);

            Graphics graphics = Graphics.FromImage(b);
            graphics.DrawString(text, font, Brushes.Aquamarine, imgWidth, imgheight);


            //return graphics;
            //directory of where the file will be saved
            b.Save(@"C:\Users\Bezaleel\Pictures\Collectibles\IMG_20150510_170224 - Copy (3).jpg");
            result.Content = new StreamContent(fs);
            result.Content.Headers.ContentType = new System.Net.Http.Headers.MediaTypeHeaderValue("image/jpeg");

            fs.Close();
            image.Dispose();
            b.Dispose();
            return result;

        }
        private void _CreateReceipt(object sender, System.Drawing.Printing.PrintPageEventArgs e)
        {
            Graphics graphic    = e.Graphics;
            Font     font       = new Font("Courier New", 6);
            float    FontHeight = font.GetHeight();
            int      startX     = 10;
            int      startY     = 10;
            int      offset     = 90;

            graphic.DrawString("CÀ PHÊ TRI ÂN".PadLeft(17), new Font("Courier New", 10, System.Drawing.FontStyle.Bold), new SolidBrush(Color.Black), startX, startY);

            graphic.DrawString("252 Sông Lu, xã Trung An".PadLeft(25), font, new SolidBrush(Color.Black), startX + 22, startY + 15);
            graphic.DrawString("huyện Củ Chi, TP.HCM".PadLeft(27), font, new SolidBrush(Color.Black), startX, startY + 25);

            graphic.DrawString("HÓA ĐƠN BÀN SỐ".PadLeft(16), new Font("Courier New", 10, System.Drawing.FontStyle.Bold), new SolidBrush(Color.Black), startX, startY + 40);
            graphic.DrawString(InputDeskNo.ToString(), new Font("Courier New", 10, System.Drawing.FontStyle.Bold), new SolidBrush(Color.Black), startX + 150, startY + 40);

            graphic.DrawString("GIỜ BẮT ĐẦU".PadLeft(8), font, new SolidBrush(Color.Black), startX, startY + 65);
            graphic.DrawString(DateTime.Now.ToString(), font, new SolidBrush(Color.Black), startX + 70, startY + 65);

            string top = "Tên Mặt Hàng".PadRight(17) + "ĐVT".PadRight(7) + "SL".PadRight(6) + "TT";

            graphic.DrawString(top, font, new SolidBrush(Color.Black), startX, startY + offset);
            offset = offset + (int)FontHeight;     //make the spacing consistent
            graphic.DrawString("------------------------------------", font, new SolidBrush(Color.Black), startX, startY + offset);
            offset = offset + (int)FontHeight + 5; //make the spacing consistent

            //Check if product was chosen, then update quantity
            foreach (DetailBillItemViewModel item in ListDetailBill)
            {
                graphic.DrawString(item.ProductName, font, new SolidBrush(Color.Black), startX, startY + offset);
                graphic.DrawString(item.UnitName, font, new SolidBrush(Color.Black), startX + 90, startY + offset);
                graphic.DrawString(item.Quantity.ToString(), font, new SolidBrush(Color.Black), startX + 125, startY + offset);
                graphic.DrawString((item.Price * item.Quantity).ToString(), font, new SolidBrush(Color.Black), startX + 148, startY + offset);
                offset = offset + (int)FontHeight + 5; //make the spacing consistent
            }

            graphic.DrawString("------------------------------------", font, new SolidBrush(Color.Black), startX, startY + offset);

            offset = offset + (int)FontHeight + 5; //make the spacing consistent
            graphic.DrawString("TỔNG CỘNG", new Font("Courier New", 8, System.Drawing.FontStyle.Bold), new SolidBrush(Color.Black), startX, startY + offset);
            graphic.DrawString(SumPrice.ToString(), font, new SolidBrush(Color.Black), startX + 80, startY + offset);

            offset = offset + (int)FontHeight + 5; //make the spacing consistent
            graphic.DrawString("XIN CHÂN THÀNH CẢM ƠN QUÝ KHÁCH!".PadLeft(10), font, new SolidBrush(Color.Black), startX, startY + offset);

            offset = offset + (int)FontHeight + 5; //make the spacing consistent
            graphic.DrawString("HẸN GẶP LẠI!".PadLeft(23), font, new SolidBrush(Color.Black), startX, startY + offset);
        }
Example #31
0
        public FontRenderer(Font font)
        {
            Font = font;
            charHeight = -Font.Height;
            GlyphBitmap = new Bitmap(TextureSize.Width, TextureSize.Height);

            texture = new Texture(GL.GenTexture());
            GL.BindTexture(TextureTarget.Texture2D, texture.GetId());
            GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureMagFilter, (int)All.Linear);
            GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureMinFilter, (int)All.Linear);

            using (Graphics gfx = Graphics.FromImage(GlyphBitmap))
            {
                //this supposedly improves perforance
                //Application.SetCompatibleTextRenderingDefault(false);

                StringFormat format = new StringFormat(StringFormat.GenericTypographic);
                Point charPoint = new Point(0, 0);
                for (int i = 0; i < chars.Length; i++)
                {
                    SizeF charSizeF = gfx.MeasureString(new string(new Char[1] { Convert.ToChar(i) }), Font, 0, format);

                    Size charSize = new Size((int)Math.Ceiling(charSizeF.Width), (int)Math.Ceiling(charSizeF.Height));

                    //fudge factor to prevent glyphs from overlapping
                    charSize.Width += 2;

                    if (charSize.Width + charPoint.X > TextureSize.Width)
                    {
                        charPoint.X = 0;
                        charPoint.Y += (int)Math.Ceiling(Font.GetHeight());
                    }
                    chars[i] = new CharData(new Rectangle(charPoint, charSize), this);
                    charPoint.X += charSize.Width;
                }

                gfx.TextRenderingHint = System.Drawing.Text.TextRenderingHint.AntiAliasGridFit;
                gfx.Clear(Color.Transparent);
                for (int i = 0; i < chars.Length; i++)
                {
                    PointF point = new PointF(chars[i].PixelRegion.X, chars[i].PixelRegion.Y);
                    gfx.DrawString(new string(new Char[1] { Convert.ToChar(i) }), Font, new SolidBrush(Color.Black), point);
                }
            }

            BitmapData data = GlyphBitmap.LockBits(new Rectangle(0, 0, GlyphBitmap.Width, GlyphBitmap.Height), ImageLockMode.ReadOnly, System.Drawing.Imaging.PixelFormat.Format32bppArgb);
            GL.TexImage2D(TextureTarget.Texture2D, 0, PixelInternalFormat.Rgba, TextureSize.Width, TextureSize.Height, 0, Format, PixelType.UnsignedByte, data.Scan0);
            GlyphBitmap.UnlockBits(data);
        }
Example #32
0
        // The PrintPage event is raised for each page to be printed.
        private void PdPrintPage(object sender, PrintPageEventArgs ev)
        {
            float linesPerPage = 0;
            int count = 0;
            float leftMargin = ev.MarginBounds.Left;
            float topMargin = ev.MarginBounds.Top;
            string line = null;
            var font = new Font("Arial", 20);

            // Calculate the number of lines per page.
            linesPerPage = ev.MarginBounds.Height /
               font.GetHeight(ev.Graphics);

            // Print each line of the file.
            while (count < linesPerPage && ((line = streamToPrint.ReadLine()) != null))
            {
                var yPos = topMargin + (count * font.GetHeight(ev.Graphics));
                ev.Graphics.DrawString(line, font, Brushes.Red, leftMargin, yPos, new StringFormat());
                count++;
            }

            // If more lines exist, print another page.
            ev.HasMorePages = line != null;
        }
Example #33
0
        private float Print_to_page_length(Graphics gr)
        {
            Graphics     grfx = gr;
            float        len  = 0F;
            float        temp_h;
            Font         font           = new System.Drawing.Font("Microsoft Sans Serif", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
            Font         font_b         = new System.Drawing.Font("Microsoft Sans Serif", 12F, System.Drawing.FontStyle.Bold | System.Drawing.FontStyle.Underline, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
            float        cyFont_heading = font_b.GetHeight(grfx);
            float        cyFont         = font.GetHeight(grfx);
            StringFormat strfmt         = new StringFormat();
            RectangleF   rectfText;
            int          iChars, iLines;

            rectfText = new RectangleF(0, 0, 600, 999999999);

            for (int i = 1; i <= this.p_item_count; i++)
            {
                //subject///////////////////////////////////////////
                len += cyFont_heading;
                //p1/////////////////////////////////////////////
                grfx.MeasureString(p_item[i].p1, font, rectfText.Size,
                                   strfmt, out iChars, out iLines);
                temp_h = cyFont * iLines;
                if (temp_h > 0)
                {
                    temp_h += cyFont;
                }
                len += temp_h;
                //p2//////////////////////////////////////////////
                grfx.MeasureString(p_item[i].p2, font, rectfText.Size,
                                   strfmt, out iChars, out iLines);
                temp_h = cyFont * iLines;
                len   += temp_h;
                //p3//////////////////////////////////////////////
                grfx.MeasureString(p_item[i].p3, font, rectfText.Size,
                                   strfmt, out iChars, out iLines);
                temp_h = cyFont * iLines;
                len   += temp_h;
                //p4///////////////////////////////////////////////////
                grfx.MeasureString(p_item[i].p4, font, rectfText.Size,
                                   strfmt, out iChars, out iLines);
                temp_h = cyFont * iLines;
                len   += temp_h;
                //end p4///////////////////////////////////////////////
            }

            return(len);
        }
Example #34
0
        private void printJob_PrintPage(object sender, PrintPageEventArgs e)
        {
            Graphics graphic = e.Graphics;

            Font font = new Font("Courier New", 12);

            SolidBrush brush = new SolidBrush(Color.Black);

            float fontHeight = font.GetHeight();

            int startX = 10;
            int startY = 10;
            int offSet = 110;
            int logoOffsetX = 110;
            int logoOffsetY = 0;

            if (Company != null && Company.CompanyLogo != null)
            {
                Image companyLogo = (Image)new ImageConverter().ConvertFrom(Company.CompanyLogo);
                companyLogo = BuzzleFunctions.ResizeImage(companyLogo, new Size(100, 100));
                graphic.DrawImage(companyLogo, startX, startY);
            }

            graphic.DrawString(Company.CompanyName + " - Jobs Receipt", new Font("Arial", 16, FontStyle.Bold), brush, startX + logoOffsetX, startY + logoOffsetY);
            logoOffsetY += 25;

            string customerName = string.IsNullOrWhiteSpace(JobToBePrinted.CustomerName) ? "Unavailable" : JobToBePrinted.CustomerName;

            var headerString = string.Format("Job No. {0:00000} {2}Customer Name: {3}{2}Date Started: {1:dd MMM yyyy hh:mm} {2}Date Completed: {4:dd MMM yyyy hh:mm}", JobToBePrinted.JobID, JobToBePrinted.DateCreated, Environment.NewLine, customerName, JobToBePrinted.EndDate);

            graphic.DrawString(headerString, new Font("Courier New", 12, FontStyle.Italic), brush, startX + logoOffsetX, startY + logoOffsetY);

            graphic.DrawLine(new Pen(brush), startX, startY + offSet, startX + 550, startY + offSet);
            graphic.DrawString("Item: " + JobToBePrinted.JobItemType.ItemName + " " + JobToBePrinted.ItemDescription, new Font("Courier New", 13), brush, startX, startY + offSet);
            offSet += 20;

            graphic.DrawString("Fault: " + JobToBePrinted.FaultType.FaultName + " " + JobToBePrinted.FaultDescription, new Font("Courier New", 13), brush, startX, startY + offSet);

            offSet += 40;
            graphic.DrawString("Total Paid: ".PadLeft(42) + JobToBePrinted.TotalAmountPaid + " CFA", font, brush, startX, startY + offSet);
            offSet += 20;

            graphic.DrawLine(new Pen(brush), startX, startY + offSet, startX + 550, startY + offSet);

            graphic.DrawString("You were served by " + BuzzleFunctions.GetCurrentUser().FullName, new Font("Courier New", 12, FontStyle.Italic), brush, startX, startY + offSet);
        }
Example #35
0
        private Font GetAdjustedFont(Graphics g, Font font, Size room) {
            const float bias = 10;

            float size = font.Size;
            float lowSize = 0, highSize = 100;

            for (int i = 0; i < 10; i++) {
                font = new Font(font.Name, (lowSize + highSize) / 2, font.Style);

                if (font.GetHeight(g) > room.Height + bias)
                    highSize = (lowSize + highSize) / 2;
                else
                    lowSize = (lowSize + highSize) / 2;
            }

            return font;
        }
Example #36
0
        private void setInvoiceHead(Graphics g)
        {
            readInvoiceHead();

            currentY = topMargin;
            currentX = leftMargin;
            int ImageHeight = 0;

            // Draw Invoice image:
            if (System.IO.File.Exists(invoiceImage))
            {
                Bitmap oinvoiceImage = new Bitmap(invoiceImage);
                // Set Image Left to center Image:
                int xImage = currentX + (InvoiceWidth - oinvoiceImage.Width) / 2;
                ImageHeight = oinvoiceImage.Height; // Get Image Height
                g.DrawImage(oinvoiceImage, xImage, currentY);
            }

            invoiceTitleHeight = (int)(invoiceTitleFont.GetHeight(g));
            InvSubTitleHeight  = (int)(invoiceSubTitleFont.GetHeight(g));

            // Get Titles Length:
            int leninvoiceTitle     = (int)g.MeasureString(invoiceTitle, invoiceTitleFont).Width;
            int leninvoiceSubTitle1 = (int)g.MeasureString(invoiceSubTitle1, invoiceSubTitleFont).Width;

            // Set Titles Left:
            int xinvoiceTitle     = currentX + (InvoiceWidth - leninvoiceTitle) / 2;
            int xinvoiceSubTitle1 = currentX + (InvoiceWidth - leninvoiceSubTitle1) / 2;

            // Draw Invoice Head:
            if (invoiceTitle != "")
            {
                currentY = currentY + ImageHeight;
                g.DrawString(invoiceTitle, invoiceTitleFont, blueBrush, xinvoiceTitle, currentY);
            }
            if (invoiceSubTitle1 != "")
            {
                currentY = currentY + invoiceTitleHeight;
                g.DrawString(invoiceSubTitle1, invoiceSubTitleFont, blueBrush, xinvoiceSubTitle1, currentY);
            }

            // Draw line:
            currentY = currentY + InvSubTitleHeight + 8;
            g.DrawLine(new Pen(Brushes.Black, 2), currentX, currentY, rightMargin, currentY);
        }
Example #37
0
        /// <summary>
        /// parse the values for the character
        /// </summary>
        public void Parse(Control refCtrl,FontDefinition fd,Font font,char c,bool doCompression)
        {
            SizeF size;

              this.Character=c;

              // space is a special case

              if(c==' ') {
            ParseSpace(refCtrl,font);
            return;
              }

              using(Graphics g=refCtrl.CreateGraphics()) {

            g.TextRenderingHint=fd.Hint;

            // get the size that the system thinks the character occupies

            size=TextRenderer.MeasureText(g,c.ToString(),font,new Size(int.MaxValue,int.MaxValue),TextFormatFlags.NoPadding | TextFormatFlags.NoPrefix);

            this.CharacterBitmap=new Bitmap(Convert.ToInt32(size.Width)+fd.ExtraSpacing.Width,Convert.ToInt32(font.GetHeight())+fd.ExtraSpacing.Height);
            this.Size=this.CharacterBitmap.Size;

            using(Graphics charGraphics=Graphics.FromImage(this.CharacterBitmap)) {

              charGraphics.TextRenderingHint=fd.Hint;

              using(SolidBrush backBrush=new SolidBrush(fd.Background))
            charGraphics.FillRectangle(backBrush,0,0,this.CharacterBitmap.Width,this.CharacterBitmap.Height);

              // draw the character into the center of the bitmap

              TextRenderer.DrawText(charGraphics,c.ToString(),font,new Point(0,0),fd.Foreground,fd.Background,TextFormatFlags.NoPadding | TextFormatFlags.NoPrefix);
            }

            // scan the bitmap

            if(doCompression)
              ScanBitmap(this.CharacterBitmap,fd);
              }
        }
Example #38
0
        /// <summary>
        /// parse character definitions. The input string must be sorted.
        /// </summary>
        public void ParseCharacters(Control refCtrl,FontDefinition fd,string str,bool doCompression)
        {
            CharDef cd;
              FormProgress progress;
              Font font;

              progress=new FormProgress();
              progress.ProgressBar.Minimum=0;
              progress.ProgressBar.Maximum=str.Length;

              if(doCompression)
            progress.Show();

              // create a font

              font=new Font(fd.Family,fd.Size,fd.Style,GraphicsUnit.Pixel);
              this.Height=Convert.ToInt32(font.GetHeight());

              try {
            this.Definitions=new List<CharDef>();

            foreach(char c in str) {

              // update progress

              progress.ProgressBar.PerformStep();
              Application.DoEvents();

              // create character

              cd=new CharDef();
              cd.Parse(refCtrl,fd,font,c,doCompression);

              Definitions.Add(cd);
            }
              }
              finally {

            if(doCompression)
              progress.Close();
              }
        }
Example #39
0
        public BrowserFont(string fontName, float size, BrowserFontType fontType)
        {
            FontName = fontName;
            FontType = fontType;

            if (fontType == BrowserFontType.Normal)
            {
                _style = FontStyle.Regular;
                _color = Color.Black;
            }
            if (FontType == BrowserFontType.UnvisitedLink)
            {
                _style = FontStyle.Bold | FontStyle.Underline;
                _color = Color.Blue;
            }
            _rawFont = new Font(fontName, size, _style);
            _brush = new SolidBrush(_color);
            FontType = fontType;
            Height = _rawFont.GetHeight();
        }
Example #40
0
        // Calculates a set of column offset info based on measurements of the font and the display geometry
        protected void CalcColumns(System.Drawing.Font font)
        {
            if (!active || font == null)
            {
                return;
            }

            SizeF max_suf_bounds = dev.graph.MeasureString(big_suf, font, new Point(0, 0), fmt_default);

            max_suffix_width = (int)(max_suf_bounds.Width + 1);


            SizeF max_lab_bounds = dev.graph.MeasureString(big_lab, font, new Point(0, 0), fmt_default);

            max_lab_width = (int)(max_lab_bounds.Width);

            int small_col = max_lab_width;
            int large_col = (width - (small_col * 2)) / 2;

            line_offset = (float)Math.Round(font.GetHeight());

            if (two_column_labeled_offsets == null)
            {
                two_column_labeled_offsets = new int[5];
            }
            two_column_labeled_offsets[0] = xoff + 0;
            two_column_labeled_offsets[1] = xoff + small_col;
            two_column_labeled_offsets[2] = two_column_labeled_offsets[1] + large_col;
            two_column_labeled_offsets[3] = two_column_labeled_offsets[2] + small_col;
            two_column_labeled_offsets[4] = xoff + width;

            if (two_column_offsets == null)
            {
                two_column_offsets = new int[3];
            }
            two_column_offsets[0] = xoff + 0;
            two_column_offsets[1] = xoff + width / 2;
            two_column_offsets[2] = xoff + width;
        }
Example #41
0
        private void pdPrint_PrintPage(object sender, PrintPageEventArgs e)
        {
            float x, y, lineOffset;

            // Instantiate font objects used in printing.
            Font printFont = new Font("Verdana", (float)11, FontStyle.Regular, GraphicsUnit.Point); // Substituted to FontA Font

            e.Graphics.PageUnit = GraphicsUnit.Point;

            // Print the receipt text
            lineOffset = printFont.GetHeight(e.Graphics) - 2;

            x = 200;
            y = -10 + lineOffset;

            e.Graphics.DrawString("Evid. broj: " + txtBroj.Text.Trim() + "", printFont, Brushes.Black, x, y);
            y += lineOffset;
            e.Graphics.DrawString("" + DateTime.Now + "", printFont, Brushes.Black, x, y);

            // Indicate that no more data to print, and the Print Document can now send the print data to the spooler.
            e.HasMorePages = false;
        }
Example #42
0
 public static void DrawWatermarkText(Graphics graphics, string text, string fontName) {
     int imageHeight = (int)graphics.VisibleClipBounds.Height;
     int imageWidth = (int)graphics.VisibleClipBounds.Width;
     int maxTextWidth = (int)(imageHeight * 0.4);
     int[] fontSizes = new int[] { 72, 48, 36, 24, 18, 18, 14, 12, 10 };
     Font font = null;
     foreach(int fontSize in fontSizes) {
         font = new Font(fontName, fontSize, GraphicsUnit.Pixel);
         if(graphics.MeasureString(text, font).Width <= maxTextWidth)
             break;
     }
     GraphicsState state = graphics.Save();
     SmoothGraphics(graphics);
     graphics.RotateTransform(-90);
     float padding = font.Size / 2;
     graphics.TranslateTransform(-imageHeight + padding, imageWidth - font.GetHeight() - padding);
     graphics.TextContrast = 12;
     graphics.PageUnit = font.Unit;
     graphics.DrawString(text, font, new SolidBrush(Color.FromArgb(120, Color.Black)), 1, 1);
     graphics.DrawString(text, font, new SolidBrush(Color.FromArgb(120, Color.White)), 0, 0);
     graphics.Restore(state);
 }
Example #43
0
        protected override void OnPaint(PaintEventArgs e)
        {
            if (VisibleTimeStart <= audio.MediaDuration)
            {
                if (samples.Count > 0 && !_creatingSamples)
                {
                    e.Graphics.TranslateTransform(-timeToPixels(VisibleTimeStart), 0);
                    float maxSample     = Math.Max(Math.Abs(samples.Low), samples.High);
                    int   workingHeight = Height - (int)(Height * .1);                  //Leave a little margin
                    float factor        = workingHeight / maxSample;

                    float maxValue = 2 * maxSample * factor;
                    float minValue = -maxSample * factor;
                    int   start    = (int)timeToPixels(VisibleTimeStart);
                    int   end      = (int)timeToPixels(VisibleTimeEnd <= audio.MediaDuration ? VisibleTimeEnd : audio.MediaDuration);

                    for (int x = start; x < end; x += 1)
                    {
                        float lowPercent  = (((samples[x].Low * factor) - minValue) / maxValue);
                        float highPercent = (((samples[x].High * factor) - minValue) / maxValue);
                        e.Graphics.DrawLine(Pens.Black, x, workingHeight * lowPercent, x, workingHeight * highPercent);
                    }
                }
                else
                {
                    using (Font f = new Font(Font.FontFamily, 10f, FontStyle.Regular))
                    {
                        e.Graphics.DrawString("Building waveform.....", f, Brushes.Black,
                                              new Point((int)timeToPixels(VisibleTimeStart) + 15,
                                                        (int)(Height - f.GetHeight(e.Graphics)) / 2),
                                              new StringFormat {
                            Alignment = StringAlignment.Near
                        });
                    }
                }
            }

            base.OnPaint(e);
        }
Example #44
0
        void pdoc_PrintPage(object sender, PrintPageEventArgs e)
        {
            Font textFont = new Font("Arial", 6);

            //BarcodeLib.Barcode bc = new Barcode();
            FNSKUBarcode bc = new FNSKUBarcode(label.FNSKU);

            Image i = bc.getBarCodeImage(1);

            Graphics graphics = e.Graphics;
              //  float fontHeight = font.GetHeight();
            int startX = 10;
            int startY = 10;
            int Offset = 10;
            //Offset = Offset + 20;
            graphics.DrawImage(i, new Point(startX, startY));
            Offset += i.Height;
            graphics.DrawString(label.FNSKU, textFont,
                              new SolidBrush(Color.Black), startX, startY + Offset);
            Offset += (int)textFont.GetHeight() + 2;

            graphics.DrawString(label.Title, textFont,
                               new SolidBrush(Color.Black), startX, startY + Offset);
        }
Example #45
0
 protected override void OnPrintPage(PrintPageEventArgs e)
 {
     base.OnPrintPage(e);
     Image image = this._document.Image;
     Size size = image.Size;
     float num = 1f;
     Graphics graphics = e.Graphics;
     Margins margins = e.PageSettings.Margins;
     float height = 0f;
     Font font = new Font("Verdana", 8f);
     StringFormat format = new StringFormat(StringFormatFlags.NoWrap);
     format.Trimming = StringTrimming.EllipsisPath;
     height = font.GetHeight(graphics);
     graphics.DrawString(this._document.DocumentPath, font, Brushes.Black, (float) margins.Left, (float) margins.Top, format);
     float num3 = (margins.Top + height) + 2f;
     graphics.DrawLine(Pens.Black, (float) margins.Left, num3, (float) (margins.Left + e.MarginBounds.Width), num3);
     format.Dispose();
     font.Dispose();
     float num4 = (((e.MarginBounds.Height - height) - 2f) - 1f) - 4f;
     if ((size.Width > e.MarginBounds.Width) || (size.Height > num4))
     {
         float num5 = ((float) e.MarginBounds.Width) / ((float) size.Width);
         float num6 = num4 / ((float) size.Height);
         num = (num5 < num6) ? num5 : num6;
     }
     try
     {
         graphics.DrawImage(image, (float) margins.Left, (float) ((margins.Top + height) + 7f), (float) (image.Size.Width * num), (float) (image.Size.Height * num));
     }
     catch
     {
         graphics.FillRectangle(SystemBrushes.Control, (float) margins.Left, (margins.Top + height) + 7f, image.Size.Width * num, image.Size.Height * num);
         graphics.DrawImageUnscaled(SystemIcons.Error.ToBitmap(), margins.Left + 4, (int) (((margins.Top + height) + 7f) + 4f));
     }
     e.HasMorePages = false;
 }
Example #46
0
        private static void printPage(object sender, PrintPageEventArgs e)
        {
            Graphics G = e.Graphics;

            float right = e.PageSettings.Margins.Right;
            float left = e.PageSettings.Margins.Left;
            float top = e.PageSettings.Margins.Top;
            float bottom = e.PageSettings.Margins.Bottom;
            float width = e.PageSettings.Bounds.Width;
            float height = e.PageSettings.Bounds.Height;
            G.FillRectangle(Brushes.White, 0, 0, width, height);

            float y = top;
            float x = left;
            Font titleFont = new Font("Calibri", 14F, FontStyle.Bold);
            Font fontQ = new Font("Calibri", 12F);
            Font fontA = new Font("Calibri", 11F);
            Font fontW = new Font("Calibri", 100F);

            flagBreak = false;
            var img = new Bitmap(1, 1);
            Graphics E = Graphics.FromImage(img);

            if (noPage == 1)
            {
                //draw these only in first page
                G.DrawStringML(title, titleFont, Brushes.Black, x, ref y, width - right);
                y += (titleFont.GetHeight(G) + 20);
                G.DrawString("Date: " + date, fontQ, Brushes.Black, width - right - 150, y);
                G.DrawString("First Name: ___________________", fontQ, Brushes.Black, x, y);
                y += fontQ.GetHeight(G) + 5;
                G.DrawString("Last Name:  ___________________", fontQ, Brushes.Black, x, y);
                y += fontQ.GetHeight(G) + 5;
                G.DrawString("Class: ________", fontQ, Brushes.Black, x, y);
                y += fontQ.GetHeight(G) + 5;
                G.DrawString("Points:________", fontQ, Brushes.Black, x, y);
                y += fontQ.GetHeight(G) + 35;
                G.DrawStringML("Choose the correct answer. There might be more than one correct answers.", fontQ, Brushes.Black, x, ref y, width - right);
                y += fontQ.GetHeight(G) + 20;
            }

            while (iq < _test.Count && flagBreak == false)
            {
                //Define the question
                string question = (iq + 1) + ". " + _test[iq].question;
                float tempY = y;
                E.DrawStringML(question, fontQ, Brushes.Black, x, ref tempY, width - right);

                if (tempY > height - bottom)
                {
                    flagBreak = true;
                    break;
                }
                else
                {
                    if (!typedQ)
                    {
                        //Draw the question
                        G.DrawStringML(question, fontQ, Brushes.Black, x, ref y, width - right);
                        typedQ = true;
                    }
                    while (ia < _test[iq].anwsers.Count && flagBreak == false)
                    {
                        //Define the answer
                        string answer = _test[iq].anwsers[ia].text;
                        tempY = y;
                        E.DrawStringML(answer, fontQ, Brushes.Black, x, ref tempY, width - right);

                        if (tempY > height - bottom)
                        {
                            flagBreak = true;
                            break;
                        }
                        else
                        {
                            y += 8;
                            //Draw the answer
                            G.DrawRectangle(new Pen(Color.Black), x+15, y, 20, 20);
                            if (solved && _test[iq].anwsers[ia].correct)
                            {
                                G.FillRectangle(Brushes.Black, x+15, y, 20, 20);
                            }
                            G.DrawStringML(answer, fontA, Brushes.Black, x + 45, ref y, width - right);
                            ia++;
                        }
                    }
                    if (ia == _test[iq].anwsers.Count)
                    {
                        ia = 0;
                    }
                    if (!flagBreak)
                    {
                        y += 30;
                        iq++;
                        typedQ = false;
                    }
                    else
                    {
                        break;
                    }
                }
            }

            string watermark = "TestME";

            // Get the size of watermark
            SizeF size = G.MeasureString(watermark, fontW);

            // Define a rotation transformation at the center of the page
            G.TranslateTransform(width / 2, height / 2);
            G.RotateTransform((float)(-Math.Atan(height / width) * 180 / Math.PI));
            G.TranslateTransform(-width / 2, -height / 2);

            // Create a string format
            StringFormat format = new StringFormat();
            format.Alignment = StringAlignment.Near;
            format.LineAlignment = StringAlignment.Near;
            Brush brush = new SolidBrush(Color.FromArgb(60, 128, 125, 123));

            // Draw the watermark
            G.DrawString(watermark, fontW, brush,
              new PointF((width - size.Width) / 2, (height - size.Height) / 2),
              format);

            noPage++;
            e.HasMorePages = flagBreak;
        }
Example #47
0
		internal virtual void  SelectElement(System.String El)
		{
			if (lastElement != null)
			{
				if (String.CompareOrdinal(lastElement, El) == 0)
					return ;
				//UPGRADE_ISSUE: Constructor 'javax.swing.Image.Image' was not converted. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1000_javaxswingImageIconImageIcon_javanetURL'"
				//UPGRADE_TODO: Method 'java.lang.Class.getResource' was converted to 'System.Uri' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073_javalangClassgetResource_javalangString'"
				toolIcons[TOOL_SETATOM] = new Bitmap(Utility.GetFullPath("/images/" + IMAGE_TOOL[TOOL_SETATOM] + ".png"));
			}
			
			int w = toolIcons[TOOL_SETATOM].Width, h = toolIcons[TOOL_SETATOM].Height;
			Bitmap img = new Bitmap(w, h, (System.Drawing.Imaging.PixelFormat) System.Drawing.Imaging.PixelFormat.Format32bppArgb);
            using (Graphics g = (Graphics)Graphics.FromImage(img))
            {
                Brush background = new SolidBrush(Color.White); 
                g.FillRectangle(background, 0, 0, w, h);
                g.DrawImage(toolIcons[TOOL_SETATOM], 0, 0);

                Font font = new Font("SansSerif", El.Length == 1 ? 12 : 10, FontStyle.Regular);
                Brush brush = new SolidBrush(System.Drawing.Color.FromArgb(0, 192, 0));
                int textWidth = (int)g.MeasureString(El, font).Width;
                float x = (w - textWidth) / 2 - 3;
                float y = (h + SupportClass.GetAscent(font)) / font.GetHeight(); 

                g.DrawString(El, font, brush, x, y);
            }
			
			lastElement = El;
		}
Example #48
0
			/// <summary>
			/// Updates the measures of the word as it would be
			/// when drawn with the specified font in the specified graphics,
			/// making sure word style is taken into account.
			/// </summary>
			public override void UpdateMeasures(Graphics graphics, Font font)
			{
				Font styledFont = CreateFont(font);

				base.UpdateMeasures(graphics, styledFont);

				// Update y-off
				if ((_format & Styles.Sub) > 0)
				{
					float wordHeight = styledFont.GetHeight(graphics);
					float textHeight = font.GetHeight(graphics);

					_yOff = textHeight - wordHeight;
				}

				else if ((_format & Styles.Sup) > 0)
				{
					_yOff = 0; // ?!
				}

				DisposeFont(styledFont);
			}
Example #49
0
		/// <summary>
		/// Assigns new text to the object. The text is formatted
		/// according to the specified font and graphics objects.
		/// </summary>
		public void Setup(string text, Graphics graphics, Font font)
		{
			_text = text;

			// Process the text
			_words.Clear();
			ProcessText();

			// Update the read-only words collection
			_readOnlyWords = new WordList(_words);

			// Recalculates the width of all words within the text,
			// using the specified font and graphics objects
			foreach (Word word in _words)
				word.UpdateMeasures(graphics, font);

			// Calculate the height of the text when
			// drawn with the specified font in the specified graphics
			_height = font.GetHeight(graphics);
		}
Example #50
0
        public void Draw(TimeLineDrawParameter parameter)
        {
            if (parameter == null)
            {
                return;
            }

            area         = new SolidBrush(PPDEditorSkin.Skin.TimeLineSeekAreaColor);
            border       = new Pen(PPDEditorSkin.Skin.TimeLineSeekAreaBorderColor);
            text         = new SolidBrush(PPDEditorSkin.Skin.TimeLineTextColor);
            hline        = new Pen(PPDEditorSkin.Skin.TimeLineHorizontalLineColor);
            time         = new Pen(PPDEditorSkin.Skin.TimeLineCurrentTimeColor);
            vline1       = new Pen(PPDEditorSkin.Skin.TimeLineVerticalLineColor1);
            vline2       = new Pen(PPDEditorSkin.Skin.TimeLineVerticalLineColor2);
            vline3       = new Pen(PPDEditorSkin.Skin.TimeLineVerticalLineColor3);
            vline4       = new Pen(PPDEditorSkin.Skin.TimeLineVerticalLineColor4);
            vline5       = new Pen(PPDEditorSkin.Skin.TimeLineVerticalLineColor5);
            selection    = new SolidBrush(PPDEditorSkin.Skin.TimeLineSelectionAreaColor);
            selectedmark = new SolidBrush(PPDEditorSkin.Skin.TimeLineSelectedMarkColor);
            holdExtent   = new SolidBrush(PPDEditorSkin.Skin.TimeLineHoldExtentColor);

            parameter.Graphics.FillRectangle(Brushes.White, new Rectangle(0, 0, parameter.Width, parameter.Height));
            if (parameter.BackGroundImage != null && parameter.Width > 0 && parameter.Height > 0)
            {
                parameter.Graphics.DrawImage(parameter.BackGroundImage, 0, 0);
            }
            parameter.Graphics.FillRectangle(area, 0, 0, parameter.Width, PPDEditorSkin.Skin.TimeLineHeight);
            parameter.Graphics.DrawLine(border, 0, PPDEditorSkin.Skin.TimeLineHeight - 1, parameter.Width, PPDEditorSkin.Skin.TimeLineHeight - 1);
            var rows     = WindowUtility.TimeLineForm.RowManager.OrderedVisibleRows;
            var visibles = WindowUtility.TimeLineForm.RowManager.Visibilities;
            //hline
            int iter = 0;

            foreach (var row in rows)
            {
                parameter.Graphics.FillRectangle(PPDEditorSkin.Skin.TimeLineBackGroundColors[row],
                                                 new Rectangle(0, PPDEditorSkin.Skin.TimeLineHeight + PPDEditorSkin.Skin.TimeLineRowHeight * iter + 1,
                                                               parameter.Width, PPDEditorSkin.Skin.TimeLineRowHeight));
                iter++;
            }
            if (parameter.Sheet != null)
            {
                //areaselection
                if (parameter.Sheet.RecStart.X != -1 && parameter.Sheet.RecStart.Y != -1)
                {
                    float startx = (parameter.Sheet.RecStart.X <= parameter.Sheet.RecEnd.X ? parameter.Sheet.RecStart.X : parameter.Sheet.RecEnd.X) * parameter.BPM / 60 * parameter.Interval;
                    float width  = Math.Abs(parameter.Sheet.RecStart.X - parameter.Sheet.RecEnd.X) * parameter.BPM / 60 * parameter.Interval;
                    int   starty = (parameter.Sheet.RecStart.Y <= parameter.Sheet.RecEnd.Y ? parameter.Sheet.RecStart.Y : parameter.Sheet.RecEnd.Y);
                    var   height = Math.Min(rows.Length, Math.Abs(parameter.Sheet.RecStart.Y - parameter.Sheet.RecEnd.Y) + 1);
                    parameter.Graphics.FillRectangle(selection, startx - parameter.LeftOffset,
                                                     starty * (PPDEditorSkin.Skin.TimeLineRowHeight) + PPDEditorSkin.Skin.TimeLineHeight,
                                                     width, height * (PPDEditorSkin.Skin.TimeLineRowHeight) + 1);
                }
            }
            iter = 0;
            foreach (var row in rows)
            {
                parameter.Graphics.DrawLine(hline, 0,
                                            PPDEditorSkin.Skin.TimeLineHeight + PPDEditorSkin.Skin.TimeLineRowHeight * (iter + 1),
                                            parameter.Width, PPDEditorSkin.Skin.TimeLineHeight + PPDEditorSkin.Skin.TimeLineRowHeight * (iter + 1));
                iter++;
            }
            int offset       = -(int)(parameter.BPMStart * parameter.Interval / parameter.BPM);
            int startpos     = offset + parameter.LeftOffset;
            int startcount   = startpos / parameter.Interval;
            int startdrawpos = startcount * parameter.Interval - startpos;
            var font         = new System.Drawing.Font("MS ゴシック", 10);

            for (int i = 0; i *parameter.Interval + startdrawpos < parameter.Width; i++)
            {
                if (parameter.DisplayMode <= DisplayLineMode.SixtyFourth)
                {
                    for (int j = 0; j < 4; j++)
                    {
                        if (parameter.DisplayMode >= DisplayLineMode.Fourth && j == 0)
                        {
                            parameter.Graphics.DrawLine(vline1, startdrawpos + parameter.Interval * (4 * i + j) / 4, 0, startdrawpos + parameter.Interval * (4 * i + j) / 4, parameter.Height);
                        }
                        if (parameter.DisplayMode >= DisplayLineMode.Eigth && j == 2)
                        {
                            parameter.Graphics.DrawLine(vline2, startdrawpos + parameter.Interval * (4 * i + j) / 4, 0, startdrawpos + parameter.Interval * (4 * i + j) / 4, parameter.Height);
                        }
                        if (parameter.DisplayMode >= DisplayLineMode.Sixteenth && (j == 1 || j == 3))
                        {
                            parameter.Graphics.DrawLine(vline3, startdrawpos + parameter.Interval * (4 * i + j) / 4, 0, startdrawpos + parameter.Interval * (4 * i + j) / 4, parameter.Height);
                        }
                        if (parameter.DisplayMode >= DisplayLineMode.ThirtySecond)
                        {
                            parameter.Graphics.DrawLine(vline4, startdrawpos + parameter.Interval * (8 * i + j * 2 + 1) / 8, 10, startdrawpos + parameter.Interval * (8 * i + j * 2 + 1) / 8, parameter.Height);
                        }
                        if (parameter.DisplayMode >= DisplayLineMode.SixtyFourth)
                        {
                            parameter.Graphics.DrawLine(vline5, startdrawpos + parameter.Interval * (16 * i + j * 4 + 1) / 16, 10, startdrawpos + parameter.Interval * (16 * i + j * 4 + 1) / 16, parameter.Height);
                            parameter.Graphics.DrawLine(vline5, startdrawpos + parameter.Interval * (16 * i + j * 4 + 3) / 16, 10, startdrawpos + parameter.Interval * (16 * i + j * 4 + 3) / 16, parameter.Height);
                        }
                    }
                }
                else if (parameter.DisplayMode >= DisplayLineMode.Twelfth && parameter.DisplayMode <= DisplayLineMode.FourthEighth)
                {
                    for (int j = 0; j < 3; j++)
                    {
                        if (j == 0)
                        {
                            parameter.Graphics.DrawLine(vline1, startdrawpos + parameter.Interval * (4 * i + j) / 4, 0, startdrawpos + parameter.Interval * (4 * i + j) / 4, parameter.Height);
                        }
                        if (parameter.DisplayMode >= DisplayLineMode.Twelfth && (j == 1 || j == 2))
                        {
                            parameter.Graphics.DrawLine(vline2, startdrawpos + parameter.Interval * (3 * i + j) / 3, 0, startdrawpos + parameter.Interval * (3 * i + j) / 3, parameter.Height);
                        }
                        if (parameter.DisplayMode >= DisplayLineMode.TwentyFourth)
                        {
                            parameter.Graphics.DrawLine(vline3, startdrawpos + parameter.Interval * (6 * i + j * 2 + 1) / 6, 0, startdrawpos + parameter.Interval * (6 * i + j * 2 + 1) / 6, parameter.Height);
                        }
                        if (parameter.DisplayMode >= DisplayLineMode.FourthEighth)
                        {
                            parameter.Graphics.DrawLine(vline4, startdrawpos + parameter.Interval * (12 * i + j * 4 + 1) / 12, 10, startdrawpos + parameter.Interval * (12 * i + j * 4 + 1) / 12, parameter.Height);
                            parameter.Graphics.DrawLine(vline4, startdrawpos + parameter.Interval * (12 * i + j * 4 + 3) / 12, 10, startdrawpos + parameter.Interval * (12 * i + j * 4 + 3) / 12, parameter.Height);
                        }
                    }
                }
                int count = (startcount + i).ToString().Length;
                if ((startcount + i) % parameter.BeatSplitCount == 0)
                {
                    parameter.Graphics.DrawString(((startcount + i) / parameter.BeatSplitCount).ToString(), font, text, new PointF(i * parameter.Interval + startdrawpos - font.GetHeight() / 2 * count / 2, 0));
                }
            }
            font.Dispose();
            float drawstarttime = (float)(parameter.LeftOffset - 10) / parameter.Interval / parameter.BPM * 60;
            float drawendtime   = (float)(parameter.LeftOffset + parameter.Width + 10) / parameter.Interval / parameter.BPM * 60;

            LayerDisplay[] layers = WindowUtility.LayerManager.AllLayerDisplay;
            if (layers != null)
            {
                foreach (var layer in layers)
                {
                    var sheet = layer.PPDData;
                    mark     = new SolidBrush(layer.MarkColor);
                    diffmark = new SolidBrush(Color.FromArgb(64 * layer.MarkColor.A / 255, layer.MarkColor));
                    bool isSelectedLayer = sheet == WindowUtility.LayerManager.SelectedPpdSheet;
                    iter = 0;
                    foreach (var row in rows)
                    {
                        var times = sheet.Data[row].Keys;
                        for (var i = 0; i < times.Count; i++)
                        {
                            var f = times[i];
                            sheet.Data[row].TryGetValue(f, out Mark mk);
                            if (!visibles[(int)mk.Type])
                            {
                                continue;
                            }
                            var exmk = mk as ExMark;
                            if (exmk == null)
                            {
                                if (f >= drawstarttime && f <= drawendtime)
                                {
                                    if (isSelectedLayer && sheet.FocusedMark[0] == row && sheet.FocusedMark[1] == sheet.Data[row].IndexOfKey(f))
                                    {
                                        parameter.Graphics.FillEllipse(selectedmark, (f * parameter.BPM / 60 * parameter.Interval - parameter.LeftOffset) - CircleWidth / 2,
                                                                       PPDEditorSkin.Skin.TimeLineHeight + PPDEditorSkin.Skin.TimeLineRowHeight * (iter + 0.5f) - CircleWidth / 2, CircleWidth, CircleWidth);
                                    }
                                    else
                                    {
                                        parameter.Graphics.FillEllipse(isSelectedLayer ? mark : diffmark, (f * parameter.BPM / 60 * parameter.Interval - parameter.LeftOffset) - CircleWidth / 2,
                                                                       PPDEditorSkin.Skin.TimeLineHeight + PPDEditorSkin.Skin.TimeLineRowHeight * (iter + 0.5f) - CircleWidth / 2,
                                                                       CircleWidth, CircleWidth);
                                    }
                                }
                            }
                            else
                            {
                                var drawLongNote   = (f >= drawstarttime && f <= drawendtime) || (exmk.EndTime >= drawstarttime && exmk.EndTime <= drawendtime);
                                var holdExtentTime = f + 5 + PPDSetting.Setting.GoodArea;
                                var drawHoldExtent = holdExtentTime >= drawstarttime && holdExtentTime <= drawendtime;

                                if (WindowUtility.MainForm.ShowHoldExtent && (drawLongNote || drawHoldExtent))
                                {
                                    if (!exmk.IsScratch && (exmk.NoteType == PPDFramework.NoteType.AC || exmk.NoteType == PPDFramework.NoteType.ACFT))
                                    {
                                        var hasNextTime = i + 1 < times.Count;
                                        var height      = PPDEditorSkin.Skin.TimeLineRowHeight - 3;
                                        var rectX       = f * parameter.BPM / 60 * parameter.Interval - parameter.LeftOffset;
                                        var rectY       = PPDEditorSkin.Skin.TimeLineHeight + PPDEditorSkin.Skin.TimeLineRowHeight * (iter + 0.5f) - height / 2;
                                        var width       = (5 + PPDSetting.Setting.GoodArea) * parameter.BPM / 60 * parameter.Interval;
                                        var nextX       = float.MaxValue;
                                        if (hasNextTime)
                                        {
                                            nextX = times[i + 1] * parameter.BPM / 60 * parameter.Interval - parameter.LeftOffset;
                                            if (rectX + width >= nextX)
                                            {
                                                width = nextX - rectX;
                                            }
                                        }
                                        var rect = new Rectangle((int)rectX, (int)rectY, (int)width, height);
                                        parameter.Graphics.FillRectangle(holdExtent, rect);
                                        var x = (int)((f + 5 + PPDSetting.Setting.GoodArea) * parameter.BPM / 60 * parameter.Interval - parameter.LeftOffset);
                                        if (nextX > x)
                                        {
                                            parameter.Graphics.DrawLine(Pens.Black, x, rect.Top + 8, x, rect.Bottom - 8);
                                        }
                                        x = (int)((f + 5 + PPDSetting.Setting.CoolArea) * parameter.BPM / 60 * parameter.Interval - parameter.LeftOffset);
                                        if (nextX > x)
                                        {
                                            parameter.Graphics.DrawLine(Pens.Black, x, rect.Top + 4, x, rect.Bottom - 4);
                                        }
                                        x = (int)((f + 5) * parameter.BPM / 60 * parameter.Interval - parameter.LeftOffset);
                                        if (nextX > x)
                                        {
                                            parameter.Graphics.DrawLine(Pens.Black, x, rect.Top, x, rect.Bottom);
                                        }
                                        x = (int)((f + 5 - PPDSetting.Setting.CoolArea) * parameter.BPM / 60 * parameter.Interval - parameter.LeftOffset);
                                        if (nextX > x)
                                        {
                                            parameter.Graphics.DrawLine(Pens.Black, x, rect.Top + 4, x, rect.Bottom - 4);
                                        }
                                        x = (int)((f + 5 - PPDSetting.Setting.GoodArea) * parameter.BPM / 60 * parameter.Interval - parameter.LeftOffset);
                                        if (nextX > x)
                                        {
                                            parameter.Graphics.DrawLine(Pens.Black, x, rect.Top + 8, x, rect.Bottom - 8);
                                        }
                                    }
                                }

                                if (drawLongNote)
                                {
                                    var rect = new Rectangle((int)(f * parameter.BPM / 60 * parameter.Interval - parameter.LeftOffset),
                                                             (int)(PPDEditorSkin.Skin.TimeLineHeight + PPDEditorSkin.Skin.TimeLineRowHeight * (iter + 0.5f) - CircleWidth / 2),
                                                             (int)((exmk.EndTime - f) * parameter.BPM / 60 * parameter.Interval), CircleWidth);
                                    if (isSelectedLayer && sheet.FocusedMark[0] == row && sheet.FocusedMark[1] == sheet.Data[row].IndexOfKey(f))
                                    {
                                        parameter.Graphics.FillRectangle(selectedmark, rect);
                                    }
                                    else
                                    {
                                        parameter.Graphics.FillRectangle(isSelectedLayer ? mark : diffmark, rect);
                                    }
                                }
                            }
                        }
                        iter++;
                    }
                }
            }
            var events = WindowUtility.EventManager.GetEventsWithinTime(drawstarttime, drawendtime);

            foreach (float eventtime in events)
            {
                DrawChange(parameter, eventtime, 0, rows.Length, PPDEditor.Properties.Resources.eventmark);
            }
            events = WindowUtility.SoundManager.GetSoundChangeWithinTime(drawstarttime, drawendtime);
            foreach (float eventtime in events)
            {
                DrawChange(parameter, eventtime, 14, rows.Length, PPDEditor.Properties.Resources.soundmark);
            }
            events = WindowUtility.KasiEditor.GetKasiChangeWithinTime(drawstarttime, drawendtime);
            foreach (float eventtime in events)
            {
                DrawChange(parameter, eventtime, 28, rows.Length, PPDEditor.Properties.Resources.lylicsmark);
            }
            var pos = (float)(parameter.CurrentTime * parameter.BPM / 60 * parameter.Interval);

            if (pos - parameter.LeftOffset >= -5 && pos - parameter.LeftOffset <= parameter.Width + 5)
            {
                parameter.Graphics.DrawLine(time, new PointF(pos - parameter.LeftOffset, PPDEditorSkin.Skin.TimeLineHeight), new PointF(pos - parameter.LeftOffset, parameter.Height));
                parameter.Graphics.DrawRectangle(time, pos - 5 - parameter.LeftOffset, 0, 10, PPDEditorSkin.Skin.TimeLineHeight - 1);
            }
        }
        /// <summary>
        /// Prints the a3 temperatur curve.
        /// </summary>
        /// <param name="patients">The patients.</param>
        /// <param name="weeks">The weeks.</param>
        /// <param name="copies">The copies.</param>
        /// <param name="printFormat">The print format.</param>
        /// <param name="opParam">The op.</param>
        public void PrintA3TemperaturCurve(IList<PatientData> patients, int weeks, int copies, PrintFormat printFormat, OperationData opParam)
        {
            if (patients == null || patients.Count == 0) {
                return;
            }

            if (copies < 1 || copies > 20) {
                return;
            }

            if (opParam != null && patients.Count != 1) {
                return;
            }

            IList<PrintablePage> printablePageA4 = new List<PrintablePage>();
            IList<PrintablePage> printablePageA3 = new List<PrintablePage>();

            PrintableDocument pd = new PrintableDocument();

            Font headlineFont = new Font("Arial", 18.0f, FontStyle.Underline | FontStyle.Bold);
            Font dateFont = new Font("Arial", 10.5f, FontStyle.Bold);
            Font printFont = new Font("Arial", 11, FontStyle.Bold);
            Font medicationFont = new Font("Arial", 10, FontStyle.Bold);
            Font symbolFont = new Font("Arial", 22, FontStyle.Bold);

            float leftMargin = 65;
            float topMargin = 30;

            foreach (PatientData patient in patients) {
                int daysSinceOp = 0;
                OperationData op;
                if (opParam == null) {
                    op = patComp.GetLastOperationByPatientID(patient.Id);
                } else {
                    op = opParam;
                }

                IList<string> medications = new List<string>();
                IList<int> medDays = new List<int>();
                bool hasCatheter = op.KathDays > 0;
                long kathDays = op.KathDays + 1; //CR ignoring OP Day.

                fillMedications(op, medications, medDays);

                //count = 0;

                DateTime opDate = op.Date;
                for (int week = 0; week < weeks; week++) {
                    //PrintablePage pp = new PrintablePage();
                    PrintablePage a4Page = new PrintablePage();
                    PrintablePage a3Page = new PrintablePage();

                    //Organ Images...
                    handleOrganImage(topMargin, op, a4Page, a3Page);

                    addPrintableTextObject(1, a4Page, a3Page, "Paediatric Urology Team Austria", headlineFont, new SolidBrush(Color.FromArgb(0, 61, 120)), leftMargin, topMargin + (float)(0 * 17.56));

                    addPrintableTextObject(1, a4Page, a3Page, "Paediatric Urology Team Austria", headlineFont, new SolidBrush(Color.FromArgb(0, 61, 120)), leftMargin, topMargin + (float)(0 * 17.56));
                    addPrintableTextObject(1, a4Page, a3Page, op.Date.Month.ToString() + " " + op.Date.Year.ToString() + "   Page: " + (week + 1), dateFont, Brushes.Red, leftMargin, topMargin + (float)28.74);

                    addPrintableTextObject(1, a4Page, a3Page, "Additional Information:", printFont, Brushes.Black, leftMargin + (float)610, topMargin + 10F);
                    //pp.AddPrintableObject(new PrintableTextObject("Notes - Final Report:", printFont, Brushes.Black, leftMargin + (float)635, topMargin + 120F));

                    addPrintableLineObject(1, a4Page, a3Page, Pens.Black, (int)leftMargin + 610, (int)topMargin + 27, (int)leftMargin + 635 + 175, (int)topMargin + 27);
                    //pp.AddPrintableObject(new PrintableLineObject(Pens.Black, (int)leftMargin + 635, (int)topMargin + 137, (int)leftMargin + 635 + 200, (int)topMargin + 137));

                    Bitmap imgKinderurologieLogo = SPD.GUI.Properties.Resources.KinderurologieLogo;
                    imgKinderurologieLogo.SetResolution(408, 408);
                    addPrintableImageObject(1, a4Page, a3Page, imgKinderurologieLogo, 500, (int)topMargin);

                    addPrintableRectangleObject(1, a4Page, a3Page, Brushes.Yellow, (int)leftMargin - 5 + 3, (int)topMargin + 198 - (2 * 17), 600, (int)printFont.GetHeight());

                    //Additional Info Rectangle
                    addPrintableRectangleObject(1, a4Page, a3Page, Pens.Black, (int)(leftMargin + 605), (int)topMargin, 300, 220);
                    addPrintableLineObject(1, a4Page, a3Page, Pens.Black, (int)(leftMargin + 605), (int)topMargin + 110, (int)(leftMargin + 605 + 300), (int)topMargin + 110);

                    List<string> addInfo = new List<string>();
                    addInfo.Add(op.Additionalinformation.Replace(Environment.NewLine, " "));
                    addInfo = this.SplitStringsForPrinting(40, addInfo);
                    int count = 0;
                    foreach (string line in addInfo) {
                        addPrintableTextObject(1, a4Page, a3Page, line, printFont, Brushes.Black, leftMargin + (float)610, topMargin + 27F + count * 17);
                        count++;
                    }

                    float y = (float)topMargin + (float)(3 * 17.56) + 9;

                    addPrintableTextObject(1, a4Page, a3Page, "Patient ID: " + patient.Id.ToString(), printFont, Brushes.Black, leftMargin, y);
                    y += 17;
                    addPrintableTextObject(1, a4Page, a3Page, "First name: " + patient.FirstName.Replace(Environment.NewLine, " "), printFont, Brushes.Black, leftMargin, y);
                    y += 17;
                    addPrintableTextObject(1, a4Page, a3Page, "Surname: " + patient.SurName.Replace(Environment.NewLine, " "), printFont, Brushes.Black, leftMargin, y);
                    y += 17;
                    if (patient.DateOfBirth != null && patient.DateOfBirth.Year > 1800) {
                        addPrintableTextObject(1, a4Page, a3Page, "Birthdate: " + patient.DateOfBirth.ToShortDateString() + " - Age: " + StaticUtilities.getAgeFromBirthDate(patient.DateOfBirth), printFont, Brushes.Black, leftMargin, y);
                        y += 17;
                    }
                    addPrintableTextObject(1, a4Page, a3Page, "Resident of Asmara: " + patient.ResidentOfAsmara.ToString(), printFont, Brushes.Black, leftMargin, y);
                    y += 17;
                    addPrintableTextObject(1, a4Page, a3Page, "OP Date: " + op.Date.ToShortDateString(), printFont, Brushes.Black, leftMargin, y);
                    y += 17;
                    addPrintableTextObject(1, a4Page, a3Page, "OP Diagnosis:", printFont, Brushes.Black, leftMargin, y);
                    if (op.Diagnoses.Replace(Environment.NewLine, " ").Length > 60) {
                        List<string> diagnosesList = new List<string>();
                        diagnosesList.Add(op.Diagnoses.Replace(Environment.NewLine, " "));
                        diagnosesList = SplitStringsForPrinting(60, diagnosesList);
                        if (diagnosesList.Count >= 1) {
                            addPrintableTextObject(1, a4Page, a3Page, diagnosesList[0], printFont, Brushes.Black, leftMargin + 110, y);
                        }
                        if (diagnosesList.Count >= 2) {
                            y += 17;
                            addPrintableTextObject(1, a4Page, a3Page, diagnosesList[1], printFont, Brushes.Black, leftMargin + 110, y);
                        }
                    } else {
                        addPrintableTextObject(1, a4Page, a3Page, op.Diagnoses.Replace(Environment.NewLine, " "), printFont, Brushes.Black, leftMargin + 110, y);
                    }
                    y += 17;
                    addPrintableTextObject(1, a4Page, a3Page, "Performed OP: " + op.Performed.Replace(Environment.NewLine, " "), printFont, Brushes.Black, leftMargin, y);
                    y += 17;
                    addPrintableTextObject(1, a4Page, a3Page, "OP Team: " + op.Team.Replace(Environment.NewLine, " "), printFont, Brushes.Black, leftMargin, y);

                    //Gray Box
                    addPrintableRectangleObject(1, a4Page, a3Page, Brushes.LightGray, 40, 270, 6 * 182, 30);
                    //vertical lines
                    for (int j = 0; j < 7; j++) {
                        addPrintableLineObject(1, a4Page, a3Page, Pens.Black, 40 + j * 182, 270, 40 + j * 182, 270 + 7 * 30);
                    }
                    //horizintal lines
                    for (int j = 0; j < 8; j++) {
                        addPrintableLineObject(1, a4Page, a3Page, Pens.Black, 40, 270 + j * 30, 40 + 6 * 182, 270 + j * 30);
                    }

                    ////Beschriftung begin

                    if (kathDays > (week * 12)) {
                        addPrintableTextObject(1, a4Page, a3Page, "catheter", printFont, Brushes.Black, 41, 305 + 5 * 30);
                    }

                    count = 0;
                    foreach (string medication in medications) {
                        if (week == 0) {
                            addPrintableTextObject(1, a4Page, a3Page, medication, medicationFont, Brushes.Black, 41, 305 + count * 30);
                        } else if (medDays[medications.IndexOf(medication)] >= ((week * 12) + 1)) {
                            addPrintableTextObject(1, a4Page, a3Page, medication, medicationFont, Brushes.Black, 41, 305 + count * 30);
                        }
                        for (int j = 0; j < 6; j++) {
                            int currentMedDay = (week * 12 + j) + 1;
                            if ((currentMedDay > 1) && (((currentMedDay - 1) % 6) != 0) && (medDays[count] >= (currentMedDay + 1))) {
                                addPrintableTextObject(1, a4Page, a3Page, "      -", symbolFont, Brushes.Black, 41 + j * 182, (305 + count * 30) - 10);
                            }
                            if ((medDays[count] == currentMedDay)) {
                                addPrintableTextObject(1, a4Page, a3Page, "      -          >", symbolFont, Brushes.Black, 41 + j * 182, (305 + count * 30) - 10);
                            }
                        }
                        count++;
                    }

                    for (int j = 0; j < 6; j++) {
                        int currentMedDay = (week * 12 + j) + 1;
                        if (hasCatheter && (currentMedDay == kathDays)) {
                            if (((kathDays - 1) % 12) == 0) {
                                addPrintableTextObject(1, a4Page, a3Page, "                 DK ex ", printFont, Brushes.Black, 41 + j * 182, 305 + 5 * 30);
                            } else {
                                addPrintableTextObject(1, a4Page, a3Page, "DK ex ", printFont, Brushes.Black, 41 + j * 182, 305 + 5 * 30);
                            }
                        } else if (hasCatheter && (currentMedDay < kathDays) && ((currentMedDay - 1) % 12) != 0) {
                            addPrintableTextObject(1, a4Page, a3Page, "      -", symbolFont, Brushes.Black, 41 + j * 182, 305 + 5 * 30 - 9);
                        }
                    }

                    //Kalendar Überschrift
                    for (int j = 0; j < 6; j++) {
                        addPrintableTextObject(1, a4Page, a3Page, "     " + opDate.DayOfWeek.ToString() + " " + opDate.ToShortDateString(), dateFont, Brushes.Blue, 41 + j * 182, 275);
                        if (daysSinceOp == 0) {
                            addPrintableTextObject(1, a4Page, a3Page, "op", dateFont, Brushes.Red, 41 + j * 182, 275);
                        } else {
                            addPrintableTextObject(1, a4Page, a3Page, daysSinceOp.ToString(), dateFont, Brushes.Red, 41 + j * 182, 275);
                        }
                        opDate = opDate.AddDays(1.0);
                        daysSinceOp++;
                    }

                    //// Beschriftung ende

                    int yNursing = 500;
                    addPrintableTextObject(1, a4Page, a3Page, "Nursing and medical orders:", printFont, Brushes.Black, 41, yNursing);
                    //vertical lines
                    for (int j = 0; j < 7; j++) {
                        addPrintableLineObject(1, a4Page, a3Page, Pens.Black, 40 + j * 182, yNursing + 20, 40 + j * 182, yNursing + 150);
                    }
                    //horizintal lines
                    addPrintableLineObject(1, a4Page, a3Page, Pens.Black, 40, yNursing + 20, 40 + 6 * 182, yNursing + 20);
                    addPrintableLineObject(1, a4Page, a3Page, Pens.Black, 40, yNursing + 150, 40 + 6 * 182, yNursing + 150);

                    int yTemperature = 670;
                    addPrintableTextObject(1, a4Page, a3Page, "Temperature:", printFont, Brushes.Black, 41, yTemperature);
                    //vertical lines
                    for (int j = 0; j < 7; j++) {
                        addPrintableLineObject(1, a4Page, a3Page, Pens.Black, 40 + j * 182, yTemperature + 20, 40 + j * 182, yTemperature + 20 + 1/*=number of lines*/ * 30);
                    }
                    //horizintal lines
                    for (int j = 0; j < 2; j++) {
                        addPrintableLineObject(1, a4Page, a3Page, Pens.Black, 40, yTemperature + 20 + j * 30, 40 + 6 * 182, yTemperature + 20 + j * 30);
                    }

                    //Local status
                    int yLocalStatus = 735;
                    addPrintableTextObject(1, a4Page, a3Page, "Localstatus:", printFont, Brushes.Black, 41, yLocalStatus);
                    //vertical lines
                    for (int j = 0; j < 7; j++) {
                        addPrintableLineObject(1, a4Page, a3Page, Pens.Black, 40 + j * 182, yLocalStatus + 20, 40 + j * 182, yLocalStatus + 20 + 1/*=number of lines*/ * 30);
                    }
                    //horizintal lines
                    for (int j = 0; j < 2; j++) {
                        addPrintableLineObject(1, a4Page, a3Page, Pens.Black, 40, yLocalStatus + 20 + j * 30, 40 + 6 * 182, yLocalStatus + 20 + j * 30);
                    }

                    printablePageA4.Add(a4Page);
                    a4Page = new PrintablePage();

                    a3Page.AddPrintableObject(new PrintableLineObject(Pens.LightGray, 0, A4smallSite + 45, A4LargeSite, A4smallSite + 45));

                    //2. seite

                    addPrintableTextObject(2, a4Page, a3Page, "Patient ID: " + patient.Id.ToString(), printFont, Brushes.Black, leftMargin, 13 + 45);

                    //Gray Box
                    int calendary = (int)topMargin + 45;
                    addPrintableRectangleObject(2, a4Page, a3Page, Brushes.LightGray, 40, calendary, 6 * 182, 30);
                    //vertical lines
                    for (int j = 0; j < 7; j++) {
                        addPrintableLineObject(2, a4Page, a3Page, Pens.Black, 40 + j * 182, calendary, 40 + j * 182, calendary + 7 * 30);
                    }
                    //horizintal lines
                    for (int j = 0; j < 8; j++) {
                        addPrintableLineObject(2, a4Page, a3Page, Pens.Black, 40, calendary + j * 30, 40 + 6 * 182, calendary + j * 30);
                    }

                    ////Beschriftung begin

                    if (kathDays > ((week * 12) + 6)) {
                        addPrintableTextObject(2, a4Page, a3Page, "catheter", printFont, Brushes.Black, 41, calendary + 5 + 6 * 30);
                    }

                    count = 0;
                    foreach (string medication in medications) {
                        if (medDays[medications.IndexOf(medication)] >= ((week * 12) + 7)) {
                            addPrintableTextObject(2, a4Page, a3Page, medication, medicationFont, Brushes.Black, 41, calendary + 5 + 30 + count * 30);
                        }
                        for (int j = 0; j < 6; j++) {
                            int currentMedDay = (week * 12 + j) + 1 + 6;
                            if (((currentMedDay - 1) % 6) != 0 && (medDays[count] >= (currentMedDay + 1))) {
                                addPrintableTextObject(2, a4Page, a3Page, "      -", symbolFont, Brushes.Black, 41 + j * 182, (calendary + 5 + 30 + count * 30) - 10);
                            }
                            if ((medDays[count] == currentMedDay)) {
                                addPrintableTextObject(2, a4Page, a3Page, "      -          >", symbolFont, Brushes.Black, 41 + j * 182, (calendary + 5 + 30 + count * 30) - 10);
                            }
                        }
                        count++;
                    }

                    for (int j = 0; j < 6; j++) {
                        int currentMedDay = (week * 12 + j) + 1 + 6;
                        if (hasCatheter && (currentMedDay == kathDays)) {
                            if (((kathDays - 7) % 12) == 0) {
                                addPrintableTextObject(2, a4Page, a3Page, "                 DK ex ", printFont, Brushes.Black, 41 + j * 182, calendary + 5 + 6 * 30);
                            } else {
                                addPrintableTextObject(2, a4Page, a3Page, "DK ex ", printFont, Brushes.Black, 41 + j * 182, calendary + 5 + 6 * 30);
                            }
                        } else if (hasCatheter && (currentMedDay < kathDays) && ((currentMedDay - 7) % 12) != 0) {
                            addPrintableTextObject(2, a4Page, a3Page, "      -", symbolFont, Brushes.Black, 41 + j * 182, calendary + 5 + 6 * 30 - 9);
                        }
                    }

                    //Kalendar Überschrift
                    for (int j = 0; j < 6; j++) {
                        addPrintableTextObject(2, a4Page, a3Page, "     " + opDate.DayOfWeek.ToString() + " " + opDate.ToShortDateString(), dateFont, Brushes.Blue, 41 + j * 182, calendary + 5);
                        if (daysSinceOp == 0) {
                            addPrintableTextObject(2, a4Page, a3Page, "op", dateFont, Brushes.Red, 41 + j * 182, calendary + 5);
                        } else {
                            addPrintableTextObject(2, a4Page, a3Page, daysSinceOp.ToString(), dateFont, Brushes.Red, 41 + j * 182, calendary + 5);
                        }
                        opDate = opDate.AddDays(1.0);
                        daysSinceOp++;
                    }

                    //// Beschriftung ende

                    yNursing = 295;
                    addPrintableTextObject(2, a4Page, a3Page, "Nursing and medical orders:", printFont, Brushes.Black, 41, yNursing);
                    //vertical lines
                    for (int j = 0; j < 7; j++) {
                        addPrintableLineObject(2, a4Page, a3Page, Pens.Black, 40 + j * 182, yNursing + 20, 40 + j * 182, yNursing + 150);
                    }
                    //horizintal lines
                    addPrintableLineObject(2, a4Page, a3Page, Pens.Black, 40, yNursing + 20, 40 + 6 * 182, yNursing + 20);
                    addPrintableLineObject(2, a4Page, a3Page, Pens.Black, 40, yNursing + 150, 40 + 6 * 182, yNursing + 150);

                    yTemperature = 455;
                    addPrintableTextObject(2, a4Page, a3Page, "Temperature:", printFont, Brushes.Black, 41, yTemperature);
                    //vertical lines
                    for (int j = 0; j < 7; j++) {
                        addPrintableLineObject(2, a4Page, a3Page, Pens.Black, 40 + j * 182, yTemperature + 20, 40 + j * 182, yTemperature + 20 + 1/*=number of lines*/ * 30);
                    }
                    //horizintal lines
                    for (int j = 0; j < 2; j++) {
                        addPrintableLineObject(2, a4Page, a3Page, Pens.Black, 40, yTemperature + 20 + j * 30, 40 + 6 * 182, yTemperature + 20 + j * 30);
                    }

                    //Local Status
                    yLocalStatus = 520;
                    addPrintableTextObject(2, a4Page, a3Page, "Localstatus:", printFont, Brushes.Black, 41, yLocalStatus);
                    //vertical lines
                    for (int j = 0; j < 7; j++) {
                        addPrintableLineObject(2, a4Page, a3Page, Pens.Black, 40 + j * 182, yLocalStatus + 20, 40 + j * 182, yLocalStatus + 20 + 1/*=number of lines*/ * 30);
                    }
                    //horizintal lines
                    for (int j = 0; j < 2; j++) {
                        addPrintableLineObject(2, a4Page, a3Page, Pens.Black, 40, yLocalStatus + 20 + j * 30, 40 + 6 * 182, yLocalStatus + 20 + j * 30);
                    }

                    int y3rdBlock = 580;
                    int widthlastbox = 335;
                    int xft = 41;
                    int xcont = xft + widthlastbox + xft;
                    int xfo = xft + widthlastbox + xft + widthlastbox + xft;

                    addPrintableTextObject(2, a4Page, a3Page, "Further Treatment for discharge:", printFont, Brushes.Black, xft, y3rdBlock);
                    addPrintableTextObject(2, a4Page, a3Page, "Control(s) planned for:", printFont, Brushes.Black, xcont, y3rdBlock);
                    addPrintableTextObject(2, a4Page, a3Page, "Further operation planned for:", printFont, Brushes.Black, xfo, y3rdBlock);

                    //3 oberen Linien der Boxen
                    addPrintableLineObject(2, a4Page, a3Page, Pens.Black, xft, y3rdBlock + 20, xft + widthlastbox, y3rdBlock + 20);
                    addPrintableLineObject(2, a4Page, a3Page, Pens.Black, xft + widthlastbox + xft, y3rdBlock + 20, xft + widthlastbox + xft + widthlastbox, y3rdBlock + 20);
                    addPrintableLineObject(2, a4Page, a3Page, Pens.Black, xft + widthlastbox + xft + widthlastbox + xft, y3rdBlock + 20, xft + widthlastbox + xft + widthlastbox + xft + widthlastbox, y3rdBlock + 20);
                    //3 unteren Linien der Boxen
                    addPrintableLineObject(2, a4Page, a3Page, Pens.Black, xft, y3rdBlock + 177, xft + widthlastbox, y3rdBlock + 177);
                    addPrintableLineObject(2, a4Page, a3Page, Pens.Black, xft + widthlastbox + xft, y3rdBlock + 200, xft + widthlastbox + xft + widthlastbox, y3rdBlock + 200);
                    addPrintableLineObject(2, a4Page, a3Page, Pens.Black, xft + widthlastbox + xft + widthlastbox + xft, y3rdBlock + 200, xft + widthlastbox + xft + widthlastbox + xft + widthlastbox, y3rdBlock + 200);

                    //vertikale Linien der Boxen
                    addPrintableLineObject(2, a4Page, a3Page, Pens.Black, xft, y3rdBlock + 20, xft, y3rdBlock + 177);
                    addPrintableLineObject(2, a4Page, a3Page, Pens.Black, xft + widthlastbox, y3rdBlock + 20, xft + widthlastbox, y3rdBlock + 177);
                    addPrintableLineObject(2, a4Page, a3Page, Pens.Black, xft + widthlastbox + xft, y3rdBlock + 20, xft + widthlastbox + xft, y3rdBlock + 200);
                    addPrintableLineObject(2, a4Page, a3Page, Pens.Black, xft + widthlastbox + xft + widthlastbox, y3rdBlock + 20, xft + widthlastbox + xft + widthlastbox, y3rdBlock + 200);
                    addPrintableLineObject(2, a4Page, a3Page, Pens.Black, xft + widthlastbox + xft + widthlastbox + xft, y3rdBlock + 20, xft + widthlastbox + xft + widthlastbox + xft, y3rdBlock + 200);
                    addPrintableLineObject(2, a4Page, a3Page, Pens.Black, xft + widthlastbox + xft + widthlastbox + xft + widthlastbox, y3rdBlock + 20, xft + widthlastbox + xft + widthlastbox + xft + widthlastbox, y3rdBlock + 200);

                    addPrintableTextObject(2, a4Page, a3Page, "Treatment completed: yes        no", printFont, Brushes.Black, xft, y3rdBlock + 180);
                    addPrintableRectangleObject(2, a4Page, a3Page, Pens.Black, xft + 195, y3rdBlock + 180, 20, 20);
                    addPrintableRectangleObject(2, a4Page, a3Page, Pens.Black, xft + 246, y3rdBlock + 180, 20, 20);

                    printablePageA4.Add(a4Page);
                    printablePageA3.Add(a3Page);
                }
            }

            pd.PrintPageList = printablePageA3;
            pd.duplicate(copies);
            pd.Landscape = false;
            pd.DocumentName = "SPD Temperature Curve A3";

            PrintDialog printDialog = null;

            if (printFormat == PrintFormat.A3) {
                pd.PaperKindOrNothing = PaperKind.A3;

                printDialog = pd.DoPrint();

                if (printDialog != null) {
                    pd.PaperKindOrNothing = PaperKind.A4;
                    pd.Landscape = true;
                    pd.PrintPageList = printablePageA4;
                    pd.duplicate(copies);
                    printDialog = pd.DoPrint(printDialog);
                }

            } else if (printFormat == PrintFormat.A4) {
                pd.PaperKindOrNothing = PaperKind.A4;

                printDialog = pd.DoPrint();
            }

            if (printDialog != null) {
                MessageBox.Show("Sorry - printing not possible!");
            }
        }
Example #52
0
        public void imprimir(object sender, PrintPageEventArgs ev)
        {
            //Confegurações de Página
            float linhasPorPagina = 0;
            float posicaoVertical = 0;
            float contador = 0;
            float margemSuperior = 20;
            float margenEsquerda = 20;
            float margemDireita = 20;
            float alturaFonte = 0;
            string linha = "";
            System.Drawing.Font fonte = new System.Drawing.Font("Arial", 10);
            alturaFonte = fonte.GetHeight(ev.Graphics);
            linhasPorPagina = ev.MarginBounds.Height / alturaFonte;

            linha = "--------------------------------------------------------------------------------------------------------------------------------------------------------------------";
            posicaoVertical = margemSuperior + contador * alturaFonte;
            ev.Graphics.DrawString(linha, fonte, Brushes.Black, margenEsquerda, posicaoVertical);
            contador++;

            linha = "\t\t\t\t\t   INFORMAÇÕES DO PROCESSO";
            posicaoVertical = margemSuperior + contador * alturaFonte;
            ev.Graphics.DrawString(linha, fonte, Brushes.Black, margenEsquerda, posicaoVertical);
            contador++;

            linha = "--------------------------------------------------------------------------------------------------------------------------------------------------------------------";
            posicaoVertical = margemSuperior + contador * alturaFonte;
            ev.Graphics.DrawString(linha, fonte, Brushes.Black, margenEsquerda, posicaoVertical);
            contador++;

            linha = "Número: "+processo.Numero;
            posicaoVertical = margemSuperior + contador * alturaFonte;
            ev.Graphics.DrawString(linha, fonte, Brushes.Black, margenEsquerda, posicaoVertical);
            contador += 2;

            linha = "Comarca: " + processo.NomeComarca;
            posicaoVertical = margemSuperior + contador * alturaFonte;
            ev.Graphics.DrawString(linha, fonte, Brushes.Black, margenEsquerda, posicaoVertical);
            contador += 2;

            linha = "Cliente: " + clienteByProcesso.Nome;
            posicaoVertical = margemSuperior + contador * alturaFonte;
            ev.Graphics.DrawString(linha, fonte, Brushes.Black, margenEsquerda, posicaoVertical);
            contador += 2;

            linha = "Telefone: "+clienteByProcesso.Telefone;
            posicaoVertical = margemSuperior + contador * alturaFonte;
            ev.Graphics.DrawString(linha, fonte, Brushes.Black, margenEsquerda, posicaoVertical);
            contador++;

            linha = "--------------------------------------------------------------------------------------------------------------------------------------------------------------------";
            posicaoVertical = margemSuperior + contador * alturaFonte;
            ev.Graphics.DrawString(linha, fonte, Brushes.Black, margenEsquerda, posicaoVertical);
            contador++;

            linha = "\t\t\t\t\t  MOVIMENTAÇÕES DO PROCESSO";
            posicaoVertical = margemSuperior + contador * alturaFonte;
            ev.Graphics.DrawString(linha, fonte, Brushes.Black, margenEsquerda, posicaoVertical);
            contador++;

            linha = "--------------------------------------------------------------------------------------------------------------------------------------------------------------------";
            posicaoVertical = margemSuperior + contador * alturaFonte;
            ev.Graphics.DrawString(linha, fonte, Brushes.Black, margenEsquerda, posicaoVertical);
            contador++;
            foreach (var movimentacao in movimentoacoesByProcesso)
            {

                linha = "Data: "+ movimentacao.Data.ToShortDateString()+"\t\t\t\tSituação: "+ movimentacao.SituacaoAndamentoProcessual;
                posicaoVertical = margemSuperior + contador * alturaFonte;
                ev.Graphics.DrawString(linha, fonte, Brushes.Black, margenEsquerda, posicaoVertical);
                contador++;

                linha = "Oberservação: "+ movimentacao.Observacao;
                posicaoVertical = margemSuperior + contador * alturaFonte;
                ev.Graphics.DrawString(linha, fonte, Brushes.Black, margenEsquerda, posicaoVertical);
                contador+=2;
            }
            contador--;
            linha = "--------------------------------------------------------------------------------------------------------------------------------------------------------------------";
            posicaoVertical = margemSuperior + contador * alturaFonte;
            ev.Graphics.DrawString(linha, fonte, Brushes.Black, margenEsquerda, posicaoVertical);
            contador++;
        }
Example #53
0
        protected override void OnPaint(PaintEventArgs e)
        {
            Graphics g        = e.Graphics;
            Color    colorIni = Color.Red;
            Color    colorFin = Color.Green;

            float v;

            /*
             * if (!this.Enabled) // || v < 1.0f)
             * {
             *  colorIni = Color.DarkGray;
             *  colorFin = Color.LightGray;
             *  //colorIni = toGrayScale(colorIni);
             *  //colorFin = toGrayScale(colorFin);
             * }
             */
            if (this.Enabled)
            {
                if (_autoCalculate)
                {
                    _value = (_volts - _volts_min) / (_volts_max - _volts_min);
                }

                v = _value;
            }
            else
            {
                colorIni = Color.DarkGray;
                colorFin = Color.LightGray;

                v = 1.0f;
            }


            int h  = this.Height - 6;
            int w  = this.Width - 2;
            int tw = h * 3 / 4;

            int ntx = w / (tw + 2);

            int lx = (int)(w * v + 1);
            LinearGradientBrush grad = new LinearGradientBrush(new Rectangle(1, 1, w, h), colorIni, colorFin, LinearGradientMode.Horizontal);
            Font f = new System.Drawing.Font("sans-serif", 3 * h / 4);


            if (_striped)
            {
                for (int i = 1; i < lx; i += tw + 2)
                {
                    g.FillRectangle(grad, i, 1, Math.Min(tw, lx - i), h);
                }
            }
            else
            {
                g.FillRectangle(grad, 1, 1, lx - 1, h);
            }

            if (this.Enabled)
            {
                string s = _volts.ToString("#0.0v");

                g.DrawString(s, f, new SolidBrush(this.ForeColor),
                             (w - g.MeasureString(s, f).Width) / 2, (h - f.GetHeight()) / 2);
            }
        }
Example #54
0
        ///<summary>Supply pd so that we know the paper size and margins.</summary>
        public static void CreateDocument(FormRpStatement sender, MigraDoc.DocumentObjectModel.Document doc, PrintDocument pd, Family fam, Patient pat, DataSet dataSet, Statement Stmt)
        {
            //doc= new MigraDoc.DocumentObjectModel.Document();//don't do this or the reference to the original doc will be lost.
            doc.DefaultPageSetup.PageWidth    = Unit.FromInch((double)pd.DefaultPageSettings.PaperSize.Width / 100);
            doc.DefaultPageSetup.PageHeight   = Unit.FromInch((double)pd.DefaultPageSettings.PaperSize.Height / 100);
            doc.DefaultPageSetup.TopMargin    = Unit.FromInch((double)pd.DefaultPageSettings.Margins.Top / 100);
            doc.DefaultPageSetup.LeftMargin   = Unit.FromInch((double)pd.DefaultPageSettings.Margins.Left / 100);
            doc.DefaultPageSetup.RightMargin  = Unit.FromInch((double)pd.DefaultPageSettings.Margins.Right / 100);
            doc.DefaultPageSetup.BottomMargin = Unit.FromInch((double)pd.DefaultPageSettings.Margins.Bottom / 100);
            MigraDoc.DocumentObjectModel.Section section = doc.AddSection();          //so that Swiss will have different footer for each patient.
            string text;

            MigraDoc.DocumentObjectModel.Font font;
            //GetPatGuar(PatNums[famIndex][0]);
            //Family fam=Patients.GetFamily(Stmt.PatNum);
            Patient PatGuar = fam.ListPats[0];          //.Copy();
            //Patient pat=fam.GetPatient(Stmt.PatNum);
            DataTable tableMisc = dataSet.Tables["misc"];

            //HEADING------------------------------------------------------------------------------
            #region Heading
            Paragraph       par       = section.AddParagraph();
            ParagraphFormat parformat = new ParagraphFormat();
            parformat.Alignment = ParagraphAlignment.Center;
            par.Format          = parformat;
            font = MigraDocHelper.CreateFont(14, true);
            text = "This statement was generated from the plug-in";
            par.AddFormattedText(text, font);
            text = DateTime.Today.ToShortDateString();
            font = MigraDocHelper.CreateFont(10);
            par.AddLineBreak();
            par.AddFormattedText(text, font);
            text = Lan.g("FormRpStatement", "Account Number") + " ";
            if (PrefC.GetBool(PrefName.StatementAccountsUseChartNumber))
            {
                text += PatGuar.ChartNumber;
            }
            else
            {
                text += PatGuar.PatNum;
            }
            par.AddLineBreak();
            par.AddFormattedText(text, font);
            TextFrame frame;
            #endregion
            //Practice Address----------------------------------------------------------------------
            #region Practice Address
            if (PrefC.GetBool(PrefName.StatementShowReturnAddress))
            {
                font  = MigraDocHelper.CreateFont(10);
                frame = section.AddTextFrame();
                frame.RelativeVertical   = RelativeVertical.Page;
                frame.RelativeHorizontal = RelativeHorizontal.Page;
                frame.MarginLeft         = Unit.Zero;
                frame.MarginTop          = Unit.Zero;
                frame.Top   = TopPosition.Parse("0.5 in");
                frame.Left  = LeftPosition.Parse("0.3 in");
                frame.Width = Unit.FromInch(3);
                if (!PrefC.GetBool(PrefName.EasyNoClinics) && Clinics.List.Length > 0 &&           //if using clinics
                    Clinics.GetClinic(PatGuar.ClinicNum) != null)                             //and this patient assigned to a clinic
                {
                    Clinic clinic = Clinics.GetClinic(PatGuar.ClinicNum);
                    par             = frame.AddParagraph();
                    par.Format.Font = font;
                    par.AddText(clinic.Description);
                    par.AddLineBreak();
                    par.AddText(clinic.Address);
                    par.AddLineBreak();
                    if (clinic.Address2 != "")
                    {
                        par.AddText(clinic.Address2);
                        par.AddLineBreak();
                    }
                    if (CultureInfo.CurrentCulture.Name.EndsWith("CH"))                     //CH is for switzerland. eg de-CH
                    {
                        par.AddText(clinic.Zip + " " + clinic.City);
                    }
                    else
                    {
                        par.AddText(clinic.City + ", " + clinic.State + " " + clinic.Zip);
                    }
                    par.AddLineBreak();
                    text = clinic.Phone;
                    if (text.Length == 10)
                    {
                        text = "(" + text.Substring(0, 3) + ")" + text.Substring(3, 3) + "-" + text.Substring(6);
                    }
                    par.AddText(text);
                    par.AddLineBreak();
                }
                else
                {
                    par             = frame.AddParagraph();
                    par.Format.Font = font;
                    par.AddText(PrefC.GetString(PrefName.PracticeTitle));
                    par.AddLineBreak();
                    if (CultureInfo.CurrentCulture.Name == "en-AU")                   //English (Australia)
                    {
                        Provider defaultProv = Providers.GetProv(PrefC.GetLong(PrefName.PracticeDefaultProv));
                        par.AddText("ABN: " + defaultProv.NationalProvID);
                        par.AddLineBreak();
                    }
                    par.AddText(PrefC.GetString(PrefName.PracticeAddress));
                    par.AddLineBreak();
                    if (PrefC.GetString(PrefName.PracticeAddress2) != "")
                    {
                        par.AddText(PrefC.GetString(PrefName.PracticeAddress2));
                        par.AddLineBreak();
                    }
                    if (CultureInfo.CurrentCulture.Name.EndsWith("CH"))                     //CH is for switzerland. eg de-CH
                    {
                        par.AddText(PrefC.GetString(PrefName.PracticeZip) + " " + PrefC.GetString(PrefName.PracticeCity));
                    }
                    else
                    {
                        par.AddText(PrefC.GetString(PrefName.PracticeCity) + ", " + PrefC.GetString(PrefName.PracticeST) + " " + PrefC.GetString(PrefName.PracticeZip));
                    }
                    par.AddLineBreak();
                    text = PrefC.GetString(PrefName.PracticePhone);
                    if (text.Length == 10)
                    {
                        text = "(" + text.Substring(0, 3) + ")" + text.Substring(3, 3) + "-" + text.Substring(6);
                    }
                    par.AddText(text);
                    par.AddLineBreak();
                }
            }
            #endregion
            //AMOUNT ENCLOSED------------------------------------------------------------------------------------------------------
            #region Amount Enclosed
            Table  table;
            Column col;
            Row    row;
            Cell   cell;
            frame = MigraDocHelper.CreateContainer(section, 450, 110, 330, 29);
            if (!Stmt.HidePayment)
            {
                table = MigraDocHelper.DrawTable(frame, 0, 0, 29);
                col   = table.AddColumn(Unit.FromInch(1.1));
                col   = table.AddColumn(Unit.FromInch(1.1));
                col   = table.AddColumn(Unit.FromInch(1.1));
                row   = table.AddRow();
                row.Format.Alignment = ParagraphAlignment.Center;
                row.Borders.Color    = Colors.Black;
                row.Shading.Color    = Colors.LightGray;
                row.TopPadding       = Unit.FromInch(0);
                row.BottomPadding    = Unit.FromInch(0);
                font = MigraDocHelper.CreateFont(8, true);
                cell = row.Cells[0];
                par  = cell.AddParagraph();
                par.AddFormattedText(Lan.g("FormRpStatement", "Amount Due"), font);
                cell = row.Cells[1];
                par  = cell.AddParagraph();
                par.AddFormattedText(Lan.g("FormRpStatement", "Date Due"), font);
                cell = row.Cells[2];
                par  = cell.AddParagraph();
                par.AddFormattedText(Lan.g("FormRpStatement", "Amount Enclosed"), font);
                row = table.AddRow();
                row.Format.Alignment     = ParagraphAlignment.Center;
                row.Borders.Left.Color   = Colors.Gray;
                row.Borders.Bottom.Color = Colors.Gray;
                row.Borders.Right.Color  = Colors.Gray;
                font = MigraDocHelper.CreateFont(9);
                double balTotal = PatGuar.BalTotal;
                if (!PrefC.GetBool(PrefName.BalancesDontSubtractIns))                 //this is typical
                {
                    balTotal -= PatGuar.InsEst;
                }
                for (int m = 0; m < tableMisc.Rows.Count; m++)
                {
                    if (tableMisc.Rows[m]["descript"].ToString() == "payPlanDue")
                    {
                        balTotal += PIn.Double(tableMisc.Rows[m]["value"].ToString());
                        //payPlanDue;//PatGuar.PayPlanDue;
                    }
                }
                text = balTotal.ToString("F");
                cell = row.Cells[0];
                par  = cell.AddParagraph();
                par.AddFormattedText(text, font);
                if (PrefC.GetLong(PrefName.StatementsCalcDueDate) == -1)
                {
                    text = Lan.g("FormRpStatement", "Upon Receipt");
                }
                else
                {
                    text = DateTime.Today.AddDays(PrefC.GetLong(PrefName.StatementsCalcDueDate)).ToShortDateString();
                }
                cell = row.Cells[1];
                par  = cell.AddParagraph();
                par.AddFormattedText(text, font);
            }
            #endregion
            //Credit Card Info--------------------------------------------------------------------------------------------------------
            #region Credit Card Info
            if (!Stmt.HidePayment)
            {
                if (PrefC.GetBool(PrefName.StatementShowCreditCard))
                {
                    float yPos = 60;
                    font = MigraDocHelper.CreateFont(7, true);
                    text = Lan.g("FormRpStatement", "CREDIT CARD TYPE");
                    MigraDocHelper.DrawString(frame, text, font, 0, yPos);
                    float rowHeight            = 26;
                    System.Drawing.Font  wfont = new System.Drawing.Font("Arial", 7, FontStyle.Bold);
                    System.Drawing.Image img   = new Bitmap(500, 30);
                    Graphics             g     = Graphics.FromImage(img);  //just to measure strings
                    MigraDocHelper.DrawLine(frame, System.Drawing.Color.Black, g.MeasureString(text, wfont).Width,
                                            yPos + wfont.GetHeight(g), 326, yPos + wfont.GetHeight(g));
                    yPos += rowHeight;
                    text  = Lan.g("FormRpStatement", "#");
                    MigraDocHelper.DrawString(frame, text, font, 0, yPos);
                    MigraDocHelper.DrawLine(frame, System.Drawing.Color.Black, g.MeasureString(text, wfont).Width,
                                            yPos + wfont.GetHeight(g), 326, yPos + wfont.GetHeight(g));
                    yPos += rowHeight;
                    text  = Lan.g("FormRpStatement", "3 DIGIT CSV");
                    MigraDocHelper.DrawString(frame, text, font, 0, yPos);
                    MigraDocHelper.DrawLine(frame, System.Drawing.Color.Black, g.MeasureString(text, wfont).Width,
                                            yPos + wfont.GetHeight(g), 326, yPos + wfont.GetHeight(g));
                    yPos += rowHeight;
                    text  = Lan.g("FormRpStatement", "EXPIRES");
                    MigraDocHelper.DrawString(frame, text, font, 0, yPos);
                    MigraDocHelper.DrawLine(frame, System.Drawing.Color.Black, g.MeasureString(text, wfont).Width,
                                            yPos + wfont.GetHeight(g), 326, yPos + wfont.GetHeight(g));
                    yPos += rowHeight;
                    text  = Lan.g("FormRpStatement", "AMOUNT APPROVED");
                    MigraDocHelper.DrawString(frame, text, font, 0, yPos);
                    MigraDocHelper.DrawLine(frame, System.Drawing.Color.Black, g.MeasureString(text, wfont).Width,
                                            yPos + wfont.GetHeight(g), 326, yPos + wfont.GetHeight(g));
                    yPos += rowHeight;
                    text  = Lan.g("FormRpStatement", "NAME");
                    MigraDocHelper.DrawString(frame, text, font, 0, yPos);
                    MigraDocHelper.DrawLine(frame, System.Drawing.Color.Black, g.MeasureString(text, wfont).Width,
                                            yPos + wfont.GetHeight(g), 326, yPos + wfont.GetHeight(g));
                    yPos += rowHeight;
                    text  = Lan.g("FormRpStatement", "SIGNATURE");
                    MigraDocHelper.DrawString(frame, text, font, 0, yPos);
                    MigraDocHelper.DrawLine(frame, System.Drawing.Color.Black, g.MeasureString(text, wfont).Width,
                                            yPos + wfont.GetHeight(g), 326, yPos + wfont.GetHeight(g));
                    yPos -= rowHeight;
                    text  = Lan.g("FormRpStatement", "(As it appears on card)");
                    wfont = new System.Drawing.Font("Arial", 5);
                    font  = MigraDocHelper.CreateFont(5);
                    MigraDocHelper.DrawString(frame, text, font, 625 - g.MeasureString(text, wfont).Width / 2 + 5, yPos + 13);
                    g.Dispose();
                    img = null;
                }
            }
            #endregion
            //Patient's Billing Address---------------------------------------------------------------------------------------------
            #region Patient Billing Address
            font            = MigraDocHelper.CreateFont(11);
            frame           = MigraDocHelper.CreateContainer(section, 62.5f + 12.5f, 225 + 1, 300, 200);
            par             = frame.AddParagraph();
            par.Format.Font = font;
            if (Stmt.SinglePatient)
            {
                par.AddText(fam.GetNameInFamFL(Stmt.PatNum));
            }
            else
            {
                par.AddText(PatGuar.GetNameFLFormal());
            }
            par.AddLineBreak();
            par.AddText(PatGuar.Address);
            par.AddLineBreak();
            if (PatGuar.Address2 != "")
            {
                par.AddText(PatGuar.Address2);
                par.AddLineBreak();
            }
            if (CultureInfo.CurrentCulture.Name.EndsWith("CH"))             //CH is for switzerland. eg de-CH
            {
                par.AddText(PatGuar.Zip + " " + PatGuar.City);
            }
            else
            {
                par.AddText(PatGuar.City + ", " + PatGuar.State + " " + PatGuar.Zip);
            }
            //perforated line------------------------------------------------------------------------------------------------------
            //yPos=350;//3.62 inches from top, 1/3 page down
            frame = MigraDocHelper.CreateContainer(section, 0, 350, 850, 30);
            if (!Stmt.HidePayment)
            {
                MigraDocHelper.DrawLine(frame, System.Drawing.Color.LightGray, 0, 0, 850, 0);
                text = Lan.g("FormRpStatement", "PLEASE DETACH AND RETURN THE UPPER PORTION WITH YOUR PAYMENT");
                font = MigraDocHelper.CreateFont(6, true, System.Drawing.Color.Gray);
                par  = frame.AddParagraph();
                par.Format.Alignment = ParagraphAlignment.Center;
                par.Format.Font      = font;
                par.AddText(text);
            }
            #endregion
            //Australian Provider Legend
            #region Australian Provider Legend
            int legendOffset = 0;
            if (CultureInfo.CurrentCulture.Name == "en-AU")           //English (Australia)
            {
                Providers.RefreshCache();
                legendOffset = 25 + 15 * (1 + ProviderC.List.Length);
                MigraDocHelper.InsertSpacer(section, legendOffset);
                frame           = MigraDocHelper.CreateContainer(section, 45, 390, 250, legendOffset);
                par             = frame.AddParagraph();
                par.Format.Font = MigraDocHelper.CreateFont(8, true);
                par.AddLineBreak();
                par.AddText("PROVIDERS:");
                par             = frame.AddParagraph();
                par.Format.Font = MigraDocHelper.CreateFont(8, false);
                for (int i = 0; i < ProviderC.List.Length; i++)           //All non-hidden providers are added to the legend.
                {
                    Provider prov   = ProviderC.List[i];
                    string   suffix = "";
                    if (prov.Suffix.Trim() != "")
                    {
                        suffix = ", " + prov.Suffix.Trim();
                    }
                    par.AddText(prov.Abbr + " - " + prov.FName + " " + prov.LName + suffix + " - " + prov.MedicaidID);
                    par.AddLineBreak();
                }
                par.AddLineBreak();
            }
            #endregion
            //Aging-----------------------------------------------------------------------------------
            #region Aging
            MigraDocHelper.InsertSpacer(section, 275);
            frame = MigraDocHelper.CreateContainer(section, 55, 390 + legendOffset, 250, 29);
            if (!Stmt.HidePayment)
            {
                table = MigraDocHelper.DrawTable(frame, 0, 0, 29);
                col   = table.AddColumn(Unit.FromInch(1.1));
                col   = table.AddColumn(Unit.FromInch(1.1));
                col   = table.AddColumn(Unit.FromInch(1.1));
                col   = table.AddColumn(Unit.FromInch(1.1));
                row   = table.AddRow();
                row.Format.Alignment = ParagraphAlignment.Center;
                row.Borders.Color    = Colors.Black;
                row.Shading.Color    = Colors.LightGray;
                row.TopPadding       = Unit.FromInch(0);
                row.BottomPadding    = Unit.FromInch(0);
                font = MigraDocHelper.CreateFont(8, true);
                cell = row.Cells[0];
                par  = cell.AddParagraph();
                par.AddFormattedText(Lan.g("FormRpStatement", "0-30"), font);
                cell = row.Cells[1];
                par  = cell.AddParagraph();
                par.AddFormattedText(Lan.g("FormRpStatement", "31-60"), font);
                cell = row.Cells[2];
                par  = cell.AddParagraph();
                par.AddFormattedText(Lan.g("FormRpStatement", "61-90"), font);
                cell = row.Cells[3];
                par  = cell.AddParagraph();
                par.AddFormattedText(Lan.g("FormRpStatement", "over 90"), font);
                row = table.AddRow();
                row.Format.Alignment     = ParagraphAlignment.Center;
                row.Borders.Left.Color   = Colors.Gray;
                row.Borders.Bottom.Color = Colors.Gray;
                row.Borders.Right.Color  = Colors.Gray;
                font = MigraDocHelper.CreateFont(9);
                text = PatGuar.Bal_0_30.ToString("F");
                cell = row.Cells[0];
                par  = cell.AddParagraph();
                par.AddFormattedText(text, font);
                text = PatGuar.Bal_31_60.ToString("F");
                cell = row.Cells[1];
                par  = cell.AddParagraph();
                par.AddFormattedText(text, font);
                text = PatGuar.Bal_61_90.ToString("F");
                cell = row.Cells[2];
                par  = cell.AddParagraph();
                par.AddFormattedText(text, font);
                text = PatGuar.BalOver90.ToString("F");
                cell = row.Cells[3];
                par  = cell.AddParagraph();
                par.AddFormattedText(text, font);
            }
            #endregion
            //Floating Balance, Ins info-------------------------------------------------------------------
            #region FloatingBalance
            frame = MigraDocHelper.CreateContainer(section, 460, 380 + legendOffset, 250, 200);
            //table=MigraDocHelper.DrawTable(frame,0,0,90);
            par                 = frame.AddParagraph();
            parformat           = new ParagraphFormat();
            parformat.Alignment = ParagraphAlignment.Right;
            par.Format          = parformat;
            font                = MigraDocHelper.CreateFont(10, false);
            MigraDoc.DocumentObjectModel.Font fontBold = MigraDocHelper.CreateFont(10, true);
            if (PrefC.GetBool(PrefName.BalancesDontSubtractIns))
            {
                text = Lan.g("FormRpStatement", "Balance:");
                par.AddFormattedText(text, fontBold);
                //par.AddLineBreak();
                //text = Lan.g(this, "Ins Pending:");
                //par.AddFormattedText(text, font);
                //par.AddLineBreak();
                //text = Lan.g(this, "After Ins:");
                //par.AddFormattedText(text, font);
                //par.AddLineBreak();
            }
            else              //this is more common
            {
                if (PrefC.GetBool(PrefName.FuchsOptionsOn))
                {
                    text = Lan.g("FormRpStatement", "Balance:");
                    par.AddFormattedText(text, font);
                    par.AddLineBreak();
                    text = Lan.g("FormRpStatement", "-Ins Estimate:");
                    par.AddFormattedText(text, font);
                    par.AddLineBreak();
                    text = Lan.g("FormRpStatement", "=Owed Now:");
                    par.AddFormattedText(text, fontBold);
                    par.AddLineBreak();
                }
                else
                {
                    text = Lan.g("FormRpStatement", "Total:");
                    par.AddFormattedText(text, font);
                    par.AddLineBreak();
                    text = Lan.g("FormRpStatement", "-Ins Estimate:");
                    par.AddFormattedText(text, font);
                    par.AddLineBreak();
                    text = Lan.g("FormRpStatement", "=Balance:");
                    par.AddFormattedText(text, fontBold);
                    par.AddLineBreak();
                }
            }
            frame = MigraDocHelper.CreateContainer(section, 730, 380 + legendOffset, 100, 200);
            //table=MigraDocHelper.DrawTable(frame,0,0,90);
            par                 = frame.AddParagraph();
            parformat           = new ParagraphFormat();
            parformat.Alignment = ParagraphAlignment.Left;
            par.Format          = parformat;
            font                = MigraDocHelper.CreateFont(10, false);
            //numbers:
            if (PrefC.GetBool(PrefName.BalancesDontSubtractIns))
            {
                text = PatGuar.BalTotal.ToString("c");
                par.AddFormattedText(text, fontBold);
                //par.AddLineBreak();
                //text = PatGuar.InsEst.ToString("c");
                //par.AddFormattedText(text, font);
                //par.AddLineBreak();
                //text = (PatGuar.BalTotal - PatGuar.InsEst).ToString("c");
                //par.AddFormattedText(text, font);
                //par.AddLineBreak();
            }
            else              //more common
            {
                if (Stmt.SinglePatient)
                {
                    double patInsEst = 0;
                    for (int m = 0; m < tableMisc.Rows.Count; m++)
                    {
                        if (tableMisc.Rows[m]["descript"].ToString() == "patInsEst")
                        {
                            patInsEst = PIn.Double(tableMisc.Rows[m]["value"].ToString());
                        }
                    }
                    double patBal = pat.EstBalance - patInsEst;
                    text = pat.EstBalance.ToString("c");
                    par.AddFormattedText(text, font);
                    par.AddLineBreak();
                    text = patInsEst.ToString("c");
                    par.AddFormattedText(text, font);
                    par.AddLineBreak();
                    text = patBal.ToString("c");
                    par.AddFormattedText(text, fontBold);
                }
                else
                {
                    text = PatGuar.BalTotal.ToString("c");
                    par.AddFormattedText(text, font);
                    par.AddLineBreak();
                    text = PatGuar.InsEst.ToString("c");
                    par.AddFormattedText(text, font);
                    par.AddLineBreak();
                    text = (PatGuar.BalTotal - PatGuar.InsEst).ToString("c");
                    par.AddFormattedText(text, fontBold);
                    par.AddLineBreak();
                }
            }
            MigraDocHelper.InsertSpacer(section, 80);
            #endregion FloatingBalance
            //Bold note-------------------------------------------------------------------------------
            #region Bold note
            if (Stmt.NoteBold != "")
            {
                MigraDocHelper.InsertSpacer(section, 7);
                font            = MigraDocHelper.CreateFont(10, true, System.Drawing.Color.DarkRed);
                par             = section.AddParagraph();
                par.Format.Font = font;
                par.AddText(Stmt.NoteBold);
                MigraDocHelper.InsertSpacer(section, 8);
            }
            #endregion Bold note
            //Payment plan grid definition---------------------------------------------------------------------------------
            #region PayPlan grid definition
            ODGridColumn gcol;
            ODGridRow    grow;
            ODGrid       gridPP = new ODGrid();
            //this.Controls.Add(gridPP);
            gridPP.BeginUpdate();
            gridPP.Columns.Clear();
            gcol = new ODGridColumn(Lan.g("FormRpStatement", "Date"), 73);
            gridPP.Columns.Add(gcol);
            gcol = new ODGridColumn(Lan.g("FormRpStatement", "Description"), 270);
            gridPP.Columns.Add(gcol);
            gcol = new ODGridColumn(Lan.g("FormRpStatement", "Charges"), 60, HorizontalAlignment.Right);
            gridPP.Columns.Add(gcol);
            gcol = new ODGridColumn(Lan.g("FormRpStatement", "Credits"), 60, HorizontalAlignment.Right);
            gridPP.Columns.Add(gcol);
            gcol = new ODGridColumn(Lan.g("FormRpStatement", "Balance"), 60, HorizontalAlignment.Right);
            gridPP.Columns.Add(gcol);
            gridPP.Width = gridPP.WidthAllColumns + 20;
            gridPP.EndUpdate();
            #endregion PayPlan grid definition
            //Payment plan grid.  There will be only one, if any-----------------------------------------------------------------
            #region PayPlan grid
            DataTable  tablePP = dataSet.Tables["payplan"];
            ODGridCell gcell;
            if (tablePP.Rows.Count > 0)
            {
                //MigraDocHelper.InsertSpacer(section,5);
                par                  = section.AddParagraph();
                par.Format.Font      = MigraDocHelper.CreateFont(10, true);
                par.Format.Alignment = ParagraphAlignment.Center;
                //par.Format.SpaceBefore=Unit.FromInch(.05);
                //par.Format.SpaceAfter=Unit.FromInch(.05);
                par.AddText(Lan.g("FormRpStatement", "Payment Plans"));
                MigraDocHelper.InsertSpacer(section, 2);
                gridPP.BeginUpdate();
                gridPP.Rows.Clear();
                for (int p = 0; p < tablePP.Rows.Count; p++)
                {
                    grow = new ODGridRow();
                    grow.Cells.Add(tablePP.Rows[p]["date"].ToString());
                    grow.Cells.Add(tablePP.Rows[p]["description"].ToString());
                    grow.Cells.Add(tablePP.Rows[p]["charges"].ToString());
                    grow.Cells.Add(tablePP.Rows[p]["credits"].ToString());
                    gcell = new ODGridCell(tablePP.Rows[p]["balance"].ToString());
                    if (p == tablePP.Rows.Count - 1)
                    {
                        gcell.Bold = YN.Yes;
                    }
                    else if (tablePP.Rows[p + 1]["balance"].ToString() == "")                 //if next row balance is blank.
                    {
                        gcell.Bold = YN.Yes;
                    }
                    grow.Cells.Add(gcell);
                    gridPP.Rows.Add(grow);
                }
                gridPP.EndUpdate();
                MigraDocHelper.DrawGrid(section, gridPP);
                MigraDocHelper.InsertSpacer(section, 2);
                par                    = section.AddParagraph();
                par.Format.Font        = MigraDocHelper.CreateFont(10, true);
                par.Format.Alignment   = ParagraphAlignment.Right;
                par.Format.RightIndent = Unit.FromInch(0.25);
                double payPlanDue = 0;
                for (int m = 0; m < tableMisc.Rows.Count; m++)
                {
                    if (tableMisc.Rows[m]["descript"].ToString() == "payPlanDue")
                    {
                        payPlanDue = PIn.Double(tableMisc.Rows[m]["value"].ToString());
                    }
                }
                par.AddText(Lan.g("FormRpStatement", "Payment Plan Amount Due: ") + payPlanDue.ToString("c"));             //PatGuar.PayPlanDue.ToString("c"));
                MigraDocHelper.InsertSpacer(section, 10);
            }
            #endregion PayPlan grid
            //Body Table definition--------------------------------------------------------------------------------------------------------
            #region Body Table definition
            ODGrid gridPat = new ODGrid();
            //this.Controls.Add(gridPat);
            gridPat.BeginUpdate();
            gridPat.Columns.Clear();
            gcol = new ODGridColumn(Lan.g("FormRpStatement", "Date"), 73);
            gridPat.Columns.Add(gcol);
            gcol = new ODGridColumn(Lan.g("FormRpStatement", "Patient"), 100);
            gridPat.Columns.Add(gcol);
            //prov
            gcol = new ODGridColumn(Lan.g("FormRpStatement", "Code"), 45);
            gridPat.Columns.Add(gcol);
            gcol = new ODGridColumn(Lan.g("FormRpStatement", "Tooth"), 42);
            gridPat.Columns.Add(gcol);
            gcol = new ODGridColumn(Lan.g("FormRpStatement", "Description"), 270);
            gridPat.Columns.Add(gcol);
            gcol = new ODGridColumn(Lan.g("FormRpStatement", "Charges"), 60, HorizontalAlignment.Right);
            gridPat.Columns.Add(gcol);
            gcol = new ODGridColumn(Lan.g("FormRpStatement", "Credits"), 60, HorizontalAlignment.Right);
            gridPat.Columns.Add(gcol);
            gcol = new ODGridColumn(Lan.g("FormRpStatement", "Balance"), 60, HorizontalAlignment.Right);
            gridPat.Columns.Add(gcol);
            gridPat.Width = gridPat.WidthAllColumns + 20;
            gridPat.EndUpdate();
            #endregion Body Table definition
            //Loop through each table.  Could be one intermingled, or one for each patient-----------------------------------------
            DataTable tableAccount;
            string    tablename;
            long      patnum;
            for (int i = 0; i < dataSet.Tables.Count; i++)
            {
                tableAccount = dataSet.Tables[i];
                tablename    = tableAccount.TableName;
                if (!tablename.StartsWith("account"))
                {
                    continue;
                }
                par                    = section.AddParagraph();
                par.Format.Font        = MigraDocHelper.CreateFont(10, true);
                par.Format.SpaceBefore = Unit.FromInch(.05);
                par.Format.SpaceAfter  = Unit.FromInch(.05);
                patnum                 = 0;
                if (tablename != "account")               //account123 etc.
                {
                    patnum = PIn.Long(tablename.Substring(7));
                }
                if (patnum != 0)
                {
                    par.AddText(fam.GetNameInFamFLnoPref(patnum));
                }
                //if(FamilyStatementDataList[famIndex].PatAboutList[i].ApptDescript!=""){
                //	par=section.AddParagraph();
                //	par.Format.Font=MigraDocHelper.CreateFont(9);//same as body font
                //	par.AddText(FamilyStatementDataList[famIndex].PatAboutList[i].ApptDescript);
                //}
                gridPat.BeginUpdate();
                gridPat.Rows.Clear();
                //lineData=FamilyStatementDataList[famIndex].PatDataList[i].PatData;
                for (int p = 0; p < tableAccount.Rows.Count; p++)
                {
                    grow = new ODGridRow();
                    grow.Cells.Add(tableAccount.Rows[p]["date"].ToString());
                    grow.Cells.Add(tableAccount.Rows[p]["patient"].ToString());
                    grow.Cells.Add(tableAccount.Rows[p]["ProcCode"].ToString());
                    grow.Cells.Add(tableAccount.Rows[p]["tth"].ToString());
                    if (CultureInfo.CurrentCulture.Name == "en-AU")                   //English (Australia)
                    {
                        if (tableAccount.Rows[p]["prov"].ToString().Trim() != "")
                        {
                            grow.Cells.Add(tableAccount.Rows[p]["prov"].ToString() + " - " + tableAccount.Rows[p]["description"].ToString());
                        }
                        else                          //No provider on this account row item, so don't put the extra leading characters.
                        {
                            grow.Cells.Add(tableAccount.Rows[p]["description"].ToString());
                        }
                    }
                    else                      //Assume English (United States)
                    {
                        grow.Cells.Add(tableAccount.Rows[p]["description"].ToString());
                    }
                    grow.Cells.Add(tableAccount.Rows[p]["charges"].ToString());
                    grow.Cells.Add(tableAccount.Rows[p]["credits"].ToString());
                    grow.Cells.Add(tableAccount.Rows[p]["balance"].ToString());
                    gridPat.Rows.Add(grow);
                }
                gridPat.EndUpdate();
                MigraDocHelper.DrawGrid(section, gridPat);
                //Total
                frame = MigraDocHelper.CreateContainer(section);
                font  = MigraDocHelper.CreateFont(9, true);
                float totalPos = ((float)(doc.DefaultPageSetup.PageWidth.Inch //-doc.DefaultPageSetup.LeftMargin.Inch
                                                                              //-doc.DefaultPageSetup.RightMargin.Inch)
                                          ) * 100f) / 2f + (float)gridPat.WidthAllColumns / 2f + 7;
                RectangleF rectF = new RectangleF(0, 0, totalPos, 16);
                if (patnum != 0)
                {
                    MigraDocHelper.DrawString(frame, " ",
                                              //I decided this was unnecessary:
                                              //dataSet.Tables["patient"].Rows[fam.GetIndex(patnum)]["balance"].ToString(),
                                              font, rectF, ParagraphAlignment.Right);
                    //MigraDocHelper.DrawString(frame,FamilyStatementDataList[famIndex].PatAboutList[i].Balance.ToString("F"),font,rectF,
                    //	ParagraphAlignment.Right);
                }
            }
            gridPat.Dispose();
            //Future appointments---------------------------------------------------------------------------------------------
            #region Future appointments
            font = MigraDocHelper.CreateFont(9);
            DataTable tableAppt = dataSet.Tables["appts"];
            if (tableAppt.Rows.Count > 0)
            {
                par             = section.AddParagraph();
                par.Format.Font = font;
                par.AddText(Lan.g("FormRpStatement", "Scheduled Appointments:"));
            }
            for (int i = 0; i < tableAppt.Rows.Count; i++)
            {
                par.AddLineBreak();
                par.AddText(tableAppt.Rows[i]["descript"].ToString());
            }
            if (tableAppt.Rows.Count > 0)
            {
                MigraDocHelper.InsertSpacer(section, 10);
            }
            #endregion Future appointments
            //Note------------------------------------------------------------------------------------------------------------
            font            = MigraDocHelper.CreateFont(9);
            par             = section.AddParagraph();
            par.Format.Font = font;
            par.AddText(Stmt.Note);
            //bold note
            if (Stmt.NoteBold != "")
            {
                MigraDocHelper.InsertSpacer(section, 10);
                font            = MigraDocHelper.CreateFont(10, true, System.Drawing.Color.DarkRed);
                par             = section.AddParagraph();
                par.Format.Font = font;
                par.AddText(Stmt.NoteBold);
            }
            //return doc;
        }
        /// <summary>
        /// Prints the labels.
        /// </summary>
        /// <param name="topBordermm">The top bordermm.</param>
        /// <param name="leftBordermm">The left bordermm.</param>
        /// <param name="columns">The columns.</param>
        /// <param name="rows">The rows.</param>
        /// <param name="startline">The startline.</param>
        /// <param name="labelFontSize">Size of the label font.</param>
        /// <param name="patients">The patients.</param>
        public void PrintLabels(int topBordermm, int leftBordermm, int columns, int rows, int startline, int labelFontSize, IList<PatientData> patients)
        {
            // 827 Pixel Breit = 210mm => 1mm = 3,9380952380952380952380952380952 Pixel
            // 1169 Pixel Hoch = 297mm => 1mm = 3,9360269360269360269360269360269 Pixel

            if (patients == null || patients.Count == 0) {
                return;
            }
            const float pixelMMFactor = 3.937F;
            const float height = 1169;
            const float width = 827;

            float leftBorderpixel = leftBordermm * pixelMMFactor;
            float topBorderpixel = topBordermm * pixelMMFactor;
            float usedplacewidth = width - (2 * leftBorderpixel);
            float usedplaceheight = height - (2 * topBorderpixel);
            float boxheight = usedplaceheight / rows;
            float boxwidth = usedplacewidth / columns;

            PrintableDocument pd = new PrintableDocument();
            pd.DocumentName = "SPD Labels";
            pd.Landscape = false;

            PrintablePage pp = new PrintablePage();

            Font font = new Font("Arial", labelFontSize);

            int line = startline - 1;
            foreach (PatientData patient in patients) {

                if (line >= rows) {
                    pd.AddPrintPage(pp);
                    pp = new PrintablePage();
                    line = 0;
                }

                for (int i = 0; i < columns; i++) {
                    font.GetHeight();
                    float x = leftBorderpixel + 7 + (i * boxwidth);
                    float y1 = topBorderpixel + (line * boxheight) + ((boxheight - (2 * font.GetHeight())) / 3);
                    float y2 = y1 + font.GetHeight();
                    float y3 = y2 + font.GetHeight();
                    pp.AddPrintableObject(new PrintableFillRectangleObject(Brushes.White, (int)(leftBorderpixel + (i * boxwidth)), (int)(topBorderpixel + (line * boxheight)), (int)boxwidth - 1, (int)boxheight));
                    //pp.AddPrintableObject(new PrintableTextObject("ID: " + patient.Id + "   Age: " + StaticUtilities.getAgeFromBirthDate(patient.DateOfBirth), font, Brushes.Black, x, y1));
                    //pp.AddPrintableObject(new PrintableTextObject(patient.FirstName, font, Brushes.Black, x, y2));
                    //pp.AddPrintableObject(new PrintableTextObject(patient.SurName, font, Brushes.Black, x, y3));

                    pp.AddPrintableObject(new PrintableTextObject(patient.FirstName + " " + patient.SurName, font, Brushes.Black, x, y1));
                    pp.AddPrintableObject(new PrintableTextObject("ID: " + patient.Id + "   Age: " + StaticUtilities.getAgeFromBirthDate(patient.DateOfBirth), font, Brushes.Black, x, y2));

                }

                line++;
            }

            pd.AddPrintPage(pp);

            pd.DoPrint();
        }
Example #56
0
        public async void RenderAsyncTest_FixedPitch()
        {
            string shortLine = "This is a line 0123456789";
            string longLine  = "This is a line 01234567890";

            Settings settings = Settings.CreateDefaultSettings();

            ModelLocator.Current.Settings.CopyPropertiesFrom(settings);

            SheetViewModel svm = new SheetViewModel();

            (svm.ContentEngine, svm.ContentType, svm.Language) = ContentTypeEngineBase.CreateContentTypeEngine(CteClassName);
            Assert.NotNull(svm.ContentEngine);
            Assert.Equal("text/plain", svm.ContentType);

            svm.ContentEngine.ContentSettings = new ContentSettings();

            // Setup page so only 1 line will fit
            svm.Margins = new System.Drawing.Printing.Margins(0, 0, 0, 0);

            // Setup page so 10 chars can fit across
            using Bitmap bitmap = new Bitmap(1, 1);
            bitmap.SetResolution(96, 96);
            Graphics g = Graphics.FromImage(bitmap);

            g.PageUnit          = GraphicsUnit.Display; // Display is 1/100th"
            g.TextRenderingHint = ContentTypeEngineBase.TextRenderingHint;

            // Set a font that's 1" high
            svm.ContentEngine.ContentSettings.Font = new Core.Models.Font()
            {
                Family = "Courier New", Size = 72
            };                                                                                                     // 72 points is 1" high
            System.Drawing.Font font = new System.Drawing.Font(svm.ContentEngine.ContentSettings.Font.Family,
                                                               svm.ContentEngine.ContentSettings.Font.Size / 72F * 96,
                                                               svm.ContentEngine.ContentSettings.Font.Style, GraphicsUnit.Pixel);

            // determine width
            // Use page settings including lineNumberWidth
            SizeF proposedSize = new SizeF(10000, font.GetHeight() + (font.GetHeight() / 2));
            SizeF size         = g.MeasureString(shortLine, font, proposedSize, ContentTypeEngineBase.StringFormat, out int charsFitted, out int linesFilled);

            ((TextCte)svm.ContentEngine).ContentSettings.LineNumbers = false;
            svm.ContentEngine.PageSize = new System.Drawing.SizeF(size.Width, font.GetHeight()); // a line will be about 108 high

            Assert.True(await svm.ContentEngine.SetDocumentAsync(shortLine));
            Assert.Equal(1, await svm.ContentEngine.RenderAsync(new System.Drawing.Printing.PrinterResolution()
            {
                X = 96, Y = 96
            }, null));

            Assert.True(await svm.ContentEngine.SetDocumentAsync($"{shortLine}\n{shortLine}"));
            Assert.Equal(2, await svm.ContentEngine.RenderAsync(new System.Drawing.Printing.PrinterResolution()
            {
                X = 96, Y = 96
            }, null));

            Assert.True(await svm.ContentEngine.SetDocumentAsync($"{shortLine}\n{shortLine}\n{shortLine}"));
            Assert.Equal(3, await svm.ContentEngine.RenderAsync(new System.Drawing.Printing.PrinterResolution()
            {
                X = 96, Y = 96
            }, null));

            // Test line wrapping
            // 0123456789
            // 0
            Assert.True(await svm.ContentEngine.SetDocumentAsync($"{longLine}"));
            Assert.Equal(2, await svm.ContentEngine.RenderAsync(new System.Drawing.Printing.PrinterResolution()
            {
                X = 96, Y = 96
            }, null));

            // 0123456789
            // 0A
            Assert.True(await svm.ContentEngine.SetDocumentAsync($"{longLine}A"));
            Assert.Equal(2, await svm.ContentEngine.RenderAsync(new System.Drawing.Printing.PrinterResolution()
            {
                X = 96, Y = 96
            }, null));

            // 0123456789
            // 0A01234567
            // 89
            Assert.True(await svm.ContentEngine.SetDocumentAsync($"{longLine}A{longLine}"));
            Assert.Equal(3, await svm.ContentEngine.RenderAsync(new System.Drawing.Printing.PrinterResolution()
            {
                X = 96, Y = 96
            }, null));
        }
Example #57
0
        public void DrawItem(DrawItemEventArgs e, Padding margin,
            Font titleFont, Font contentFont, Font timeFont, StringFormat format,
            Size imageSize, Color selectedBackColor)
        {
            if (this.Avatar == null) return;
            // if selected, mark the background differently.
            if ((e.State & DrawItemState.Selected) == DrawItemState.Selected)
            {
                using (var brush = new SolidBrush(selectedBackColor))
                {
                    e.Graphics.FillRectangle(brush, e.Bounds);
                }
            }
            else
            {
                e.Graphics.FillRectangle(Brushes.Beige, e.Bounds);
            }

            // draw some item separate line.
            e.Graphics.DrawLine(Pens.DarkGray, e.Bounds.X, e.Bounds.Y, e.Bounds.X + e.Bounds.Width, e.Bounds.Y);

            // draw item image
            e.Graphics.DrawImage(this.Avatar, e.Bounds.X + margin.Left, e.Bounds.Y + margin.Top, imageSize.Width,
                    imageSize.Height);

            var timeSize = e.Graphics.MeasureString(this.Time, timeFont).ToSize();

            // calculate bounds for title text drawing
            var titleBounds = new Rectangle(e.Bounds.X + margin.Horizontal + imageSize.Width,
                e.Bounds.Y + margin.Top,
                e.Bounds.Width - margin.Right - imageSize.Width - margin.Horizontal,
                (int)titleFont.GetHeight() + 2);

            // calculate bounds for content text drawing
            var contentBounds = new Rectangle(e.Bounds.X + margin.Horizontal + imageSize.Width,
                e.Bounds.Y + (int)titleFont.GetHeight() + 2 + margin.Vertical + margin.Top,
                e.Bounds.Width - margin.Right - imageSize.Width - margin.Horizontal,
                e.Bounds.Height - margin.Bottom - (int)titleFont.GetHeight() - 2 - margin.Vertical - margin.Top);

            // calculate bounds for timeBounds text drawing
            var timeBounds = new Rectangle(e.Bounds.Width - margin.Right - 60 - margin.Horizontal,
                e.Bounds.Y + margin.Top,
                60,
                imageSize.Height);

            // draw title string
            e.Graphics.DrawString(Title, titleFont, Brushes.Black, titleBounds, format);
            e.Graphics.DrawString(Content, contentFont, Brushes.DarkGray, contentBounds, format);
            //e.Graphics.DrawString(Time, timeFont, Brushes.Black, timeBounds, format);

            // put some focus rectangle
            e.DrawFocusRectangle();
        }
        private void ImpgrdTurnos_PrintPage(object sender, System.Drawing.Printing.PrintPageEventArgs e)
        {
            //PaintEventArgs myPaintArgs = new PaintEventArgs(e.Graphics, new System.Drawing.Rectangle(new System.Drawing.Point(0, 0), this.Size));
            //this.InvokePaint(grdTurnos, myPaintArgs);
            System.Drawing.Font printFont = new System.Drawing.Font("Arial", 10);
            float           topMargin     = e.MarginBounds.Top;
            float           yPos          = 0;
            float           linesPerPage  = 0;
            int             count         = 0;
            string          texto         = "";
            DataGridViewRow row;

            // Calculamos el número de líneas que caben en cada página.
            linesPerPage = e.MarginBounds.Height / printFont.GetHeight(e.Graphics);

            // Recorremos las filas del DataGridView hasta que llegemos// a las líneas que nos caben en cada página o al final del grid.
            while (count < linesPerPage && i < this.grdTurnos.Rows.Count)
            {
                row   = grdTurnos.Rows[i];
                texto = "";

                if (i == 0)
                {
                    //foreach(DataGridViewColumn col in grdTurnos.Columns)
                    //{
                    //texto += "\t" + col.Name.ToString();

                    //}
                    texto = "         IdBloqueo     Manguera        LecturaInicial             LecturaFinal          Producto           Turno          Precio      Cantidad";
                    System.Drawing.Font printFontEncabezado = new System.Drawing.Font("Arial", 8);
                    e.Graphics.DrawString(texto, printFontEncabezado, Brushes.Black, 10, e.MarginBounds.Top);
                    texto = "";
                }

                foreach (DataGridViewCell celda in row.Cells)
                {
                    texto += "\t" + celda.Value.ToString().Trim();
                }

                // Calculamos la posición en la que se escribe la línea

                yPos = topMargin + ((count + 1) * printFont.GetHeight(e.Graphics));

                // Escribimos la línea con el objeto Graphics

                e.Graphics.DrawString(texto, printFont, Brushes.Black, 10, yPos);

                count++;
                i++;
            }

            if (i < this.grdTurnos.Rows.Count)
            {
                e.HasMorePages = true;
            }
            else
            {
                // si llegamos al final, se establece                 HasMorePages a
                // false para que se acabe la impresión
                e.HasMorePages = false;

                i = 0;
            }
        }
        /*MÉTODO PARA IMPRIMIR*/

        /*MÉTODO PARA IMPRIMIR*/

        private void Imprimir(object sender, PrintPageEventArgs e)
        {
            StringFormat stringFormat = new StringFormat();

            stringFormat.Alignment = StringAlignment.Center;

            System.Drawing.Font font   = new System.Drawing.Font("Courier New", 12, System.Drawing.FontStyle.Bold);
            System.Drawing.Font titulo = new System.Drawing.Font("Courier New", 12, System.Drawing.FontStyle.Bold);
            System.Drawing.Font cuerpo = new System.Drawing.Font("Courier New", 9);
            System.Drawing.Font final  = new System.Drawing.Font("Courier New", 6);

            // MODIFICADORES DE FORMATO DE HOJA/
            float  margen_izquierdo        = 0;
            float  margen_superior         = 10;
            double margen_cuerpo           = 0.42; //DESPUES DEL TITULO
            double tamanio_hoja_horizontal = 3.8;
            // ----------------------------------/

            double cambio = (Convert.ToDouble(this.txt_efectivo.Text)) - (Convert.ToDouble(this.txtAbono.Text));
            //double restante = this.restante - (Int32.Parse(this.txtAbono.Text));

            string fecha_inicio       = DateTime.Now.ToString("d/M/yyyy");
            string fecha_finalizacion = DateTime.Now.AddYears(1).ToString("d/M/yyyy");
            string hora            = DateTime.Now.ToString("HH:mm:ss") + " hrs";
            Abonos a               = new Abonos(bandera_online_offline);
            double restante_pagado = a.Restante(id_motivo, paciente.clinica.id_clinica, paciente.id_paciente);
            double abonado_pagado  = a.Abonados(id_motivo, paciente.id_paciente, paciente.clinica.id_clinica);
            string sucursal        = obtener_nombre_sucursal(paciente.clinica.id_clinica);

            System.Drawing.Image      imagen = System.Drawing.Image.FromFile(System.IO.Path.Combine(@System.Diagnostics.Process.GetCurrentProcess().MainModule.FileName, @"..\..\..\Assets\bs_ticket_imagen.bmp"));
            System.Drawing.RectangleF rect   = new System.Drawing.RectangleF(margen_izquierdo, margen_superior, centimetroAPixel(3.8), 30);//tamanio_hoja_horizontal en vez de 4
            RectangleF rImage = new RectangleF(38, margen_superior, 110, 110);

            e.Graphics.DrawImage(imagen, rImage);

            //e.Graphics.FillRectangle(Brushes.Red, rect); usarlo para cada recyangulo
            rect.Y = (cuerpo.GetHeight(e.Graphics) * 7) + margen_superior;
            e.Graphics.DrawString("BONITA SMILE", titulo, new SolidBrush(Color.Black), rect, stringFormat);

            rect.X     = Convert.ToSingle(centimetroAPixel(margen_cuerpo));
            rect.Width = centimetroAPixel(tamanio_hoja_horizontal); //nuevo

            rect.Y = (cuerpo.GetHeight(e.Graphics) * 9) + margen_superior;
            stringFormat.Alignment = StringAlignment.Near;
            e.Graphics.DrawString("SUCURSAL: " + sucursal, cuerpo, new SolidBrush(Color.Black), rect, stringFormat);

            rect.Y = (cuerpo.GetHeight(e.Graphics) * 10) + margen_superior;
            e.Graphics.DrawString("CLIENTE: " + paciente.nombre + " " + paciente.apellidos, cuerpo, new SolidBrush(Color.Black), rect, stringFormat);

            rect.Y = (cuerpo.GetHeight(e.Graphics) * 12) + margen_superior;
            e.Graphics.DrawString("FECHA: " + fecha_inicio, cuerpo, new SolidBrush(Color.Black), rect, stringFormat);

            rect.Y = (cuerpo.GetHeight(e.Graphics) * 13) + margen_superior;
            e.Graphics.DrawString("HORA: " + hora, cuerpo, new SolidBrush(Color.Black), rect, stringFormat);

            rect.Y = (cuerpo.GetHeight(e.Graphics) * 15) + margen_superior;
            e.Graphics.DrawString("MOTIVO: ", cuerpo, new SolidBrush(Color.Black), rect, stringFormat);

            rect.Y = (cuerpo.GetHeight(e.Graphics) * 17) + margen_superior;
            e.Graphics.DrawString(this.motivo, cuerpo, new SolidBrush(Color.Black), rect, stringFormat);

            rect.Y = (cuerpo.GetHeight(e.Graphics) * 18) + margen_superior;
            e.Graphics.DrawString("PRECIO: $" + this.total, cuerpo, new SolidBrush(Color.Black), rect, stringFormat);

            rect.Y = (cuerpo.GetHeight(e.Graphics) * 19) + margen_superior + 10;
            e.Graphics.DrawString("-------------------", cuerpo, new SolidBrush(Color.Black), rect, stringFormat);
            rect.Y = ((cuerpo.GetHeight(e.Graphics) * 19) + margen_superior + 10) + 5;
            e.Graphics.DrawString("-------------------", cuerpo, new SolidBrush(Color.Black), rect, stringFormat);

            rect.Y = (cuerpo.GetHeight(e.Graphics) * 21) + margen_superior - 5;
            e.Graphics.DrawString("-------------------", cuerpo, new SolidBrush(Color.Black), rect, stringFormat);

            rect.Y = ((cuerpo.GetHeight(e.Graphics) * 21) + margen_superior - 5) + 5;
            e.Graphics.DrawString("-------------------", cuerpo, new SolidBrush(Color.Black), rect, stringFormat);

            rect.Y = ((cuerpo.GetHeight(e.Graphics) * 23) + margen_superior);
            e.Graphics.DrawString("TOTAL: $" + this.total, cuerpo, new SolidBrush(Color.Black), rect, stringFormat);

            rect.Y = (cuerpo.GetHeight(e.Graphics) * 24) + margen_superior;
            e.Graphics.DrawString("ABONO: $" + txtAbono.Text, cuerpo, new SolidBrush(Color.Black), rect, stringFormat);

            rect.Y = (cuerpo.GetHeight(e.Graphics) * 25) + margen_superior;
            e.Graphics.DrawString("RECIBIDO: $" + txt_efectivo.Text, cuerpo, new SolidBrush(Color.Black), rect, stringFormat);

            rect.Y = (cuerpo.GetHeight(e.Graphics) * 26) + margen_superior;
            e.Graphics.DrawString("CAMBIO: $" + cambio, cuerpo, new SolidBrush(Color.Black), rect, stringFormat);

            rect.Y = (cuerpo.GetHeight(e.Graphics) * 28) + margen_superior - 5;
            e.Graphics.DrawString("-------------------", cuerpo, new SolidBrush(Color.Black), rect, stringFormat);
            rect.Y = ((cuerpo.GetHeight(e.Graphics) * 28) + margen_superior - 5) + 5;
            e.Graphics.DrawString("-------------------", cuerpo, new SolidBrush(Color.Black), rect, stringFormat);

            rect.Y = (cuerpo.GetHeight(e.Graphics) * 30) + margen_superior;
            e.Graphics.DrawString("ABONADO: " + abonado_pagado, cuerpo, new SolidBrush(Color.Black), rect, stringFormat);

            rect.Y = (cuerpo.GetHeight(e.Graphics) * 31) + margen_superior;
            e.Graphics.DrawString("RESTANTE: " + restante_pagado, cuerpo, new SolidBrush(Color.Black), rect, stringFormat);

            rect.X = Convert.ToSingle(centimetroAPixel(0.27));
            rect.Y = (cuerpo.GetHeight(e.Graphics) * 33) + margen_superior;
            e.Graphics.DrawString("La fundación Doi Esperanza brinda una aportación del " + txt_Aportacion.Text + "% del total", final, new SolidBrush(Color.Black), rect, stringFormat);

            e.HasMorePages = false;
        }
Example #60
0
        /// <exception cref="ArgumentException">Invalid font style</exception>
        private static SD.Bitmap CreateFontBitmap(SD.FontFamily fontFamily, SD.FontStyle fontStyle, int fontSize, int resolution, ref int leading, IEnumerable <Range> codePoints, IDictionary <char, RectangleF> glyphs)
        {
            if (!fontFamily.IsStyleAvailable(fontStyle))
            {
                throw new ArgumentException("Invalid font style", "fontStyle");
            }

            using (var font = new SD.Font(fontFamily, fontSize, fontStyle, SD.GraphicsUnit.Point))
            {
                if (leading == 0)
                {
                    leading = (int)Math.Ceiling(font.GetHeight());
                }

                using (var sf = new StringFormat(StringFormat.GenericTypographic))
                {
                    sf.FormatFlags ^= StringFormatFlags.NoClip;

                    IEnumerable <int> codePointList = GetCodePointList(codePoints);
                    float             x = 0, y = 0;

                    // get texture dimensions
                    var texSize    = GetTexSize(codePointList, resolution, font, sf, leading);

                    // draw font texture
                    var fontBitmap = new SD.Bitmap(texSize.Width, texSize.Height);
                    fontBitmap.SetResolution(resolution, resolution);
                    float italicPadding = 0f;                    //pkubat added
                    if (font.Italic)
                    {
                        italicPadding = fontSize / 7f;
                    }

                    using (var g = SD.Graphics.FromImage(fontBitmap))
                    {
                        using (var brush = new SD.SolidBrush(SD.Color.White))
                        {
                            g.Clear(SD.Color.Transparent);
                            //g.InterpolationMode = InterpolationMode.Low;
                            //g.CompositingQuality = CompositingQuality.HighSpeed;
                            //g.SmoothingMode = SmoothingMode.HighSpeed;

                            g.InterpolationMode  = InterpolationMode.HighQualityBicubic;
                            g.CompositingQuality = CompositingQuality.HighQuality;
                            g.SmoothingMode      = SmoothingMode.HighQuality;

                            g.PixelOffsetMode   = PixelOffsetMode.HighQuality;
                            g.TextRenderingHint = TextRenderingHint.AntiAlias;
                            g.PageUnit          = SD.GraphicsUnit.Pixel;

                            foreach (int i in codePointList)
                            {
                                string c    = char.ConvertFromUtf32(i);
                                var    size = g.MeasureString(c, font, texSize.Width, sf);
                                size.Width += italicPadding;

                                if (x + size.Width >= texSize.Width)
                                {
                                    x  = 0;
                                    y += leading + 2;
                                }

                                g.DrawString(c, font, brush, new SD.RectangleF(x, y, size.Width, leading), sf);

                                // fill glyphdict
                                glyphs[(char)i] = new RectangleF(
                                    x / texSize.Width,
                                    y / texSize.Height,
                                    size.Width / texSize.Width,
                                    (float)leading / texSize.Height);

                                x += size.Width + 2;
                            }

                            // get space width
                            var spaceSize = g.MeasureString(" ", font);
                            glyphs[' '] = new RectangleF(0, 0, spaceSize.Width / texSize.Width, (float)leading / texSize.Height);
                        }

                        return(fontBitmap);
                    }
                }
            }
        }