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; }
protected virtual void OnArrowChanged(ArrowChangedEventArgs e) { if (ArrowChanged != null) ArrowChanged(this, e); }
void _arrowController_ArrowChanged(object sender, ArrowChangedEventArgs e) { // Pass the event on to the calling party OnArrowChanged(e); }
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); } }