示例#1
0
		private static void CheckIfAnchoringTop(Control anchoringControl, Control attachingControl)
		{
			if (anchoringControl.DrawArea.Top > attachingControl.DrawArea.Bottom)
				return; //ncrunch: no coverage 
			float horizontalDistance = attachingControl.DrawArea.Top - anchoringControl.DrawArea.Top;
			attachingControl.TopMargin = new Margin(anchoringControl, Edge.Top, horizontalDistance);
		}
示例#2
0
		private void UpdateState(Control control, InteractiveState state)
		{
			ProcessAnyLeftClick(control, state);
			ProcessAnyLeftRelease(control, state);
			ProcessAnyMovement(control, state);
			ProcessAnyDrag(state);
		}
示例#3
0
		private static void CheckIfAnchoringLeft(Control anchoringControl, Control attachingControl)
		{
			if (anchoringControl.DrawArea.Left > attachingControl.DrawArea.Right)
				return; //ncrunch: no coverage 
			float verticalDistance = attachingControl.DrawArea.Left - anchoringControl.DrawArea.Left;
			attachingControl.LeftMargin = new Margin(anchoringControl, Edge.Left, verticalDistance);
		}
示例#4
0
 private static void ClickControl(Control control, InteractiveState state)
 {
     state.IsPressed = false;
     control.Click();
     if (state.CanHaveFocus)
         state.WantsFocus = true;
 }
示例#5
0
		public Margin(Control other, Edge othersEdge, float distance)
			: this()
		{
			if (other != null)
				OtherControlName = other.Name;
			OthersEdge = othersEdge;
			Distance = distance;
		}
示例#6
0
		private static void AnchorVertical(Control anchoringControl, Control attachingControl)
		{
			if (anchoringControl.DrawArea.Left < attachingControl.DrawArea.Left)
				CheckIfAnchoringLeft(anchoringControl, attachingControl);
			else if (anchoringControl.DrawArea.Left > attachingControl.DrawArea.Left)
				CHeckIfAnchoringRight(anchoringControl, attachingControl);
			else
				attachingControl.LeftMargin = new Margin(anchoringControl, Edge.Left, 0);
		}
示例#7
0
		private static void AnchorHorizontal(Control anchoringControl, Control attachingControl)
		{
			if (anchoringControl.DrawArea.Top < attachingControl.DrawArea.Top)
				CheckIfAnchoringTop(anchoringControl, attachingControl);
			else if (anchoringControl.DrawArea.Top > attachingControl.DrawArea.Top)
				CheckIfAnchoringBottom(anchoringControl, attachingControl);
			else
				attachingControl.TopMargin = new Margin(anchoringControl, Edge.Top, 0);
		}
示例#8
0
		private static void ChangeCorruptedButtonMaterial(Control newControl)
		{
			var theme = newControl.Get<Theme>();
			if (theme.Button.Shader == null)
				theme.Button = new Theme().Button;
			if (theme.ButtonDisabled.Shader == null)
				theme.ButtonDisabled = new Theme().ButtonDisabled;
			if (theme.ButtonMouseover.Shader == null)
				theme.ButtonMouseover = new Theme().ButtonMouseover;
			if (theme.ButtonPressed.Shader == null)
				theme.ButtonPressed = new Theme().ButtonPressed;
		}
示例#9
0
		private static void CHeckIfAnchoringRight(Control anchoringControl, Control attachingControl)
		{
			if (anchoringControl.DrawArea.Left > attachingControl.DrawArea.Right)
			{
				float verticalDistance = anchoringControl.DrawArea.Left - attachingControl.DrawArea.Right;
				attachingControl.RightMargin = new Margin(anchoringControl, Edge.Left, verticalDistance);
			}
			else
			{
				float verticalDistance = anchoringControl.DrawArea.Left - attachingControl.DrawArea.Left;
				attachingControl.RightMargin = new Margin(anchoringControl, Edge.Right, verticalDistance);
			}
		}
示例#10
0
		private static void CheckIfAnyMaterialIsCorrupt(Control newControl)
		{
			if (newControl.Get<Material>().Shader == null)
				newControl.Set(new Theme().Button);
			if (newControl.GetType() == typeof(Button) ||
				newControl.GetType() == typeof(InteractiveButton))
				ChangeCorruptedButtonMaterial(newControl);
			if (newControl.GetType() == typeof(Slider))
				ChangeCorruptedSliderMaterial(newControl);
			if (newControl.GetType() == typeof(Label))
				if (newControl.Get<Theme>().Label.Shader == null)
					newControl.Get<Theme>().Label = new Theme().Label;
		}
示例#11
0
		public Rectangle CalculateDrawArea(Control control)
		{
			this.control = control;
			UpdateDrawAreaHint(GetAnchoringDrawArea(control));
			if (HasNoMargins())
				return drawAreaHint;
			if (HasOppositeMargins())
				return AlignOppositeMargins();
			if (NumberOfMargins <= 2)
				return AlignAdjacentMargins();
			if (NumberOfMargins == 3)
				return AlignThreeMargins();
			return AlignFourMargins();
		}
示例#12
0
		private static void CheckIfAnchoringBottom(Control anchoringControl, Control attachingControl)
		{
			if (anchoringControl.DrawArea.Top > attachingControl.DrawArea.Bottom)
			{
				float horizontalDistance = anchoringControl.DrawArea.Top - attachingControl.DrawArea.Bottom;
				attachingControl.BottomMargin = new Margin(anchoringControl, Edge.Top, horizontalDistance);
			}
			else
			{
				float horizontalDistance = anchoringControl.DrawArea.Top - attachingControl.DrawArea.Top;
				attachingControl.BottomMargin = new Margin(anchoringControl, Edge.Bottom,
					horizontalDistance);
			}
		}
示例#13
0
		private static void ChangeCorruptedSliderMaterial(Control newControl)
		{
			var theme = newControl.Get<Theme>();
			if (theme.Slider.Shader == null)
				theme.Slider = new Theme().Slider;
			if (theme.SliderDisabled.Shader == null)
				theme.SliderDisabled = new Theme().SliderDisabled;
			if (theme.SliderPointerMouseover.Shader == null)
				theme.SliderPointerMouseover = new Theme().SliderPointerMouseover;
			if (theme.SliderPointer.Shader == null)
				theme.SliderPointer = new Theme().SliderPointer;
			if (theme.SliderPointerDisabled.Shader == null)
				theme.SliderPointerDisabled = new Theme().SliderPointerDisabled;
		}
示例#14
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);
 }
示例#15
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);
		}
示例#16
0
		public void SetSingleSelectedControl(Control control)
		{
			SelectedEntity2DList.Clear();
			SelectedControlNamesInList.Clear();
			SelectedEntity2DList.Add(control);
			SelectedControlNamesInList.Add(control.Name);
		}
示例#17
0
		private void UpdateUIControlAndLists(Control control)
		{
			SelectedControlNamesInList.Add(control.Name);
			if (!SelectedEntity2DList.Contains(control))
				SelectedEntity2DList.Add(control);
			IsSelectingControl = true;
			uiControl.SetMaterials(SelectedEntity2DList);
			Messenger.Default.Send(SelectedControlNamesInList, "SetSelectedName");
			Messenger.Default.Send(uiControl.Index, "SetSelectedIndex");
			ControlProcessor.UpdateOutlines(SelectedEntity2DList);
			controlChanger.SetControlLayer(control.RenderLayer, this);
		}
示例#18
0
		public void SetEntity2D(Control control)
		{
			if (control == null)
				return;
			if (!IsMultiSelecting)
			{
				SelectedEntity2DList.Clear();
				SelectedControlNamesInList.Clear();
			}
			controlChanger.ChangeUIControlWidthAndHeight(control, uiControl);
			uiControl.Index = Scene.Controls.IndexOf(control);
			if (uiControl.Index < 0)
				return;
			UpdateUIControlAndLists(control);
			SelectedName = control.Name;
		}
示例#19
0
		private void ActivateControl(Control control)
		{
			control.IsActive = true;
			if (control.Contains<Material>())
				if (control.Get<Material>().Shader == null)
					control.Set(new Theme().Button); //ncrunch: no coverage
			UIImagesInList.Add(control.Name);
			Messenger.Default.Send(control.Name, "AddToHierachyList");
			if (uiSceneGrid.GridRenderLayer <= control.RenderLayer)
				uiSceneGrid.GridRenderLayer = control.RenderLayer + 1; //ncrunch: no coverage
			controlAdder.AddControlToScene(control, Scene);
			control.IsActive = false;
		}
示例#20
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);
		}
示例#21
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);
		}
示例#22
0
		private void ProcessAnyLeftClick(Control control, InteractiveState state)
		{
			if (leftClick != Vector2D.Unused)
				state.IsPressed = control.RotatedDrawAreaContains(leftClick);
		}
示例#23
0
		private void CheckTypeOfNewControl(Control control, string controlName)
		{
			uiEditorViewModel.UiEditorScene.Scene.Add(control);
			var controls = uiEditorViewModel.UiEditorScene.Scene.Controls;
			Assert.AreEqual(controlName, (controls[controls.Count - 1] as Control).Name);
		}
示例#24
0
		private static bool RefreshControlIfAtCurrentLevel(Control control, int level)
		{
			if (control.GetLevel() != level)
				return false;
			control.RefreshDrawAreaIfAnchored();
			return true;
		}
示例#25
0
		private void ProcessAnyMovement(Control control, InteractiveState state)
		{
			if (movement == Vector2D.Unused)
				return;
			state.IsInside = control.RotatedDrawAreaContains(movement);
			Vector2D rotatedMovement = control.Rotation == 0.0f
				? movement : movement.RotateAround(control.RotationCenter, -control.Rotation);
			state.RelativePointerPosition = control.DrawArea.GetRelativePoint(rotatedMovement);
		}
示例#26
0
		internal static void LoadControl(Control control, BinaryReader reader, byte[] versionBytes)
		{
			control.SetComponents(LoadComponents(control, reader, versionBytes));
			var tagCount = reader.ReadByte();
			if (tagCount > 0)
			{
				var arrayType1 = reader.ReadByte();
				reader.ReadString();
				for (int i = 0; i < tagCount; i++)
					control.AddTag(reader.ReadString());
			}
			var behaviorCount = reader.ReadByte();
			var arrayType2 = reader.ReadByte();
			reader.ReadString();
			for (int i = 0; i < behaviorCount; i++)
				reader.ReadString();
			var hasOneDrawBehavior = reader.ReadByte();
			var arrayType3 = reader.ReadByte();
			reader.ReadString();
			reader.ReadString();
			control.Start<UpdateRenderingCalculations>();
			control.Start<ControlUpdater>();
			control.OnDraw<SpriteRenderer>();
		}
示例#27
0
		private static Rectangle GetAnchoringDrawArea(Control control)
		{
			var size = control.AnchoringSize;
			return (size == Size.Unused
				? control.DrawArea : Rectangle.FromCenter(control.DrawArea.Center, size));
		}
示例#28
0
		private Theme GetCreateNewControlAndChangeMaterials(Control control)
		{
			uiEditorScene.SelectedEntity2DList.Clear();
			uiEditorScene.SelectedEntity2DList.Add(control);
			ChangeAllMaterials();
			var theme = uiEditorScene.SelectedEntity2DList[0].Get<Theme>();
			return theme;
		}
示例#29
0
 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;
 }
示例#30
0
		private void ProcessAnyLeftRelease(Control control, InteractiveState state)
		{
			if (leftRelease == Vector2D.Unused)
				return;
			if (state.IsPressed && control.RotatedDrawAreaContains(leftRelease) && control.IsVisible)
				ClickControl(control, state);
			state.IsPressed = false;
		}