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


C# GuiWidget.AddChild方法代码示例

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


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

示例1: BottomAndTopTextControl

		public void BottomAndTopTextControl(double controlPadding, double buttonMargin)
		{
			GuiWidget containerControl = new GuiWidget(200, 300);
			containerControl.DoubleBuffer = true;
			containerControl.BackBuffer.NewGraphics2D().Clear(RGBA_Bytes.White);
			TextWidget controlButton1 = new TextWidget("text1");
			controlButton1.Margin = new BorderDouble(buttonMargin);
			controlButton1.OriginRelativeParent = new VectorMath.Vector2(-controlButton1.LocalBounds.Left, -controlButton1.LocalBounds.Bottom + controlPadding + buttonMargin);
			controlButton1.LocalBounds = new RectangleDouble(controlButton1.LocalBounds.Left, controlButton1.LocalBounds.Bottom, controlButton1.LocalBounds.Right, controlButton1.LocalBounds.Bottom + containerControl.Height - (controlPadding + buttonMargin) * 2);
			containerControl.AddChild(controlButton1);
			containerControl.OnDraw(containerControl.NewGraphics2D());

			GuiWidget containerTest = new GuiWidget(200, 200);
			containerTest.Padding = new BorderDouble(controlPadding);
			containerTest.DoubleBuffer = true;
			containerTest.BackBuffer.NewGraphics2D().Clear(RGBA_Bytes.White);

			TextWidget testButton1 = new TextWidget("text1");
			testButton1.Margin = new BorderDouble(buttonMargin);
			testButton1.VAnchor = VAnchor.ParentBottom | VAnchor.ParentTop;
			containerTest.AddChild(testButton1);
			containerTest.OnDraw(containerTest.NewGraphics2D());
			OutputImages(containerControl, containerTest);

			// now change it's size
			containerTest.LocalBounds = containerControl.LocalBounds;
			containerTest.BackBuffer.NewGraphics2D().Clear(RGBA_Bytes.White);

			containerTest.OnDraw(containerTest.NewGraphics2D());
			OutputImages(containerControl, containerTest);

			Assert.IsTrue(containerControl.BackBuffer != null, "When we set a guiWidget to DoubleBuffer it needs to create one.");
			Assert.IsTrue(containerControl.BackBuffer == containerTest.BackBuffer, "The Anchored widget should be in the correct place.");
		}
开发者ID:glocklueng,项目名称:agg-sharp,代码行数:34,代码来源:AnchorTests.cs

示例2: TextWidgetVisibleTest

		public void TextWidgetVisibleTest()
		{
			{
				GuiWidget rectangleWidget = new GuiWidget(100, 50);
				TextWidget itemToAdd = new TextWidget("test Item", 10, 10);
				rectangleWidget.AddChild(itemToAdd);
				rectangleWidget.DoubleBuffer = true;
				rectangleWidget.BackBuffer.NewGraphics2D().Clear(RGBA_Bytes.White);
				rectangleWidget.OnDraw(rectangleWidget.BackBuffer.NewGraphics2D());

				ImageBuffer textOnly = new ImageBuffer(75, 20, 32, new BlenderBGRA());
				textOnly.NewGraphics2D().Clear(RGBA_Bytes.White);

				textOnly.NewGraphics2D().DrawString("test Item", 1, 1);

				if (saveImagesForDebug)
				{
					ImageTgaIO.Save(rectangleWidget.BackBuffer, "-rectangleWidget.tga");
					//ImageTgaIO.Save(itemToAdd.Children[0].BackBuffer, "-internalTextWidget.tga");
					ImageTgaIO.Save(textOnly, "-textOnly.tga");
				}

				Assert.IsTrue(rectangleWidget.BackBuffer.FindLeastSquaresMatch(textOnly, 1), "TextWidgets need to be drawing.");
				rectangleWidget.Close();
			}

			{
				GuiWidget rectangleWidget = new GuiWidget(100, 50);
				TextEditWidget itemToAdd = new TextEditWidget("test Item", 10, 10);
				rectangleWidget.AddChild(itemToAdd);
				rectangleWidget.DoubleBuffer = true;
				rectangleWidget.BackBuffer.NewGraphics2D().Clear(RGBA_Bytes.White);
				rectangleWidget.OnDraw(rectangleWidget.BackBuffer.NewGraphics2D());

				ImageBuffer textOnly = new ImageBuffer(75, 20, 32, new BlenderBGRA());
				textOnly.NewGraphics2D().Clear(RGBA_Bytes.White);

				TypeFacePrinter stringPrinter = new TypeFacePrinter("test Item", 12);
				IVertexSource offsetText = new VertexSourceApplyTransform(stringPrinter, Affine.NewTranslation(1, -stringPrinter.LocalBounds.Bottom));
				textOnly.NewGraphics2D().Render(offsetText, RGBA_Bytes.Black);

				if (saveImagesForDebug)
				{
					ImageTgaIO.Save(rectangleWidget.BackBuffer, "-rectangleWidget.tga");
					//ImageTgaIO.Save(itemToAdd.Children[0].BackBuffer, "-internalTextWidget.tga");
					ImageTgaIO.Save(textOnly, "-textOnly.tga");
				}

				Assert.IsTrue(rectangleWidget.BackBuffer.FindLeastSquaresMatch(textOnly, 1), "TextWidgets need to be drawing.");
				rectangleWidget.Close();
			}
		}
开发者ID:glocklueng,项目名称:agg-sharp,代码行数:52,代码来源:TextAndTextWidgetTests.cs

示例3: TextEditTextSelectionTests

		public void TextEditTextSelectionTests()
		{
			GuiWidget container = new GuiWidget();
			container.LocalBounds = new RectangleDouble(0, 0, 200, 200);
			TextEditWidget editField1 = new TextEditWidget("", 0, 0, pixelWidth: 51);
			container.AddChild(editField1);

			// select the conrol and type something in it
			container.OnMouseDown(new MouseEventArgs(MouseButtons.Left, 1, 0, 0, 0));
			container.OnMouseUp(new MouseEventArgs(MouseButtons.Left, 0, 0, 0, 0));
			SendKey(Keys.A, 'a', container);
			Assert.IsTrue(editField1.Text == "a", "It should have a in it.");

			// select the begining again and type something else in it
			container.OnMouseDown(new MouseEventArgs(MouseButtons.Left, 1, 0, 0, 0));
			container.OnMouseUp(new MouseEventArgs(MouseButtons.Left, 0, 0, 0, 0));
			SendKey(Keys.B, 'b', container);
			Assert.IsTrue(editField1.Text == "ba", "It should have ba in it.");

			// select the ba and delete them
			container.OnMouseDown(new MouseEventArgs(MouseButtons.Left, 1, 0, 0, 0));
			container.OnMouseMove(new MouseEventArgs(MouseButtons.Left, 0, 15, 0, 0));
			container.OnMouseUp(new MouseEventArgs(MouseButtons.Left, 0, 15, 0, 0));
			SendKey(Keys.Back, ' ', container);
			Assert.IsTrue(editField1.Text == "", "It should have nothing in it.");

			// select the other way
			editField1.Text = "ab";
			Assert.IsTrue(editField1.Text == "ab", "It should have ab in it.");
			container.OnMouseDown(new MouseEventArgs(MouseButtons.Left, 1, 15, 0, 0));
			container.OnMouseMove(new MouseEventArgs(MouseButtons.Left, 0, 0, 0, 0));
			container.OnMouseUp(new MouseEventArgs(MouseButtons.Left, 0, 0, 0, 0));
			SendKey(Keys.Back, ' ', container);
			Assert.IsTrue(editField1.Text == "", "It should have nothing in it.");

			// select the other way but start far to the right
			editField1.Text = "abc";
			Assert.IsTrue(editField1.Text == "abc", "It should have abc in it.");
			container.OnMouseDown(new MouseEventArgs(MouseButtons.Left, 1, 30, 0, 0));
			container.OnMouseMove(new MouseEventArgs(MouseButtons.Left, 0, 0, 0, 0));
			container.OnMouseUp(new MouseEventArgs(MouseButtons.Left, 0, 0, 0, 0));
			SendKey(Keys.Back, ' ', container);
			Assert.IsTrue(editField1.Text == "", "It should have nothing in it.");

			container.Close();
		}
开发者ID:CNCBrasil,项目名称:agg-sharp,代码行数:46,代码来源:TextEditTests.cs

示例4: ValidateOnlyTopWidgetGetsLeftClick

		public void ValidateOnlyTopWidgetGetsLeftClick()
		{
			bool gotClick = false;
			GuiWidget container = new GuiWidget();
			container.Name = "container";
			container.LocalBounds = new RectangleDouble(0, 0, 200, 200);
			Button button = new Button("Test", 100, 100);
			button.Name = "button";
			button.Click += (sender, e) => { gotClick = true; };
			container.AddChild(button);

			GuiWidget blockingWidegt = new GuiWidget();
			blockingWidegt.Name = "blockingWidegt";
			blockingWidegt.LocalBounds = new RectangleDouble(105, 105, 125, 125);
			container.AddChild(blockingWidegt);

			// the widget is not in the way
			Assert.IsTrue(gotClick == false);
			container.OnMouseDown(new MouseEventArgs(MouseButtons.Left, 1, 101, 101, 0));
			Assert.IsTrue(container.MouseCaptured == false);
			Assert.IsTrue(blockingWidegt.MouseCaptured == false);
			Assert.IsTrue(container.ChildHasMouseCaptured == true);
			Assert.IsTrue(blockingWidegt.ChildHasMouseCaptured == false);
			Assert.IsTrue(button.MouseCaptured == true);
			container.OnMouseUp(new MouseEventArgs(MouseButtons.Left, 1, 101, 101, 0));
			Assert.IsTrue(container.MouseCaptured == false);
			Assert.IsTrue(blockingWidegt.MouseCaptured == false);
			Assert.IsTrue(button.MouseCaptured == false);
			Assert.IsTrue(gotClick == true);

			gotClick = false;

			// the widget is in the way
			Assert.IsTrue(gotClick == false);
			container.OnMouseDown(new MouseEventArgs(MouseButtons.Left, 1, 110, 110, 0));
			Assert.IsTrue(container.MouseCaptured == false);
			Assert.IsTrue(blockingWidegt.MouseCaptured == true);
			Assert.IsTrue(button.MouseCaptured == false);
			container.OnMouseUp(new MouseEventArgs(MouseButtons.Left, 1, 110, 110, 0));
			Assert.IsTrue(container.MouseCaptured == false);
			Assert.IsTrue(blockingWidegt.MouseCaptured == false);
			Assert.IsTrue(button.MouseCaptured == false);
			Assert.IsTrue(gotClick == false);
		}
开发者ID:CNCBrasil,项目名称:agg-sharp,代码行数:44,代码来源:MouseInteractionTests.cs

示例5: TopToBottomContainerAppliesExpectedMargin

		public void TopToBottomContainerAppliesExpectedMargin()
		{
			int marginSize = 40;
			int dimensions = 300;

			GuiWidget outerContainer = new GuiWidget(dimensions, dimensions);

			FlowLayoutWidget topToBottomContainer = new FlowLayoutWidget(FlowDirection.TopToBottom)
			{
				HAnchor = HAnchor.ParentLeftRight,
				VAnchor = UI.VAnchor.ParentBottomTop,
			};
			outerContainer.AddChild(topToBottomContainer);

			GuiWidget childWidget = new GuiWidget()
			{
				HAnchor = HAnchor.ParentLeftRight,
				VAnchor = VAnchor.ParentBottomTop,
				Margin = new BorderDouble(marginSize),
				BackgroundColor = RGBA_Bytes.Red,
			};

			topToBottomContainer.AddChild(childWidget);
			topToBottomContainer.AnchorAll();
			topToBottomContainer.PerformLayout();

			outerContainer.DoubleBuffer = true;
			outerContainer.BackBuffer.NewGraphics2D().Clear(RGBA_Bytes.White);
			outerContainer.OnDraw(outerContainer.NewGraphics2D());

			// For troubleshooting or visual validation
			//saveImagesForDebug = true;
			//OutputImages(outerContainer, outerContainer);

			var bounds = childWidget.BoundsRelativeToParent;
			Assert.IsTrue(bounds.Left == marginSize, "Left margin is incorrect");
			Assert.IsTrue(bounds.Right == dimensions - marginSize, "Right margin is incorrect");
			Assert.IsTrue(bounds.Top == dimensions - marginSize, "Top margin is incorrect");
			Assert.IsTrue(bounds.Bottom == marginSize, "Bottom margin is incorrect");
		}
开发者ID:eriser,项目名称:agg-sharp,代码行数:40,代码来源:FlowLayoutTests.cs

示例6: ValidateSimpleLeftClick

        public void ValidateSimpleLeftClick()
        {
            GuiWidget container = new GuiWidget();
            container.Name = "Container";
            container.LocalBounds = new RectangleDouble(0, 0, 200, 200);
            Button button = new Button("Test", 100, 100);
            button.Name = "button";
            bool gotClick = false;
            button.Click += (sender, e) => { gotClick = true; };
            container.AddChild(button);

            Assert.IsTrue(gotClick == false);
            Assert.IsTrue(button.Focused == false);

            container.OnMouseDown(new MouseEventArgs(MouseButtons.Left, 1, 10, 10, 0));
            container.OnMouseUp(new MouseEventArgs(MouseButtons.Left, 1, 10, 10, 0));
            Assert.IsTrue(gotClick == false);
            Assert.IsTrue(button.Focused == false);
            
            container.OnMouseDown(new MouseEventArgs(MouseButtons.Left, 1, 110, 110, 0));
            container.OnMouseUp(new MouseEventArgs(MouseButtons.Left, 1, 10, 10, 0));
            Assert.IsTrue(gotClick == false);
            Assert.IsTrue(button.Focused == true, "Down click triggers focused."); 

            Assert.IsTrue(gotClick == false);
            container.OnMouseDown(new MouseEventArgs(MouseButtons.Left, 1, 110, 110, 0));
            container.OnMouseUp(new MouseEventArgs(MouseButtons.Left, 1, 110, 110, 0));
            Assert.IsTrue(gotClick == true);
            Assert.IsTrue(button.Focused == true);

            gotClick = false;
            container.OnMouseDown(new MouseEventArgs(MouseButtons.Left, 1, 10, 10, 0));
            container.OnMouseUp(new MouseEventArgs(MouseButtons.Left, 1, 10, 10, 0));
            Assert.IsTrue(gotClick == false);
            Assert.IsTrue(button.Focused == false);

        }
开发者ID:jeske,项目名称:agg-sharp,代码行数:37,代码来源:MouseInteractionTests.cs

示例7: NestedFlowWidgetsLeftToRightTest

		public void NestedFlowWidgetsLeftToRightTest(BorderDouble controlPadding, BorderDouble buttonMargin)
		{
			GuiWidget containerControl = new GuiWidget(500, 300);
			containerControl.Padding = controlPadding;
			containerControl.DoubleBuffer = true;

			{
				Button buttonRight = new Button("buttonRight");
				Button buttonLeft = new Button("buttonLeft");
				buttonLeft.OriginRelativeParent = new VectorMath.Vector2(controlPadding.Left + buttonMargin.Left, buttonLeft.OriginRelativeParent.y);
				buttonRight.OriginRelativeParent = new VectorMath.Vector2(buttonLeft.BoundsRelativeToParent.Right + buttonMargin.Width, buttonRight.OriginRelativeParent.y);
				containerControl.AddChild(buttonRight);
				containerControl.AddChild(buttonLeft);
				containerControl.OnDraw(containerControl.NewGraphics2D());
			}

			GuiWidget containerTest = new GuiWidget(500, 300);
			containerTest.DoubleBuffer = true;
			{
				FlowLayoutWidget leftToRightFlowLayoutAll = new FlowLayoutWidget(FlowDirection.LeftToRight);
				leftToRightFlowLayoutAll.AnchorAll();
				leftToRightFlowLayoutAll.Padding = controlPadding;
				{
					FlowLayoutWidget leftToRightFlowLayoutLeft = new FlowLayoutWidget(FlowDirection.LeftToRight);
					Button buttonTop = new Button("buttonLeft");
					buttonTop.Margin = buttonMargin;
					leftToRightFlowLayoutLeft.AddChild(buttonTop);
					leftToRightFlowLayoutLeft.SetBoundsToEncloseChildren();
					leftToRightFlowLayoutAll.AddChild(leftToRightFlowLayoutLeft);
				}

				{
					FlowLayoutWidget leftToRightFlowLayoutRight = new FlowLayoutWidget(FlowDirection.LeftToRight);
					Button buttonBottom = new Button("buttonRight");
					buttonBottom.Margin = buttonMargin;
					leftToRightFlowLayoutRight.AddChild(buttonBottom);
					leftToRightFlowLayoutRight.SetBoundsToEncloseChildren();
					leftToRightFlowLayoutAll.AddChild(leftToRightFlowLayoutRight);
				}

				containerTest.AddChild(leftToRightFlowLayoutAll);
			}

			containerTest.OnDraw(containerTest.NewGraphics2D());
			OutputImages(containerControl, containerTest);

			Assert.IsTrue(containerControl.BackBuffer != null, "When we set a guiWidget to DoubleBuffer it needs to create one.");
			Assert.IsTrue(containerControl.BackBuffer == containerTest.BackBuffer, "The Anchored widget should be in the correct place.");
		}
开发者ID:eriser,项目名称:agg-sharp,代码行数:49,代码来源:FlowLayoutTests.cs

示例8: NestedFlowWidgetsTopToBottomTest

		public void NestedFlowWidgetsTopToBottomTest(BorderDouble controlPadding, BorderDouble buttonMargin)
		{
			GuiWidget containerControl = new GuiWidget(300, 500);
			containerControl.Padding = controlPadding;
			containerControl.DoubleBuffer = true;

			{
				Button buttonTop = new Button("buttonTop");
				Button buttonBottom = new Button("buttonBottom");
				buttonTop.OriginRelativeParent = new VectorMath.Vector2(buttonTop.OriginRelativeParent.x, containerControl.LocalBounds.Top - buttonMargin.Top - controlPadding.Top - buttonTop.Height);
				buttonBottom.OriginRelativeParent = new VectorMath.Vector2(buttonBottom.OriginRelativeParent.x, buttonTop.BoundsRelativeToParent.Bottom - buttonBottom.Height - buttonMargin.Height);
				containerControl.AddChild(buttonTop);
				containerControl.AddChild(buttonBottom);
				containerControl.OnDraw(containerControl.NewGraphics2D());
			}

			GuiWidget containerTest = new GuiWidget(300, 500);
			containerTest.DoubleBuffer = true;
			{
				FlowLayoutWidget topToBottomFlowLayoutAll = new FlowLayoutWidget(FlowDirection.TopToBottom);
				topToBottomFlowLayoutAll.AnchorAll();
				topToBottomFlowLayoutAll.Padding = controlPadding;
				{
					FlowLayoutWidget topToBottomFlowLayoutTop = new FlowLayoutWidget(FlowDirection.TopToBottom);
					Button buttonTop = new Button("buttonTop");
					buttonTop.Margin = buttonMargin;
					topToBottomFlowLayoutTop.AddChild(buttonTop);
					topToBottomFlowLayoutTop.SetBoundsToEncloseChildren();
					topToBottomFlowLayoutAll.AddChild(topToBottomFlowLayoutTop);
				}

				{
					FlowLayoutWidget topToBottomFlowLayoutBottom = new FlowLayoutWidget(FlowDirection.TopToBottom);
					Button buttonBottom = new Button("buttonBottom");
					buttonBottom.Margin = buttonMargin;
					topToBottomFlowLayoutBottom.AddChild(buttonBottom);
					topToBottomFlowLayoutBottom.SetBoundsToEncloseChildren();
					topToBottomFlowLayoutAll.AddChild(topToBottomFlowLayoutBottom);
				}

				containerTest.AddChild(topToBottomFlowLayoutAll);
			}

			containerTest.OnDraw(containerTest.NewGraphics2D());
			OutputImages(containerControl, containerTest);

			Assert.IsTrue(containerControl.BackBuffer != null, "When we set a guiWidget to DoubleBuffer it needs to create one.");
			Assert.IsTrue(containerControl.BackBuffer == containerTest.BackBuffer, "The Anchored widget should be in the correct place.");
		}
开发者ID:eriser,项目名称:agg-sharp,代码行数:49,代码来源:FlowLayoutTests.cs

示例9: NestedFitToChildrenParentWidth

		public void NestedFitToChildrenParentWidth()
		{
			// child of flow layout is ParentLeftRight
			{
				//  _________________________________________
				//  |            containerControl            |
				//  | _____________________________________  |
				//  | |    Max_FitToChildren_ParentWidth   | |
				//  | | ________________________ ________  | |
				//  | | |                      | |       | | |
				//  | | |    ParentLeftRight   | | 10x10 | | |
				//  | | |______________________| |_______| | |
				//  | |____________________________________| |
				//  |________________________________________|
				//

				GuiWidget containerControl = new GuiWidget(300, 200); // containerControl = 0, 0, 300, 200
				containerControl.DoubleBuffer = true;
				FlowLayoutWidget flowWidget = new FlowLayoutWidget()
				{
					HAnchor = HAnchor.Max_FitToChildren_ParentWidth,
				};
				containerControl.AddChild(flowWidget); // flowWidget = 0, 0, 300, 0
				GuiWidget fitToChildrenOrParent = new GuiWidget(20, 20)
				{
					HAnchor = HAnchor.ParentLeftRight,
				};
				flowWidget.AddChild(fitToChildrenOrParent); // flowWidget = 0, 0, 300, 20  fitToChildrenOrParent = 0, 0, 300, 20
				GuiWidget fixed10x10 = new GuiWidget(10, 10);
				flowWidget.AddChild(fixed10x10); // flowWidget = 0, 0, 300, 20  fitToChildrenOrParent = 0, 0, 290, 20
				containerControl.OnDraw(containerControl.NewGraphics2D());

				//OutputImage(containerControl, "countainer");

				Assert.IsTrue(flowWidget.Width == containerControl.Width);
				Assert.IsTrue(fitToChildrenOrParent.Width + fixed10x10.Width == containerControl.Width);

				containerControl.Width = 350;
				Assert.IsTrue(flowWidget.Width == containerControl.Width);
				Assert.IsTrue(fitToChildrenOrParent.Width + fixed10x10.Width == containerControl.Width);

				containerControl.Width = 310;
				Assert.IsTrue(flowWidget.Width == containerControl.Width);
				Assert.IsTrue(fitToChildrenOrParent.Width + fixed10x10.Width == containerControl.Width);
			}

			// child of flow layout is Max_FitToChildren_ParentWidth
			{
				//  ___________________________________________________
				//  |            containerControl                      |
				//  | _______________________________________________  |
				//  | |    Max_FitToChildren_ParentWidth             | |
				//  | | _________________________________   _______  | |
				//  | | |                                | |       | | |
				//  | | | Max_FitToChildren_ParentWidth  | | 10x10 | | |
				//  | | |________________________________| |_______| | |
				//  | |______________________________________________| |
				//  |__________________________________________________|
				//

				GuiWidget containerControl = new GuiWidget(300, 200); // containerControl = 0, 0, 300, 200
				containerControl.DoubleBuffer = true;
				FlowLayoutWidget flowWidget = new FlowLayoutWidget()
				{
					HAnchor = HAnchor.Max_FitToChildren_ParentWidth,
				};
				containerControl.AddChild(flowWidget);
				GuiWidget fitToChildrenOrParent = new GuiWidget(20, 20)
				{
					Name = "fitToChildrenOrParent",
					HAnchor = HAnchor.Max_FitToChildren_ParentWidth,
				};
				flowWidget.AddChild(fitToChildrenOrParent); // flowWidget = 0, 0, 300, 20  fitToChildrenOrParent = 0, 0, 300, 20
				GuiWidget fixed10x10 = new GuiWidget(10, 10);
				flowWidget.AddChild(fixed10x10); // flowWidget = 0, 0, 300, 20  fitToChildrenOrParent = 0, 0, 290, 20
				containerControl.OnDraw(containerControl.NewGraphics2D());

				//OutputImage(containerControl, "countainer");

				Assert.IsTrue(flowWidget.Width == containerControl.Width);
				Assert.IsTrue(fitToChildrenOrParent.Width + fixed10x10.Width == containerControl.Width);

				containerControl.Width = 350;
				Assert.IsTrue(flowWidget.Width == containerControl.Width);
				Assert.IsTrue(fitToChildrenOrParent.Width + fixed10x10.Width == containerControl.Width);

				containerControl.Width = 310;
				Assert.IsTrue(flowWidget.Width == containerControl.Width);
				Assert.IsTrue(fitToChildrenOrParent.Width + fixed10x10.Width == containerControl.Width);
			}
		}
开发者ID:eriser,项目名称:agg-sharp,代码行数:91,代码来源:FlowLayoutTests.cs

示例10: NestedLayoutTopToBottomTest

		public void NestedLayoutTopToBottomTest(BorderDouble controlPadding, BorderDouble buttonMargin)
		{
			GuiWidget containerControl = new GuiWidget(300, 200);
			containerControl.DoubleBuffer = true;
			containerControl.BackBuffer.NewGraphics2D().Clear(RGBA_Bytes.White);
			{
				Button topButtonC = new Button("top button");
				Button bottomButtonC = new Button("bottom wide button");
				topButtonC.LocalBounds = new RectangleDouble(0, 0, bottomButtonC.LocalBounds.Width, 40);
				topButtonC.OriginRelativeParent = new Vector2(bottomButtonC.OriginRelativeParent.x + buttonMargin.Left, containerControl.Height - controlPadding.Top - topButtonC.Height - buttonMargin.Top);
				containerControl.AddChild(topButtonC);
				bottomButtonC.OriginRelativeParent = new Vector2(bottomButtonC.OriginRelativeParent.x + buttonMargin.Left, topButtonC.OriginRelativeParent.y - buttonMargin.Height - bottomButtonC.Height);
				containerControl.AddChild(bottomButtonC);
			}
			containerControl.OnDraw(containerControl.NewGraphics2D());

			GuiWidget containerTest = new GuiWidget(300, 200);
			containerTest.DoubleBuffer = true;
			containerTest.BackBuffer.NewGraphics2D().Clear(RGBA_Bytes.White);

			FlowLayoutWidget allButtons = new FlowLayoutWidget(FlowDirection.TopToBottom);
			allButtons.AnchorAll();
			Button topButtonT;
			Button bottomButtonT;
			FlowLayoutWidget topButtonBar;
			FlowLayoutWidget bottomButtonBar;
			allButtons.Padding = controlPadding;
			{
				bottomButtonT = new Button("bottom wide button");

				topButtonBar = new FlowLayoutWidget();
				{
					topButtonT = new Button("top button");
					topButtonT.LocalBounds = new RectangleDouble(0, 0, bottomButtonT.LocalBounds.Width, 40);
					topButtonT.Margin = buttonMargin;
					topButtonBar.AddChild(topButtonT);
				}
				allButtons.AddChild(topButtonBar);

				bottomButtonBar = new FlowLayoutWidget();
				{
					bottomButtonT.Margin = buttonMargin;
					bottomButtonBar.AddChild(bottomButtonT);
				}
				allButtons.AddChild(bottomButtonBar);
			}
			containerTest.AddChild(allButtons);
			containerTest.OnDraw(containerTest.NewGraphics2D());

			OutputImages(containerControl, containerTest);

			Assert.IsTrue(containerTest.BackBuffer != null, "When we set a guiWidget to DoubleBuffer it needs to create one.");
			Assert.IsTrue(containerTest.BackBuffer.Equals(containerControl.BackBuffer, 1), "The test should contain the same image as the control.");
		}
开发者ID:eriser,项目名称:agg-sharp,代码行数:54,代码来源:FlowLayoutTests.cs

示例11: ChildHAnchorPriority

		public void ChildHAnchorPriority()
		{
			// make sure a middle spacer grows and shrinks correctly
			{
				FlowLayoutWidget leftRightFlowLayout = new FlowLayoutWidget();
				Assert.IsTrue(leftRightFlowLayout.HAnchor == HAnchor.FitToChildren); // flow layout starts with FitToChildren
				leftRightFlowLayout.HAnchor |= HAnchor.ParentLeftRight; // add to the existing flags ParentLeftRight (starts with FitToChildren)
				// [<-><->] // attempting to make a visual descrition of what is happening
				Assert.IsTrue(leftRightFlowLayout.Width == 0); // nothing is forcing it to have a width so it doesn't
				GuiWidget leftWidget = new GuiWidget(10, 10); // we call it left widget as it will be the first one in the left to right flow layout
				leftRightFlowLayout.AddChild(leftWidget); // add in a child with a width of 10
				// [<->(10)<->] // the flow layout should now be forced to be 10 wide
				Assert.IsTrue(leftRightFlowLayout.Width == 10);

				GuiWidget middleSpacer = new GuiWidget(0, 10); // this widget will hold the space
				middleSpacer.HAnchor = HAnchor.ParentLeftRight; // by resizing to whatever width it can be
				leftRightFlowLayout.AddChild(middleSpacer);
				// [<->(10)(<->)<->]
				Assert.IsTrue(leftRightFlowLayout.Width == 10);
				Assert.IsTrue(middleSpacer.Width == 0);

				GuiWidget rightItem = new GuiWidget(10, 10);
				leftRightFlowLayout.AddChild(rightItem);
				// [<->(10)(<->)(10)<->]
				Assert.IsTrue(leftRightFlowLayout.Width == 20);

				GuiWidget container = new GuiWidget(40, 20);
				container.AddChild(leftRightFlowLayout);
				// (40[<->(10)(<->)(10)<->]) // the extra 20 must be put into the expandable (<->)
				Assert.IsTrue(container.Width == 40);
				Assert.IsTrue(leftRightFlowLayout.Width == 40);
				Assert.IsTrue(middleSpacer.Width == 20);

				container.Width = 50;
				// (50[<->(10)(<->)(10)<->]) // the extra 30 must be put into the expandable (<->)
				Assert.IsTrue(container.Width == 50);
				Assert.IsTrue(leftRightFlowLayout.Width == 50);
				Assert.IsTrue(middleSpacer.Width == 30);

				container.Width = 40;
				// (40[<->(10)(<->)(10)<->]) // the extra 20 must be put into the expandable (<->) by shrinking it
				Assert.IsTrue(container.Width == 40);
				Assert.IsTrue(leftRightFlowLayout.Width == 40);
				Assert.IsTrue(middleSpacer.Width == 20);

				Assert.IsTrue(container.MinimumSize.x == 40); // minimum size is set to the construction size for normal GuiWidgets
				container.MinimumSize = new Vector2(0, 0); // make sure we can make this smaller
				container.Width = 10;
				// (10[<->(10)(<->)(10)<->]) // the extra 20 must be put into the expandable (<->) by shrinking it
				Assert.IsTrue(container.Width == 10); // nothing should be keeping this big
				Assert.IsTrue(leftRightFlowLayout.Width == 20); // it can't get smaller than its contents
				Assert.IsTrue(middleSpacer.Width == 0);
			}

			// make sure the middle spacer works the same when in a flow layout
			{
				FlowLayoutWidget leftRightFlowLayout = new FlowLayoutWidget();
				leftRightFlowLayout.Name = "leftRightFlowLayout";
				Assert.IsTrue(leftRightFlowLayout.HAnchor == HAnchor.FitToChildren); // flow layout starts with FitToChildren
				leftRightFlowLayout.HAnchor |= HAnchor.ParentLeftRight; // add to the existing flags ParentLeftRight (starts with FitToChildren)
				// [<-><->] // attempting to make a visual descrition of what is happening
				Assert.IsTrue(leftRightFlowLayout.Width == 0); // nothing is forcing it to have a width so it doesn't
				GuiWidget leftWidget = new GuiWidget(10, 10); // we call it left widget as it will be the first one in the left to right flow layout
				leftWidget.Name = "leftWidget";
				leftRightFlowLayout.AddChild(leftWidget); // add in a child with a width of 10
				// [<->(10)<->] // the flow layout should now be forced to be 10 wide
				Assert.IsTrue(leftRightFlowLayout.Width == 10);

				FlowLayoutWidget middleFlowLayoutWrapper = new FlowLayoutWidget(); // we are going to wrap the implicitly middle items to test nested resizing
				middleFlowLayoutWrapper.Name = "middleFlowLayoutWrapper";
				middleFlowLayoutWrapper.HAnchor |= HAnchor.ParentLeftRight;
				GuiWidget middleSpacer = new GuiWidget(0, 10); // this widget will hold the space
				middleSpacer.Name = "middleSpacer";
				middleSpacer.HAnchor = HAnchor.ParentLeftRight; // by resizing to whatever width it can be
				middleFlowLayoutWrapper.AddChild(middleSpacer);
				// {<->(<->)<->}
				leftRightFlowLayout.AddChild(middleFlowLayoutWrapper);
				// [<->(10){<->(<->)<->}<->]
				Assert.IsTrue(leftRightFlowLayout.Width == 10);
				Assert.IsTrue(middleFlowLayoutWrapper.Width == 0);
				Assert.IsTrue(middleSpacer.Width == 0);

				GuiWidget rightWidget = new GuiWidget(10, 10);
				rightWidget.Name = "rightWidget";
				leftRightFlowLayout.AddChild(rightWidget);
				// [<->(10){<->(<->)<->}(10)<->]
				Assert.IsTrue(leftRightFlowLayout.Width == 20);

				GuiWidget container = new GuiWidget(40, 20);
				container.Name = "container";
				container.AddChild(leftRightFlowLayout);
				// (40[<->(10){<->(<->)<->}(10)<->]) // the extra 20 must be put into the expandable (<->)
				Assert.IsTrue(leftRightFlowLayout.Width == 40);
				Assert.IsTrue(middleFlowLayoutWrapper.Width == 20);
				Assert.IsTrue(middleSpacer.Width == 20);

				container.Width = 50;
				// (50[<->(10){<->(<->)<->}(10)<->]) // the extra 30 must be put into the expandable (<->)
				Assert.IsTrue(leftRightFlowLayout.Width == 50);
				Assert.IsTrue(middleSpacer.Width == 30);
//.........这里部分代码省略.........
开发者ID:eriser,项目名称:agg-sharp,代码行数:101,代码来源:FlowLayoutTests.cs

示例12: FlowLayoutAndListBoxShouldLookTheSameWhenNoScrollBar

        public void FlowLayoutAndListBoxShouldLookTheSameWhenNoScrollBar()
        {
            GuiWidget control = new GuiWidget(200, 300);
            control.DoubleBuffer = true;
            FlowLayoutWidget flowItemContainer = new FlowLayoutWidget(FlowDirection.TopToBottom);
            flowItemContainer.HAnchor = HAnchor.LeftRight;
            flowItemContainer.HAnchor = HAnchor.LeftRight;
            flowItemContainer.VAnchor = VAnchor.BottomTop;
            //flowItemContainer.HAnchor = HAnchor.LeftRight;
            //flowItemContainer.HAnchor = HAnchor.Left;
            //flowItemContainer.VAnchor = VAnchor.Top;
            AddContents(flowItemContainer);
            control.AddChild(flowItemContainer);
            control.OnDraw(control.NewGraphics2D());
            OutputImage(control.BackBuffer, "control.tga");

            GuiWidget test = new GuiWidget(200, 300);
            test.DoubleBuffer = true;
            ListBox listItemContainer = new ListBox();
            AddContents(listItemContainer);
            test.AddChild(listItemContainer);
            test.OnDraw(test.NewGraphics2D());
            OutputImage(test.BackBuffer, "test.tga");

            Assert.IsTrue(control.BackBuffer.FindLeastSquaresMatch(test.BackBuffer, 0), "The test and control need to match.");
        }
开发者ID:jeske,项目名称:agg-sharp,代码行数:26,代码来源:ListBoxTests.cs

示例13: ScrollPositionStartsCorrect

        public void ScrollPositionStartsCorrect()
        {
            GuiWidget contents = new GuiWidget(300, 300);
            contents.DoubleBuffer = true;
            ListBox container = new ListBox(new RectangleDouble(0, 0, 200, 300));
            //container.BackgroundColor = RGBA_Bytes.Red;
            container.Name = "containerListBox";
            container.VAnchor = UI.VAnchor.ParentTop;
            container.Margin = new BorderDouble(15);
            
            contents.AddChild(container);

            container.AddChild(new ListBoxTextItem("hand.stl", "c:\\development\\hand.stl"));

            contents.OnDraw(contents.NewGraphics2D());

            Assert.IsTrue(container.TopLeftOffset.y == 0);
        }
开发者ID:jeske,项目名称:agg-sharp,代码行数:18,代码来源:ListBoxTests.cs

示例14: HCenterHRightAndVCenterVTopTest

		public void HCenterHRightAndVCenterVTopTest(BorderDouble controlPadding, BorderDouble buttonMargin)
		{
			GuiWidget containerControl = new GuiWidget(200, 300);
			containerControl.Padding = controlPadding;
			containerControl.DoubleBuffer = true;
			Button controlButton1 = new Button("button1");
			controlButton1.OriginRelativeParent = new VectorMath.Vector2(
				controlPadding.Left + buttonMargin.Left + (containerControl.Width - (controlPadding.Left + controlPadding.Right)) / 2,
				controlPadding.Bottom + buttonMargin.Bottom + (containerControl.Height - (controlPadding.Bottom + controlPadding.Top)) / 2);
			controlButton1.LocalBounds = new RectangleDouble(
				controlButton1.LocalBounds.Left,
				controlButton1.LocalBounds.Bottom,
				controlButton1.LocalBounds.Left + containerControl.Width / 2 - (controlPadding.Left + controlPadding.Right) / 2 - (buttonMargin.Left + buttonMargin.Right),
				controlButton1.LocalBounds.Bottom + containerControl.Height / 2 - (controlPadding.Bottom + controlPadding.Top) / 2 - (buttonMargin.Bottom + buttonMargin.Top));
			containerControl.AddChild(controlButton1);
			containerControl.OnDraw(containerControl.NewGraphics2D());

			GuiWidget containerTest = new GuiWidget(200, 300);
			containerTest.Padding = controlPadding;
			containerTest.DoubleBuffer = true;

			Button testButton1 = new Button("button1");
			testButton1.Margin = buttonMargin;
			testButton1.VAnchor = VAnchor.ParentCenter | VAnchor.ParentTop;
			testButton1.HAnchor = HAnchor.ParentCenter | HAnchor.ParentRight;
			containerTest.AddChild(testButton1);

			containerTest.OnDraw(containerTest.NewGraphics2D());
			OutputImages(containerControl, containerTest);

			Assert.IsTrue(containerControl.BackBuffer != null, "When we set a guiWidget to DoubleBuffer it needs to create one.");
			Assert.IsTrue(containerControl.BackBuffer == containerTest.BackBuffer, "The Anchored widget should be in the correct place.");
		}
开发者ID:glocklueng,项目名称:agg-sharp,代码行数:33,代码来源:AnchorTests.cs

示例15: CenterBothOffsetBoundsTest

		public void CenterBothOffsetBoundsTest(BorderDouble controlPadding, BorderDouble buttonMargin)
		{
			GuiWidget containerControl = new GuiWidget(200, 300);
			containerControl.Padding = controlPadding;
			containerControl.DoubleBuffer = true;
			GuiWidget controlRectangle = new GuiWidget(100, 100);
			controlRectangle.BackgroundColor = RGBA_Bytes.Red;
			controlRectangle.Margin = buttonMargin;
			double controlCenterX = controlPadding.Left + (containerControl.Width - controlPadding.Left - controlPadding.Right) / 2;
			double buttonX = controlCenterX - (controlRectangle.Width + controlRectangle.Margin.Left + controlRectangle.Margin.Right) / 2 + controlRectangle.Margin.Left;
			double controlCenterY = controlPadding.Bottom + (containerControl.Height - controlPadding.Bottom - controlPadding.Top) / 2 + controlRectangle.Margin.Bottom;
			double buttonY = controlCenterY - (controlRectangle.Height + controlRectangle.Margin.Bottom + controlRectangle.Margin.Top) / 2;
			controlRectangle.OriginRelativeParent = new VectorMath.Vector2(buttonX, buttonY);
			containerControl.AddChild(controlRectangle);
			containerControl.OnDraw(containerControl.NewGraphics2D());

			GuiWidget containerTest = new GuiWidget(200, 300);
			containerTest.Padding = controlPadding;
			containerTest.DoubleBuffer = true;

			GuiWidget testRectangle = new GuiWidget(100, 100);
			RectangleDouble offsetBounds = testRectangle.LocalBounds;
			offsetBounds.Offset(-10, -10);
			testRectangle.LocalBounds = offsetBounds;
			testRectangle.BackgroundColor = RGBA_Bytes.Red;
			testRectangle.Margin = buttonMargin;
			testRectangle.VAnchor = VAnchor.ParentCenter;
			testRectangle.HAnchor = HAnchor.ParentCenter;
			containerTest.AddChild(testRectangle);

			containerTest.OnDraw(containerTest.NewGraphics2D());
			OutputImages(containerControl, containerTest);

			Assert.IsTrue(containerControl.BackBuffer != null, "When we set a guiWidget to DoubleBuffer it needs to create one.");
			Assert.IsTrue(containerControl.BackBuffer == containerTest.BackBuffer, "The Anchored widget should be in the correct place.");
		}
开发者ID:glocklueng,项目名称:agg-sharp,代码行数:36,代码来源:AnchorTests.cs


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