• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# TextGenerator类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中TextGenerator的典型用法代码示例。如果您正苦于以下问题:C# TextGenerator类的具体用法?C# TextGenerator怎么用?C# TextGenerator使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



TextGenerator类属于命名空间,在下文中一共展示了TextGenerator类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: GenerateBuilderMembers

 public void GenerateBuilderMembers(TextGenerator writer)
 {
     // Note:  We can return the original list here, because we make it unmodifiable when we build
       writer.WriteLine("public scg::IList<{0}> {1}List {{", TypeName, PropertyName);
       writer.WriteLine("  get {{ return result.{0}_; }}", Name);
       writer.WriteLine("}");
       writer.WriteLine("public int {0}Count {{", PropertyName);
       writer.WriteLine("  get {{ return result.{0}Count; }}", PropertyName);
       writer.WriteLine("}");
       writer.WriteLine("public {0} Get{1}(int index) {{", TypeName, PropertyName);
       writer.WriteLine("  return result.Get{0}(index);", PropertyName);
       writer.WriteLine("}");
       writer.WriteLine("public Builder Set{0}(int index, {1} value) {{", PropertyName, TypeName);
       AddNullCheck(writer);
       writer.WriteLine("  result.{0}_[index] = value;", Name);
       writer.WriteLine("  return this;");
       writer.WriteLine("}");
       writer.WriteLine("public Builder Add{0}({1} value) {{", PropertyName, TypeName);
       AddNullCheck(writer);
       writer.WriteLine("  result.{0}_.Add(value);", Name, TypeName);
       writer.WriteLine("  return this;");
       writer.WriteLine("}");
       writer.WriteLine("public Builder AddRange{0}(scg::IEnumerable<{1}> values) {{", PropertyName, TypeName);
       writer.WriteLine("  base.AddRange(values, result.{0}_);", Name);
       writer.WriteLine("  return this;");
       writer.WriteLine("}");
       writer.WriteLine("public Builder Clear{0}() {{", PropertyName);
       writer.WriteLine("  result.{0}_.Clear();", Name);
       writer.WriteLine("  return this;");
       writer.WriteLine("}");
 }
开发者ID:nuirnr01,项目名称:dotnet-protobufs,代码行数:31,代码来源:RepeatedPrimitiveFieldGenerator.cs


示例2: GenerateSerializedSizeCode

 public void GenerateSerializedSizeCode(TextGenerator writer)
 {
     writer.WriteLine("if (Has{0}) {{", PropertyName);
       writer.WriteLine("  size += pb::CodedOutputStream.Compute{0}Size({1}, {2});",
       CapitalizedTypeName, Number, PropertyName);
       writer.WriteLine("}");
 }
开发者ID:nuirnr01,项目名称:dotnet-protobufs,代码行数:7,代码来源:PrimitiveFieldGenerator.cs


示例3: GenerateBuilderMembers

 public void GenerateBuilderMembers(TextGenerator writer)
 {
     AddDeprecatedFlag(writer);
     writer.WriteLine("public bool Has{0} {{", PropertyName);
     writer.WriteLine(" get {{ return result.has{0}; }}", PropertyName);
     writer.WriteLine("}");
     AddPublicMemberAttributes(writer);
     writer.WriteLine("public {0} {1} {{", TypeName, PropertyName);
     writer.WriteLine("  get {{ return result.{0}; }}", PropertyName);
     writer.WriteLine("  set {{ Set{0}(value); }}", PropertyName);
     writer.WriteLine("}");
     AddPublicMemberAttributes(writer);
     writer.WriteLine("public Builder Set{0}({1} value) {{", PropertyName, TypeName);
     writer.WriteLine("  PrepareBuilder();");
     writer.WriteLine("  result.has{0} = true;", PropertyName);
     writer.WriteLine("  result.{0}_ = value;", Name);
     writer.WriteLine("  return this;");
     writer.WriteLine("}");
     AddDeprecatedFlag(writer);
     writer.WriteLine("public Builder Clear{0}() {{", PropertyName);
     writer.WriteLine("  PrepareBuilder();");
     writer.WriteLine("  result.has{0} = false;", PropertyName);
     writer.WriteLine("  result.{0}_ = {1};", Name, DefaultValue);
     writer.WriteLine("  return this;");
     writer.WriteLine("}");
 }
开发者ID:ZhouX1ang,项目名称:protobuf-csharp-port,代码行数:26,代码来源:EnumFieldGenerator.cs


示例4: GenerateBuilderMembers

 public void GenerateBuilderMembers(TextGenerator writer)
 {
     // Note:  We can return the original list here, because we make it unmodifiable when we build
       // We return it via IPopsicleList so that collection initializers work more pleasantly.
       writer.WriteLine("public pbc::IPopsicleList<{0}> {1}List {{", TypeName, PropertyName);
       writer.WriteLine("  get {{ return result.{0}_; }}", Name);
       writer.WriteLine("}");
       writer.WriteLine("public int {0}Count {{", PropertyName);
       writer.WriteLine("  get {{ return result.{0}Count; }}", PropertyName);
       writer.WriteLine("}");
       writer.WriteLine("public {0} Get{1}(int index) {{", TypeName, PropertyName);
       writer.WriteLine("  return result.Get{0}(index);", PropertyName);
       writer.WriteLine("}");
       writer.WriteLine("public Builder Set{0}(int index, {1} value) {{", PropertyName, TypeName);
       writer.WriteLine("  result.{0}_[index] = value;", Name);
       writer.WriteLine("  return this;");
       writer.WriteLine("}");
       writer.WriteLine("public Builder Add{0}({1} value) {{", PropertyName, TypeName);
       writer.WriteLine("  result.{0}_.Add(value);", Name, TypeName);
       writer.WriteLine("  return this;");
       writer.WriteLine("}");
       writer.WriteLine("public Builder AddRange{0}(scg::IEnumerable<{1}> values) {{", PropertyName, TypeName);
       writer.WriteLine("  base.AddRange(values, result.{0}_);", Name);
       writer.WriteLine("  return this;");
       writer.WriteLine("}");
       writer.WriteLine("public Builder Clear{0}() {{", PropertyName);
       writer.WriteLine("  result.{0}_.Clear();", Name);
       writer.WriteLine("  return this;");
       writer.WriteLine("}");
 }
开发者ID:ayende,项目名称:dotnet-protobufs,代码行数:30,代码来源:RepeatedEnumFieldGenerator.cs


示例5: CSharpMarshalContext

 public CSharpMarshalContext(Driver driver)
     : base(driver)
 {
     Kind = CSharpMarshalKind.Unknown;
     ArgumentPrefix = new TextGenerator();
     Cleanup = new TextGenerator();
 }
开发者ID:fangsunjian,项目名称:CppSharp,代码行数:7,代码来源:CSharpMarshal.cs


示例6: MarshalContext

 public MarshalContext(Driver driver)
 {
     Driver = driver;
     SupportBefore = new TextGenerator();
     Return = new TextGenerator();
     MarshalVarPrefix = string.Empty;
 }
开发者ID:kitsilanosoftware,项目名称:CppSharp,代码行数:7,代码来源:Marshal.cs


示例7: WriteNamespaces

 internal static void WriteNamespaces(TextGenerator writer)
 {
     writer.WriteLine("using pb = global::Google.ProtocolBuffers;");
       writer.WriteLine("using pbc = global::Google.ProtocolBuffers.Collections;");
       writer.WriteLine("using pbd = global::Google.ProtocolBuffers.Descriptors;");
       writer.WriteLine("using scg = global::System.Collections.Generic;");
 }
开发者ID:ayende,项目名称:dotnet-protobufs,代码行数:7,代码来源:Helpers.cs


示例8: GenerateBuilderMembers

 public void GenerateBuilderMembers(TextGenerator writer)
 {
     // Note:  We can return the original list here, because we make it unmodifiable when we build
     // We return it via IPopsicleList so that collection initializers work more pleasantly.
     AddDeprecatedFlag(writer);
     writer.WriteLine("public pbc::IPopsicleList<{0}> {1}List {{", TypeName, PropertyName);
     writer.WriteLine("  get {{ return PrepareBuilder().{0}_; }}", Name);
     writer.WriteLine("}");
     AddDeprecatedFlag(writer);
     writer.WriteLine("public int {0}Count {{", PropertyName);
     writer.WriteLine("  get {{ return result.{0}Count; }}", PropertyName);
     writer.WriteLine("}");
     AddDeprecatedFlag(writer);
     writer.WriteLine("public {0} Get{1}(int index) {{", TypeName, PropertyName);
     writer.WriteLine("  return result.Get{0}(index);", PropertyName);
     writer.WriteLine("}");
     AddDeprecatedFlag(writer);
     writer.WriteLine("public Builder Set{0}(int index, {1} value) {{", PropertyName, TypeName);
     AddNullCheck(writer);
     writer.WriteLine("  PrepareBuilder();");
     writer.WriteLine("  result.{0}_[index] = value;", Name);
     writer.WriteLine("  return this;");
     writer.WriteLine("}");
     // Extra overload for builder (just on messages)
     AddDeprecatedFlag(writer);
     writer.WriteLine("public Builder Set{0}(int index, {1}.Builder builderForValue) {{", PropertyName, TypeName);
     AddNullCheck(writer, "builderForValue");
     writer.WriteLine("  PrepareBuilder();");
     writer.WriteLine("  result.{0}_[index] = builderForValue.Build();", Name);
     writer.WriteLine("  return this;");
     writer.WriteLine("}");
     AddDeprecatedFlag(writer);
     writer.WriteLine("public Builder Add{0}({1} value) {{", PropertyName, TypeName);
     AddNullCheck(writer);
     writer.WriteLine("  PrepareBuilder();");
     writer.WriteLine("  result.{0}_.Add(value);", Name, TypeName);
     writer.WriteLine("  return this;");
     writer.WriteLine("}");
     // Extra overload for builder (just on messages)
     AddDeprecatedFlag(writer);
     writer.WriteLine("public Builder Add{0}({1}.Builder builderForValue) {{", PropertyName, TypeName);
     AddNullCheck(writer, "builderForValue");
     writer.WriteLine("  PrepareBuilder();");
     writer.WriteLine("  result.{0}_.Add(builderForValue.Build());", Name);
     writer.WriteLine("  return this;");
     writer.WriteLine("}");
     AddDeprecatedFlag(writer);
     writer.WriteLine("public Builder AddRange{0}(scg::IEnumerable<{1}> values) {{", PropertyName, TypeName);
     writer.WriteLine("  PrepareBuilder();");
     writer.WriteLine("  result.{0}_.Add(values);", Name);
     writer.WriteLine("  return this;");
     writer.WriteLine("}");
     AddDeprecatedFlag(writer);
     writer.WriteLine("public Builder Clear{0}() {{", PropertyName);
     writer.WriteLine("  PrepareBuilder();");
     writer.WriteLine("  result.{0}_.Clear();", Name);
     writer.WriteLine("  return this;");
     writer.WriteLine("}");
 }
开发者ID:ZhouX1ang,项目名称:protobuf-csharp-port,代码行数:59,代码来源:RepeatedMessageFieldGenerator.cs


示例9: Block

 public Block(int kind)
 {
     Kind = kind;
     Blocks = new List<Block>();
     Text = new TextGenerator();
     hasIndentChanged = false;
     isSubBlock = false;
 }
开发者ID:ddobrev,项目名称:CppSharp,代码行数:8,代码来源:Template.cs


示例10: GenerateMembers

 public void GenerateMembers(TextGenerator writer) {
   writer.WriteLine("private bool has{0};", PropertyName);
   writer.WriteLine("private {0} {1}_ = {2};", TypeName, Name, DefaultValue);
   writer.WriteLine("public bool Has{0} {{", PropertyName);
   writer.WriteLine("  get {{ return has{0}; }}", PropertyName);
   writer.WriteLine("}");
   writer.WriteLine("public {0} {1} {{", TypeName, PropertyName);
   writer.WriteLine("  get {{ return {0}_; }}", Name);
   writer.WriteLine("}");
 }
开发者ID:huawuzui,项目名称:HBNews,代码行数:10,代码来源:MessageFieldGenerator.cs


示例11: CompanyMakerState

 public CompanyMakerState(DwarfGame game, GameStateManager stateManager)
     : base(game, "CompanyMakerState", stateManager)
 {
     CompanyName = DefaultName;
     CompanyMotto = DefaultMotto;
     CompanyLogo = DefaultLogo;
     CompanyColor = DefaultColor;
     EdgePadding = 32;
     Input = new InputManager();
     Drawer = new Drawer2D(Game.Content, Game.GraphicsDevice);
     TextGenerator = new TextGenerator();
 }
开发者ID:scorvi,项目名称:dwarfcorp,代码行数:12,代码来源:CompanyMakerState.cs


示例12: LayoutText

    public virtual void LayoutText(string content)
    {
        this.content = content.Trim();
        Canvas.ForceUpdateCanvases();

        TextGenerator generator = new TextGenerator();
        TextGenerationSettings settings = text.GetGenerationSettings(new Vector2(rectTransform.sizeDelta.x, 0));
        settings.updateBounds = true;
        settings.scaleFactor = 1;
        generator.Populate(content, settings);
        layoutElement.preferredHeight = generator.rectExtents.height;
    }
开发者ID:Giesch,项目名称:the-intercept,代码行数:12,代码来源:StoryElementView.cs


示例13: GenerateMembers

 public void GenerateMembers(TextGenerator writer)
 {
     writer.WriteLine("private bool has{0};", PropertyName);
     writer.WriteLine("private {0} {1}_{2};", TypeName, Name, HasDefaultValue ? " = " + DefaultValue : "");
     AddDeprecatedFlag(writer);
     writer.WriteLine("public bool Has{0} {{", PropertyName);
     writer.WriteLine("  get {{ return has{0}; }}", PropertyName);
     writer.WriteLine("}");
     AddPublicMemberAttributes(writer);
     writer.WriteLine("public {0} {1} {{", TypeName, PropertyName);
     writer.WriteLine("  get {{ return {0}_; }}", Name);
     writer.WriteLine("}");
 }
开发者ID:ZhouX1ang,项目名称:protobuf-csharp-port,代码行数:13,代码来源:PrimitiveFieldGenerator.cs


示例14: GenerateParsingCode

 public void GenerateParsingCode(TextGenerator writer)
 {
     // TODO(jonskeet): Make a more efficient way of doing this
       writer.WriteLine("int rawValue = input.ReadEnum();");
       writer.WriteLine("if (!global::System.Enum.IsDefined(typeof({0}), rawValue)) {{", TypeName);
       writer.WriteLine("  if (unknownFields == null) {"); // First unknown field - create builder now
       writer.WriteLine("    unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields);");
       writer.WriteLine("  }");
       writer.WriteLine("  unknownFields.MergeVarintField({0}, (ulong) rawValue);", Number);
       writer.WriteLine("} else {");
       writer.WriteLine("  {0} = ({1}) rawValue;", PropertyName, TypeName);
       writer.WriteLine("}");
 }
开发者ID:nuirnr01,项目名称:dotnet-protobufs,代码行数:13,代码来源:EnumFieldGenerator.cs


示例15: GenerateParsingCode

 public void GenerateParsingCode(TextGenerator writer)
 {
     writer.WriteLine("{0}.Builder subBuilder = {0}.CreateBuilder();", TypeName);
       writer.WriteLine("if (Has{0}) {{", PropertyName);
       writer.WriteLine("  subBuilder.MergeFrom({0});", PropertyName);
       writer.WriteLine("}");
       if (Descriptor.FieldType == FieldType.Group) {
     writer.WriteLine("input.ReadGroup({0}, subBuilder, extensionRegistry);", Number);
       } else {
     writer.WriteLine("input.ReadMessage(subBuilder, extensionRegistry);");
       }
       writer.WriteLine("{0} = subBuilder.BuildPartial();", PropertyName);
 }
开发者ID:nuirnr01,项目名称:dotnet-protobufs,代码行数:13,代码来源:MessageFieldGenerator.cs


示例16: ResizeInput

    // Resize input field as new lines get added
    private void ResizeInput(string iText)
    {
        string fullText = text;

        Vector2 extents = textComponent.rectTransform.rect.size;
        var settings = textComponent.GetGenerationSettings(extents);
        settings.generateOutOfBounds = false;
        var prefHeight = new TextGenerator().GetPreferredHeight(fullText, settings) + 16;

        if(prefHeight > textComponent.rectTransform.rect.height - 16 || prefHeight < textComponent.rectTransform.rect.height + 16) {
            rectTransform.sizeDelta = new Vector2(rectTransform.sizeDelta.x, prefHeight);
        }
    }
开发者ID:nathanchau,项目名称:make,代码行数:14,代码来源:ExpandingInputField.cs


示例17: GenerateBuilderMembers

 public void GenerateBuilderMembers(TextGenerator writer)
 {
     AddDeprecatedFlag(writer);
     writer.WriteLine("public bool Has{0} {{", PropertyName);
     writer.WriteLine(" get {{ return result.has{0}; }}", PropertyName);
     writer.WriteLine("}");
     AddDeprecatedFlag(writer);
     writer.WriteLine("public {0} {1} {{", TypeName, PropertyName);
     writer.WriteLine("  get {{ return result.{0}; }}", PropertyName);
     writer.WriteLine("  set {{ Set{0}(value); }}", PropertyName);
     writer.WriteLine("}");
     AddDeprecatedFlag(writer);
     writer.WriteLine("public Builder Set{0}({1} value) {{", PropertyName, TypeName);
     AddNullCheck(writer);
     writer.WriteLine("  PrepareBuilder();");
     writer.WriteLine("  result.has{0} = true;", PropertyName);
     writer.WriteLine("  result.{0}_ = value;", Name);
     writer.WriteLine("  return this;");
     writer.WriteLine("}");
     AddDeprecatedFlag(writer);
     writer.WriteLine("public Builder Set{0}({1}.Builder builderForValue) {{", PropertyName, TypeName);
     AddNullCheck(writer, "builderForValue");
     writer.WriteLine("  PrepareBuilder();");
     writer.WriteLine("  result.has{0} = true;", PropertyName);
     writer.WriteLine("  result.{0}_ = builderForValue.Build();", Name);
     writer.WriteLine("  return this;");
     writer.WriteLine("}");
     AddDeprecatedFlag(writer);
     writer.WriteLine("public Builder Merge{0}({1} value) {{", PropertyName, TypeName);
     AddNullCheck(writer);
     writer.WriteLine("  PrepareBuilder();");
     writer.WriteLine("  if (result.has{0} &&", PropertyName);
     writer.WriteLine("      result.{0}_ != {1}) {{", Name, DefaultValue);
     writer.WriteLine("      result.{0}_ = {1}.CreateBuilder(result.{0}_).MergeFrom(value).BuildPartial();", Name,
                      TypeName);
     writer.WriteLine("  } else {");
     writer.WriteLine("    result.{0}_ = value;", Name);
     writer.WriteLine("  }");
     writer.WriteLine("  result.has{0} = true;", PropertyName);
     writer.WriteLine("  return this;");
     writer.WriteLine("}");
     AddDeprecatedFlag(writer);
     writer.WriteLine("public Builder Clear{0}() {{", PropertyName);
     writer.WriteLine("  PrepareBuilder();");
     writer.WriteLine("  result.has{0} = false;", PropertyName);
     writer.WriteLine("  result.{0}_ = null;", Name);
     writer.WriteLine("  return this;");
     writer.WriteLine("}");
 }
开发者ID:ZhouX1ang,项目名称:protobuf-csharp-port,代码行数:49,代码来源:MessageFieldGenerator.cs


示例18: GenerateMembers

    public void GenerateMembers(TextGenerator writer) {
      writer.WriteLine("private pbc::PopsicleList<{0}> {1}_ = new pbc::PopsicleList<{0}>();", TypeName, Name);
      writer.WriteLine("public scg::IList<{0}> {1}List {{", TypeName, PropertyName);
      writer.WriteLine("  get {{ return {0}_; }}", Name);
      writer.WriteLine("}");

      // TODO(jonskeet): Redundant API calls? Possibly - include for portability though. Maybe create an option.
      writer.WriteLine("public int {0}Count {{", PropertyName);
      writer.WriteLine("  get {{ return {0}_.Count; }}", Name);
      writer.WriteLine("}");

      writer.WriteLine("public {0} Get{1}(int index) {{", TypeName, PropertyName);
      writer.WriteLine("  return {0}_[index];", Name);
      writer.WriteLine("}");
    }    
开发者ID:huawuzui,项目名称:HBNews,代码行数:15,代码来源:RepeatedMessageFieldGenerator.cs


示例19: Start

 void Start()
 {
     TextGenerationSettings settings = new TextGenerationSettings();
     settings.textAnchor = TextAnchor.MiddleCenter;
     settings.color = Color.red;
     settings.generationExtents = extents;
     settings.pivot = Vector2.zero;
     settings.richText = true;
     settings.font = font;
     settings.fontSize = 32;
     settings.resizeTextMinSize = resizeTextMinSize;
     settings.resizeTextMaxSize = resizeTextMaxSize;
     settings.fontStyle = FontStyle.Normal;
     settings.verticalOverflow = VerticalWrapMode.Overflow;
     TextGenerator generator = new TextGenerator();
     generator.Populate("I am a string", settings);
     Debug.Log("I generated: " + generator.vertexCount + " verts!");
 }
开发者ID:pass86,项目名称:Unity,代码行数:18,代码来源:ExampleClass.cs


示例20: ResizeToText

 public void ResizeToText() {
     string fullText = _textField.text;
     Vector2 extents = _textField.rectTransform.rect.size;
     TextGenerationSettings settings = _textField.GetGenerationSettings(extents);
     settings.generateOutOfBounds = false;
     settings.updateBounds = true;
     float genHeight = new TextGenerator().GetPreferredHeight(fullText, settings);
     float windowHeight = _windowTransform.rect.height;
     if (genHeight < windowHeight) {
         genHeight = windowHeight;
         _scrollbar.value = 1f;
         _scrollbar.size = 1f;
         _scrollbar.numberOfSteps = 0;
     } else {
         _scrollbar.value = 0f;
     }
     _textField.GetComponent<RectTransform>().SetSizeWithCurrentAnchors(RectTransform.Axis.Vertical, genHeight);
 }
开发者ID:BrianErikson,项目名称:ScriptingTheGame,代码行数:18,代码来源:ResizeConsole.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# TextLine类代码示例发布时间:2022-05-24
下一篇:
C# TextFormatFlags类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap