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


C# TextWidget.SetBoundsToEncloseChildren方法代码示例

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


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

示例1: TextEditPage

		public TextEditPage()
			: base("Text Edit Widget")
		{
			FlowLayoutWidget topToBottom = new FlowLayoutWidget(FlowDirection.TopToBottom);
			BackgroundColor = new RGBA_Bytes(210, 210, 255);
			topToBottom.Padding = new BorderDouble(20);

			topToBottom.AddChild(new TextWidget("testing underline jpqy", underline: true));
			topToBottom.AddChild(new TextWidget("testing1\ntest2\ntest3"));

			topToBottom.AddChild(new TextWidget("this is some multiline\ntext\nwith centering", justification: Justification.Center));

			int tabIndex = 0;
#if true
			InternalTextEditWidget internalMultiLine = new InternalTextEditWidget("line1\nline2\nline3", 12, true, tabIndex++);
			//InternalTextEditWidget internalMultiLine = new InternalTextEditWidget("Line 1 - Multi Line Text Control\nLine 2 - Multi Line Text Control\nLine 3 - Multi Line Text Control\n", 12, true);
			topToBottom.AddChild(internalMultiLine);
#endif
			// show some masking for passwords
			{
				FlowLayoutWidget leftToRight = new FlowLayoutWidget();
				leftToRight.Margin = new BorderDouble(3);
				TextEditWidget passwordeTextEdit = new TextEditWidget("Password", tabIndex: tabIndex++);
				//passwordeTextEdit.InternalTextEditWidget.MaskCharacter = '*';
				passwordeTextEdit.Margin = new BorderDouble(4, 0);
				leftToRight.AddChild(passwordeTextEdit);

				TextWidget description = new TextWidget("Content:");
				leftToRight.AddChild(description);

				TextWidget passwordContent = new TextWidget("Password");
				leftToRight.AddChild(passwordContent);

				passwordeTextEdit.TextChanged += (sender, e) =>
				{
					passwordContent.Text = passwordeTextEdit.Text;
				};

				topToBottom.AddChild(leftToRight);
			}

			TextEditWidget singleLineTextEdit = new TextEditWidget("Single Line Edit Text Control", tabIndex: tabIndex++);
			topToBottom.AddChild(singleLineTextEdit);

			TextEditWidget multiLineTextConrol = new TextEditWidget("Line 1 - Multi Line Text Control\nLine 2 - Multi Line Text Control\nLine 3 - Multi Line Text Control\n", tabIndex: tabIndex++);
			multiLineTextConrol.Multiline = true;
			topToBottom.AddChild(multiLineTextConrol);

			TextEditWidget longTextWidget = new TextEditWidget("This is some really long text.", pixelWidth: 100, tabIndex: tabIndex++);
			topToBottom.AddChild(longTextWidget);

			topToBottom.AddChild(new TextWidget("Integer Text Control:"));
			topToBottom.AddChild(new NumberEdit(512102416, tabIndex: tabIndex++));

			topToBottom.AddChild(new TextWidget("Floating Point Text Control:"));
			topToBottom.AddChild(new NumberEdit(512102416, allowNegatives: true, allowDecimals: true, tabIndex: tabIndex++));

			TextWidget paddingAdjustText = new TextWidget("Padding: 0");
			paddingAdjustText.AutoExpandBoundsToText = true;
			topToBottom.AddChild(paddingAdjustText);

			TextEditWidget paddingAdjustTextEdit = new TextEditWidget("Edit With Padding", tabIndex: tabIndex++);
			GuiWidget paddingAroundTextEdit = new GuiWidget(100, 16);
			topToBottom.AddChild(paddingAroundTextEdit);
			paddingAroundTextEdit.AddChild(paddingAdjustTextEdit);
			paddingAdjustText.SetBoundsToEncloseChildren();

			//AddChild(new TextEditWidget("Multiline Edit Text Widget line 1\nline 2\nline 3", 200, 400, 200, 80, multiLine: true));
			AddChild(topToBottom);

			foreach (GuiWidget child in topToBottom.Children)
			{
				//child.Padding = new BorderDouble(4);
				child.HAnchor = UI.HAnchor.ParentCenter;
				child.BackgroundColor = RGBA_Bytes.White;
				//child.Margin = new BorderDouble(3);
				if (child is TextWidget)
				{
					child.BackgroundColor = new RGBA_Bytes(255, 200, 200);
				}
			}

			Slider textPaddingSlider = new Slider(new Vector2(), 200, 0, 10);
			topToBottom.AddChild(textPaddingSlider);
			textPaddingSlider.ValueChanged += (sender, e) =>
			{
				double padding = ((Slider)sender).Value;
				paddingAdjustText.Padding = new BorderDouble(padding);

				paddingAroundTextEdit.Padding = new BorderDouble(padding);
				paddingAroundTextEdit.SetBoundsToEncloseChildren();
				((Slider)sender).Parent.SetBoundsToEncloseChildren();
			};

			topToBottom.HAnchor = UI.HAnchor.ParentCenter;
			topToBottom.VAnchor = UI.VAnchor.ParentCenter;
		}
开发者ID:glocklueng,项目名称:agg-sharp,代码行数:97,代码来源:TextEditPage.cs


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