本文整理汇总了C#中TextFormat类的典型用法代码示例。如果您正苦于以下问题:C# TextFormat类的具体用法?C# TextFormat怎么用?C# TextFormat使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
TextFormat类属于命名空间,在下文中一共展示了TextFormat类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: TryFormatUInt64
internal static bool TryFormatUInt64(ulong value, byte numberOfBytes, Span<byte> buffer, TextFormat format, EncodingData formattingData, out int bytesWritten)
{
if(format.Symbol == 'g')
{
format.Symbol = 'G';
}
if (format.IsHexadecimal && formattingData.IsInvariantUtf16) {
return TryFormatHexadecimalInvariantCultureUtf16(value, buffer, format, out bytesWritten);
}
if (format.IsHexadecimal && formattingData.IsInvariantUtf8) {
return TryFormatHexadecimalInvariantCultureUtf8(value, buffer, format, out bytesWritten);
}
if ((formattingData.IsInvariantUtf16) && (format.Symbol == 'D' || format.Symbol == 'G')) {
return TryFormatDecimalInvariantCultureUtf16(value, buffer, format, out bytesWritten);
}
if ((formattingData.IsInvariantUtf8) && (format.Symbol == 'D' || format.Symbol == 'G')) {
return TryFormatDecimalInvariantCultureUtf8(value, buffer, format, out bytesWritten);
}
return TryFormatDecimal(value, buffer, format, formattingData, out bytesWritten);
}
开发者ID:AlexGhiondea,项目名称:corefxlab,代码行数:25,代码来源:IntegerFormatter.cs
示例2: OnCreateDeviceIndependentResources
protected override void OnCreateDeviceIndependentResources(Direct2DFactory factory)
{
base.OnCreateDeviceIndependentResources(factory);
this._textFormat = DirectWriteFactory.CreateTextFormat("Gabriola",
FontWeight.Normal,
FontStyle.Normal,
FontStretch.Normal,
72);
this._textFormat.TextAlignment = TextAlignment.Center;
this._textFormat.ParagraphAlignment = ParagraphAlignment.Center;
float width = ClientSize.Width / _dpiScaleX;
float height = ClientSize.Height / _dpiScaleY;
this._textLayout = DirectWriteFactory.CreateTextLayout(
_text,
this._textFormat,
width,
height);
this._textLayout.SetFontSize(100, new TextRange(20, 6));
this._textLayout.SetUnderline(true, new TextRange(20, 11));
this._textLayout.SetFontWeight(FontWeight.Bold, new TextRange(20, 11));
using (Typography typography = DirectWriteFactory.CreateTypography())
{
typography.AddFontFeature(FontFeatureTag.StylisticSet7, 1);
this._textLayout.SetTypography(typography, new TextRange(0, _text.Length));
}
}
开发者ID:eugeniomiro,项目名称:Terrarium,代码行数:32,代码来源:CustomTextControl.cs
示例3: Button
public Button(DisplayObject upState, string text ="", DisplayObject downState=null, TextFormat format=null)
{
//if (upState == null) throw new ErrorEvent("Texture cannot be null");
mParent = upState.parent;
mUpState = upState;
mDownState = downState != null ? downState : upState;
mBackground = upState;
mTextFormat = format;
mScaleWhenDown = 0.9f;
mAlphaWhenDisabled = 0.5f;
mEnabled = true;
mIsDown = false;
mUseHandCursor = true;
mTextBounds = new Rectangle(0, 0, upState.width, upState.height);
mContents = new Sprite();
mContents.addChild(mBackground);
addChild(mContents);
//addEventListener(TouchEvent.TOUCH, onTouch);
addEventListener(MouseEvent.MOUSE_DOWN, onMouseDown);
if (text.Length > 0) this.text = text;
this.x = upState.x;
this.y = upState.y;
upState.x = upState.y = 0;
if(mParent != null)
(mParent as MovieClip).addChild(this);
}
开发者ID:crl,项目名称:UniStarling,代码行数:33,代码来源:Button.cs
示例4: Start
void Start ( ) {
BMFontReader.registerFonts( bmFonts );
// Font linkage from swf using font name & size mapping
stage.addChild( new MovieClip("uniSWF/Examples/Extra examples/BMFont reader/swf/bmfonttest.swf:Font") );
// Add Text to stage
TextFormat format = new TextFormat();
format.font = "Times Bold";
format.color = Color.green;
format.size = 64;
BitmapTextField txt = new BitmapTextField( );
txt.width = 500;
txt.height = 200;
txt.textFormat = format;
txt.text = "BMText set from code";
txt.y = 100;
txt.x = 10;
txt.type = TextFieldType.INPUT;
txt.addCharColor( 7, 9, Color.cyan );
txt.addCharColor( 16, 19, Color.red );
txt.appendText( ", Appended text" );
stage.addChild( txt );
}
开发者ID:Angryman80,项目名称:spi,代码行数:31,代码来源:BMFontReaderExample.cs
示例5: OnCreateDeviceIndependentResources
protected override void OnCreateDeviceIndependentResources(Direct2DFactory factory)
{
base.OnCreateDeviceIndependentResources(factory);
this._textFormat = DirectWriteFactory.CreateTextFormat("Gabriola", 72);
this._textFormat.TextAlignment = TextAlignment.Center;
this._textFormat.ParagraphAlignment = ParagraphAlignment.Center;
float width = ClientSize.Width / dpiScaleX;
float height = ClientSize.Height / dpiScaleY;
this._textLayout = DirectWriteFactory.CreateTextLayout("Click on this text Click on this text", this._textFormat, width, height);
this._textAnalyzer = DirectWriteFactory.CreateTextAnalyzer();
this._source = new MyTextSource("Click on this text Click on this text");
using (FontCollection coll = this._textFormat.FontCollection)
{
int count = coll.Count;
for (int index = 0; index < count; ++index)
{
using (FontFamily ff = coll[index])
{
using (Font font = ff.GetFirstMatchingFont(FontWeight.Normal, FontStretch.Normal, FontStyle.Normal))
{
LocalizedStrings ls = font.FaceNames;
LocalizedStrings desc = font.GetInformationalStrings(InformationalStringId.Designer);
int cultureIndex = ls.FindCulture(CultureInfo.CurrentCulture);
string faceName = ls[cultureIndex];
FontMetrics metrics = font.Metrics;
}
}
}
}
this._textAnalyzer.AnalyzeLineBreakpoints(_source, 0, (uint)_source.Text.Length);
this._textAnalyzer.AnalyzeScript(_source, 0, (uint)_source.Text.Length);
}
开发者ID:eugeniomiro,项目名称:Terrarium,代码行数:33,代码来源:MainWindow.cs
示例6: TryFormatInt64
internal static bool TryFormatInt64(long value, byte numberOfBytes, Span<byte> buffer, TextFormat format, EncodingData formattingData, out int bytesWritten)
{
Precondition.Require(numberOfBytes <= sizeof(long));
if (value >= 0)
{
return TryFormatUInt64(unchecked((ulong)value), numberOfBytes, buffer, format, formattingData, out bytesWritten);
}
else if (format.IsHexadecimal)
{
ulong bitMask = GetBitMask(numberOfBytes);
return TryFormatUInt64(unchecked((ulong)value) & bitMask, numberOfBytes, buffer, format, formattingData, out bytesWritten);
}
else
{
int minusSignBytes = 0;
if(!formattingData.TryEncode(EncodingData.Symbol.MinusSign, buffer, out minusSignBytes))
{
bytesWritten = 0;
return false;
}
int digitBytes = 0;
if(!TryFormatUInt64(unchecked((ulong)-value), numberOfBytes, buffer.Slice(minusSignBytes), format, formattingData, out digitBytes))
{
bytesWritten = 0;
return false;
}
bytesWritten = digitBytes + minusSignBytes;
return true;
}
}
开发者ID:AlexGhiondea,项目名称:corefxlab,代码行数:32,代码来源:IntegerFormatter.cs
示例7: OnCreateDeviceIndependentResources
protected override void OnCreateDeviceIndependentResources(Direct2DFactory factory)
{
base.OnCreateDeviceIndependentResources(factory);
this._textFormat = DirectWriteFactory.CreateTextFormat("Gabriola",
FontWeight.Normal,
FontStyle.Normal,
FontStretch.Normal,
72);
this._textFormat.TextAlignment = TextAlignment.Center;
this._textFormat.ParagraphAlignment = ParagraphAlignment.Center;
float width = ClientSize.Width / _dpiScaleX;
float height = ClientSize.Height / _dpiScaleY;
this._textLayout = DirectWriteFactory.CreateTextLayout(
_text,
this._textFormat,
width,
height);
using (Typography typography = DirectWriteFactory.CreateTypography())
{
typography.AddFontFeature(FontFeatureTag.StylisticSet7, 1);
this._textLayout.SetTypography(typography, new TextRange(0, _text.Length));
}
Bitmap bitmap = RenderTarget.CreateBitmap(this.GetType(), "heart.png");
this._bitmapInlineObject = new BitmapInlineObject(RenderTarget, bitmap);
this._textLayout.SetInlineObject(this._bitmapInlineObject, new TextRange(2, 1));
}
开发者ID:eugeniomiro,项目名称:Terrarium,代码行数:34,代码来源:InlineObjectControl.cs
示例8: TryFormat
public static bool TryFormat(this DateTime value, Span<byte> buffer, TextFormat format, EncodingData formattingData, out int bytesWritten)
{
if (format.IsDefault)
{
format.Symbol = 'G';
}
Precondition.Require(format.Symbol == 'R' || format.Symbol == 'O' || format.Symbol == 'G');
switch (format.Symbol)
{
case 'R':
var utc = value.ToUniversalTime();
if (formattingData.IsInvariantUtf16)
{
return TryFormatDateTimeRfc1123(utc, buffer, EncodingData.InvariantUtf16, out bytesWritten);
}
else
{
return TryFormatDateTimeRfc1123(utc, buffer, EncodingData.InvariantUtf8, out bytesWritten);
}
case 'O':
if (formattingData.IsInvariantUtf16)
{
return TryFormatDateTimeFormatO(value, true, buffer, EncodingData.InvariantUtf16, out bytesWritten);
}
else
{
return TryFormatDateTimeFormatO(value, true, buffer, EncodingData.InvariantUtf8, out bytesWritten);
}
case 'G':
return TryFormatDateTimeFormagG(value, buffer, formattingData, out bytesWritten);
default:
throw new NotImplementedException();
}
}
开发者ID:AlexGhiondea,项目名称:corefxlab,代码行数:35,代码来源:PrimitiveFormatter_time.cs
示例9: CreateTextFormat
private void CreateTextFormat()
{
var factory = new SlimDX.DirectWrite.Factory(SlimDX.DirectWrite.FactoryType.Shared);
mTextFormat = factory.CreateTextFormat("Consola", FontWeight.Normal,
SlimDX.DirectWrite.FontStyle.Normal, FontStretch.Normal, 100, "en-us");
mTextFormat.TextAlignment = TextAlignment.Center;
mTextFormat.ParagraphAlignment = ParagraphAlignment.Center;
}
开发者ID:Christof,项目名称:ionfish,代码行数:8,代码来源:TextRenderTarget.cs
示例10: When
public ScenarioBuilder When(
string stepName,
Action<Step> action = null,
string multilineParameter = "",
TextFormat multilineParameterFormat = TextFormat.text)
{
var step = factory.CreateStep(stepName, action, multilineParameter, multilineParameterFormat);
return When(step);
}
开发者ID:Stewartarmbrecht,项目名称:xBDD,代码行数:9,代码来源:ScenarioBuilder.cs
示例11: CreateStep
public static Step CreateStep(
string stepName,
Action<Step> action = null,
string multilineParameter = "",
TextFormat multilineParameterFormat = TextFormat.text)
{
action = action ?? ((s) => { });
return factory.CreateStep(stepName, action, multilineParameter, multilineParameterFormat);
}
开发者ID:Stewartarmbrecht,项目名称:xBDD,代码行数:9,代码来源:xB.cs
示例12: CreateAsyncStep
public static Step CreateAsyncStep(
string stepName,
Func<Step, Task> action = null,
string multilineParameter = "",
TextFormat multilineParameterFormat = TextFormat.text)
{
action = action ?? ((s) => { return Task.Run(() => { }); });
return factory.CreateStep(stepName, action, multilineParameter, multilineParameterFormat);
}
开发者ID:Stewartarmbrecht,项目名称:xBDD,代码行数:9,代码来源:xB.cs
示例13: TryFormat
public static bool TryFormat(this float value, Span<byte> buffer, TextFormat format, EncodingData formattingData, out int bytesWritten)
{
if (format.IsDefault)
{
format.Symbol = 'G';
}
Precondition.Require(format.Symbol == 'G');
return FloatFormatter.TryFormatNumber(value, true, buffer, format, formattingData, out bytesWritten);
}
开发者ID:AlexGhiondea,项目名称:corefxlab,代码行数:9,代码来源:PrimitiveFormatter_float.cs
示例14: GivenAsync
public ScenarioBuilder GivenAsync(
string stepName,
Func<Step, Task> action = null,
string multilineParameter = "",
TextFormat multilineParameterFormat = TextFormat.text)
{
var step = factory.CreateStep(stepName, action, multilineParameter, multilineParameterFormat);
return Given(step);
}
开发者ID:Stewartarmbrecht,项目名称:xBDD,代码行数:9,代码来源:ScenarioBuilder.cs
示例15: DrawString
public void DrawString(string text, Rectangle rectangle, TextFormat format, Color4 color)
{
QFont.Begin();
_font.Options.Colour = color.ToGLColor4();
_font.Print(text, new OpenTK.Vector2(rectangle.X, rectangle.Y));
QFont.End();
}
开发者ID:HaKDMoDz,项目名称:Psy,代码行数:9,代码来源:WrappedFont.cs
示例16: CreateStep
internal Step CreateStep(string stepName, Func<Step, Task> action, string multilineParameter, TextFormat multilineParameterFormat)
{
return new Step()
{
Name = stepName,
ActionAsync = action,
MultilineParameter = multilineParameter,
MultilineParameterFormat = multilineParameterFormat
};
}
开发者ID:Stewartarmbrecht,项目名称:xBDD,代码行数:10,代码来源:CoreFactory.cs
示例17: GetInputData
internal static List<Point> GetInputData(string file, TextFormat fmt)
{
if (fmt == TextFormat.csv)
{
return GetCsvData(file);
}
if (fmt == TextFormat.vic)
{
return GetVicData(file);
}
return new List<Point> { };
}
开发者ID:usbr,项目名称:BiasCorrectQ,代码行数:12,代码来源:Program.cs
示例18: TryFormat
public bool TryFormat(Span<byte> buffer, out int bytesWritten, TextFormat format, EncodingData encoding)
{
if (!PrimitiveFormatter.TryFormat(_age, buffer, out bytesWritten, format, encoding)) return false;
char symbol = _inMonths ? 'm' : 'y';
int symbolBytes;
if (!PrimitiveFormatter.TryEncode(symbol, buffer.Slice(bytesWritten), out symbolBytes, encoding.TextEncoding)) return false;
bytesWritten += symbolBytes;
return true;
}
开发者ID:AlexGhiondea,项目名称:corefxlab,代码行数:12,代码来源:CustomTypeFormatting.cs
示例19: MeasureString
/// <summary>
/// Measures width of string, correctly taking into account trailing spaces.
/// </summary>
/// <param name="text"></param>
/// <param name="textFormat"></param>
/// <returns></returns>
public Rectangle MeasureString(string text, TextFormat textFormat)
{
if (_spaceWidth == -1)
{
CalculateSpaceWidth();
}
var size = MeasureString(null, text, MapTextFormat(textFormat));
var trimStr = text.TrimEnd(' ');
var spaceCount = text.Length - trimStr.Length;
size.Width += (_spaceWidth * spaceCount);
return size;
}
开发者ID:HaKDMoDz,项目名称:Psy,代码行数:18,代码来源:Font.cs
示例20: OnCreateDeviceIndependentResources
protected override void OnCreateDeviceIndependentResources(Direct2DFactory factory)
{
base.OnCreateDeviceIndependentResources(factory);
this._textFormat = DirectWriteFactory.CreateTextFormat("Gabriola",
FontWeight.Normal,
FontStyle.Normal,
FontStretch.Normal,
72);
this._textFormat.TextAlignment = TextAlignment.Center;
this._textFormat.ParagraphAlignment = ParagraphAlignment.Center;
System.Globalization.CultureInfo ci = this._textFormat.Culture;
Trimming trimming = this._textFormat.Trimming;
}
开发者ID:eugeniomiro,项目名称:Terrarium,代码行数:14,代码来源:SimpleTextControl.cs
注:本文中的TextFormat类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论