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


C# Font.?.Dispose方法代码示例

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


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

示例1: AddSpineText

		/// <summary>Adds a spine text.</summary>
		/// <param name="graphics">The graphics object to draw to.</param>
		/// <param name="dpi">The DPI of the cover.</param>
		/// <param name="rectSafe">The spine safe rectangle.</param>
		private static void AddSpineText(Graphics graphics, int dpi, RectangleF rectSafe)
		{
			Contract.Requires<ArgumentNullException>(graphics != null);

			Font fontTitleSpine = null;
			Font fontAuthorSpine = null;

			try
			{
				string fontTypeface = Settings.Default.FontTypeface;
				string bookTitle = Settings.Default.BookTitle;
				string bookAuthor = Settings.Default.BookAuthor;
				float marginText = Settings.Default.MarginTextInches * dpi;

				fontTitleSpine = new Font(fontTypeface, Settings.Default.FontTitleSpineSize);
				fontAuthorSpine = new Font(fontTypeface, Settings.Default.FontAuthorSpineSize);

				SizeF sizeTextTitleSpine = graphics.MeasureString(bookTitle, fontTitleSpine);
				SizeF sizeTextAuthorSpine = graphics.MeasureString(bookAuthor, fontAuthorSpine);

				using (StringFormat stringFormat = new StringFormat(StringFormatFlags.DirectionVertical))
				{
					RectangleF rectTitleSpine = new RectangleF(
						rectSafe.X + ((rectSafe.Width - sizeTextTitleSpine.Height) / 2),
						rectSafe.Y + marginText,
						sizeTextTitleSpine.Height,
						sizeTextTitleSpine.Width);
					graphics.DrawStringEmbossed(bookTitle, fontTitleSpine, Brushes.White, rectTitleSpine, stringFormat);

					RectangleF rectAuthorSpine = new RectangleF(
						rectSafe.X + ((rectSafe.Width - sizeTextAuthorSpine.Height) / 2),
						rectSafe.Bottom - marginText - sizeTextAuthorSpine.Width,
						sizeTextAuthorSpine.Height,
						sizeTextAuthorSpine.Width);
					graphics.DrawStringEmbossed(bookAuthor, fontAuthorSpine, Brushes.White, rectAuthorSpine, stringFormat);
				}
			}
			finally
			{
				fontTitleSpine?.Dispose();
				fontAuthorSpine?.Dispose();
			}
		}
开发者ID:GregReddick,项目名称:Xoc.CoverGenerator,代码行数:47,代码来源:Program.cs

示例2: AddBackCoverText

		/// <summary>Adds a back cover text.</summary>
		/// <param name="graphics">The graphics object to draw to.</param>
		/// <param name="dpi">The DPI of the cover.</param>
		/// <param name="rectSafe">The back cover safe rectangle.</param>
		private static void AddBackCoverText(Graphics graphics, int dpi, RectangleF rectSafe)
		{
			Contract.Requires<ArgumentNullException>(graphics != null);

			Font fontBlurb = null;

			try
			{
				float marginText = Settings.Default.MarginTextInches * dpi;
				string directoryImages = Settings.Default.DirectoryImages;
				Contract.Assume(directoryImages != null);

				// Draw the blurb
				string bookBlurb = Settings.Default.BookBlurb;
				PointF pointBlurb = new PointF(rectSafe.X + marginText, rectSafe.Y + marginText);
				fontBlurb = new Font(Settings.Default.FontTypeface, Settings.Default.FontBlurbSize);
				SizeF sizeTextBlurb = graphics.MeasureString(bookBlurb, fontBlurb, (int)Math.Ceiling(rectSafe.Width - (2 * marginText)));
				graphics.DrawStringEmbossed(bookBlurb, fontBlurb, Brushes.White, pointBlurb, sizeTextBlurb);

				// Draw the logo
				string logoFileNameFull = string.Format(CultureInfo.InvariantCulture, Settings.Default.FileNameLogo, dpi);
				Contract.Assume(logoFileNameFull != null);
				string logoPathName = Path.Combine(directoryImages, logoFileNameFull);
				if (File.Exists(logoPathName))
				{
					using (Bitmap bitmapLogo = new Bitmap(logoPathName))
					{
						graphics.DrawImage(bitmapLogo, rectSafe.X + marginText, rectSafe.Bottom - marginText - bitmapLogo.Height);
					}
				}

				// Draw the ISBN
				SizeF sizeIsbnBlockInches = Settings.Default.SizeIsbnBlockInches;
				SizeF sizeIsbnBlock = new SizeF(sizeIsbnBlockInches.Width * dpi, sizeIsbnBlockInches.Height * dpi);
				RectangleF rectIsbn = new RectangleF(
					rectSafe.Right - marginText - sizeIsbnBlock.Width,
					rectSafe.Bottom - marginText - sizeIsbnBlock.Height,
					sizeIsbnBlock.Width,
					sizeIsbnBlock.Height);

				graphics.FillRectangle(Brushes.White, rectIsbn);

				if (Settings.Default.ShowIsbn)
				{
					// Get the isbn graphic and draw it on the back. If not done, CoverSpace will automatically add an ISBN barcode to the
					// white block.
					string isbnFileNameFull = string.Format(CultureInfo.InvariantCulture, Settings.Default.FileNameIsbn, dpi);
					Contract.Assume(isbnFileNameFull != null);
					string isbnPathName = Path.Combine(directoryImages, isbnFileNameFull);
					if (File.Exists(isbnPathName))
					{
						using (Bitmap bitmapIsbn = new Bitmap(isbnPathName))
						{
							graphics.DrawImage(bitmapIsbn, rectIsbn.Left, rectIsbn.Top, rectIsbn.Width, rectIsbn.Height);
						}
					}
				}
			}
			finally
			{
				fontBlurb?.Dispose();
			}
		}
开发者ID:GregReddick,项目名称:Xoc.CoverGenerator,代码行数:67,代码来源:Program.cs

示例3: AddFrontCoverText

		/// <summary>Adds a front cover text.</summary>
		/// <param name="graphics">The graphics object to draw to.</param>
		/// <param name="dpi">The DPI of the cover.</param>
		/// <param name="rectSafe">The front cover safe rectangle.</param>
		private static void AddFrontCoverText(Graphics graphics, int dpi, RectangleF rectSafe)
		{
			Contract.Requires<ArgumentNullException>(graphics != null);

			Font fontTitle = null;
			Font fontAuthor = null;
			Font fontSubtitle = null;
			Font fontDraft = null;

			try
			{
				string fontTypeface = Settings.Default.FontTypeface;
				string bookTitle = Settings.Default.BookTitle;
				string bookAuthor = Settings.Default.BookAuthor;
				string bookSubtitle = Settings.Default.BookSubtitle;
				string bookDraftText = Settings.Default.BookDraftText;
				float spacingTitle = Settings.Default.SpacingTitleInches * dpi;
				float spacingAuthor = Settings.Default.SpacingAuthorInches * dpi;
				float spacingSubtitle = Settings.Default.SpacingSubtitleInches * dpi;
				float spacingDraft = Settings.Default.SpacingDraftInches * dpi;

				fontAuthor = new Font(fontTypeface, Settings.Default.FontAuthorSize);
				fontDraft = new Font(fontTypeface, Settings.Default.FontDraftSize);
				fontSubtitle = new Font(fontTypeface, Settings.Default.FontSubtitleSize, FontStyle.Italic);
				fontTitle = new Font(fontTypeface, Settings.Default.FontTitleSize, FontStyle.Bold);

				SizeF sizeTextAuthor = graphics.MeasureString(bookAuthor, fontAuthor);
				SizeF sizeTextDraft = graphics.MeasureString(bookDraftText, fontDraft);
				SizeF sizeTextSubtitle = graphics.MeasureString(bookSubtitle, fontSubtitle);
				SizeF sizeTextTitle = graphics.MeasureString(bookTitle, fontTitle);

				PointF pointTextTitle = new PointF(rectSafe.X + ((rectSafe.Width - sizeTextTitle.Width) / 2), rectSafe.Top + spacingTitle);
				PointF pointTextAuthor = new PointF(
					rectSafe.X + ((rectSafe.Width - sizeTextAuthor.Width) / 2),
					pointTextTitle.Y + spacingAuthor);
				PointF pointTextSubtitle = new PointF(
					rectSafe.X + ((rectSafe.Width - sizeTextSubtitle.Width) / 2),
					pointTextAuthor.Y + spacingSubtitle);
				PointF pointTextDraft = new PointF(
					rectSafe.X + ((rectSafe.Width - sizeTextDraft.Width) / 2),
					pointTextSubtitle.Y + spacingDraft);

				// Draw the text on the Front Cover
				graphics.DrawStringEmbossed(bookTitle, fontTitle, Brushes.White, pointTextTitle, sizeTextTitle);
				graphics.DrawStringEmbossed(bookAuthor, fontAuthor, Brushes.White, pointTextAuthor, sizeTextAuthor);
				graphics.DrawStringEmbossed(bookSubtitle, fontSubtitle, Brushes.White, pointTextSubtitle, sizeTextSubtitle);
				if (Settings.Default.ShowDraft)
				{
					// Puts the draft text on the front cover
					graphics.DrawStringEmbossed(bookDraftText, fontDraft, Brushes.Black, pointTextDraft, sizeTextDraft);
				}
			}
			finally
			{
				fontTitle?.Dispose();
				fontAuthor?.Dispose();
				fontSubtitle?.Dispose();
				fontDraft?.Dispose();
			}
		}
开发者ID:GregReddick,项目名称:Xoc.CoverGenerator,代码行数:64,代码来源:Program.cs


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