本文整理汇总了C#中System.Windows.Media.FormattedText类的典型用法代码示例。如果您正苦于以下问题:C# FormattedText类的具体用法?C# FormattedText怎么用?C# FormattedText使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
FormattedText类属于System.Windows.Media命名空间,在下文中一共展示了FormattedText类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: DrawHelpText
/// <summary>
/// Draw some helpful text.
/// </summary>
/// <param name="dc"></param>
protected virtual void DrawHelpText(DrawingContext dc)
{
System.Windows.Media.Typeface backType =
new System.Windows.Media.Typeface(new System.Windows.Media.FontFamily("sans courier"),
FontStyles.Normal, FontWeights.Normal, FontStretches.Normal);
System.Windows.Media.FormattedText formatted = new System.Windows.Media.FormattedText(
"Click & move the mouse to select a capture area.\nENTER/F10: Capture\nBACKSPACE/DEL: Start over\nESC: Exit",
System.Globalization.CultureInfo.CurrentCulture,
FlowDirection.LeftToRight,
backType,
32.0f,
new System.Windows.Media.SolidColorBrush(System.Windows.Media.Colors.White));
// Make sure the text shows at 0,0 on the primary screen
System.Drawing.Point primScreen = System.Windows.Forms.Screen.PrimaryScreen.Bounds.Location;
Point clientBase = PointFromScreen(new Point(primScreen.X + 5, primScreen.Y + 5));
Geometry textGeo = formatted.BuildGeometry(clientBase);
dc.DrawGeometry(
System.Windows.Media.Brushes.White,
null,
textGeo);
dc.DrawGeometry(
null,
new System.Windows.Media.Pen(System.Windows.Media.Brushes.White, 1),
textGeo);
}
开发者ID:biki3507,项目名称:FreeCapture,代码行数:30,代码来源:CaptureSurface.cs
示例2: DrawPointElement
protected override void DrawPointElement(DrawingContext dc, int Zoom)
{
if (Zoom > 12 || IsMouseOver)
{
string postLabelText = string.Format("{0}км", (double)Post.Ordinate / 1000);
var postLabel = new FormattedText(postLabelText, CultureInfo.CurrentCulture,
FlowDirection.LeftToRight, new Typeface("Verdana"), 10, mainBrush);
const int flagHeight = 22;
dc.PushTransform(new TranslateTransform(0, -flagHeight));
dc.DrawRectangle(Brushes.White, new Pen(mainBrush, 1), new Rect(-0.5, -0.5, Math.Round(postLabel.Width) + 5, Math.Round(postLabel.Height) + 2));
dc.DrawText(postLabel, new Point(2, 0));
dc.DrawLine(new Pen(mainBrush, 2), new Point(0, 0), new Point(0, flagHeight));
dc.Pop();
}
if (Zoom > 8)
dc.DrawEllipse(SectionBrush, new Pen(mainBrush, 1.5), new Point(0, 0), 5, 5);
else
dc.DrawRectangle(SectionBrush, null, new Rect(-2, -2, 4, 4));
if (IsMouseOver)
{
dc.PushTransform(new TranslateTransform(3, 10));
PrintStack(dc,
new FormattedText(Post.Direction == OrdinateDirection.Increasing ? "Возрастает по неч." : "Убывает по неч.",
CultureInfo.CurrentCulture, FlowDirection.LeftToRight, new Typeface("Verdana"), 10, Brushes.DarkBlue),
new FormattedText(String.Format("Пути: {0}", string.Join(", ", Post.Tracks.Select(TrackName))),
CultureInfo.CurrentCulture, FlowDirection.LeftToRight, new Typeface("Verdana"), 10, Brushes.DarkOliveGreen));
dc.Pop();
}
}
开发者ID:NpoSaut,项目名称:netEMapTools,代码行数:34,代码来源:KilometerPostMapElement.cs
示例3: CreateText
/// <summary>
/// Create the outline geometry based on the formatted text.
/// </summary>
public void CreateText()
{
FontStyle fontStyle = FontStyles.Normal;
FontWeight fontWeight = FontWeights.Medium;
if (Bold == true) fontWeight = FontWeights.Bold;
if (Italic == true) fontStyle = FontStyles.Italic;
// Create the formatted text based on the properties set.
FormattedText formattedText = new FormattedText(
Text,
CultureInfo.GetCultureInfo("en-us"),
FlowDirection.LeftToRight,
new Typeface(Font, fontStyle, fontWeight, FontStretches.Normal),
FontSize,
Brushes.Black // This brush does not matter since we use the geometry of the text.
);
// Build the geometry object that represents the text.
_textGeometry = formattedText.BuildGeometry(new Point(0, 0));
//set the size of the custome control based on the size of the text
this.MinWidth = formattedText.Width;
this.MinHeight = formattedText.Height;
}
开发者ID:step4u,项目名称:CallService,代码行数:32,代码来源:OutlinedText.cs
示例4: CalculateIsTextTrimmed
/// <summary>
/// Determines whether or not the text in <paramref name="textBlock" /> is currently being
/// trimmed due to width or height constraints.
/// </summary>
/// <remarks>Does not work properly when TextWrapping is set to WrapWithOverflow.</remarks>
/// <param name="textBlock"><see cref="TextBlock" /> to evaluate</param>
/// <returns><c>true</c> if the text is currently being trimmed; otherwise <c>false</c></returns>
static bool CalculateIsTextTrimmed(TextBlock textBlock) {
if (!textBlock.IsArrangeValid)
return GetIsTextTrimmed(textBlock);
var typeface = new Typeface(
textBlock.FontFamily,
textBlock.FontStyle,
textBlock.FontWeight,
textBlock.FontStretch);
// FormattedText is used to measure the whole width of the text held up by TextBlock container
var formattedText = new FormattedText(
textBlock.Text,
Thread.CurrentThread.CurrentCulture,
textBlock.FlowDirection,
typeface,
textBlock.FontSize,
textBlock.Foreground) {MaxTextWidth = textBlock.ActualWidth};
// When the maximum text width of the FormattedText instance is set to the actual
// width of the textBlock, if the textBlock is being trimmed to fit then the formatted
// text will report a larger height than the textBlock. Should work whether the
// textBlock is single or multi-line.
return formattedText.Height > textBlock.ActualHeight;
}
开发者ID:SIXNetworks,项目名称:withSIX.Desktop,代码行数:32,代码来源:TextBlockTrimmedTooltip.cs
示例5: Highlight
public void Highlight(FormattedText text)
{
foreach (var item in Rules)
{
item.Highlight(text);
}
}
开发者ID:JackWangCUMT,项目名称:extensions,代码行数:7,代码来源:Highlighter.cs
示例6: GetTextOrigin
private static Point GetTextOrigin(ShapeStyle style, ref Rect rect, FormattedText ft)
{
double ox, oy;
switch (style.TextStyle.TextHAlignment)
{
case TextHAlignment.Left:
ox = rect.TopLeft.X;
break;
case TextHAlignment.Right:
ox = rect.Right - ft.Width;
break;
case TextHAlignment.Center:
default:
ox = (rect.Left + rect.Width / 2.0) - (ft.Width / 2.0);
break;
}
switch (style.TextStyle.TextVAlignment)
{
case TextVAlignment.Top:
oy = rect.TopLeft.Y;
break;
case TextVAlignment.Bottom:
oy = rect.Bottom - ft.Height;
break;
case TextVAlignment.Center:
default:
oy = (rect.Bottom - rect.Height / 2.0) - (ft.Height / 2.0);
break;
}
return new Point(ox, oy);
}
开发者ID:Core2D,项目名称:Core2D,代码行数:34,代码来源:WpfRenderer.cs
示例7: OnRender
/// <summary>
/// any custom drawing here
/// </summary>
/// <param name="drawingContext"></param>
protected override void OnRender(DrawingContext drawingContext)
{
base.OnRender(drawingContext);
if (selectedDirection != null && hasDirection == true)
{
//start = DateTime.Now;
//end = DateTime.Now;
//delta = (int)(end - start).TotalMilliseconds;
//FormattedText text = new FormattedText(string.Format(CultureInfo.InvariantCulture, "{0:0.0}", Zoom) + "z, " + MapProvider + ", refresh: " + counter++ + ", load: " + ElapsedMilliseconds + "ms, render: " + delta + "ms", CultureInfo.InvariantCulture, fd, tf, 20, Brushes.Blue);
//drawingContext.DrawText(text, new Point(text.Height, text.Height));
//text = null;
SolidColorBrush brush = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#FF072527"));
FormattedText text = new FormattedText("End location: " + selectedDirection.EndAddress + ".\nStart location: " + selectedDirection.StartAddress + ".\nDistance: " + selectedDirection.Distance + ", duration: " + selectedDirection.Duration, CultureInfo.InvariantCulture, fd, tf, 20, brush);
SolidColorBrush boxy = new SolidColorBrush(Color.FromArgb(130, 180, 180, 180));
drawingContext.DrawRectangle(boxy, new Pen(), new Rect(new Point(text.Height, text.Height), new Point(text.Height + text.Width, text.Height * 2)));
drawingContext.DrawText(text, new Point(text.Height, text.Height));
text = null;
}
}
开发者ID:MatejHrlec,项目名称:OculusView,代码行数:33,代码来源:Map.cs
示例8: BuildFaceModel
void BuildFaceModel( DrawingContext dc )
{
if ( produced ) {
FormattedText completed_msg = new FormattedText( "Status : Completed", CultureInfo.GetCultureInfo( "ja-JP" ), FlowDirection.LeftToRight, new Typeface( "Georgia" ), 25, Brushes.Green );
dc.DrawText( completed_msg, new Point( 50, 50 ) );
return;
}
if ( faceModelBuilder == null ) {
return;
}
FaceModelBuilderCollectionStatus collection;
collection = faceModelBuilder.CollectionStatus;
if ( collection == 0 ) {
return;
}
//Collection Status
FormattedText text = new FormattedText( "Status : " + collection.ToString(), CultureInfo.GetCultureInfo( "ja-JP" ), FlowDirection.LeftToRight, new Typeface( "Georgia" ), 25, Brushes.Green );
dc.DrawText( text, new Point( 50, 50 ) );
String status = status2string( collection );
text = new FormattedText( status, CultureInfo.GetCultureInfo( "ja-JP" ), FlowDirection.LeftToRight, new Typeface( "Georgia" ), 25, Brushes.Green );
dc.DrawText( text, new Point( 50, 80 ) );
//Capture Status
FaceModelBuilderCaptureStatus capture;
capture = faceModelBuilder.CaptureStatus;
if ( capture == 0 ) {
return;
}
status = status2string( capture );
text = new FormattedText( status, CultureInfo.GetCultureInfo( "ja-JP" ), FlowDirection.LeftToRight, new Typeface( "Georgia" ), 25, Brushes.Green );
dc.DrawText( text, new Point( 50, 110 ) );
return;
}
开发者ID:noa99kee,项目名称:K4W2-Book,代码行数:33,代码来源:MainWindow.xaml.cs
示例9: escribeTexto
private void escribeTexto()
{
string texto = "";
FormattedText frmTxt = new FormattedText(texto,
CultureInfo.GetCultureInfo("en-us"),
FlowDirection.LeftToRight, new Typeface("Verdana"), 32, Brushes.Black);
// Set a maximum width and height. If the text overflows these values, an ellipsis "..." appears.
frmTxt.MaxTextWidth = 300;
frmTxt.MaxTextHeight = 240;
// Use a larger font size beginning at the first (zero-based) character and continuing for 5 characters.
// The font size is calculated in terms of points -- not as device-independent pixels.
frmTxt.SetFontSize(36 * (96.0 / 72.0), 0, 5);
// Use a Bold font weight beginning at the 6th character and continuing for 11 characters.
frmTxt.SetFontWeight(FontWeights.Bold, 6, 11);
// Use a linear gradient brush beginning at the 6th character and continuing for 11 characters.
frmTxt.SetForegroundBrush(
new LinearGradientBrush(
Colors.Orange,
Colors.Teal,
90.0),
6, 11);
// Use an Italic font style beginning at the 28th character and continuing for 28 characters.
frmTxt.SetFontStyle(FontStyles.Italic, 28, 28);
//// Draw the formatted text string to the DrawingContext of the control.
//drawingContext.DrawText(frmTxt, new Point(10, 0));
}
开发者ID:amarodev,项目名称:PantallasCC,代码行数:31,代码来源:CuboHorario.xaml.cs
示例10: GetTrimmedPath
private string GetTrimmedPath(double width)
{
if (string.IsNullOrWhiteSpace(Path))
return string.Empty;
var filename = System.IO.Path.GetFileName(Path);
var directory = System.IO.Path.GetDirectoryName(Path);
bool widthOK;
var changedWidth = false;
do
{
FormattedText formatted = new FormattedText(
string.Format("{0}...\\{1}", directory, filename),
CultureInfo.CurrentCulture,
FlowDirection.LeftToRight,
FontFamily.GetTypefaces().First(),
FontSize,
Foreground);
widthOK = formatted.Width < (width * 0.95);
if (widthOK) continue;
changedWidth = true;
if (directory == null) return "...\\" + filename;
directory = directory.Substring(0, directory.Length - 1);
if (directory.Length == 0) return "...\\" + filename;
} while (!widthOK);
return !changedWidth ? Path : string.Format("{0}...{1}", directory, filename);
}
开发者ID:lycilph,项目名称:Projects,代码行数:33,代码来源:PathTrimmingTextBlock.cs
示例11: CreateFormattedText
public static FormattedText CreateFormattedText(ExportText exportText)
{
FlowDirection flowDirection;
var culture = CultureInfo.CurrentCulture;
if (culture.TextInfo.IsRightToLeft) {
flowDirection = FlowDirection.RightToLeft;
} else {
flowDirection = FlowDirection.LeftToRight;
}
var emSize = ExtensionMethodes.ToPoints((int)exportText.Font.SizeInPoints +1);
var formattedText = new FormattedText(exportText.Text,
CultureInfo.CurrentCulture,
flowDirection,
new Typeface(exportText.Font.FontFamily.Name),
emSize,
new SolidColorBrush(exportText.ForeColor.ToWpf()), null, TextFormattingMode.Display);
formattedText.MaxTextWidth = ExtensionMethodes.ToPoints(exportText.DesiredSize.Width);
ApplyPrintStyles(formattedText,exportText);
return formattedText;
}
开发者ID:hefnerliu,项目名称:SharpDevelop,代码行数:26,代码来源:FixedDocumentCreator.cs
示例12: UpdateVisual
/// <summary>
/// Store <paramref name="timeStamp"/> and updates the text for the visual.
/// </summary>
/// <param name="timeStamp">Time of the event.</param>
/// <param name="line">The line that this time stamp corresponds to.</param>
/// <param name="view">The <see cref="IWpfTextView"/> to whom the <paramref name="line"/> belongs.</param>
/// <param name="formatting">Properties for the time stamp text.</param>
/// <param name="marginWidth">Used to calculate the horizontal offset for <see cref="OnRender(DrawingContext)"/>.</param>
/// <param name="verticalOffset">Used to calculate the vertical offset for <see cref="OnRender(DrawingContext)"/>.</param>
/// <param name="showHours">Option to show hours on the time stamp.</param>
/// <param name="showMilliseconds">Option to show milliseconds on the time stamp.</param>
internal void UpdateVisual(DateTime timeStamp, ITextViewLine line, IWpfTextView view, TextRunProperties formatting, double marginWidth, double verticalOffset,
bool showHours, bool showMilliseconds)
{
this.LineTag = line.IdentityTag;
if (timeStamp != this.TimeStamp)
{
this.TimeStamp = timeStamp;
string text = GetFormattedTime(timeStamp, showHours, showMilliseconds);
TextFormattingMode textFormattingMode = view.FormattedLineSource.UseDisplayMode ? TextFormattingMode.Display : TextFormattingMode.Ideal;
_text = new FormattedText(text, CultureInfo.InvariantCulture, FlowDirection.LeftToRight,
formatting.Typeface, formatting.FontRenderingEmSize, formatting.ForegroundBrush,
InvariantNumberSubstitution, textFormattingMode);
_horizontalOffset = Math.Round(marginWidth - _text.Width);
this.InvalidateVisual(); // force redraw
}
double newVerticalOffset = line.TextTop - view.ViewportTop + verticalOffset;
if (newVerticalOffset != _verticalOffset)
{
_verticalOffset = newVerticalOffset;
this.InvalidateVisual(); // force redraw
}
}
开发者ID:xornand,项目名称:VS-PPT,代码行数:36,代码来源:TimeStampVisual.cs
示例13: Window_Loaded
private void Window_Loaded(object sender, RoutedEventArgs e)
{
const int TextFontSize = 30;
// Make a System.Windows.Media.FormattedText object.
FormattedText text = new FormattedText("Hello Visual Layer!",
new System.Globalization.CultureInfo("en-us"),
FlowDirection.LeftToRight,
new Typeface(this.FontFamily, FontStyles.Italic,
FontWeights.DemiBold, FontStretches.UltraExpanded),
TextFontSize,
Brushes.Green);
// Create a DrawingVisual, and obtain the DrawingContext.
DrawingVisual drawingVisual = new DrawingVisual();
using (DrawingContext drawingContext = drawingVisual.RenderOpen())
{
// Now, call any of the methods of DrawingContext to render data.
drawingContext.DrawRoundedRectangle(Brushes.Yellow, new Pen(Brushes.Black, 5),
new Rect(5, 5, 450, 100), 20, 20);
drawingContext.DrawText(text, new Point(20, 20));
}
// Dynamically make a bitmap, using the data in the DrawingVisual.
RenderTargetBitmap bmp = new RenderTargetBitmap(500, 100, 100, 90, PixelFormats.Pbgra32);
bmp.Render(drawingVisual);
// Set the source of the Image control!
myImage.Source = bmp;
}
开发者ID:usedflax,项目名称:flaxbox,代码行数:30,代码来源:MainWindow.xaml.cs
示例14: DrawBar
private void DrawBar(DrawingContext drawingContext, int row, int column, FormattedText font)
{
drawingContext.DrawLine(
new Pen(Foreground, 2),
new Point(column * font.Width, row * font.Height),
new Point(column * font.Width, (row + 1) * font.Height));
}
开发者ID:faboo,项目名称:Agent,代码行数:7,代码来源:CursorPresenter.cs
示例15: OnRender
protected override void OnRender(System.Windows.Media.DrawingContext drawingContext)
{
double fontSize;
Typeface typeFace;
TextAlignment alignment;
FlowDirection flowDirection;
double padding;
if (AdornedPasswordBox != null) {
alignment = ConvertAlignment (AdornedPasswordBox.HorizontalContentAlignment);
flowDirection = AdornedPasswordBox.FlowDirection;
fontSize = AdornedPasswordBox.FontSize;
typeFace = AdornedPasswordBox.FontFamily.GetTypefaces ().FirstOrDefault ();
padding = 6;
}
else {
alignment = AdornedTextBox.ReadLocalValue (TextBox.TextAlignmentProperty) !=DependencyProperty.UnsetValue ? AdornedTextBox.TextAlignment : ConvertAlignment (AdornedTextBox.HorizontalContentAlignment);
flowDirection = AdornedTextBox.FlowDirection;
fontSize = AdornedTextBox.FontSize;
typeFace = AdornedTextBox.FontFamily.GetTypefaces ().FirstOrDefault ();
padding = 6;
}
var text = new System.Windows.Media.FormattedText (PlaceholderText ?? "", CultureInfo.CurrentCulture, flowDirection, typeFace, fontSize, System.Windows.Media.Brushes.LightGray) {
TextAlignment = alignment
};
drawingContext.DrawText (text, new System.Windows.Point (padding, (RenderSize.Height - text.Height) / 2));
}
开发者ID:nite2006,项目名称:xwt,代码行数:27,代码来源:PlaceholderTextAdorner.cs
示例16: ConstructElement
/// <inheritdoc/>
public override VisualLineElement ConstructElement(int offset)
{
if (FoldingManager == null)
return null;
int foldedUntil = -1;
string title = null;
foreach (FoldingSection fs in FoldingManager.GetFoldingsAt(offset)) {
if (fs.IsFolded) {
if (fs.EndOffset > foldedUntil) {
foldedUntil = fs.EndOffset;
title = fs.Title;
}
}
}
if (foldedUntil > offset) {
if (string.IsNullOrEmpty(title))
title = "...";
FormattedText text = new FormattedText(
title,
CurrentContext.GlobalTextRunProperties.CultureInfo,
FlowDirection.LeftToRight,
CurrentContext.GlobalTextRunProperties.Typeface,
CurrentContext.GlobalTextRunProperties.FontRenderingEmSize,
Brushes.Gray
);
return new FoldingLineElement(text, foldedUntil - offset);
} else {
return null;
}
}
开发者ID:kjk,项目名称:kjkpub,代码行数:31,代码来源:FoldingElementGenerator.cs
示例17: Render
public override void Render(DrawingContext dc, Point screenPoint)
{
Point dataPoint = screenPoint.ScreenToData(this.ct.Transform);
Point dataPointZero = new Point(dataPoint.X,0.0);
Point screenPointZero = dataPointZero.DataToScreen(this.ct.Transform);
//const double verticalShift = 5; // px
//dc.DrawLine(new Pen(Brushes.Black, 1), Point.Add(screenPoint, new Vector(0, 40)), screenPoint);
double pointx = screenPointZero.X + 2;
double pointy = screenPointZero.Y + 2;
FormattedText textToDraw = new FormattedText(dataPoint.Y.ToString("0.000"), Thread.CurrentThread.CurrentCulture,
FlowDirection.LeftToRight, new Typeface("Arial"), 12, Brushes.Black);
dc.DrawText(textToDraw, new Point(pointx, pointy));
/*
string svalue = dataPoint.Y.ToString("0.000");
foreach (var s in svalue)
{
if (s.Equals('.'))
continue;
FormattedText textToDraw = new FormattedText(s.ToString(), Thread.CurrentThread.CurrentCulture,
FlowDirection.LeftToRight, new Typeface("Arial"), 12, Brushes.Black);
dc.DrawText(textToDraw, new Point(pointx,pointy));
pointy = pointy + 10;
}
* */
}
开发者ID:supercrawler,项目名称:Chinchilla,代码行数:30,代码来源:XValueTextMarker.cs
示例18: ZTextBufferWindow
public ZTextBufferWindow(ZWindowManager manager, FontAndColorService fontAndColorService)
: base(manager, fontAndColorService)
{
this.normalFontFamily = new FontFamily("Cambria");
this.fixedFontFamily = new FontFamily("Consolas");
var zero = new FormattedText(
textToFormat: "0",
culture: CultureInfo.InstalledUICulture,
flowDirection: FlowDirection.LeftToRight,
typeface: new Typeface(normalFontFamily, FontStyles.Normal, FontWeights.Normal, FontStretches.Normal),
emSize: this.FontSize,
foreground: Brushes.Black);
this.fontCharSize = new Size(zero.Width, zero.Height);
this.document = new FlowDocument
{
FontFamily = normalFontFamily,
FontSize = this.FontSize,
PagePadding = new Thickness(8.0)
};
this.paragraph = new Paragraph();
this.document.Blocks.Add(this.paragraph);
this.scrollViewer = new FlowDocumentScrollViewer
{
FocusVisualStyle = null,
Document = this.document
};
this.Children.Add(this.scrollViewer);
}
开发者ID:modulexcite,项目名称:NZag,代码行数:34,代码来源:ZTextBufferWindow.cs
示例19: DrawVisualThumbnail
protected override void DrawVisualThumbnail(System.Windows.Media.DrawingContext drawingContext, out string title, ref BitmapSource icon)
{
var aeroColor = (Color)Application.Current.Resources["AeroColor"];
var aeroBrush = new SolidColorBrush(aeroColor);
var aeroPen = new Pen(aeroBrush, 7);
var grayBrush = new SolidColorBrush(Color.FromArgb(255, 0xaf, 0xaf, 0xaf));
var fontFamily = (FontFamily)Application.Current.Resources["CuprumFont"];
var typeface = new Typeface(fontFamily, FontStyles.Normal, FontWeights.Light, FontStretches.Normal);
const int sourceTextOffset = VisualThumbnailMargin;
var sourceText = new FormattedText(Name, CultureInfo.CurrentCulture, FlowDirection.LeftToRight,
typeface, 14, grayBrush);
sourceText.MaxTextWidth = VisualThumbnailWidth - sourceTextOffset - VisualThumbnailMargin;
sourceText.MaxTextHeight = 32;
var imageRectangle = new Rect(VisualThumbnailWidth / 2 - 64 / 2, VisualThumbnailHeight / 2 - 64 / 2, 64, 64);
drawingContext.DrawRectangle(Brushes.White, aeroPen, new Rect(-1, -1, VisualThumbnailWidth + 2, VisualThumbnailHeight + 2));
drawingContext.DrawImage(Icon, imageRectangle);
drawingContext.DrawText(sourceText, new Point(sourceTextOffset, VisualThumbnailHeight - VisualThumbnailMargin - 16));
title = Name + " from " + Source.ApplicationName;
}
开发者ID:Zargess,项目名称:Shapeshifter-old,代码行数:27,代码来源:ClipboardCustomData.cs
示例20: GetPage
public override DocumentPage GetPage(int pageNumber)
{
// Get the requested page.
DocumentPage page = flowDocumentPaginator.GetPage(pageNumber);
// Wrap the page in a Visual. You can then add a transformation and extras.
ContainerVisual newVisual = new ContainerVisual();
newVisual.Children.Add(page.Visual);
// Create a header.
DrawingVisual header = new DrawingVisual();
using (DrawingContext context = header.RenderOpen())
{
Typeface typeface = new Typeface("Times New Roman");
FormattedText text = new FormattedText("Page " + (pageNumber + 1).ToString(),
CultureInfo.CurrentCulture, FlowDirection.LeftToRight,
typeface, 14, Brushes.Black);
// Leave a quarter-inch of space between the page edge and this text.
context.DrawText(text, new Point(96*0.25, 96*0.25));
}
// Add the title to the visual.
newVisual.Children.Add(header);
// Wrap the visual in a new page.
DocumentPage newPage = new DocumentPage(newVisual);
return newPage;
}
开发者ID:ittray,项目名称:LocalDemo,代码行数:28,代码来源:HeaderedFlowDocumentPaginator.cs
注:本文中的System.Windows.Media.FormattedText类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论