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


C# StringFormat.Dispose方法代码示例

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


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

示例1: OnPaint

	protected override void OnPaint (PaintEventArgs args)
	{
		Graphics g = args.Graphics;

		SolidBrush brush = new SolidBrush (ForeColor);
		StringFormat sformat = new StringFormat ();
		sformat.FormatFlags = StringFormatFlags.LineLimit;
		g.DrawString ("WeShouldIncludeWhiteSpaces", Font, brush, new Rectangle (0, 0, 55, 100),
				sformat);
		brush.Dispose ();
		sformat.Dispose ();
	}
开发者ID:mono,项目名称:gert,代码行数:12,代码来源:MainForm.cs

示例2: DrawDialog

    private void DrawDialog(Graphics g, string title, string text)
    {
        StringFormat format = new StringFormat(StringFormatFlags.NoClip);
        format.Alignment = StringAlignment.Near;
        format.LineAlignment = StringAlignment.Center;

        Rectangle aboutRectangle = new Rectangle((Width / 2) - 90, (Height / 2) - 60, MinimumDialogHeight, 120);

        // Box
        //
        g.FillRectangle(Brushes.SteelBlue, aboutRectangle);
        g.DrawRectangle(Pens.Black, aboutRectangle);

        //Contents
        //
        aboutRectangle.Inflate(-5, -5);
        aboutRectangle.Y = aboutRectangle.Y + 5;

        Font textFont = new Font("Arial", 8f);
        //Draw text
        //
        g.DrawString(text, textFont, Brushes.White, aboutRectangle, format);

        //Title
        //
        aboutRectangle.Inflate(5, -47);
        aboutRectangle.Y = (Height / 2) - 60;
        g.FillRectangle(Brushes.Black, aboutRectangle);
        g.DrawRectangle(Pens.Black, aboutRectangle);

        aboutRectangle.Inflate(-5, 0);
        g.DrawString(title, textFont, Brushes.White, aboutRectangle, format);

        //Close
        //
        aboutRectangle.Inflate(-78, 0);
        aboutRectangle.X = (Width / 2) + 76;
        g.FillRectangle(Brushes.Red, aboutRectangle);
        g.DrawRectangle(Pens.Black, aboutRectangle);

        StringFormat closeFormat = new StringFormat(StringFormatFlags.NoClip | StringFormatFlags.DirectionVertical);
        format.Alignment = StringAlignment.Near;
        format.LineAlignment = StringAlignment.Center;

        Font closeFont = new Font("Verdana", 10.5f, FontStyle.Bold);
        aboutRectangle.Inflate(3, -1);
        g.DrawString("X",
                     closeFont,
                     Brushes.White,
                     aboutRectangle,
                     closeFormat);

        dialogCloseRectangle = aboutRectangle;
        format.Dispose();
        closeFormat.Dispose();
        textFont.Dispose();
        closeFont.Dispose();
    }
开发者ID:vantruc,项目名称:skimpt,代码行数:58,代码来源:camera.cs

示例3: GetTextBitmap

		public static Bitmap GetTextBitmap(string Text, Color BackColor, Color ForeColor, Color OutlineColor, Shape BorderShape, int Height, int Width)
		{
			Bitmap BMP = new Bitmap(1, 1);
			Graphics g = Graphics.FromImage(BMP);
			if (Width == -1 || Height == -1)
			{
				SizeF CalculatedAutoSize;
				CalculatedAutoSize = g.MeasureString(Text, Control.DefaultFont);
				if (Width == -1)
					Width = (int)(CalculatedAutoSize.Width + 3);
				if (Height == -1)
					Height = (int)(CalculatedAutoSize.Height + 1);
			}

			BMP = new Bitmap(Width, Height);
			g = Graphics.FromImage(BMP);
			g.Clear(Color.Transparent);
			Rectangle R = new Rectangle(0, 0, Width - 1, Height - 1);
			System.Drawing.SolidBrush BackColorBrush = new System.Drawing.SolidBrush(BackColor);
			System.Drawing.Pen ForeColorPen = new System.Drawing.Pen(ForeColor);
			System.Drawing.Pen OutlineColorPen = new System.Drawing.Pen(OutlineColor);
			switch (BorderShape)
			{
				case Shape.Ellipse:
					g.FillEllipse(BackColorBrush, R);
					g.DrawEllipse(OutlineColorPen, R);
					break;
				case Shape.Rectangle:
					g.FillRectangle(BackColorBrush, R);
					g.DrawRectangle(OutlineColorPen, R);
					break;
			}

			StringFormat SF = new StringFormat(StringFormatFlags.NoWrap);

			SF.Alignment = StringAlignment.Center;
			SF.LineAlignment = StringAlignment.Center;
			SF.Trimming = StringTrimming.None;

			System.Drawing.SolidBrush ForeColorBrush = new System.Drawing.SolidBrush(ForeColor);

			RectangleF RF = new RectangleF(0, 0, Width, Height);

			g.DrawString(Text, Control.DefaultFont, ForeColorBrush, RF, SF);
			SF.Dispose();
			ForeColorBrush.Dispose();
			BackColorBrush.Dispose();
			ForeColorPen.Dispose();
			OutlineColorPen.Dispose();
			g.Dispose();
			return BMP;
		}
开发者ID:heimanhon,项目名称:researchwork,代码行数:52,代码来源:DummyDataCreator.cs


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