public void CommitAction(VotingAction action)
        {
            switch (action.Action.Key)
            {
                case Key.CLICK:
                    ClickCell();

                    break;
                case Key.FLAG:
                    MarkCell(true, false);

                    break;
                case Key.QUESTION:
                    MarkCell(false, false);

                    break;
                case Key.UNTOUCHED:
                    MarkCell(false, true);

                    break;
                default:
                    PressedArrowKey(action);

                    break;
            }
        }
        public void AddVote(VotingAction action)
        {
            var vote = from v in votes
                       where v.Key.Action == action.Action
                       select v;

            if (vote.Count() > 0)
            {
                var actVote = vote.First();

                action.Count = (actVote.Key.Count + action.Count) / 2;
                actVote.Value.AddVote(action);

                DisplaySortedVotes();
            }
            else
            {
                Votes aVote = new Votes(votes.Count(), action);

                votes.Add(action, aVote);

                aVote.AddToPanel(votingPanel);
            }
        }
        private void ParseMessage(string user, string message)
        {
            string[] components = message.Split(' ');
            string possibleCount = components.Last();

            int count = 1;
            int tryCount = 1;

            if (int.TryParse(possibleCount, out tryCount))
            {
                components = components.Where((source, index) => index != components.Count() - 1).ToArray();

                message = string.Join(" ", components);

                count = tryCount;
            }

            var acts = from a in Actions
                       where a.Key.Equals(message.ToLower())
                       select a;

            if (acts.Count() > 0)
            {
                var action = acts.First().Value;

                System.Console.WriteLine("Count: " + count);

                if (game.Board.CanMoveByCount(action, count))
                {
                    var votingAction = new VotingAction() { Action = action, Count = count };

                    SynchronizationContext.Current.Send(_ => voting.AddVote(votingAction), null);
                }
            }
        }
        public void MoveCursor(VotingAction key)
        {
            Cell cell = null;

            switch (key.Action.Key)
            {
                case Key.NEXT:
                    int refX = CursorPos.X;
                    int refY = CursorPos.Y;

                    for (int y = refY; y < Height + refY; y++)
                    {
                        for (int x = refX + 1; x < Width; x++)
                        {
                            int yy = y >= Height ? y - Height : y;

                            cell = GetCell(x, yy);

                            if (cell.IsClickable()) goto Finished;
                            else cell = null;
                        }

                        refX = -1;
                    }

                    Finished: break;
                case Key.UP:
                    for (int i = CursorPos.Y - 1; i >= 0; i++)
                        if (GetCellRelativeTo(CursorPos.X, i, out cell)) break;

                    break;
                case Key.DOWN:
                    for (int i = CursorPos.Y + 1; i < Height; i++)
                        if (GetCellRelativeTo(CursorPos.X, i, out cell)) break;

                    break;
                case Key.LEFT:
                    for (int i = CursorPos.X - 1; i >= 0; i--)
                        if (GetCellRelativeTo(i, CursorPos.Y, out cell)) break;

                    break;
                case Key.RIGHT:

                    GetCellRelativeTo(key.Count, CursorPos.Y, out cell);

                    /*
                    for (int i = CursorPos.X + 1; i < Width; i++)
                        if (GetCellRelativeTo(i, CursorPos.Y, out cell)) break;
                        */
                    break;
                case Key.UP_LEFT:
                    for (int xy = 1; xy < Math.Min(CursorPos.X + 1, CursorPos.Y + 1); xy++)
                        if (GetCellRelativeTo(CursorPos.X - xy, CursorPos.Y - xy, out cell)) break;

                    break;
                case Key.UP_RIGHT:
                    for (int xy = 1; xy < Math.Min(Width - CursorPos.X, CursorPos.Y + 1); xy++)
                        if (GetCellRelativeTo(CursorPos.X + xy, CursorPos.Y - xy, out cell)) break;

                    break;
                case Key.DOWN_LEFT:
                    for (int xy = 1; xy < Math.Min(CursorPos.X + 1, Height - CursorPos.Y); xy++)
                        if (GetCellRelativeTo(CursorPos.X - xy, CursorPos.Y + xy, out cell)) break;

                    break;
                case Key.DOWN_RIGHT:
                    for (int xy = 1; xy < Math.Min(Width - CursorPos.X, Height - CursorPos.Y); xy++)
                        if (GetCellRelativeTo(CursorPos.X + xy, CursorPos.Y + xy, out cell)) break;

                    break;
            }

            if (cell != null)
            {
                GetCell(CursorPos).Hover(false);

                CursorPos = new Point(cell.X, cell.Y);

                cell.Hover(true);
            }
        }
 private void PressedArrowKey(VotingAction key)
 {
     Board.MoveCursor(key);
 }