Beispiel #1
0
        private void InitialComponent()
        {
            _grid.Bind(new List<RecordModel>{
                new RecordModel{ID = "001", Name = "First Record"},
                new RecordModel{ID = "002", Name = "Second Record"}
            });

            State initialState = new State("Initial State", () => {
                _header.Enabled = true;
                _grid.Enabled = false;
            });

            State gridState = new State("Grid State", () => {
                _header.Enabled = false;
                _grid.Enabled = true;
            });

            initialState.OnStateEntered += Display;
            gridState.OnStateEntered += Display;

            initialState.SetupStateItem(Operation.SCROLL_DOWN, OperationResult.NORMALLY, gridState);
            gridState.SetupStateItem(Operation.SCROLL_UP, OperationResult.GRID_TOP, initialState);

            _currentState = initialState;
            _currentState.Enter();
        }
Beispiel #2
0
        public void SetupStateItem(Operation op, OperationResult result, State state)
        {
            if (_router.ContainsKey (op)) {
                if(_router[op].ContainsKey(result))
                    throw new Exception("Mapping already exists.");

                _router[op].Add(result, state);
                return;
            }

            ResultStateMapping mapping = new ResultStateMapping();
            mapping.Add(result, state);
            _router.Add(op, mapping);
        }
Beispiel #3
0
 public void Operate(Operation op)
 {
     _currentState = _currentState.Operate(op, _grid.Operate(op));
     _currentState.Enter();
 }