Esempio n. 1
0
 public void SetControlLayer(int value, UIControl uiControl, UIEditorScene uiEditorScene)
 {
     var selectedEntity2D = uiEditorScene.SelectedEntity2D;
     uiControl.controlLayer = value < 0 ? 0 : value;
     if (selectedEntity2D == null)
         return;
     selectedEntity2D.RenderLayer = uiControl.controlLayer;
 }
Esempio n. 2
0
 public void SetContentText(string value, UIControl uiControl, UIEditorScene uiEditorScene)
 {
     var selectedEntity2D = uiEditorScene.SelectedEntity2D;
     uiControl.contentText = value;
     if (selectedEntity2D.GetType() == typeof(Button))
         ChangeButton((Button)selectedEntity2D, uiControl);
     if (selectedEntity2D.GetType() == typeof(Label))
         ChangeLabel((Label)selectedEntity2D, uiControl);
 }
Esempio n. 3
0
		private void InitializeClasses()
		{
			ScreenSpace.Scene = new SceneScreenSpace(editorService.Viewport.Window, SceneResolution);
			ControlProcessor = new ControlProcessor();
			controlAdder = new ControlAdder();
			controlChanger = new ControlChanger();
			uiControl = new UIControl();
			controlTransformer = new ControlTransformer(editorService);
			controlAllignmentAndMargins = new ControlAllignmentAndMargins(this);
			controlMaterialChanger = new ControlMaterialChanger(this);
			uiSceneGrid = new UISceneGrid(this);
		}
Esempio n. 4
0
 public void AddImage(Vector2D position, UIControl uiControl, UIEditorScene uiEditorScene)
 {
     if (!IsDraggingImage)
         return;
     var sprite = AddNewImageToList(position, uiControl, uiEditorScene);
     uiEditorScene.SelectedEntity2D = sprite;
     uiControl.Index = uiEditorScene.Scene.Controls.IndexOf(sprite);
     uiControl.EntityWidth = sprite.DrawArea.Width;
     uiControl.EntityHeight = sprite.DrawArea.Height;
     IsDraggingImage = false;
     IsDragging = false;
     Messenger.Default.Send(sprite.GetTags()[0], "AddToHierachyList");
 }
Esempio n. 5
0
 public void ChangeControlName(string controlName, UIControl uiControl,
     UIEditorScene uiEditorScene)
 {
     var selectedEntity2D = uiEditorScene.SelectedEntity2D;
     uiControl.ControlName = controlName;
     Messenger.Default.Send(uiControl.ControlName, "ChangeSelectedControlName");
     var spriteListIndex = uiEditorScene.Scene.Controls.IndexOf(selectedEntity2D);
     if (spriteListIndex < 0)
         return; //ncrunch: no coverage
     uiEditorScene.UIImagesInList[spriteListIndex] = controlName;
     uiEditorScene.SelectedControlNameInList = controlName;
     selectedEntity2D.ClearTags();
     selectedEntity2D.AddTag(controlName);
 }
Esempio n. 6
0
 public void AddButton(Vector2D position, UIControl uiControl, UIEditorScene uiEditorScene)
 {
     if (!IsDraggingButton)
         return;
     var button = AddNewButtonToList(position, uiEditorScene);
     uiEditorScene.SelectedEntity2D = button;
     uiControl.Index = uiEditorScene.Scene.Controls.IndexOf(button);
     uiControl.contentText = "Default Button";
     uiControl.EntityWidth = button.DrawArea.Width;
     uiControl.EntityHeight = button.DrawArea.Height;
     IsDraggingButton = false;
     IsDragging = false;
     Messenger.Default.Send(button.GetTags()[0], "AddToHierachyList");
 }
Esempio n. 7
0
 public void SetWidth(float value, UIControl uiControl, UIEditorScene uiEditorScene)
 {
     var selectedEntity2D = uiEditorScene.SelectedEntity2D;
     if (uiControl.isClicking || selectedEntity2D == null)
         return;
     uiControl.EntityWidth = value;
     var rect = selectedEntity2D.DrawArea;
     rect.Width = uiControl.EntityWidth;
     rect.Height = uiControl.EntityHeight;
     selectedEntity2D.DrawArea = rect;
     if (selectedEntity2D.GetType() == typeof(Button))
         ChangeButton((Button)selectedEntity2D, uiControl);
     uiEditorScene.UpdateOutLine(selectedEntity2D);
 }
Esempio n. 8
0
		public void AddImage(Vector2D position, UIEditorScene uiEditorScene)
		{
			uiControl = uiEditorScene.uiControl;
			if (!IsDraggingImage)
				return;
			var sprite = AddNewImageToList(position, uiEditorScene);
			uiEditorScene.SetSingleSelectedControl(sprite);
			uiControl.Index = uiEditorScene.Scene.Controls.IndexOf(sprite);
			uiControl.EntityWidth = sprite.DrawArea.Width;
			uiControl.EntityHeight = sprite.DrawArea.Height;
			uiControl.contentText = "";
			uiControl.ControlName = sprite.Name;
			IsDraggingImage = false;
			IsDragging = false;
			Messenger.Default.Send(sprite.Name, "AddToHierachyList");
		}
Esempio n. 9
0
        public void AddImage(Vector2D position, UIEditorScene uiEditorScene)
        {
            uiControl = uiEditorScene.uiControl;
            if (!IsDraggingImage)
            {
                return;
            }
            var sprite = AddNewImageToList(position, uiEditorScene);

            uiEditorScene.SetSingleSelectedControl(sprite);
            uiControl.Index        = uiEditorScene.Scene.Controls.IndexOf(sprite);
            uiControl.EntityWidth  = sprite.DrawArea.Width;
            uiControl.EntityHeight = sprite.DrawArea.Height;
            uiControl.contentText  = "";
            uiControl.ControlName  = sprite.Name;
            IsDraggingImage        = false;
            IsDragging             = false;
            Messenger.Default.Send(sprite.Name, "AddToHierachyList");
        }
Esempio n. 10
0
        public void AddLabel(Vector2D position, UIEditorScene uiEditorScene)
        {
            uiControl = uiEditorScene.uiControl;
            if (!IsDraggingLabel)
            {
                return;
            }
            var label = AddNewLabelToList(position, uiEditorScene);

            uiEditorScene.SetSingleSelectedControl(label);
            uiControl.Index        = uiEditorScene.Scene.Controls.IndexOf(label);
            uiControl.contentText  = "Default Label";
            uiControl.EntityWidth  = label.DrawArea.Width;
            uiControl.EntityHeight = label.DrawArea.Height;
            uiControl.ControlName  = label.Name;
            IsDraggingLabel        = false;
            IsDragging             = false;
            Messenger.Default.Send(label.Name, "AddToHierachyList");
        }
Esempio n. 11
0
 public void SetSelectedControlNameInList(string value, UIControl uiControl,
     UIEditorScene uiEditorScene)
 {
     if (value == null || uiControl.Index < 0 || uiEditorScene.Scene.Controls.Count <= 0)
         return;
     uiEditorScene.SelectedControlNameInList = value;
     uiEditorScene.SelectedEntity2D = uiEditorScene.Scene.Controls[uiControl.Index];
     uiEditorScene.UpdateOutLine(uiEditorScene.SelectedEntity2D);
     uiControl.ControlName = value;
     uiControl.controlLayer = uiEditorScene.SelectedEntity2D.RenderLayer;
     uiControl.EntityWidth = uiEditorScene.SelectedEntity2D.DrawArea.Width;
     uiControl.EntityHeight = uiEditorScene.SelectedEntity2D.DrawArea.Height;
     if (uiEditorScene.SelectedEntity2D.GetType() == typeof(Button))
         uiControl.contentText = ((Button)uiEditorScene.SelectedEntity2D).Text;
     else if (uiEditorScene.SelectedEntity2D.GetType() == typeof(Label))
         uiControl.contentText = ((Label)uiEditorScene.SelectedEntity2D).Text;
     else
         uiControl.contentText = "";
 }
Esempio n. 12
0
        public void AddButton(Vector2D position, UIEditorScene uiEditorScene)
        {
            uiControl = uiEditorScene.uiControl;
            if (!IsDraggingButton)
            {
                return;
            }
            var button = AddNewButtonToList(position, uiEditorScene);

            uiEditorScene.SetSingleSelectedControl(button);
            uiControl.Index        = uiEditorScene.Scene.Controls.IndexOf(button);
            uiControl.contentText  = "Default Button";
            uiControl.EntityWidth  = button.DrawArea.Width;
            uiControl.EntityHeight = button.DrawArea.Height;
            uiControl.contentText  = "Defualt button";
            uiControl.ControlName  = button.Name;
            IsDraggingButton       = false;
            IsDragging             = false;
            Messenger.Default.Send(button.Name, "AddToHierachyList");
        }
Esempio n. 13
0
        public void ChangeUIControlWidthAndHeight(Control control, UIControl uiControl)
        {
            Rectangle drawArea;

            if (control.GetType() == typeof(Button))
            {
                drawArea = new Rectangle(control.DrawArea.TopLeft, (control).Size);
                uiControl.IsInteractiveButton = false;
            }
            else if (control.GetType() == typeof(InteractiveButton))
            {
                drawArea = Rectangle.FromCenter(control.Center, control.Size);
                if (uiControl.IsInteractiveButton == false)
                {
                    uiControl.IsInteractiveButton = true;
                }
            }
            else
            {
                drawArea = control.DrawArea;
            }
            uiControl.SetWidthAndHeight(drawArea);
        }
Esempio n. 14
0
 public UIEditorViewModel(Service service)
 {
     this.service = service;
     Messenger.Default.Send("ClearScene", "ClearScene");
     uiEditorScene = new UIEditorScene();
     uiEditorScene.ControlProcessor = new ControlProcessor(this);
     uiControl = new UIControl();
     controlAdder = new ControlAdder();
     controlChanger = new ControlChanger();
     Adder = new ControlAdder();
     Scene = new Scene();
     InitializeDefaults();
     InitializeGrid();
     FillContentImageList();
     FillMaterialList();
     FillSceneNames();
     FillListOfAvailableFonts();
     SetMouseCommands("");
     SetMessengers();
     CreateCenteredControl("Button");
     UIName = "MyScene";
     CheckIfCanSaveScene();
     new Command(() => DeleteSelectedControl("")).Add(new KeyTrigger(Key.Delete));
 }
Esempio n. 15
0
		public void AddButton(Vector2D position, UIEditorScene uiEditorScene)
		{
			uiControl = uiEditorScene.uiControl;
			if (!IsDraggingButton)
				return;
			var button = AddNewButtonToList(position, uiEditorScene);
			uiEditorScene.SetSingleSelectedControl(button);
			uiControl.Index = uiEditorScene.Scene.Controls.IndexOf(button);
			uiControl.contentText = "Default Button";
			uiControl.EntityWidth = button.DrawArea.Width;
			uiControl.EntityHeight = button.DrawArea.Height;
			uiControl.contentText = "Defualt button";
			uiControl.ControlName = button.Name;
			IsDraggingButton = false;
			IsDragging = false;
			Messenger.Default.Send(button.Name, "AddToHierachyList");
		}
Esempio n. 16
0
 public void AddLabel(Vector2D position, UIControl uiControl, UIEditorScene uiEditorScene)
 {
     if (!IsDraggingLabel)
         return;
     var label = AddNewLabelToList(position, uiEditorScene);
     uiEditorScene.SelectedEntity2D = label;
     uiControl.Index = uiEditorScene.Scene.Controls.IndexOf(label);
     uiControl.contentText = "Default Label";
     uiControl.EntityWidth = label.DrawArea.Width;
     uiControl.EntityHeight = label.DrawArea.Height;
     IsDraggingLabel = false;
     IsDragging = false;
     Messenger.Default.Send(label.GetTags()[0], "AddToHierachyList");
 }
Esempio n. 17
0
 public void AddSlider(Vector2D position, UIControl uiControl, UIEditorScene uiEditorScene)
 {
     if (!IsDraggingSlider)
         return;
     var slider = AddNewSliderToList(position, uiEditorScene);
     uiEditorScene.SelectedEntity2D = slider;
     uiControl.Index = uiEditorScene.Scene.Controls.IndexOf(slider);
     uiControl.contentText = "Default Slider";
     uiControl.EntityWidth = slider.DrawArea.Width;
     uiControl.EntityHeight = slider.DrawArea.Height;
     IsDraggingSlider = false;
     IsDragging = false;
     Messenger.Default.Send(slider.GetTags()[0], "AddToHierachyList");
 }
Esempio n. 18
0
 private static void ChangeLabel(Label label, UIControl uiControl)
 {
     label.Size = new Size(uiControl.EntityWidth, uiControl.EntityHeight);
     label.Text = uiControl.contentText;
 }
Esempio n. 19
0
 private static void ChangeButton(Button button, UIControl uiControl)
 {
     button.Size = new Size(uiControl.EntityWidth, uiControl.EntityHeight);
     button.Text = uiControl.contentText;
 }
Esempio n. 20
0
 private static void ChangeLabel(Label label, UIControl uiControl)
 {
     label.Size = new Size(uiControl.EntityWidth, uiControl.EntityHeight);
     label.Text = uiControl.contentText;
 }
Esempio n. 21
0
 private static void ChangeButton(Button button, UIControl uiControl)
 {
     button.Size = new Size(uiControl.EntityWidth, uiControl.EntityHeight);
     button.Text = uiControl.contentText;
 }
Esempio n. 22
0
 public Picture AddNewImageToList(Vector2D position, UIControl uiControl,
     UIEditorScene uiEditorScene)
 {
     var newSprite = CreateANewDefaultImage(position);
     uiEditorScene.Scene.Add(newSprite);
     SetDefaultNamesOfNewImages(newSprite, uiEditorScene);
     return newSprite;
 }
Esempio n. 23
0
		public void CreateCenteredControl(string newControl, UIEditorScene uiEditorScene)
		{
			uiControl = uiEditorScene.uiControl;
			IsDragging = true;
			if (newControl == "Image")
			{
				IsDraggingImage = true;
				AddImage(Vector2D.Half, uiEditorScene);
			}
			else if (newControl == "Button")
			{
				IsDraggingButton = true;
				AddButton(Vector2D.Half, uiEditorScene);
			}
			else if (newControl == "Label")
			{
				IsDraggingLabel = true;
				AddLabel(Vector2D.Half, uiEditorScene);
			}
			else if (newControl == "Slider")
			{
				IsDraggingSlider = true;
				AddSlider(Vector2D.Half, uiEditorScene);
			}
			uiEditorScene.uiControl.isClicking = false;
			if (uiEditorScene.SelectedEntity2DList.Count == 0)
				return;
			uiEditorScene.ControlProcessor.UpdateOutlines(uiEditorScene.SelectedEntity2DList);
		}
Esempio n. 24
0
		public void AddSlider(Vector2D position, UIEditorScene uiEditorScene)
		{
			uiControl = uiEditorScene.uiControl;
			if (!IsDraggingSlider)
				return;
			var slider = AddNewSliderToList(position, uiEditorScene);
			uiEditorScene.SetSingleSelectedControl(slider);
			uiControl.Index = uiEditorScene.Scene.Controls.IndexOf(slider);
			uiControl.contentText = "Default Slider";
			uiControl.EntityWidth = slider.DrawArea.Width;
			uiControl.EntityHeight = slider.DrawArea.Height;
			uiControl.ControlName = slider.Name;
			IsDraggingSlider = false;
			IsDragging = false;
			Messenger.Default.Send(slider.Name, "AddToHierachyList");
		}
Esempio n. 25
0
		public void AddLabel(Vector2D position, UIEditorScene uiEditorScene)
		{
			uiControl = uiEditorScene.uiControl;
			if (!IsDraggingLabel)
				return;
			var label = AddNewLabelToList(position, uiEditorScene);
			uiEditorScene.SetSingleSelectedControl(label);
			uiControl.Index = uiEditorScene.Scene.Controls.IndexOf(label);
			uiControl.contentText = "Default Label";
			uiControl.EntityWidth = label.DrawArea.Width;
			uiControl.EntityHeight = label.DrawArea.Height;
			uiControl.ControlName = label.Name;
			IsDraggingLabel = false;
			IsDragging = false;
			Messenger.Default.Send(label.Name, "AddToHierachyList");
		}
Esempio n. 26
0
		public void ChangeUIControlWidthAndHeight(Control control, UIControl uiControl)
		{
			Rectangle drawArea;
			if (control.GetType() == typeof(Button))
			{
				drawArea = new Rectangle(control.DrawArea.TopLeft, (control).Size);
				uiControl.IsInteractiveButton = false;
			}
			else if (control.GetType() == typeof(InteractiveButton))
			{
				drawArea = Rectangle.FromCenter(control.Center, control.Size);
				if (uiControl.IsInteractiveButton == false)
					uiControl.IsInteractiveButton = true;
			}
			else
				drawArea = control.DrawArea;
			uiControl.SetWidthAndHeight(drawArea);
		}