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);
 }
Exemple #2
0
		public void ChangeToInteractiveButton(UIEditorScene uiEditorScene)
		{
			if (uiEditorScene == null)
				return; //ncrunch: no coverage 
			for (int i = 0; i < uiEditorScene.SelectedEntity2DList.Count; i++)
			{
				var selectedEntity2D = uiEditorScene.SelectedEntity2DList[i];
				if (selectedEntity2D == null ||
					(selectedEntity2D.GetType() != typeof(Button) &&
						selectedEntity2D.GetType() != typeof(InteractiveButton)))
					return;
				var index = uiEditorScene.Scene.Controls.IndexOf(selectedEntity2D);
				var selectedIndex = uiEditorScene.SelectedEntity2DList.IndexOf(selectedEntity2D);
				uiEditorScene.Scene.Remove(selectedEntity2D);
				uiEditorScene.SelectedEntity2DList.RemoveAt(i);
				var renderLayer = selectedEntity2D.RenderLayer;
				var anchorState = selectedEntity2D.Get<AnchoringState>();
				var controlName = (selectedEntity2D as Control).Name;
				if (IsInteractiveButton)
					selectedEntity2D = new InteractiveButton(selectedEntity2D.Get<Theme>(),
						selectedEntity2D.DrawArea, ((Button)selectedEntity2D).Text);
				else
					selectedEntity2D = new Button(selectedEntity2D.Get<Theme>(), selectedEntity2D.DrawArea,
						((Button)selectedEntity2D).Text);
				selectedEntity2D.RenderLayer = renderLayer;
				selectedEntity2D.Set(anchorState);
				(selectedEntity2D as Control).Name = controlName;
				uiEditorScene.Scene.Controls.Insert(index, selectedEntity2D);
				uiEditorScene.SelectedEntity2DList.Insert(selectedIndex, selectedEntity2D);
			}
		}
Exemple #3
0
		public Picture AddNewImageToList(Vector2D position, UIEditorScene uiEditorScene)
		{
			var newSprite = CreateANewDefaultImage(position);
			uiEditorScene.Scene.Add(newSprite);
			SetDefaultNamesOfNewImages(newSprite, uiEditorScene);
			return newSprite;
		}
Exemple #4
0
		public UISceneGrid(UIEditorScene uiEditorScene)
		{
			GridHeight = 30;
			GridHeight = 30;
			this.uiEditorScene = uiEditorScene;
			DrawGrid();
		}
        public void SetSelectedControlNameInList(List <string> value, UIEditorScene uiEditorScene)
        {
            var uiControl = uiEditorScene.uiControl;

            if (value == null || uiControl.Index < 0 || uiEditorScene.Scene.Controls.Count <= 0)
            {
                return;
            }
            var entity = uiEditorScene.Scene.Controls[uiControl.Index];

            uiEditorScene.UpdateOutLine(uiEditorScene.SelectedEntity2DList);
            uiControl.ControlName  = value[value.Count - 1];
            uiControl.controlLayer = entity.RenderLayer;
            uiControl.EntityWidth  = entity.DrawArea.Width;
            uiControl.EntityHeight = entity.DrawArea.Height;
            if (uiEditorScene.SelectedEntity2DList.GetType() == typeof(Button) ||
                uiEditorScene.SelectedEntity2DList.GetType() == typeof(InteractiveButton))
            {
                uiControl.contentText = ((Button)entity).Text;
            }
            else if (uiEditorScene.SelectedEntity2DList.GetType() == typeof(Label))
            {
                uiControl.contentText = ((Label)entity).Text;
            }
            else
            {
                uiControl.contentText = "";
            }
        }
Exemple #6
0
 public UISceneGrid(UIEditorScene uiEditorScene)
 {
     GridHeight         = 30;
     GridHeight         = 30;
     this.uiEditorScene = uiEditorScene;
     DrawGrid();
 }
Exemple #7
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;
 }
Exemple #8
0
		public void AddControl(Vector2D position, UIEditorScene uiEditorScene)
		{
			AddImage(position, uiEditorScene);
			AddButton(position, uiEditorScene);
			AddLabel(position, uiEditorScene);
			AddSlider(position, uiEditorScene);
			IsDragging = false;
		}
 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 void SetDefaultSliderName(Slider newSlider, UIEditorScene uiEditorScene)
 {
     uiEditorScene.UIImagesInList.Add(newSlider.Name);
     if (uiEditorScene.UIImagesInList[0] == null)
     {
         uiEditorScene.UIImagesInList[0] = newSlider.Name;
     }
 }
 private static void SetDefaultNameOfLable(Label newLabel, UIEditorScene uiEditorScene)
 {
     uiEditorScene.UIImagesInList.Add(newLabel.Name);
     if (uiEditorScene.UIImagesInList[0] == null)
     {
         uiEditorScene.UIImagesInList[0] = newLabel.Name;
     }
 }
        public Picture AddNewImageToList(Vector2D position, UIEditorScene uiEditorScene)
        {
            var newSprite = CreateANewDefaultImage(position);

            uiEditorScene.Scene.Add(newSprite);
            SetDefaultNamesOfNewImages(newSprite, uiEditorScene);
            return(newSprite);
        }
 private static void SetDefaultButtonName(Button newButton, UIEditorScene uiEditorScene)
 {
     uiEditorScene.UIImagesInList.Add(newButton.Name);
     if (uiEditorScene.UIImagesInList[0] == null)
     {
         uiEditorScene.UIImagesInList[0] = newButton.Name;
     }
 }
 public void AddControl(Vector2D position, UIEditorScene uiEditorScene)
 {
     AddImage(position, uiEditorScene);
     AddButton(position, uiEditorScene);
     AddLabel(position, uiEditorScene);
     AddSlider(position, uiEditorScene);
     IsDragging = false;
 }
        private static Slider AddNewSliderToList(Vector2D position, UIEditorScene uiEditorScene)
        {
            var newSlider = new Slider(new Theme(),
                                       Rectangle.FromCenter(position, new Size(0.15f, 0.03f)));

            uiEditorScene.Scene.Add(newSlider);
            SetDefaultSliderName(newSlider, uiEditorScene);
            return(newSlider);
        }
        private static Button AddNewButtonToList(Vector2D position, UIEditorScene uiEditorScene)
        {
            var newButton = new Button(new Theme(), Rectangle.FromCenter(position, new Size(0.2f, 0.1f)),
                                       "Default Button");

            uiEditorScene.Scene.Add(newButton);
            SetDefaultButtonName(newButton, uiEditorScene);
            return(newButton);
        }
Exemple #17
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);
 }
        private static Label AddNewLabelToList(Vector2D position, UIEditorScene uiEditorScene)
        {
            var newLabel = new Label(new Theme(), Rectangle.FromCenter(position, new Size(0.2f, 0.1f)),
                                     "DefaultLabel");

            uiEditorScene.Scene.Add(newLabel);
            SetDefaultNameOfLable(newLabel, uiEditorScene);
            newLabel.Set(BlendMode.Normal);
            return(newLabel);
        }
Exemple #19
0
 public bool ChangeToInteractiveButton(bool value, UIEditorScene uiEditorScene)
 {
     if (IsInteractiveButton == value)
     {
         return(true);
     }
     IsInteractiveButton = value;
     ChangeToInteractiveButton(uiEditorScene);
     return(false);
 }
Exemple #20
0
		public void SetControlLayer(int value, UIEditorScene uiEditorScene)
		{
			var uiControl = uiEditorScene.uiControl;
			uiControl.controlLayer = value < 0 ? 0 : value;
			foreach (var selectedEntity2D in uiEditorScene.SelectedEntity2DList)
			{
				if (selectedEntity2D == null)
					return;
				selectedEntity2D.RenderLayer = uiControl.controlLayer;
			}
		}
		public UIEditorViewModel(Service service)
		{
			this.service = service;
			Messenger.Default.Send("ClearScene", "ClearScene");
			UiEditorScene = new UIEditorScene(service);
			SetMouseCommands("");
			CreateCenteredControl("Button");
			UIName = "MyScene";
			UpdateIfCanSaveScene();
			SetMessengers();
		}
Exemple #22
0
 public UIEditorViewModel(Service service)
 {
     this.service = service;
     Messenger.Default.Send("ClearScene", "ClearScene");
     UiEditorScene = new UIEditorScene(service);
     SetMouseCommands("");
     CreateCenteredControl("Button");
     UIName = "MyScene";
     UpdateIfCanSaveScene();
     SetMessengers();
 }
 internal void MoveImage(Vector2D mousePosition, Entity2D selectedEntity2D, bool isDragging,
     bool isSnappingToGrid, UIEditorScene scene)
 {
     if (selectedEntity2D == null || isDragging)
         return; //ncrunch: no coverage
     if (uiEditorViewModel.GridWidth == 0 || uiEditorViewModel.GridHeight == 0 ||
         !isSnappingToGrid || !scene.IsDrawingGrid)
         MoveImageWithoutGrid(mousePosition, selectedEntity2D);
     else
         MoveImageUsingTheGrid(mousePosition, selectedEntity2D, scene);
     UpdateOutLines(selectedEntity2D);
 }
Exemple #24
0
		public void SetContentText(string value, UIEditorScene uiEditorScene)
		{
			var uiControl = uiEditorScene.uiControl;
			foreach (var selectedEntity2D in uiEditorScene.SelectedEntity2DList)
			{
				uiControl.contentText = value;
				if (selectedEntity2D.GetType() == typeof(Button) ||
					selectedEntity2D.GetType() == typeof(InteractiveButton))
					ChangeButton((Button)selectedEntity2D, uiControl);
				if (selectedEntity2D.GetType() == typeof(Label))
					ChangeLabel((Label)selectedEntity2D, uiControl);
			}
		}
Exemple #25
0
		public void SetControlSize(Entity2D control, Material material, UIEditorScene scene)
		{
			if (material.DiffuseMap.PixelSize.Width < 10 || material.DiffuseMap.PixelSize.Height < 10)
				return;
			if (scene.SceneResolution.AspectRatio > 1)
				control.DrawArea = new Rectangle(control.DrawArea.TopLeft,
					new Size(((material.DiffuseMap.PixelSize.Width / scene.SceneResolution.Width)),
						((material.DiffuseMap.PixelSize.Height / scene.SceneResolution.Width))));
			else
				control.DrawArea = new Rectangle(control.DrawArea.TopLeft,
					new Size(((material.DiffuseMap.PixelSize.Width / scene.SceneResolution.Height)),
						((material.DiffuseMap.PixelSize.Height / scene.SceneResolution.Height))));
		}
Exemple #26
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");
 }
Exemple #27
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");
 }
Exemple #28
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);
 }
Exemple #29
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);
 }
        public void SetControlLayer(int value, UIEditorScene uiEditorScene)
        {
            var uiControl = uiEditorScene.uiControl;

            uiControl.controlLayer = value < 0 ? 0 : value;
            foreach (var selectedEntity2D in uiEditorScene.SelectedEntity2DList)
            {
                if (selectedEntity2D == null)
                {
                    return;
                }
                selectedEntity2D.RenderLayer = uiControl.controlLayer;
            }
        }
Exemple #31
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");
		}
Exemple #32
0
		public void SetHeight(float value, UIEditorScene uiEditorScene)
		{
			var uiControl = uiEditorScene.uiControl;
			foreach (var selectedEntity2D in uiEditorScene.SelectedEntity2DList)
			{
				if (uiControl.isClicking || selectedEntity2D == null)
					return;
				uiControl.EntityHeight = 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(uiEditorScene.SelectedEntity2DList);
		}
        public void SetContentText(string value, UIEditorScene uiEditorScene)
        {
            var uiControl = uiEditorScene.uiControl;

            foreach (var selectedEntity2D in uiEditorScene.SelectedEntity2DList)
            {
                uiControl.contentText = value;
                if (selectedEntity2D.GetType() == typeof(Button) ||
                    selectedEntity2D.GetType() == typeof(InteractiveButton))
                {
                    ChangeButton((Button)selectedEntity2D, uiControl);
                }
                if (selectedEntity2D.GetType() == typeof(Label))
                {
                    ChangeLabel((Label)selectedEntity2D, uiControl);
                }
            }
        }
Exemple #34
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);
 }
 internal void MoveImage(Vector2D mousePosition, List <Entity2D> selectedEntity2DList,
                         bool isDragging, UIEditorScene scene)
 {
     if (selectedEntity2DList.Count == 0 || isDragging)
     {
         return;                 //ncrunch: no coverage
     }
     if (scene.UISceneGrid.GridWidth == 0 || scene.UISceneGrid.GridHeight == 0 ||
         !scene.IsSnappingToGrid || !scene.IsDrawingGrid)
     {
         MoveImageWithoutGrid(mousePosition, selectedEntity2DList);
     }
     else
     {
         MoveImageUsingTheGrid(mousePosition, selectedEntity2DList, scene);
     }
     UpdateOutlines(selectedEntity2DList);
 }
 public void ChangeControlName(string controlName, UIEditorScene uiEditorScene)
 {
     foreach (var selectedEntity2D in uiEditorScene.SelectedEntity2DList)
     {
         uiEditorScene.uiControl.ControlName = controlName;
         Messenger.Default.Send(controlName, "ChangeSelectedControlName");
         var spriteListIndex = uiEditorScene.Scene.Controls.IndexOf(selectedEntity2D);
         if (spriteListIndex < 0)
         {
             return;                     //ncrunch: no coverage
         }
         uiEditorScene.UIImagesInList[spriteListIndex] = controlName;
         for (int index = 0; index < uiEditorScene.SelectedControlNamesInList.Count; index++)
         {
             uiEditorScene.SelectedControlNamesInList[index] = controlName;
         }
         (selectedEntity2D as Control).Name = controlName;
     }
 }
        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");
        }
Exemple #38
0
 public void SetControlSize(Entity2D control, Material material, UIEditorScene scene)
 {
     if (material.DiffuseMap.PixelSize.Width < 10 || material.DiffuseMap.PixelSize.Height < 10)
     {
         return;
     }
     if (scene.SceneResolution.AspectRatio > 1)
     {
         control.DrawArea = new Rectangle(control.DrawArea.TopLeft,
                                          new Size(((material.DiffuseMap.PixelSize.Width / scene.SceneResolution.Width)),
                                                   ((material.DiffuseMap.PixelSize.Height / scene.SceneResolution.Width))));
     }
     else
     {
         control.DrawArea = new Rectangle(control.DrawArea.TopLeft,
                                          new Size(((material.DiffuseMap.PixelSize.Width / scene.SceneResolution.Height)),
                                                   ((material.DiffuseMap.PixelSize.Height / scene.SceneResolution.Height))));
     }
 }
        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");
        }
Exemple #40
0
		public void SetSelectedControlNameInList(List<string> value, UIEditorScene uiEditorScene)
		{
			var uiControl = uiEditorScene.uiControl;
			if (value == null || uiControl.Index < 0 || uiEditorScene.Scene.Controls.Count <= 0)
				return;
			var entity = uiEditorScene.Scene.Controls[uiControl.Index];
			uiEditorScene.UpdateOutLine(uiEditorScene.SelectedEntity2DList);
			uiControl.ControlName = value[value.Count - 1];
			uiControl.controlLayer = entity.RenderLayer;
			uiControl.EntityWidth = entity.DrawArea.Width;
			uiControl.EntityHeight = entity.DrawArea.Height;
			if (uiEditorScene.SelectedEntity2DList.GetType() == typeof(Button) ||
				uiEditorScene.SelectedEntity2DList.GetType() == typeof(InteractiveButton))
				uiControl.contentText = ((Button)entity).Text;
			else if (uiEditorScene.SelectedEntity2DList.GetType() == typeof(Label))
				uiControl.contentText = ((Label)entity).Text;
			else
				uiControl.contentText = "";
		}
Exemple #41
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 = "";
 }
        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");
        }
        private void MoveImageUsingTheGrid(Vector2D mousePosition,
                                           List <Entity2D> selectedEntity2DList, UIEditorScene scene)
        {
            Vector2D topLeft          = scene.UISceneGrid.LinesInGridList[0].TopLeft;
            var      relativePosition = mousePosition - lastMousePosition;

            foreach (var selectedEntity2D in selectedEntity2DList)
            {
                float posX      = (selectedEntity2D.DrawArea.Left + relativePosition.X);
                float posY      = (selectedEntity2D.DrawArea.Top + relativePosition.Y);
                var   sceneSize =
                    ScreenSpace.Current.FromPixelSpace(new Size(scene.SceneResolution.Width,
                                                                scene.SceneResolution.Height));
                var tileSize =
                    ScreenSpace.Current.FromPixelSpace(new Size(scene.UISceneGrid.GridWidth,
                                                                scene.UISceneGrid.GridHeight));
                float tilewidth;
                float tileheight;
                if (sceneSize.Width > sceneSize.Height)
                {
                    tilewidth  = 1 / (sceneSize.Width / tileSize.Width);
                    tileheight = 1 / (sceneSize.Width / tileSize.Height);
                }
                else
                {
                    tilewidth  = 1 / (sceneSize.Height / tileSize.Width);
                    tileheight = 1 / (sceneSize.Height / tileSize.Height);
                }
                var columnNumberInGrid = (int)Math.Round((posX - topLeft.X) / tilewidth);
                var rowNumberInGrid    = (int)Math.Round((posY - topLeft.Y) / tileheight);
                selectedEntity2D.DrawArea = new Rectangle((tilewidth * columnNumberInGrid) + topLeft.X,
                                                          (tileheight * rowNumberInGrid) + topLeft.Y, selectedEntity2D.DrawArea.Width,
                                                          selectedEntity2D.DrawArea.Height);
                if (spritePos == selectedEntity2D.Center)
                {
                    return;                     //ncrunch: no coverage
                }
                lastMousePosition = mousePosition;
                spritePos         = selectedEntity2D.Center;
            }
        }
        public void SetHeight(float value, UIEditorScene uiEditorScene)
        {
            var uiControl = uiEditorScene.uiControl;

            foreach (var selectedEntity2D in uiEditorScene.SelectedEntity2DList)
            {
                if (uiControl.isClicking || selectedEntity2D == null)
                {
                    return;
                }
                uiControl.EntityHeight = 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(uiEditorScene.SelectedEntity2DList);
        }
Exemple #45
0
 public void ChangeToInteractiveButton(UIEditorScene uiEditorScene)
 {
     if (uiEditorScene == null)
     {
         return;                 //ncrunch: no coverage
     }
     for (int i = 0; i < uiEditorScene.SelectedEntity2DList.Count; i++)
     {
         var selectedEntity2D = uiEditorScene.SelectedEntity2DList[i];
         if (selectedEntity2D == null ||
             (selectedEntity2D.GetType() != typeof(Button) &&
              selectedEntity2D.GetType() != typeof(InteractiveButton)))
         {
             return;
         }
         var index         = uiEditorScene.Scene.Controls.IndexOf(selectedEntity2D);
         var selectedIndex = uiEditorScene.SelectedEntity2DList.IndexOf(selectedEntity2D);
         uiEditorScene.Scene.Remove(selectedEntity2D);
         uiEditorScene.SelectedEntity2DList.RemoveAt(i);
         var renderLayer = selectedEntity2D.RenderLayer;
         var anchorState = selectedEntity2D.Get <AnchoringState>();
         var controlName = (selectedEntity2D as Control).Name;
         if (IsInteractiveButton)
         {
             selectedEntity2D = new InteractiveButton(selectedEntity2D.Get <Theme>(),
                                                      selectedEntity2D.DrawArea, ((Button)selectedEntity2D).Text);
         }
         else
         {
             selectedEntity2D = new Button(selectedEntity2D.Get <Theme>(), selectedEntity2D.DrawArea,
                                           ((Button)selectedEntity2D).Text);
         }
         selectedEntity2D.RenderLayer = renderLayer;
         selectedEntity2D.Set(anchorState);
         (selectedEntity2D as Control).Name = controlName;
         uiEditorScene.Scene.Controls.Insert(index, selectedEntity2D);
         uiEditorScene.SelectedEntity2DList.Insert(selectedIndex, selectedEntity2D);
     }
 }
 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));
 }
Exemple #47
0
		private static void SetDefaultNameOfLable(Label newLabel, UIEditorScene uiEditorScene)
		{
			uiEditorScene.UIImagesInList.Add(newLabel.Name);
			if (uiEditorScene.UIImagesInList[0] == null)
				uiEditorScene.UIImagesInList[0] = newLabel.Name;
		}
Exemple #48
0
 public ControlMaterialChanger(UIEditorScene uiEditorScene)
 {
     this.uiEditorScene = uiEditorScene;
 }
Exemple #49
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");
		}
Exemple #50
0
		private static Label AddNewLabelToList(Vector2D position, UIEditorScene uiEditorScene)
		{
			var newLabel = new Label(new Theme(), Rectangle.FromCenter(position, new Size(0.2f, 0.1f)),
				"DefaultLabel");
			uiEditorScene.Scene.Add(newLabel);
			SetDefaultNameOfLable(newLabel, uiEditorScene);
			newLabel.Set(BlendMode.Normal);
			return newLabel;
		}
Exemple #51
0
		private static Slider AddNewSliderToList(Vector2D position, UIEditorScene uiEditorScene)
		{
			var newSlider = new Slider(new Theme(),
				Rectangle.FromCenter(position, new Size(0.15f, 0.03f)));
			uiEditorScene.Scene.Add(newSlider);
			SetDefaultSliderName(newSlider, uiEditorScene);
			return newSlider;
		}
Exemple #52
0
		private static void SetDefaultNamesOfNewImages(Picture newSprite, UIEditorScene uiEditorScene)
		{
			uiEditorScene.UIImagesInList.Add(newSprite.Name);
			if (uiEditorScene.UIImagesInList[0] == null)
				uiEditorScene.UIImagesInList[0] = newSprite.Name;
		}
Exemple #53
0
		private static void SetDefaultSliderName(Slider newSlider, UIEditorScene uiEditorScene)
		{
			uiEditorScene.UIImagesInList.Add(newSlider.Name);
			if (uiEditorScene.UIImagesInList[0] == null)
				uiEditorScene.UIImagesInList[0] = newSlider.Name;
		}
Exemple #54
0
		public bool ChangeToInteractiveButton(bool value, UIEditorScene uiEditorScene)
		{
			if (IsInteractiveButton == value)
				return true;
			IsInteractiveButton = value;
			ChangeToInteractiveButton(uiEditorScene);
			return false;
		}
 public ControlAllignmentAndMargins(UIEditorScene uiEditorScene)
 {
     this.uiEditorScene = uiEditorScene;
 }
Exemple #56
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");
		}
Exemple #57
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);
		}