//Анимация перемещения элементов
        public void MoveElements(VisualElement a, VisualElement b)
        {
            Position a_pos = new Position(a.Position);
            Position b_pos = new Position(b.Position);

            game.Swap(a_pos, b_pos);
            SwapElements(a_pos, b_pos);
            bool result = game.Remove();

            //Если в результате перемещения не возникает комбинация, то элементы возвращаются на исходные позиции
            if (result == false)
            {
                SwapAnimation Swap = new SwapAnimation(this);
                Swap.AnimationFinish += delegate
                {
                    a_pos = new Position(a.Position);
                    b_pos = new Position(b.Position);
                    game.Swap(a_pos, b_pos);
                    SwapElements(a_pos, b_pos);
                    active = true;
                };

                Swap.Start(b, a);
            }
        }
            public void Click()
            {
                if (level.active == false)
                {
                    return;
                }
                if (checkedElement != null)
                {
                    //Выделение первого выбранного элемента
                    if (checkedElement == this)
                    {
                        backColor      = Color.Transparent;
                        checkedElement = null;
                    }
                    else
                    {
                        bool near = false;

                        //Проверка второго выбранного элемента на соседство с первым
                        if ((checkedElement.Position.X == Position.X - 1 && checkedElement.Position.Y == Position.Y) ||
                            (checkedElement.Position.X == Position.X + 1 && checkedElement.Position.Y == Position.Y) ||
                            (checkedElement.Position.X == Position.X && checkedElement.Position.Y == Position.Y - 1) ||
                            (checkedElement.Position.X == Position.X && checkedElement.Position.Y == Position.Y + 1))
                        {
                            near = true;
                        }

                        if (near == false)
                        {
                            //Выбор другого элемента
                            checkedElement.backColor = Color.Transparent;
                            backColor      = Color.DarkSlateBlue;
                            checkedElement = this;
                        }
                        else
                        {
                            //проверка двух соседних элементов
                            checkedElement.backColor = Color.Transparent;
                            level.active             = false;
                            VisualElement el = checkedElement;
                            checkedElement = null;
                            SwapAnimation Swap = new SwapAnimation(level);
                            Swap.AnimationFinish += delegate { level.MoveElements(el, this); };
                            Swap.Start(el, this);
                        }
                    }
                }
                else
                {
                    //выбор элемента
                    backColor      = Color.DarkSlateBlue;
                    checkedElement = this;
                }
                level.Refresh();
            }