public static SystemJoystickValue Load(TextBlock block) { var value = new SystemJoystickValue(); { var type = block.GetAttribute("type"); if (!string.IsNullOrEmpty(type)) value.type = (Types)Enum.Parse(typeof(Types), type); } { var button = block.GetAttribute("button"); if (!string.IsNullOrEmpty(button)) value.button = (JoystickButtons)Enum.Parse(typeof(JoystickButtons), button); } { var axis = block.GetAttribute("axis"); if (!string.IsNullOrEmpty(axis)) value.axis = (JoystickAxes)Enum.Parse(typeof(JoystickAxes), axis); } { var axisfilter = block.GetAttribute("axisfilter"); if (!string.IsNullOrEmpty(axisfilter)) value.axisFilter = (JoystickAxisFilters)Enum.Parse(typeof(JoystickAxisFilters), axisfilter); } { var pov = block.GetAttribute("POV"); if (!string.IsNullOrEmpty(pov)) value.pov = (JoystickPOVs)Enum.Parse(typeof(JoystickPOVs), pov); } { var povdirection = block.GetAttribute("POVDirection"); if (!string.IsNullOrEmpty(povdirection)) value.povDirection = (JoystickPOVDirections)Enum.Parse(typeof(JoystickPOVDirections), povdirection); } { var slider = block.GetAttribute("slider"); if (!string.IsNullOrEmpty(slider)) value.slider = (JoystickSliders)Enum.Parse(typeof(JoystickSliders), slider); } { var slideraxis = block.GetAttribute("sliderAxis"); if (!string.IsNullOrEmpty(slideraxis)) value.sliderAxis = (JoystickSliderAxes)Enum.Parse(typeof(JoystickSliderAxes), slideraxis); } { var strength = block.GetAttribute("strength"); if (!string.IsNullOrEmpty("strength")) { value.strength = float.Parse(strength); } } return value; }
public static void Save(SystemJoystickValue item, TextBlock block) { block.SetAttribute("type", item.Type.ToString()); switch (item.Type) { case Types.Button: block.SetAttribute("button", item.Button.ToString()); block.SetAttribute("strength", item.strength.ToString()); break; case Types.Axis: block.SetAttribute("axis", item.Axis.ToString()); block.SetAttribute("axisfilter", item.AxisFilter.ToString()); block.SetAttribute("strength", item.strength.ToString()); break; case Types.POV: block.SetAttribute("POV", item.POV.ToString()); block.SetAttribute("POVDirection", item.POVDirection.ToString()); block.SetAttribute("strength", item.strength.ToString()); break; case Types.Slider: block.SetAttribute("slider", item.Slider.ToString()); block.SetAttribute("sliderAxis", item.SliderAxis.ToString()); block.SetAttribute("axisfilter", item.AxisFilter.ToString()); block.SetAttribute("strength", item.strength.ToString()); break; } }
public SystemJoystickValue(SystemJoystickValue source) { type = source.Type; button = source.Button; axis = source.Axis; axisFilter = source.AxisFilter; pov = source.POV; povDirection = source.POVDirection; _parent = source.Parent; strength = source.strength; }
/// <summary> /// Check if the Given Input is Binded. Return the currently binded control to the input /// </summary> public bool IsAlreadyBinded(JoystickSliders slider, JoystickSliderAxes axis, JoystickAxisFilters filter, out SystemJoystickValue control) { control = null; foreach (GameControlItem item in Items) { if (item.BindedJoystickValues.Count <= 0) continue; foreach (SystemJoystickValue value in item.BindedJoystickValues) { if (value.Type == SystemJoystickValue.Types.Slider && value.Slider == slider && value.SliderAxis == axis && value.AxisFilter == filter) { 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(JoystickPOVs pov, JoystickPOVDirections dir, out SystemJoystickValue control) { control = null; foreach (GameControlItem item in Items) { if (item.BindedJoystickValues.Count <= 0) continue; foreach (SystemJoystickValue value in item.BindedJoystickValues) { if (value.Type == SystemJoystickValue.Types.POV && value.POV == pov && value.POVDirection == dir) { 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(JoystickButtons button, out SystemJoystickValue control) { control = null; foreach (GameControlItem item in Items) { if (item.BindedJoystickValues.Count <= 0) continue; foreach (SystemJoystickValue value in item.BindedJoystickValues) { if (value.Type == SystemJoystickValue.Types.Button && value.Button == button) { control = value; return true; } } } return false; }