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


C# TextWidget.AnchorCenter方法代码示例

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


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

示例1: LoadHTML

 public void LoadHTML(string htmlContent)
 {
     htmlContent = DoTemplateReplacements(htmlContent);
     TextWidget textwdigt = new TextWidget("some test text");
     textwdigt.AnchorCenter();
     AddChild(textwdigt);
 }
开发者ID:rubenkar,项目名称:MatterControl,代码行数:7,代码来源:AboutPage.cs

示例2: AddRotateControls

		private void AddRotateControls(FlowLayoutWidget buttonPanel)
		{
			List<GuiWidget> rotateControls = new List<GuiWidget>();
			transformControls.Add("Rotate".Localize(), rotateControls);

			textImageButtonFactory.FixedWidth = EditButtonHeight;

			FlowLayoutWidget degreesContainer = new FlowLayoutWidget(FlowDirection.LeftToRight);
			degreesContainer.HAnchor = HAnchor.ParentLeftRight;
			degreesContainer.Padding = new BorderDouble(5);

			string degreesLabelText = "Degrees".Localize();
			string degreesLabelTextFull = "{0}:".FormatWith(degreesLabelText);
			TextWidget degreesLabel = new TextWidget(degreesLabelText, textColor: ActiveTheme.Instance.PrimaryTextColor);
			degreesContainer.AddChild(degreesLabel);
			degreesContainer.AddChild(new HorizontalSpacer());

			MHNumberEdit degreesControl = new MHNumberEdit(45, pixelWidth: 40, allowNegatives: true, allowDecimals: true, increment: 5, minValue: -360, maxValue: 360);
			degreesControl.VAnchor = Agg.UI.VAnchor.ParentTop;
			degreesContainer.AddChild(degreesControl);
			rotateControls.Add(degreesControl);

			buttonPanel.AddChild(degreesContainer);

			FlowLayoutWidget rotateButtonContainer = new FlowLayoutWidget(FlowDirection.LeftToRight);
			rotateButtonContainer.HAnchor = HAnchor.ParentLeftRight;

			Button rotateXButton = textImageButtonFactory.Generate("", "icon_rotate_32x32.png");
			TextWidget centeredX = new TextWidget("X", pointSize: 10, textColor: ActiveTheme.Instance.PrimaryTextColor); centeredX.Margin = new BorderDouble(3, 0, 0, 0); centeredX.AnchorCenter(); rotateXButton.AddChild(centeredX);
			rotateButtonContainer.AddChild(rotateXButton);
			rotateControls.Add(rotateXButton);
			rotateXButton.Click += (object sender, EventArgs mouseEvent) =>
			{
				if (SelectedMeshGroupIndex != -1)
				{
					double radians = MathHelper.DegreesToRadians(degreesControl.ActuallNumberEdit.Value);
					// rotate it
					ScaleRotateTranslate rotated = SelectedMeshGroupTransform;
					rotated.rotation *= Matrix4X4.CreateRotationX(radians);
					SelectedMeshGroupTransform = rotated;

					PlatingHelper.PlaceMeshGroupOnBed(MeshGroups, MeshGroupTransforms, SelectedMeshGroupIndex);
					PartHasBeenChanged();
					Invalidate();
				}
			};

			Button rotateYButton = textImageButtonFactory.Generate("", "icon_rotate_32x32.png");
			TextWidget centeredY = new TextWidget("Y", pointSize: 10, textColor: ActiveTheme.Instance.PrimaryTextColor); centeredY.Margin = new BorderDouble(3, 0, 0, 0); centeredY.AnchorCenter(); rotateYButton.AddChild(centeredY);
			rotateButtonContainer.AddChild(rotateYButton);
			rotateControls.Add(rotateYButton);
			rotateYButton.Click += (object sender, EventArgs mouseEvent) =>
			{
				if (SelectedMeshGroupIndex != -1)
				{
					double radians = MathHelper.DegreesToRadians(degreesControl.ActuallNumberEdit.Value);
					// rotate it
					ScaleRotateTranslate rotated = SelectedMeshGroupTransform;
					rotated.rotation *= Matrix4X4.CreateRotationY(radians);
					SelectedMeshGroupTransform = rotated;
					PlatingHelper.PlaceMeshGroupOnBed(MeshGroups, MeshGroupTransforms, SelectedMeshGroupIndex);
					saveButtons.Visible = true;
					Invalidate();
				}
			};

			Button rotateZButton = textImageButtonFactory.Generate("", "icon_rotate_32x32.png");
			TextWidget centeredZ = new TextWidget("Z", pointSize: 10, textColor: ActiveTheme.Instance.PrimaryTextColor); centeredZ.Margin = new BorderDouble(3, 0, 0, 0); centeredZ.AnchorCenter(); rotateZButton.AddChild(centeredZ);
			rotateButtonContainer.AddChild(rotateZButton);
			rotateControls.Add(rotateZButton);
			rotateZButton.Click += (object sender, EventArgs mouseEvent) =>
			{
				if (SelectedMeshGroupIndex != -1)
				{
					double radians = MathHelper.DegreesToRadians(degreesControl.ActuallNumberEdit.Value);
					// rotate it
					ScaleRotateTranslate rotated = SelectedMeshGroupTransform;
					rotated.rotation *= Matrix4X4.CreateRotationZ(radians);
					SelectedMeshGroupTransform = rotated;

					PlatingHelper.PlaceMeshGroupOnBed(MeshGroups, MeshGroupTransforms, SelectedMeshGroupIndex);
					PartHasBeenChanged();
					Invalidate();
				}
			};

			buttonPanel.AddChild(rotateButtonContainer);

			Button layFlatButton = whiteButtonFactory.Generate("Align to Bed".Localize(), centerText: true);
			layFlatButton.Cursor = Cursors.Hand;
			buttonPanel.AddChild(layFlatButton);

			layFlatButton.Click += (object sender, EventArgs mouseEvent) =>
			{
				if (SelectedMeshGroupIndex != -1)
				{
					MakeLowestFaceFlat(SelectedMeshGroupIndex);

					PartHasBeenChanged();
					Invalidate();
//.........这里部分代码省略.........
开发者ID:gobrien4418,项目名称:MatterControl,代码行数:101,代码来源:View3DWidget.cs

示例3: AddRotateControls

        private void AddRotateControls(FlowLayoutWidget buttonPanel)
        {
            List<GuiWidget> rotateControls = new List<GuiWidget>();
			transformControls.Add(new LocalizedString("Rotate").Translated, rotateControls);

            textImageButtonFactory.FixedWidth = 44;

            FlowLayoutWidget degreesContainer = new FlowLayoutWidget(FlowDirection.LeftToRight);
            degreesContainer.HAnchor = HAnchor.ParentLeftRight;
            degreesContainer.Padding = new BorderDouble(5);

            GuiWidget horizontalSpacer = new GuiWidget();
            horizontalSpacer.HAnchor = HAnchor.ParentLeftRight;

			string degreesLabelTxt = new LocalizedString("Degrees").Translated;
			string degreesLabelTxtFull = string.Format("{0}:", degreesLabelTxt);
			TextWidget degreesLabel = new TextWidget(degreesLabelTxt, textColor: RGBA_Bytes.White);
            degreesContainer.AddChild(degreesLabel);
            degreesContainer.AddChild(horizontalSpacer);

            MHNumberEdit degreesControl = new MHNumberEdit(45, pixelWidth: 40, allowNegatives: true, increment: 5, minValue: -360, maxValue: 360);
            degreesControl.VAnchor = Agg.UI.VAnchor.ParentTop;
            degreesContainer.AddChild(degreesControl);
            rotateControls.Add(degreesControl);

            buttonPanel.AddChild(degreesContainer);

            FlowLayoutWidget rotateButtonContainer = new FlowLayoutWidget(FlowDirection.LeftToRight);
            rotateButtonContainer.HAnchor = HAnchor.ParentLeftRight;

            Button rotateXButton = textImageButtonFactory.Generate("", "icon_rotate_32x32.png");
            TextWidget centeredX = new TextWidget("X", pointSize: 10, textColor: RGBA_Bytes.White); centeredX.Margin = new BorderDouble(3, 0, 0, 0); centeredX.AnchorCenter(); rotateXButton.AddChild(centeredX);
            rotateButtonContainer.AddChild(rotateXButton);
            rotateControls.Add(rotateXButton);
            rotateXButton.Click += (object sender, MouseEventArgs mouseEvent) =>
            {
                double radians = MathHelper.DegreesToRadians(degreesControl.ActuallNumberEdit.Value);
                AxisAlignedBoundingBox bounds = SelectedMesh.GetAxisAlignedBoundingBox(SelectedMeshTransform);
                Vector3 startingCenter = bounds.Center;
                // move it to the origin so it rotates about it's center
                Matrix4X4 totalTransfrom = Matrix4X4.CreateTranslation(-startingCenter);
                // rotate it
                totalTransfrom *= Matrix4X4.CreateRotationX(radians);
                SelectedMeshTransform *= totalTransfrom;
                // find the new center
                bounds = SelectedMesh.GetAxisAlignedBoundingBox(SelectedMeshTransform);
                // and shift it back so the new center is where the old center was
                SelectedMeshTransform *= Matrix4X4.CreateTranslation(startingCenter - bounds.Center);
                PlatingHelper.PlaceMeshOnBed(Meshes, MeshTransforms, SelectedMeshIndex, false);
                saveButton.Visible = true;
                Invalidate();
            };

            Button rotateYButton = textImageButtonFactory.Generate("", "icon_rotate_32x32.png");
            TextWidget centeredY = new TextWidget("Y", pointSize: 10, textColor: RGBA_Bytes.White); centeredY.Margin = new BorderDouble(3, 0, 0, 0); centeredY.AnchorCenter(); rotateYButton.AddChild(centeredY);
            rotateButtonContainer.AddChild(rotateYButton);
            rotateControls.Add(rotateYButton);
            rotateYButton.Click += (object sender, MouseEventArgs mouseEvent) =>
            {
                double radians = MathHelper.DegreesToRadians(degreesControl.ActuallNumberEdit.Value);
                AxisAlignedBoundingBox bounds = SelectedMesh.GetAxisAlignedBoundingBox(SelectedMeshTransform);
                Vector3 startingCenter = bounds.Center;
                // move it to the origin so it rotates about it's center
                Matrix4X4 totalTransfrom = Matrix4X4.CreateTranslation(-startingCenter);
                // rotate it
                totalTransfrom *= Matrix4X4.CreateRotationY(radians);
                SelectedMeshTransform *= totalTransfrom;
                // find the new center
                bounds = SelectedMesh.GetAxisAlignedBoundingBox(SelectedMeshTransform);
                // and shift it back so the new center is where the old center was
                SelectedMeshTransform *= Matrix4X4.CreateTranslation(startingCenter - bounds.Center);
                PlatingHelper.PlaceMeshOnBed(Meshes, MeshTransforms, SelectedMeshIndex, false);
                saveButton.Visible = true;
                Invalidate();
            };

            Button rotateZButton = textImageButtonFactory.Generate("", "icon_rotate_32x32.png");
            TextWidget centeredZ = new TextWidget("Z", pointSize: 10, textColor: RGBA_Bytes.White); centeredZ.Margin = new BorderDouble(3, 0, 0, 0); centeredZ.AnchorCenter(); rotateZButton.AddChild(centeredZ);
            rotateButtonContainer.AddChild(rotateZButton);
            rotateControls.Add(rotateZButton);
            rotateZButton.Click += (object sender, MouseEventArgs mouseEvent) =>
            {
                double radians = MathHelper.DegreesToRadians(degreesControl.ActuallNumberEdit.Value);
                AxisAlignedBoundingBox bounds = SelectedMesh.GetAxisAlignedBoundingBox(SelectedMeshTransform);
                Vector3 startingCenter = bounds.Center;
                // move it to the origin so it rotates about it's center
                Matrix4X4 totalTransfrom = Matrix4X4.CreateTranslation(-startingCenter);
                // rotate it
                totalTransfrom *= Matrix4X4.CreateRotationZ(radians);
                SelectedMeshTransform *= totalTransfrom;
                // find the new center
                bounds = SelectedMesh.GetAxisAlignedBoundingBox(SelectedMeshTransform);
                // and shift it back so the new center is where the old center was
                SelectedMeshTransform *= Matrix4X4.CreateTranslation(startingCenter - bounds.Center);
                saveButton.Visible = true;
                Invalidate();
            };

            buttonPanel.AddChild(rotateButtonContainer);

//.........这里部分代码省略.........
开发者ID:rubenkar,项目名称:MatterControl,代码行数:101,代码来源:View3DTransfromPart.cs


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