本文整理汇总了C#中SharpDX.DirectWrite.TextFormat类的典型用法代码示例。如果您正苦于以下问题:C# TextFormat类的具体用法?C# TextFormat怎么用?C# TextFormat使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
TextFormat类属于SharpDX.DirectWrite命名空间,在下文中一共展示了TextFormat类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Initialize
protected override void Initialize(DemoConfiguration demoConfiguration)
{
base.Initialize(demoConfiguration);
// Initialize a TextFormat
TextFormat = new TextFormat(FactoryDWrite, "Calibri", 128) {TextAlignment = TextAlignment.Center, ParagraphAlignment = ParagraphAlignment.Center};
RenderTarget2D.TextAntialiasMode = TextAntialiasMode.Cleartype;
// Initialize a TextLayout
TextLayout = new TextLayout(FactoryDWrite, "SharpDX D2D1 - DWrite", TextFormat, demoConfiguration.Width, demoConfiguration.Height);
}
示例2: Radar
public Radar(CSGOTheme theme, TextFormat font, float resolution) : base(theme, font) {
this.Width = 256f;
this.Height = 256f;
this.dotSize = 6f;
this.viewX = 24f;
this.viewY = 48f;
}
示例3: FormattedTextImpl
public FormattedTextImpl(
string text,
string fontFamily,
double fontSize,
FontStyle fontStyle,
TextAlignment textAlignment,
FontWeight fontWeight,
TextWrapping wrapping)
{
var factory = AvaloniaLocator.Current.GetService<DWrite.Factory>();
using (var format = new DWrite.TextFormat(
factory,
fontFamily,
(DWrite.FontWeight)fontWeight,
(DWrite.FontStyle)fontStyle,
(float)fontSize))
{
format.WordWrapping = wrapping == TextWrapping.Wrap ?
DWrite.WordWrapping.Wrap : DWrite.WordWrapping.NoWrap;
TextLayout = new DWrite.TextLayout(
factory,
text ?? string.Empty,
format,
float.MaxValue,
float.MaxValue);
}
TextLayout.TextAlignment = textAlignment.ToDirect2D();
}
示例4: OnLoad
protected override void OnLoad(EventArgs e)
{
base.OnLoad(e);
// Direct2D
var renderTargetProperties = new RenderTargetProperties()
{
PixelFormat = new PixelFormat(SharpDX.DXGI.Format.B8G8R8A8_UNorm, AlphaMode.Ignore)
};
var hwndRenderTargetProperties = new HwndRenderTargetProperties()
{
Hwnd = this.Handle,
PixelSize = new Size2(bounds.Width, bounds.Height),
PresentOptions = PresentOptions.Immediately,
};
renderTarget = new WindowRenderTarget(factory, renderTargetProperties, hwndRenderTargetProperties);
var bitmapProperties = new BitmapProperties()
{
PixelFormat = new PixelFormat(SharpDX.DXGI.Format.B8G8R8A8_UNorm, AlphaMode.Ignore)
};
bitmap = new SharpDX.Direct2D1.Bitmap(renderTarget, new Size2(bounds.Width, bounds.Height), bitmapProperties);
textFormat = new TextFormat(directWriteFacrtory, "Arial", FontWeight.Normal, SharpDX.DirectWrite.FontStyle.Normal, 96.0f);
textFormat.ParagraphAlignment = ParagraphAlignment.Center;
textFormat.TextAlignment = TextAlignment.Center;
solidColorBrush = new SolidColorBrush(renderTarget, Color4.White);
}
示例5: ListPanel
public ListPanel(Theme theme, TextFormat font, float x, float y, float width, float height, float paddingX, float paddingY, float spaceY)
: base(theme, font, x, y, width, height)
{
this.paddingX = paddingX;
this.paddingY = paddingY;
this.spaceY = spaceY;
}
示例6: MenuItem
public MenuItem(Theme theme, TextFormat font, float x, float y, float width, float height, Menu parentMenu, string text, string extraData)
: base(theme, font, x, y, width, height)
{
this.parentMenu = parentMenu;
this.Text = text;
this.extraData = extraData;
}
示例7: Label
public Label(Theme theme, TextFormat font, float x, float y, float width, float height, string text)
: base(theme, font, x, y, width, height)
{
this.Text = text;
this.align = HorizontalAlign.Left;
this.castShadow = false;
}
示例8: Initialize
public virtual void Initialize(DeviceManager deviceManager)
{
sceneColorBrush = new SolidColorBrush(deviceManager.ContextDirect2D, Color.Blue);
textFormat = new TextFormat(deviceManager.FactoryDirectWrite, "Calibri", 20) { TextAlignment = TextAlignment.Leading, ParagraphAlignment = ParagraphAlignment.Center };
clock = Stopwatch.StartNew();
deviceManager.ContextDirect2D.TextAntialiasMode = TextAntialiasMode.Grayscale;
}
示例9: FormattedTextImpl
public FormattedTextImpl(
string text,
string fontFamily,
double fontSize,
FontStyle fontStyle,
TextAlignment textAlignment,
FontWeight fontWeight)
{
var factory = Locator.Current.GetService<DWrite.Factory>();
var format = new DWrite.TextFormat(
factory,
fontFamily,
(DWrite.FontWeight)fontWeight,
(DWrite.FontStyle)fontStyle,
(float)fontSize);
TextLayout = new DWrite.TextLayout(
factory,
text ?? string.Empty,
format,
float.MaxValue,
float.MaxValue);
TextLayout.TextAlignment = textAlignment.ToDirect2D();
}
示例10: InfoText
public InfoText(SharpDX.Direct3D11.Device device, int width, int height)
{
_immediateContext = device.ImmediateContext;
_rect.Size = new Size2F(width, height);
_bitmapSize = width * height * 4;
IsEnabled = true;
using (var factoryWic = new SharpDX.WIC.ImagingFactory())
{
_wicBitmap = new SharpDX.WIC.Bitmap(factoryWic,
width, height, _pixelFormat, SharpDX.WIC.BitmapCreateCacheOption.CacheOnLoad);
}
var renderTargetProperties = new RenderTargetProperties(RenderTargetType.Default,
new SharpDX.Direct2D1.PixelFormat(SharpDX.DXGI.Format.R8G8B8A8_UNorm,
SharpDX.Direct2D1.AlphaMode.Premultiplied), 0, 0, RenderTargetUsage.None,
SharpDX.Direct2D1.FeatureLevel.Level_DEFAULT);
using (var factory2D = new SharpDX.Direct2D1.Factory())
{
_wicRenderTarget = new WicRenderTarget(factory2D, _wicBitmap, renderTargetProperties);
_wicRenderTarget.TextAntialiasMode = TextAntialiasMode.Default;
}
using (var factoryDWrite = new SharpDX.DirectWrite.Factory(SharpDX.DirectWrite.FactoryType.Shared))
{
_textFormat = new TextFormat(factoryDWrite, "Tahoma", 20);
}
Color4 color = new Color4(1, 1, 1, 1);
_sceneColorBrush = new SolidColorBrush(_wicRenderTarget, color);
_clearColor = color;
_clearColor.Alpha = 0;
_renderTexture = new Texture2D(device, new Texture2DDescription()
{
ArraySize = 1,
BindFlags = BindFlags.ShaderResource,
CpuAccessFlags = CpuAccessFlags.Write,
Format = Format.R8G8B8A8_UNorm,
Height = height,
Width = width,
MipLevels = 1,
OptionFlags = ResourceOptionFlags.None,
SampleDescription = new SampleDescription(1, 0),
Usage = ResourceUsage.Dynamic
});
OverlayBufferRes = new ShaderResourceView(device, _renderTexture, new ShaderResourceViewDescription()
{
Format = _renderTexture.Description.Format,
Dimension = ShaderResourceViewDimension.Texture2D,
Texture2D = new ShaderResourceViewDescription.Texture2DResource()
{
MipLevels = 1,
MostDetailedMip = 0
}
});
}
示例11: Initialize
//public static Brush TEXT_BRUSH;
public static void Initialize(RenderTarget g)
{
SCBRUSH_RED = new SolidColorBrush(g, Color.Red);
SCBRUSH_BLACK = new SolidColorBrush(g, Color.Black);
WRITE_FACTORY = new SharpDX.DirectWrite.Factory();
TEXT_FORMAT = new TextFormat(WRITE_FACTORY, "Arial", 14);
//TEXT_BRUSH = new SolidColorBrush(g, Color.Red);
}
示例12: ProgressBar
public ProgressBar(ProgressBarTheme theme, TextFormat font, float x, float y, float width, float height, float value, float maxValue, bool blinkingEnabled, float blinkingThreshold)
: base(theme, font, x, y, width, height)
{
this.currValue = value;
this.maxValue = maxValue;
this.blinkingEnabled = blinkingEnabled;
this.blinkingThreshold = blinkingThreshold;
}
示例13: KeyMenuItem
public KeyMenuItem(Theme theme, TextFormat font, float x, float y, float width, float height, Menu parentMenu, string text, string extraData, Keys key)
: base(theme, font, x, y, width, height, parentMenu, text, extraData)
{
this.Key = key;
this.acceptKey = false;
if (Program.GameImplementation.HasKey(this.ExtraData))
this.Key = Program.GameImplementation.GetValue<Keys>(this.ExtraData);
}
示例14: TrackbarMenuItem
public TrackbarMenuItem(Theme theme, TextFormat font, float x, float y, float width, float height, Menu parentMenu, string text, float min, float max, float step, float value, string extraData)
: base(theme, font, x, y, width, height, parentMenu, text, extraData)
{
this.minimum = min;
this.maximum = max;
this.value = value;
this.step = step;
if (Program.GameImplementation.HasKey(this.ExtraData))
this.value = Program.GameImplementation.GetValue<float>(this.ExtraData);
}
示例15: EngineInfoDrawer
public EngineInfoDrawer(RenderTarget renderTarget)
{
var factory = new DW.Factory(DW.FactoryType.Shared);
defaultBrush = new SolidColorBrush(renderTarget, Color.Black);
defaultTextFormat = new TextFormat(factory, "Microsoft Yahei Mono", FONT_SIZE);
defaultRectangleFList = new RectangleF[MAX_ROW_COUNT];
for (int i = 0; i < MAX_ROW_COUNT; i++) {
defaultRectangleFList[i] = new RectangleF(0, i * FONT_SIZE, ROW_WEIGHT, FONT_SIZE);
}
}