Example #1
0
 public void DrawLoadedPicture()
 {
     var material = new Material(Shader.Position2DColorUV, "DeltaEngineLogo");
     var picture = new Picture(Theme.Default, material, Rectangle.HalfCentered);
     var stream = BinaryDataExtensions.SaveToMemoryStream(picture);
     picture.IsActive = false;
     stream.CreateFromMemoryStream();
 }
Example #2
0
		public RadioButton(Theme theme, Rectangle drawArea, string text = "")
			: base(theme, theme.RadioButtonBackground, drawArea)
		{
			Text = text;
			var selector = new Picture(theme, theme.RadioButtonNotSelected, GetSelectorDrawArea());
			Add(selector);
			AddChild(selector);
		}
Example #3
0
		public void DrawLoadedPicture()
		{
			picture.IsActive = false;
			picture = new Picture(new Theme(), material, Rectangle.HalfCentered);
			var stream = BinaryDataExtensions.SaveToMemoryStream(picture);
			picture.IsActive = false;
			stream.CreateFromMemoryStream();
		}
Example #4
0
		public void CreateNewControlsWithIDNames()
		{
			var button1 = new Button(new Theme(), new Rectangle());
			Assert.AreEqual("Button1", button1.Name);
			var button2 = new Button(new Theme(), new Rectangle());
			Assert.AreEqual("Button2", button2.Name);
			var picture1 = new Picture(new Theme(), new Material(Color.Red, ShaderFlags.Position2DColored),
				new Rectangle());
			Assert.AreEqual("Picture1", picture1.Name);
		}
Example #5
0
 public void SaveAndLoad()
 {
     var material = new Material(Shader.Position2DColorUV, "DeltaEngineLogo");
     var theme = new Theme();
     theme.SliderPointer = material;
     var picture = new Picture(theme, material, Rectangle.HalfCentered);
     var stream = BinaryDataExtensions.SaveToMemoryStream(picture);
     var loadedPicture = (Picture)stream.CreateFromMemoryStream();
     Assert.AreEqual("DeltaEngineLogo", loadedPicture.Material.DiffuseMap.Name);
     Assert.AreEqual("DeltaEngineLogo", loadedPicture.Get<Theme>().SliderPointer.DiffuseMap.Name);
     Assert.AreEqual(Rectangle.HalfCentered, loadedPicture.DrawArea);
 }
Example #6
0
 public void AddControlToScene(Control control, UIEditorScene scene)
 {
     Control newControl = null;
     if (control.GetType() == typeof(Picture))
         newControl = new Picture(control.Get<Theme>(), control.Get<Material>(), control.DrawArea);
     else if (control.GetType() == typeof(Label))
     {
         newControl = new Label(control.Get<Theme>(), control.DrawArea, (control as Label).Text);
         newControl.Set(control.Get<Material>());
     }
     else if (control.GetType() == typeof(Button))
         newControl = new Button(control.Get<Theme>(), control.DrawArea, (control as Button).Text);
     else if (control.GetType() == typeof(Slider))
         newControl = new Slider(control.Get<Theme>(), control.DrawArea);
     newControl.AddTag(control.GetTags()[0]);
     newControl.RenderLayer = control.RenderLayer;
     scene.Scene.Add(newControl);
 }
Example #7
0
		public void AddControlToScene(Control control)
		{
			Control newControl = null;
			if (control.GetType() == typeof(Picture))
				newControl = new Picture(control.Get<Theme>(), control.Get<Material>(), control.DrawArea);
			else if (control.GetType() == typeof(Label))
			{
				newControl = new Label(control.Get<Theme>(), control.DrawArea, (control as Label).Text);
				newControl.Set(control.Get<BlendMode>());
				newControl.Set(control.Get<Material>());
			}
			else if (control.GetType() == typeof(Button))
				newControl = new Button(control.Get<Theme>(), control.DrawArea, (control as Button).Text);
			else if (control.GetType() == typeof(InteractiveButton))
				newControl = new InteractiveButton(control.Get<Theme>(), control.DrawArea,
					(control as Button).Text);
			else if (control.GetType() == typeof(Slider))
				newControl = new Slider(control.Get<Theme>(), control.DrawArea);
			newControl.RenderLayer = control.RenderLayer;
			if (!newControl.Contains<AnchoringState>())
				newControl.Add(new AnchoringState()); //ncrunch: no coverage
			CheckIfAnyMaterialIsCorrupt(newControl);
			Scene.Add(newControl);
		}
Example #8
0
		public void ChangingPointerChangesChild()
		{
			var pointer = new Picture(new Theme(), new Theme().ScrollbarPointer, Rectangle.Unused);
			scrollbar.Set(pointer);
			Assert.AreEqual(pointer, scrollbar.children[0].Entity2D);
		}
Example #9
0
		private void ReplaceChild(Picture selector)
		{
			if (Contains<Picture>())
				RemoveChild(Get<Picture>()); //ncrunch: no coverage
			AddChild(selector);
		}
Example #10
0
 private static Picture CreateANewDefaultImage(Vector2D position)
 {
     var costumImage = CreateDefaultImage();
     var material = new Material(ContentLoader.Load<Shader>(Shader.Position2DColorUV),
         costumImage, costumImage.PixelSize);
     var newSprite = new Picture(new Theme(), material,
         Rectangle.FromCenter(position, new Size(0.05f)));
     newSprite.Set(BlendMode.Normal);
     return newSprite;
 }
Example #11
0
 private static void SetDefaultNamesOfNewImages(Picture newSprite, UIEditorScene uiEditorScene)
 {
     bool freeName = false;
     int numberOfNames = 0;
     while (freeName == false)
         if (uiEditorScene.UIImagesInList.Contains("NewSprite" + numberOfNames))
             numberOfNames++;
         else
             freeName = true;
     uiEditorScene.UIImagesInList.Add("NewSprite" + numberOfNames);
     if (uiEditorScene.UIImagesInList[0] == null)
         uiEditorScene.UIImagesInList[0] = "NewSprite" + numberOfNames;
     newSprite.AddTag("NewSprite" + numberOfNames);
 }
Example #12
0
		private static void SetDefaultNamesOfNewImages(Picture newSprite, UIEditorScene uiEditorScene)
		{
			uiEditorScene.UIImagesInList.Add(newSprite.Name);
			if (uiEditorScene.UIImagesInList[0] == null)
				uiEditorScene.UIImagesInList[0] = newSprite.Name;
		}
Example #13
0
		private static Picture CreateANewDefaultImage(Vector2D position)
		{
			var material = ContentExtensions.CreateDefaultMaterial2D();
			var newSprite = new Picture(new Theme(), material,
				Rectangle.FromCenter(position, new Size(0.05f)));
			newSprite.Set(BlendMode.Normal);
			return newSprite;
		}
Example #14
0
		public void AddControlToScene(Control control, Scene scene)
		{
			Control newControl = null;
			if (control.GetType() == typeof(Picture))
				newControl = new Picture((control as Picture).Theme, control.Material, control.DrawArea);
			else if (control.GetType() == typeof(Label))
			{
				newControl = new Label((control as Picture).Theme, control.DrawArea, (control as Label).Text);
				newControl.Set(control.Get<BlendMode>());
				newControl.Set(control.Material);
			}
			else if (control.GetType() == typeof(Button))
				newControl = new Button((control as Picture).Theme, control.DrawArea, (control as Button).Text);
			else if (control.GetType() == typeof(InteractiveButton))
				newControl = new InteractiveButton((control as Picture).Theme, control.DrawArea,
					(control as Button).Text);
			else if (control.GetType() == typeof(Slider))
				newControl = new Slider((control as Picture).Theme, control.DrawArea);
			newControl.Name = control.Name;
			if (newControl.Name == null && newControl.GetTags()[0] != null)
				newControl.Name = newControl.GetTags()[0];
			newControl.RenderLayer = control.RenderLayer;
			if (!control.Contains<AnchoringState>())
				newControl.Set(new AnchoringState()); //ncrunch: no coverage
			else
				newControl.Set(control.Get<AnchoringState>());
			scene.Add(newControl);
		}
Example #15
0
		private static Picture LoadPicture(BinaryReader reader, byte[] versionBytes)
		{
			var picture = new Picture();
			picture.SetComponents(LoadComponents(picture, reader, versionBytes));
			var hasZeroTags = reader.ReadByte();
			var hasTwoBehaviors = reader.ReadByte();
			var arrayType1 = reader.ReadByte();
			var x = reader.ReadString();
			var y = reader.ReadString();
			var z = reader.ReadString();
			var hasOneDrawBehavior = reader.ReadByte();
			var arrayType2 = reader.ReadByte();
			var a = reader.ReadString();
			var b = reader.ReadString();
			picture.Start<UpdateRenderingCalculations>();
			picture.Start<ControlUpdater>();
			picture.OnDraw<SpriteRenderer>();
			return picture;
		}
Example #16
0
		public void AddNewSpriteToScene()
		{
			var picture = new Picture(new Theme(), new Material(ShaderFlags.Position2DColoredTextured, "deltalogo"),
				Rectangle.One);
			CheckTypeOfNewControl(picture, "Picture1");
		}
Example #17
0
		public void SetUp()
		{
			material = new Material(ShaderFlags.Position2DColoredTextured, "DeltaEngineLogo");
			var theme = new Theme { SliderPointer = material };
			picture = new Picture(theme, material, Rectangle.HalfCentered);
		}
Example #18
0
			private void CreateInterior(Color backgroundColor)
			{
				Add(Interior = new Picture(new Theme(), 
					new Material(backgroundColor, ShaderFlags.Position2DColored), Rectangle.One)
				{
					LeftMargin = new Margin(Edge.Left, EdgeWidth),
					RightMargin = new Margin(Edge.Right, EdgeWidth),
					TopMargin = new Margin(Edge.Top, EdgeWidth),
					BottomMargin = new Margin(Edge.Bottom, EdgeWidth)
				});
			}
Example #19
0
			private void CreateInterior(Color background)
			{
				Interior = new Picture(new Theme(), new Material(background, ShaderFlags.Position2DColored),
					DrawArea)
				{
					LeftMargin = new Margin(this, Edge.Left, EdgeWidth),
					RightMargin = new Margin(this, Edge.Right, EdgeWidth),
					TopMargin = new Margin(this, Edge.Top, EdgeWidth),
					BottomMargin = new Margin(this, Edge.Bottom, EdgeWidth)
				};
			}
Example #20
0
		private static Control LoadControl(BinaryReader reader, bool doNotNullRead,
			byte[] versionBytes)
		{
			var controlType = reader.ReadString();
			Control control;
			if (controlType == "Button")
				control = new Button();
			else if (controlType == "InteractiveButton")
				control = new InteractiveButton();
			else if (controlType == "Picture")
				control = new Picture();
			else if (controlType == "Label")
				control = new Label();
			else if (controlType == "Slider")
				control = new Slider();
			else
				throw new ControlTypeNotImplemented(controlType);
			if (doNotNullRead)
				reader.ReadBoolean();
			LoadControl(control, reader, versionBytes);
			return control;
		}
Example #21
0
		private void ReplaceChild(Picture pointer)
		{
			if (Contains<Picture>())
				RemoveChild(Get<Picture>());
			AddChild(pointer);
		}