Ejemplo n.º 1
0
		private bool CheckIfMouseTriggerIsInList(string adding, Trigger trigger)
		{
			var mouseButtonTrigger = (MouseButtonTrigger)trigger;
			if (mouseButtonTrigger.Button.ToString() == adding)
				isAlreadyInList = true;
			return isAlreadyInList;
		}
Ejemplo n.º 2
0
		private bool CheckIfGamepadTriggerIsInList(string adding, Trigger trigger)
		{
			var gamePadButtonTrigger = (GamePadButtonTrigger)trigger;
			if (gamePadButtonTrigger.Button.ToString() == adding)
				isAlreadyInList = true;
			return isAlreadyInList;
		}
Ejemplo n.º 3
0
		private bool CheckIfKeyTriggerIsInList(string adding, Trigger trigger)
		{
			var keyTrigger = (KeyTrigger)trigger;
			if (keyTrigger.Key.ToString() == adding)
				isAlreadyInList = true;
			return isAlreadyInList;
		}
Ejemplo n.º 4
0
		private static void ChangeKeyTriggerStateInCommandList(string adding, string key,
			Trigger trigger)
		{
			var newKeyTrigger = (KeyTrigger)trigger;
			if (newKeyTrigger.Key.ToString() == key)
				newKeyTrigger.State = (State)Enum.Parse(typeof(State), adding);
		}
Ejemplo n.º 5
0
		//private static void ChangeMouseButtonTriggerStateInCommandList(string adding, string key,
		//	Trigger trigger)
		//{
		//	var newMouseTrigger = (MouseButtonTrigger)trigger;
		//	if (newMouseTrigger.Button.ToString() == key)
		//		newMouseTrigger.State = (State)Enum.Parse(typeof(State), adding);
		//}

		private static void ChangeGamepadButtonTriggerStateInCommandList(string adding, string key,
			Trigger trigger)
		{
			var newGamepadTrigger = (GamePadButtonTrigger)trigger;
			if (newGamepadTrigger.Button.ToString() == key)
				newGamepadTrigger.State = (State)Enum.Parse(typeof(State), adding);
		}
Ejemplo n.º 6
0
		private static void CheckWichTriggerToChange(string adding, string removing, Trigger trigger)
		{
			if (trigger.GetType() == typeof(KeyTrigger))
				ChangeKeyButtonInCommandList(adding, removing, trigger);
			if (trigger.GetType() == typeof(MouseButtonTrigger))
				ChangeMouseButtonInCommandList(adding, removing, trigger); //ncrunch: no coverage
			if (trigger.GetType() == typeof(GamePadButtonTrigger))
				ChangeGamepadButtonInCommandList(adding, removing, trigger);
		}
Ejemplo n.º 7
0
		private static void CheckWichTriggerTypeToChange(string adding, string key, Trigger trigger)
		{
			if (trigger.GetType() == typeof(KeyTrigger))
				ChangeKeyTriggerStateInCommandList(adding, key, trigger);
			//if (trigger.GetType() == typeof(MouseButtonTrigger))
			//	ChangeMouseButtonTriggerStateInCommandList(adding, key, trigger);
			if (trigger.GetType() == typeof(GamePadButtonTrigger))
				ChangeGamepadButtonTriggerStateInCommandList(adding, key, trigger);
		}
Ejemplo n.º 8
0
		private bool CheckTriggerTypeOfAlreadyHas(string adding, Trigger trigger)
		{
			if (trigger.GetType() == typeof(KeyTrigger))
				isAlreadyInList = CheckIfKeyTriggerIsInList(adding, trigger);
			if (trigger.GetType() == typeof(MouseButtonTrigger))
				isAlreadyInList = CheckIfMouseTriggerIsInList(adding, trigger); //ncrunch: no coverage
			if (trigger.GetType() == typeof(GamePadButtonTrigger))
				isAlreadyInList = CheckIfGamepadTriggerIsInList(adding, trigger);
			return isAlreadyInList;
		}
Ejemplo n.º 9
0
 protected static Trigger[] ParseTriggers(XmlData command)
 {
     var triggers = new Trigger[command.Children.Count];
     for (int index = 0; index < command.Children.Count; index++)
     {
         var trigger = command.Children[index];
         var triggerType = trigger.Name.GetTypeFromShortNameOrFullNameIfNotFound();
         if (triggerType == null)
             throw new Trigger.UnableToCreateTriggerTypeIsUnknown(trigger.Name); //ncrunch: no coverage
         triggers[index] =
             Trigger.GenerateTriggerFromType(triggerType, trigger.Name, trigger.Value) as Trigger;
     }
     return triggers;
 }
Ejemplo n.º 10
0
		private static void SetTrigger(Trigger trigger, XmlData xmlData)
		{
			XmlData child = null;
			if (trigger.GetType() == typeof(KeyTrigger))
			{
				var keyTrigger = trigger as KeyTrigger;
				child = new XmlData("KeyTrigger") { Value = keyTrigger.Key + " " + keyTrigger.State };
			}
			if (trigger.GetType() == typeof(MouseButtonTrigger))
			{
				var mouseButtonTrigger = trigger as MouseButtonTrigger;
				child = new XmlData("MouseButtonTrigger");
				child.Value = mouseButtonTrigger.Button + " " + mouseButtonTrigger.State;
			}
			if (trigger.GetType() == typeof(MouseDragDropTrigger))
			{
				var mouseDragDropTrigger = trigger as MouseDragDropTrigger;
				child = new XmlData("MouseDragAndDropTrigger");
				child.Value = mouseDragDropTrigger.Button.ToString();
			}
			if (trigger.GetType() == typeof(MouseHoldTrigger))
			{
				var mouseHoldTrigger = trigger as MouseHoldTrigger;
				child = new XmlData("MouseHoldTrigger");
				child.Value = mouseHoldTrigger.Button.ToString();
			}
			if (trigger.GetType() == typeof(MouseHoverTrigger))
				child = new XmlData("MouseHoverTrigger");
			if (trigger.GetType() == typeof(MouseMovementTrigger))
				child = new XmlData("MouseMovementTrigger");
			if (trigger.GetType() == typeof(GamePadButtonTrigger))
			{
				var gamePadButtonTrigger = trigger as GamePadButtonTrigger;
				child = new XmlData("GamePadButtonTrigger");
				child.Value = gamePadButtonTrigger.Button + " " + gamePadButtonTrigger.State;
			}
			if (trigger.GetType() == typeof(TouchPressTrigger))
			{
				var touchPressTrigger = trigger as TouchPressTrigger;
				child = new XmlData("TouchPressTrigger") { Value = touchPressTrigger.State.ToString() };
			}
			xmlData.AddChild(child);
		}
Ejemplo n.º 11
0
		private void CheckWhatTriggerType(string adding, Trigger trigger)
		{
			int index = GetTriggersOfCommand().IndexOf(trigger);
			if (adding == "Keyboard")
				ChanceTriggerToKeyTrigger(index);
			else if (adding == "MouseButton")
				ChangeTriggerToMouseTrigger(index);
			else if (adding == "MouseDragAndDrop")
				ChangeTriggerToMouseDragDropTrigger(index);
			else if (adding == "MouseHold")
				ChangeTriggerToMouseHoldTrigger(index);
			else if (adding == "MouseHover")
				ChangeTriggerToMouseHoverTrigger(index);
			else if (adding == "MouseMovement")
				ChangeTriggerToMouseMovementTrigger(index);
			else if (adding == "Gamepad")
				ChangeTriggerToGamePadTrigger(index);
			else if (adding == "Touchpad")
				ChangeKeyTriggerToTouchPadTrigger(index);
		}
Ejemplo n.º 12
0
		private string RegisterCommand(Trigger trigger)
		{
			const string CommandName = "PositionActionCommand";
			Command.Register(CommandName, trigger);
			actionPerformed = false;
			return CommandName;
		}
Ejemplo n.º 13
0
		private static void ChangeKeyButtonInCommandList(string adding, string removing,
			Trigger trigger)
		{
			var newKeyTrigger = (KeyTrigger)trigger;
			if (newKeyTrigger.Key.ToString() == removing)
				newKeyTrigger.Key = (Key)Enum.Parse(typeof(Key), adding);
		}
Ejemplo n.º 14
0
		private void AddMouseHoldTriggerToList(Trigger trigger)
		{
			var mouseHoldTrigger = (MouseHoldTrigger)trigger;
			var triggerLayoutView = new TriggerLayoutView();
			inputNewTriggerEditor.SetMouseHoldTrigger(mouseHoldTrigger.Button, triggerLayoutView);
			TriggerList.Add(triggerLayoutView);
		}
Ejemplo n.º 15
0
		private void AddGamePadTriggerToList(Trigger trigger)
		{
			var newGamepadTrigger = (GamePadButtonTrigger)trigger;
			var triggerLayoutView = new TriggerLayoutView();
			inputNewTriggerEditor.SetGamePadTrigger(newGamepadTrigger.Button, newGamepadTrigger.State,
				triggerLayoutView);
			TriggerList.Add(triggerLayoutView);
		}
Ejemplo n.º 16
0
		private void ChangeMouseMovementTriggerTypeInCommandList(string adding, Trigger trigger)
		{
			CheckWhatTriggerType(adding, trigger);
		}
Ejemplo n.º 17
0
		private void AddMouseTriggerToList(Trigger trigger)
		{ 
			var newMouseTrigger = (MouseButtonTrigger)trigger;
			var triggerLayoutView = new TriggerLayoutView();
			inputNewTriggerEditor.SetMouseButtonTrigger(newMouseTrigger.Button, newMouseTrigger.State,
				triggerLayoutView);
			TriggerList.Add(triggerLayoutView);
		}
Ejemplo n.º 18
0
		private void AddKeyTriggerToList(Trigger trigger)
		{
			var newKeyTrigger = (KeyTrigger)trigger;
			var triggerLayoutView = new TriggerLayoutView();
			inputNewTriggerEditor.SetKeyTrigger(newKeyTrigger.Key, newKeyTrigger.State,
				triggerLayoutView);
			TriggerList.Add(triggerLayoutView);
		}
Ejemplo n.º 19
0
		private static void ChangeTouchpadButtonTriggerStateInCommandList(string adding,
			Trigger trigger)
		{
			var newTouchpadTrigger = (TouchPressTrigger)trigger;
			newTouchpadTrigger.State = (State)Enum.Parse(typeof(State), adding);
		}
Ejemplo n.º 20
0
		private static void ChangeMouseButtonInCommandList(string adding, string removing,
			Trigger trigger)
		{
			var mouseButtonTrigger = (MouseButtonTrigger)trigger;
			if (mouseButtonTrigger.Button.ToString() == removing)
			{
				mouseButtonTrigger.Dispose();
				mouseButtonTrigger = new MouseButtonTrigger((MouseButton)Enum.Parse(typeof(MouseButton),
					adding));
			}
		}
Ejemplo n.º 21
0
		private void ChangeTriggerTypeInCommandList(string adding, string key, Trigger trigger)
		{
			var newKeyTrigger = (KeyTrigger)trigger;
			if (newKeyTrigger.Key.ToString() == key)
				CheckWhatTriggerType(adding, trigger);
		}
Ejemplo n.º 22
0
		private void ChangeGamePadTriggerTypeInCommandList(string adding, string key,
			Trigger trigger)
		{
			var newMouseTrigger = (GamePadButtonTrigger)trigger;
			if (newMouseTrigger.Button.ToString() == key)
				CheckWhatTriggerType(adding, trigger); //ncrunch: no coverage
		}
Ejemplo n.º 23
0
		private void AssertActionPerformed(Trigger trigger)
		{
			Assert.IsFalse(actionPerformed);
			trigger.Invoke();
			entities.RunEntities();
			Assert.IsTrue(actionPerformed);
		}
Ejemplo n.º 24
0
		private static bool CheckIfGamePadButtonIsALreadyUsed(Trigger newTrigger, object key,
			bool keyAlreadyUsed)
		{
			if (newTrigger.GetType() != typeof(GamePadButtonTrigger))
				return keyAlreadyUsed;
			var mouseButtonTrigger = (GamePadButtonTrigger)newTrigger;
			if (mouseButtonTrigger.Button.ToString() == key.ToString())
				keyAlreadyUsed = true;
			return keyAlreadyUsed;
		}
Ejemplo n.º 25
0
		private void AddTouchPadTriggerToList(Trigger trigger)
		{ 
			var newTouchpadTrigger = (TouchPressTrigger)trigger;
			var triggerLayoutView = new TriggerLayoutView();
			inputNewTriggerEditor.SetTouchPadTrigger(newTouchpadTrigger.State, triggerLayoutView);
			TriggerList.Add(triggerLayoutView);
		} 
Ejemplo n.º 26
0
		private void ChangeMouseHoldTriggerTypeInCommandList(string adding, string key, Trigger trigger)
		{
			var newMouseTrigger = (MouseHoldTrigger)trigger;
			if (newMouseTrigger.Button.ToString() == key)
				CheckWhatTriggerType(adding, trigger);
		}
Ejemplo n.º 27
0
		private static void ChangeGamepadButtonInCommandList(string adding, string removing,
			Trigger trigger)
		{
			var gamepadButtonTrigger = (GamePadButtonTrigger)trigger;
			if (gamepadButtonTrigger.Button.ToString() == removing)
				gamepadButtonTrigger.Button = (GamePadButton)Enum.Parse(typeof(GamePadButton), adding);
		}
Ejemplo n.º 28
0
		private static bool CheckIfKeyIsAlreadyUsed(Trigger newTrigger, object key,
			bool keyAlreadyUsed)
		{
			if (newTrigger.GetType() != typeof(KeyTrigger))
				return keyAlreadyUsed;
			var keyTrigger = (KeyTrigger)newTrigger;
			if (keyTrigger.Key.ToString() == key.ToString())
				keyAlreadyUsed = true;
			return keyAlreadyUsed;
		}
Ejemplo n.º 29
0
 public Command Add(Trigger trigger)
 {
     triggers.Add(trigger);
     return this;
 }
Ejemplo n.º 30
0
		private void CheckWhichTriggerToAdd(Trigger trigger)
		{
			if (trigger.GetType() == typeof(KeyTrigger))
				AddKeyTriggerToList(trigger);
			if (trigger.GetType() == typeof(MouseButtonTrigger))
				AddMouseTriggerToList(trigger); //ncrunch: no coverage
			if (trigger.GetType() == typeof(MouseDragDropTrigger))
				AddMouseDragDropTriggerToList(trigger); //ncrunch: no coverage
			if (trigger.GetType() == typeof(MouseHoldTrigger))
				AddMouseHoldTriggerToList(trigger); //ncrunch: no coverage
			if (trigger.GetType() == typeof(MouseHoverTrigger))
				AddMouseHoverTriggerToList(); //ncrunch: no coverage
			if (trigger.GetType() == typeof(MouseMovementTrigger))
				AddMouseMovementTriggerToList(); //ncrunch: no coverage
			if (trigger.GetType() == typeof(GamePadButtonTrigger))
				AddGamePadTriggerToList(trigger);
			if (trigger.GetType() == typeof(TouchPressTrigger))
				AddTouchPadTriggerToList(trigger); //ncrunch: no coverage
		}