当前位置: 首页>>代码示例>>C#>>正文


C# Font.GetHeight方法代码示例

本文整理汇总了C#中System.Drawing.Font.GetHeight方法的典型用法代码示例。如果您正苦于以下问题:C# Font.GetHeight方法的具体用法?C# Font.GetHeight怎么用?C# Font.GetHeight使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Drawing.Font的用法示例。


在下文中一共展示了Font.GetHeight方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: DrawStringML

 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();
 }
开发者ID:Hli4S,项目名称:TestMeApp,代码行数:25,代码来源:Print.cs

示例2: GetCommonPrintValues

        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;
        }
开发者ID:sreenandini,项目名称:test_buildscripts,代码行数:48,代码来源:PrintUtility.cs

示例3: CreateFont

        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"));
                    }
                }
            }
        }
开发者ID:TautvydasZilys,项目名称:Direct3D-Sandbox,代码行数:34,代码来源:FontCreator.cs

示例4: Init

 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);
 }
开发者ID:JohnHiness,项目名称:pacman-csharp,代码行数:9,代码来源:Renderer.cs

示例5: Doc_PrintPage

        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());
            }
        }
开发者ID:Jusharra,项目名称:RMS,代码行数:55,代码来源:ReservationReport.cs

示例6: drawItem

        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();
        
        }
开发者ID:NikithShetty,项目名称:Virtual-wifi,代码行数:41,代码来源:exListBox.cs

示例7: SetFont

        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;
        }
开发者ID:ksuquix,项目名称:cardmaker,代码行数:12,代码来源:FormattedTextProcessData.cs

示例8: drawSimpleBanner

 /// <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;
 }
开发者ID:barneh,项目名称:mptvseries,代码行数:18,代码来源:imageAllocator.cs

示例9: calculate_height_difference_for_font_baseline_match

        /// <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);
        }
开发者ID:JUNICHIFUJIO,项目名称:PathfinderManager,代码行数:20,代码来源:UnselectedCharacterMenuButton.cs

示例10: pd_PrintPage

        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());
        }
开发者ID:kexinn,项目名称:Edu,代码行数:12,代码来源:test.aspx.cs

示例11: GetPicture

        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;

        }
开发者ID:Bezaeel,项目名称:Talabi,代码行数:39,代码来源:MarkController.cs

示例12: CPrintPage

        //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;
        }
开发者ID:ShanioDeJesus,项目名称:FBLA,代码行数:23,代码来源:CustomPrintDocument.cs

示例13: FontRenderer

        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);
        }
开发者ID:AyyTee,项目名称:Aventyr,代码行数:49,代码来源:FontRenderer.cs

示例14: PdPrintPage

        // 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;
        }
开发者ID:xcui4,项目名称:ConsoleSample,代码行数:25,代码来源:Form1.cs

示例15: printJob_PrintPage

        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);
        }
开发者ID:titusxp,项目名称:buzzle,代码行数:46,代码来源:ReceiptPrinter.cs


注:本文中的System.Drawing.Font.GetHeight方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。