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); }
private bool SetEntity2D(Control control) { Rectangle drawArea; if (control.GetType() == typeof(Button)) { drawArea = new Rectangle(control.DrawArea.TopLeft, (control).Size); IsInteractiveButton = false; } else if (control.GetType() == typeof(InteractiveButton)) { drawArea = Rectangle.FromCenter(control.Center, ((InteractiveButton)control).BaseSize); if (IsInteractiveButton == false) IsInteractiveButton = true; } else drawArea = control.DrawArea; ControlListIndex = Scene.Controls.IndexOf(control); if (ControlListIndex < 0) return true; //ncrunch: no coverage SelectedControlNameInList = control.GetTags()[0]; SelectedEntity2D = control; SetMaterials(); Messenger.Default.Send(SelectedControlNameInList, "SetSelectedName"); Messenger.Default.Send(ControlListIndex, "SetSelectedIndex"); uiEditorScene.ControlProcessor.UpdateOutLines(SelectedEntity2D); SetWidthAndHeight(drawArea); ControlLayer = control.RenderLayer; return false; }