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

C# GuiWidget类代码示例

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

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



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

    public GuiDisplayObject(SortedList args)
    {
        //Pflichtfelde
        if(args.ContainsKey("rect") == false){
            throw new Exception("No Rect defined");
        }

        //Text
        _text = "";
        if(args.ContainsKey("text")){
            _text = (string) args["text"];
        }

        _args = args;
        _id = _idCounter++;
        _go2D = new GameObject("2D GameObject - " + _id);

        //Position
        _rect = (Rect) args["rect"];
        _widget = _go2D.AddComponent<GuiWidget>();
        _widget.LocalPosition = new Vector2(_rect.x, _rect.y);
        _widget.Dimension = new Vector2(_rect.width, _rect.height);

        //make active
        Visible = true;
    }
开发者ID:Tjomas,项目名称:Thesis,代码行数:26,代码来源:GuiDisplayObject.cs


示例3: OutputImage

		private void OutputImage(GuiWidget widgetToOutput, string fileName)
		{
			if (saveImagesForDebug)
			{
				OutputImage(widgetToOutput.BackBuffer, fileName);
			}
		}
开发者ID:eriser,项目名称:agg-sharp,代码行数:7,代码来源:FlowLayoutTests.cs


示例4: OutputImages

		private void OutputImages(GuiWidget control, GuiWidget test)
		{
			if (saveImagesForDebug)
			{
				ImageTgaIO.Save(control.BackBuffer, "image-control.tga");
				ImageTgaIO.Save(test.BackBuffer, "image-test.tga");
			}
		}
开发者ID:glocklueng,项目名称:agg-sharp,代码行数:8,代码来源:AnchorTests.cs


示例5: ContainerWidget

 public ContainerWidget(Game game, GuiWidget[] widgets = null)
     : base(game)
 {
     if (widgets != null) {
         Widgets.AddRange(widgets);
     }
     UpdateBounds = GetType() != typeof(ContainerWidget);
 }
开发者ID:Gyoo,项目名称:FEZMod,代码行数:8,代码来源:ContainerWidget.cs


示例6: OnInit

 protected override void OnInit()
 {
     if (Target == null) {
         Target = GetComponent<GuiWidget> ();
     }
     if (Target == null) {
         enabled = false;
     }
 }
开发者ID:Leopotam,项目名称:LeopotamGroupLibraryUnity,代码行数:9,代码来源:GuiTweenColor.cs


示例7: SendKey

		public void SendKey(Keys keyDown, char keyPressed, GuiWidget reciever)
		{
			KeyEventArgs keyDownEvent = new KeyEventArgs(keyDown);
			reciever.OnKeyDown(keyDownEvent);
			if (!keyDownEvent.SuppressKeyPress)
			{
				KeyPressEventArgs keyPressEvent = new KeyPressEventArgs(keyPressed);
				reciever.OnKeyPress(keyPressEvent);
			}
		}
开发者ID:CNCBrasil,项目名称:agg-sharp,代码行数:10,代码来源:TextEditTests.cs


示例8: 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


示例9: GroupBox

		public GroupBox(GuiWidget groupBoxLabel)
			: base(HAnchor.FitToChildren, VAnchor.FitToChildren)
		{
			this.Padding = new BorderDouble(14, 14, 14, 16);
			groupBoxLabel.Margin = new BorderDouble(20, 0, 0, -this.Padding.Top);
			groupBoxLabel.VAnchor = UI.VAnchor.ParentTop;
			groupBoxLabel.HAnchor = UI.HAnchor.ParentLeft;
			base.AddChild(groupBoxLabel);

			this.groupBoxLabel = groupBoxLabel;

			clientArea = new GuiWidget(HAnchor.Max_FitToChildren_ParentWidth, VAnchor.Max_FitToChildren_ParentHeight);
			base.AddChild(clientArea);
		}
开发者ID:glocklueng,项目名称:agg-sharp,代码行数:14,代码来源:GroupBox.cs


示例10: 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


示例11: LimitScrolToContetsTests

		public void LimitScrolToContetsTests()
		{
			GuiWidget containerControl = new GuiWidget(200, 200);
			containerControl.DoubleBuffer = true;
			containerControl.BackBuffer.NewGraphics2D().Clear(RGBA_Bytes.White);
			containerControl.OnDraw(containerControl.NewGraphics2D());

			ScrollableWidget containerTest = new ScrollableWidget(200, 200);
			containerTest.DoubleBuffer = true;
			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,代码行数:17,代码来源:ScrollableWidgetTests.cs


示例12: 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


示例13: 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


示例14: 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


示例15: 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


示例16: NestedLayoutTopToBottomWithResizeTest

		public void NestedLayoutTopToBottomWithResizeTest(BorderDouble controlPadding, BorderDouble buttonMargin)
		{
			GuiWidget containerTest = new GuiWidget(300, 200);
			containerTest.Padding = controlPadding;
			containerTest.DoubleBuffer = true;
			containerTest.BackBuffer.NewGraphics2D().Clear(RGBA_Bytes.White);

			FlowLayoutWidget allButtons = new FlowLayoutWidget(FlowDirection.TopToBottom);
			{
				FlowLayoutWidget topButtonBar = new FlowLayoutWidget();
				{
					Button button1 = new Button("button1");
					button1.Margin = buttonMargin;
					topButtonBar.AddChild(button1);
				}
				allButtons.AddChild(topButtonBar);

				FlowLayoutWidget bottomButtonBar = new FlowLayoutWidget();
				{
					Button button2 = new Button("wide button2");
					button2.Margin = buttonMargin;
					bottomButtonBar.AddChild(button2);
				}
				allButtons.AddChild(bottomButtonBar);
			}
			containerTest.AddChild(allButtons);
			containerTest.OnDraw(containerTest.NewGraphics2D());
			ImageBuffer controlImage = new ImageBuffer(containerTest.BackBuffer, new BlenderBGRA());

			OutputImage(controlImage, "image-control.tga");

			RectangleDouble oldBounds = containerTest.LocalBounds;
			RectangleDouble newBounds = oldBounds;
			newBounds.Right += 10;
			containerTest.LocalBounds = newBounds;
			containerTest.BackBuffer.NewGraphics2D().Clear(RGBA_Bytes.White);
			containerTest.OnDraw(containerTest.NewGraphics2D());
			OutputImage(containerTest, "image-test.tga");

			containerTest.LocalBounds = oldBounds;
			containerTest.BackBuffer.NewGraphics2D().Clear(RGBA_Bytes.White);
			containerTest.OnDraw(containerTest.NewGraphics2D());
			OutputImage(containerTest, "image-test.tga");

			Assert.IsTrue(containerTest.BackBuffer != null, "When we set a guiWidget to DoubleBuffer it needs to create one.");
			Assert.IsTrue(containerTest.BackBuffer == controlImage, "The control should contain the same image after being scaled away and back to the same size.");
		}
开发者ID:eriser,项目名称:agg-sharp,代码行数:47,代码来源:FlowLayoutTests.cs


示例17: 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


示例18: OutputImages

		private void OutputImages(GuiWidget control, GuiWidget test)
		{
			OutputImage(control, "image-control.tga");
			OutputImage(test, "image-test.tga");
		}
开发者ID:eriser,项目名称:agg-sharp,代码行数:5,代码来源:FlowLayoutTests.cs


示例19: CreateLeftToRightMiddleWidget

		private GuiWidget CreateLeftToRightMiddleWidget(BorderDouble buttonMargin, double buttonSize, VAnchor vAnchor, RGBA_Bytes color)
		{
			GuiWidget middle = new GuiWidget(buttonSize / 2, buttonSize);
			middle.Margin = buttonMargin;
			middle.HAnchor = HAnchor.ParentLeftRight;
			middle.VAnchor = vAnchor;
			middle.BackgroundColor = color;
			return middle;
		}
开发者ID:eriser,项目名称:agg-sharp,代码行数:9,代码来源:FlowLayoutTests.cs


示例20: 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



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
C# Guid类代码示例发布时间:2022-05-24
下一篇:
C# GuiRenderer类代码示例发布时间: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