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(); }
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); }
public void DrawLoadedPicture() { picture.IsActive = false; picture = new Picture(new Theme(), material, Rectangle.HalfCentered); var stream = BinaryDataExtensions.SaveToMemoryStream(picture); picture.IsActive = false; stream.CreateFromMemoryStream(); }
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); }
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); }
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); }
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); }
public void ChangingPointerChangesChild() { var pointer = new Picture(new Theme(), new Theme().ScrollbarPointer, Rectangle.Unused); scrollbar.Set(pointer); Assert.AreEqual(pointer, scrollbar.children[0].Entity2D); }
private void ReplaceChild(Picture selector) { if (Contains<Picture>()) RemoveChild(Get<Picture>()); //ncrunch: no coverage AddChild(selector); }
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; }
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); }
private static void SetDefaultNamesOfNewImages(Picture newSprite, UIEditorScene uiEditorScene) { uiEditorScene.UIImagesInList.Add(newSprite.Name); if (uiEditorScene.UIImagesInList[0] == null) uiEditorScene.UIImagesInList[0] = newSprite.Name; }
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; }
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); }
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; }
public void AddNewSpriteToScene() { var picture = new Picture(new Theme(), new Material(ShaderFlags.Position2DColoredTextured, "deltalogo"), Rectangle.One); CheckTypeOfNewControl(picture, "Picture1"); }
public void SetUp() { material = new Material(ShaderFlags.Position2DColoredTextured, "DeltaEngineLogo"); var theme = new Theme { SliderPointer = material }; picture = new Picture(theme, material, Rectangle.HalfCentered); }
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) }); }
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) }; }
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; }
private void ReplaceChild(Picture pointer) { if (Contains<Picture>()) RemoveChild(Get<Picture>()); AddChild(pointer); }