public void ChangeActionState(GuiActions action, bool isOn) { if (actionCache.ContainsKey(action)) { actionCache[action].IsOn = isOn; } }
private void RaiseActionEvent(GuiActions action) { if (PlayerPerformedAction != null) { PlayerPerformedAction(this, new ActionEventArgs(action)); } }
public bool GetActionState(GuiActions action) { if (actionCache.ContainsKey(action)) { return(actionCache[action].IsOn); } return(false); }
/// <summary> /// A callback for a player action button click /// </summary> /// <param name="sender"></param> /// <param name="args"></param> private void ActionButtonClicked(object sender, RoutedEventArgs args) { // must have a valid player as the data context to handle the current action GuiMainPlayer thePlayer = DataContext as GuiMainPlayer; if (thePlayer == null) { return; } // the action is also the button tag Button clickedButton = (Button)sender; GuiActions action = (GuiActions)clickedButton.Tag; // send the player the action played thePlayer.HandleAction(action); }
/// <summary>Converts a value. </summary> /// <returns>A converted value. If the method returns null, the valid null value is used.</returns> /// <param name="value">The value produced by the binding source.</param> /// <param name="targetType">The type of the binding target property.</param> /// <param name="parameter">The converter parameter to use.</param> /// <param name="culture">The culture to use in the converter.</param> public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) { if (value == null) { return(Binding.DoNothing); } GuiActions action = (GuiActions)value; // split the all in value, if (action == GuiActions.AllIn) { return("All In"); } // in all other cases, use the action name else { return(action.ToString()); } }
public ActionWrapper(GuiActions action) { this.action = action; }
public void HandleAction(GuiActions action) { RaiseActionEvent(action); }
public ActionEventArgs(GuiActions action) { this.action = action; }