private bool CheckIfMouseTriggerIsInList(string adding, Trigger trigger)
		{
			var mouseButtonTrigger = (MouseButtonTrigger)trigger;
			if (mouseButtonTrigger.Button.ToString() == adding)
				isAlreadyInList = true;
			return isAlreadyInList;
		}
		private bool CheckIfGamepadTriggerIsInList(string adding, Trigger trigger)
		{
			var gamePadButtonTrigger = (GamePadButtonTrigger)trigger;
			if (gamePadButtonTrigger.Button.ToString() == adding)
				isAlreadyInList = true;
			return isAlreadyInList;
		}
		private bool CheckIfKeyTriggerIsInList(string adding, Trigger trigger)
		{
			var keyTrigger = (KeyTrigger)trigger;
			if (keyTrigger.Key.ToString() == adding)
				isAlreadyInList = true;
			return isAlreadyInList;
		}
Пример #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);
		}
Пример #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);
		}
		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);
		}
Пример #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);
		}
		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;
		}
Пример #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;
 }
Пример #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);
		}
Пример #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);
		}
Пример #12
0
		private string RegisterCommand(Trigger trigger)
		{
			const string CommandName = "PositionActionCommand";
			Command.Register(CommandName, trigger);
			actionPerformed = false;
			return CommandName;
		}
Пример #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);
		}
Пример #14
0
		private void AddMouseHoldTriggerToList(Trigger trigger)
		{
			var mouseHoldTrigger = (MouseHoldTrigger)trigger;
			var triggerLayoutView = new TriggerLayoutView();
			inputNewTriggerEditor.SetMouseHoldTrigger(mouseHoldTrigger.Button, triggerLayoutView);
			TriggerList.Add(triggerLayoutView);
		}
Пример #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);
		}
Пример #16
0
		private void ChangeMouseMovementTriggerTypeInCommandList(string adding, Trigger trigger)
		{
			CheckWhatTriggerType(adding, trigger);
		}
Пример #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);
		}
Пример #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);
		}
Пример #19
0
		private static void ChangeTouchpadButtonTriggerStateInCommandList(string adding,
			Trigger trigger)
		{
			var newTouchpadTrigger = (TouchPressTrigger)trigger;
			newTouchpadTrigger.State = (State)Enum.Parse(typeof(State), adding);
		}
Пример #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));
			}
		}
Пример #21
0
		private void ChangeTriggerTypeInCommandList(string adding, string key, Trigger trigger)
		{
			var newKeyTrigger = (KeyTrigger)trigger;
			if (newKeyTrigger.Key.ToString() == key)
				CheckWhatTriggerType(adding, trigger);
		}
Пример #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
		}
Пример #23
0
		private void AssertActionPerformed(Trigger trigger)
		{
			Assert.IsFalse(actionPerformed);
			trigger.Invoke();
			entities.RunEntities();
			Assert.IsTrue(actionPerformed);
		}
Пример #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;
		}
Пример #25
0
		private void AddTouchPadTriggerToList(Trigger trigger)
		{ 
			var newTouchpadTrigger = (TouchPressTrigger)trigger;
			var triggerLayoutView = new TriggerLayoutView();
			inputNewTriggerEditor.SetTouchPadTrigger(newTouchpadTrigger.State, triggerLayoutView);
			TriggerList.Add(triggerLayoutView);
		} 
Пример #26
0
		private void ChangeMouseHoldTriggerTypeInCommandList(string adding, string key, Trigger trigger)
		{
			var newMouseTrigger = (MouseHoldTrigger)trigger;
			if (newMouseTrigger.Button.ToString() == key)
				CheckWhatTriggerType(adding, trigger);
		}
Пример #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);
		}
Пример #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;
		}
Пример #29
0
 public Command Add(Trigger trigger)
 {
     triggers.Add(trigger);
     return this;
 }
Пример #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
		}