//выполнить действия, полагающиеся на входе / выходе из конкретного состояния private void performStateActions(int stateId, ActionOnEnterOrLeaveEnum enterOrLeave) { bool visible; foreach (StateAction sa in stateActions) { if (sa.stateId == stateId && sa.enterOrLeave == enterOrLeave) { //нашли нужное нам действие switch (sa.actionType) { case StateActionTypeEnum.Show: case StateActionTypeEnum.Hide: visible = sa.actionType == StateActionTypeEnum.Show; foreach (Control ctl in sa.targetControls) { ctl.Visible = visible; } break; case StateActionTypeEnum.SetProperty: foreach (Control ctl in sa.targetControls) { ObjectParameters.setObjectParameter(ctl, sa.targetParameter, sa.targetParameterValue); } break; case StateActionTypeEnum.ExecDelegate: sa.doAction(); break; } } } }
public void addHideAction(int stateId, ActionOnEnterOrLeaveEnum enterOrLeave, List <Control> targetControls) { StateAction c = new StateAction(); c.stateId = stateId; c.enterOrLeave = enterOrLeave; c.actionType = StateActionTypeEnum.Hide; c.targetControls = targetControls; stateActions.Add(c); }
public void addDelegateAction(int stateId, ActionOnEnterOrLeaveEnum enterOrLeave, actionDelegate dlg) { StateAction c = new StateAction(); c.stateId = stateId; c.enterOrLeave = enterOrLeave; c.actionType = StateActionTypeEnum.ExecDelegate; c.dlg = dlg; stateActions.Add(c); }
public void addSetPropertyAction(int stateId, ActionOnEnterOrLeaveEnum enterOrLeave, string targetParameter, object targetParameterValue, List <Control> targetControls) { StateAction c = new StateAction(); c.stateId = stateId; c.enterOrLeave = enterOrLeave; c.actionType = StateActionTypeEnum.SetProperty; c.targetControls = targetControls; c.targetParameter = targetParameter; c.targetParameterValue = targetParameterValue; stateActions.Add(c); }