コード例 #1
0
        void _uiController_ArrowChanged(object sender, ArrowChangedEventArgs e)
        {
            if (_isRunning)
            {
                Diagnostics.Logger.Instance.Log("Handling the arrow changed event.");
                ArrowContext ac = e.Arrow;
                Diagnostics.Logger.Instance.Log("Current State: " + ac.CurrentState.ToString());
                Diagnostics.Logger.Instance.Log(String.Format("X:{0} Y:{1}", ac.X, ac.Y));

                string direction = String.Empty;
                if (ac.CurrentState.ToString().ToUpper().Contains("RIGHT"))
                {
                    direction = "R";
                }
                else if (ac.CurrentState.ToString().ToUpper().Contains("LEFT"))
                {
                    direction = "L";
                }
                else if (ac.CurrentState.ToString().ToUpper().Contains("FORWARD"))
                {
                    direction = "F";
                }

                UpdateGrid(ac.X, ac.Y, direction);
            }
        }
コード例 #2
0
ファイル: ArrowUnitTests.cs プロジェクト: riyaan/ADS4
 public void CreateArrowSuccess()
 {
     ArrowContext arrow = new ArrowContext(new ConcreteStateForward());
     arrow.Right();
     arrow.Right();
     arrow.Left();
 }
コード例 #3
0
        public void CreateArrowSuccess()
        {
            ArrowContext arrow = new ArrowContext(new ConcreteStateForward());

            arrow.Right();
            arrow.Right();
            arrow.Left();
        }
コード例 #4
0
        public ArrowController(int rows, int columns)
        {
            Arrow   = new ArrowContext(new ConcreteStateForward());
            Arrow.X = 0;
            Arrow.Y = 0;

            _rows    = rows;
            _columns = columns;

            _acea = new ArrowChangedEventArgs();

            // TODO: Create a 'Common' configuration class for this.
            ConfigurationManager.RefreshSection("appSettings");
            int speed = Int32.Parse(ConfigurationManager.AppSettings["animationSpeed"]) * 1000;

            _timer          = new Timer(speed);
            _timer.Elapsed += _timer_Elapsed;
        }
コード例 #5
0
ファイル: ArrowContext.cs プロジェクト: riyaan/ADS4
 public override void Left(ArrowContext context)
 {
     context.X++;
 }
コード例 #6
0
ファイル: ArrowContext.cs プロジェクト: riyaan/ADS4
 public override void Left(ArrowContext context)
 {
     context.CurrentState = new ConcreteStateLeft();
     context.X++;
 }
コード例 #7
0
ファイル: ArrowContext.cs プロジェクト: riyaan/ADS4
 public abstract void Right(ArrowContext context);
コード例 #8
0
ファイル: ArrowContext.cs プロジェクト: riyaan/ADS4
 public abstract void Forward(ArrowContext context);
コード例 #9
0
 public override void Forward(ArrowContext context)
 {
     context.CurrentState = new ConcreteStateForward();
     context.Y++;
 }
コード例 #10
0
 public override void Left(ArrowContext context)
 {
     context.CurrentState = new ConcreteStateLeft();
     context.X++;
 }
コード例 #11
0
 public override void Forward(ArrowContext context)
 {
     context.Y++;
 }
コード例 #12
0
 public override void Right(ArrowContext context)
 {
     context.X--;
 }
コード例 #13
0
 public abstract void Left(ArrowContext context);
コード例 #14
0
    private TypeContext type(int _p)
    {
        ParserRuleContext _parentctx = Context;
        int         _parentState     = State;
        TypeContext _localctx        = new TypeContext(Context, _parentState);
        TypeContext _prevctx         = _localctx;
        int         _startState      = 8;

        EnterRecursionRule(_localctx, 8, RULE_type, _p);
        try {
            int _alt;
            EnterOuterAlt(_localctx, 1);
            {
                {
                    _localctx = new BoolContext(_localctx);
                    Context   = _localctx;
                    _prevctx  = _localctx;

                    State = 63; Match(T__13);
                }
                Context.Stop = TokenStream.LT(-1);
                State        = 70;
                ErrorHandler.Sync(this);
                _alt = Interpreter.AdaptivePredict(TokenStream, 4, Context);
                while (_alt != 2 && _alt != global::Antlr4.Runtime.Atn.ATN.INVALID_ALT_NUMBER)
                {
                    if (_alt == 1)
                    {
                        if (ParseListeners != null)
                        {
                            TriggerExitRuleEvent();
                        }
                        _prevctx = _localctx;
                        {
                            {
                                _localctx = new ArrowContext(new TypeContext(_parentctx, _parentState));
                                PushNewRecursionContext(_localctx, _startState, RULE_type);
                                State = 65;
                                if (!(Precpred(Context, 2)))
                                {
                                    throw new FailedPredicateException(this, "Precpred(Context, 2)");
                                }
                                State = 66; Match(T__12);
                                State = 67; type(3);
                            }
                        }
                    }
                    State = 72;
                    ErrorHandler.Sync(this);
                    _alt = Interpreter.AdaptivePredict(TokenStream, 4, Context);
                }
            }
        }
        catch (RecognitionException re) {
            _localctx.exception = re;
            ErrorHandler.ReportError(this, re);
            ErrorHandler.Recover(this, re);
        }
        finally {
            UnrollRecursionContexts(_parentctx);
        }
        return(_localctx);
    }
コード例 #15
0
ファイル: ArrowContext.cs プロジェクト: riyaan/ADS4
 public override void Forward(ArrowContext context)
 {
     context.CurrentState = new ConcreteStateForward();
     context.Y++;
 }
コード例 #16
0
ファイル: ArrowContext.cs プロジェクト: riyaan/ADS4
 public override void Right(ArrowContext context)
 {
     context.X--;
 }
コード例 #17
0
 public abstract void Forward(ArrowContext context);
コード例 #18
0
ファイル: ArrowContext.cs プロジェクト: riyaan/ADS4
 public abstract void Left(ArrowContext context);
コード例 #19
0
 public override void Left(ArrowContext context)
 {
     context.X++;
 }
コード例 #20
0
ファイル: ArrowContext.cs プロジェクト: riyaan/ADS4
 public override void Forward(ArrowContext context)
 {
     context.Y++;
 }
コード例 #21
0
 public abstract void Right(ArrowContext context);
コード例 #22
0
ファイル: ArrowContext.cs プロジェクト: riyaan/ADS4
 public override void Right(ArrowContext context)
 {
     context.CurrentState = new ConcreteStateRight();
     context.X--;
 }
コード例 #23
0
 public override void Right(ArrowContext context)
 {
     context.CurrentState = new ConcreteStateRight();
     context.X--;
 }