Beispiel #1
0
        private void OnIconMouseDown(object sender, MouseButtonEventArgs args)
        {
            if (MasterFactory == null)
            {
                return;
            }

            var pressedIconPoint = (ChessPoint)((Image)sender).Tag;

            if (args.LeftButton == MouseButtonState.Pressed && IsClickable(pressedIconPoint))
            {
                var selectedCellTemp = _selectedCell;
                if (IsGreenSelectedPoint(pressedIconPoint))
                {
                    Controller?.RaiseMovementEvent(selectedCellTemp, pressedIconPoint);

                    return;
                }

                ClearSelection();

                if (selectedCellTemp != pressedIconPoint)
                {
                    PieceMasterBase master;
                    if (MasterFactory.TryGetMaster(FieldFrame, pressedIconPoint, out master))
                    {
                        SetSelection(pressedIconPoint, master.GetMovements());
                        _selectedCell = pressedIconPoint;
                    }
                }
                else
                {
                    _selectedCell = DefaultCell;
                }
            }
        }