public static SystemKeyboardMouseValue Load(TextBlock block) { var value = new SystemKeyboardMouseValue(); var type = block.GetAttribute("type"); if (!string.IsNullOrEmpty(type)) value.type = (Types)Enum.Parse(typeof(Types), type); var key = block.GetAttribute("key"); if (!string.IsNullOrEmpty(key)) value.key = (EKeys)Enum.Parse(typeof(EKeys), key); var button = block.GetAttribute("button"); if (!string.IsNullOrEmpty(button)) value.mouseButton = (EMouseButtons)Enum.Parse(typeof(EMouseButtons), button); var scroll = block.GetAttribute("scroll"); if (!string.IsNullOrEmpty(scroll)) value.scrollDirection = (MouseScroll)Enum.Parse(typeof(MouseScroll), scroll); var strength = block.GetAttribute("strength"); if (!string.IsNullOrEmpty(strength)) value.strength = float.Parse(strength); return value; }
public static void Save(SystemKeyboardMouseValue item, TextBlock block) { block.SetAttribute("type", item.Type.ToString()); switch (item.Type) { case Types.Key: block.SetAttribute("key", item.Key.ToString()); block.SetAttribute("strength", item.Strength.ToString()); break; case Types.MouseButton: block.SetAttribute("button", item.MouseButton.ToString()); block.SetAttribute("strength", item.Strength.ToString()); break; case Types.MouseScrollDirection: block.SetAttribute("scroll", item.scrollDirection.ToString()); block.SetAttribute("strength", item.Strength.ToString()); break; } }
public SystemKeyboardMouseValue(SystemKeyboardMouseValue source) { type = source.Type; key = source.Key; mouseButton = source.MouseButton; scrollDirection = source.scrollDirection; strength = source.strength; _parent = source.Parent; }
/// <summary> /// Check if the Given Input is Binded. Return the currently binded control to the input /// </summary> public bool IsAlreadyBinded(MouseScroll scrollDirection, float strength, out SystemKeyboardMouseValue control) { control = null; foreach (GameControlItem item in Items) { if (item.BindedKeyboardMouseValues.Count <= 0) continue; foreach (SystemKeyboardMouseValue value in item.BindedKeyboardMouseValues) { if (value.Type == SystemKeyboardMouseValue.Types.MouseScrollDirection && value.ScrollDirection == scrollDirection && value.Strength == strength) { control = value; return true; } } } return false; }
/// <summary> /// Check if the Given Input is Binded. Return the currently binded control to the input /// </summary> public bool IsAlreadyBinded(EMouseButtons button, out SystemKeyboardMouseValue control) { control = null; foreach (GameControlItem item in Items) { if (item.BindedKeyboardMouseValues.Count <= 0) continue; foreach (SystemKeyboardMouseValue value in item.BindedKeyboardMouseValues) { if (value.Type == SystemKeyboardMouseValue.Types.MouseButton && value.MouseButton == button) { control = value; return true; } } } return false; }
/// <summary> /// Check if the Given Input is Binded. Return the currently binded control to the input /// </summary> public bool IsAlreadyBinded(EKeys key, out SystemKeyboardMouseValue control) { control = null; foreach (GameControlItem item in Items) { if (item.BindedKeyboardMouseValues.Count <= 0) continue; foreach (SystemKeyboardMouseValue value in item.BindedKeyboardMouseValues) { if (value.Type == SystemKeyboardMouseValue.Types.Key && value.Key == key) { control = value; return true; } } } return false; }