WCF сервис клиент серверная игра, как в сервис передать класс Button?

У меня есть сервис, в нём интерфейс и класс реализующий этот интерфейс и ещё у меня есть клиент это Win form приложение, чтобы пользоваться в клиенте методом GetPrevButColor я же должен его сначала прописать в интерфейсе, затем реализовать в классе на сервисе, а потом в клиенте через поле client обращаюсь к client.GetPrevButColor() и вызываю этот метод на сервисе, так вот этот метод принимает Button prevButton, а интерфейс на сервисе знать не знает, что такое Button, как мне быть в этой ситуации, может что-то подскажите. Суть в том, что мне нужно сделать шашки, в которые будут играть два человека и нужно это реализовать через wcf.

Это мой интерфейс, я взял часть кода из видео по созданию чата ,на wcf. по сути ведь должно быть одно и тоже, только в чате отправляются сообщение, а у меня должны шашки двигаться.

[ServiceContract(CallbackContract = typeof(IServerChatCallback))]
public interface ICheckersService
{
    [OperationContract]
    int Connect(string name);
    [OperationContract]
    void DisConnect(int id);

    [OperationContract(IsOneWay = true)]
    void SendMsg(string msg, int id);

 
    [OperationContract]
    string GetPrevButColor();

    [OperationContract]
    void SwitchPlayer();
    [OperationContract]
    void ActivateButtons();
    [OperationContract]
    void OnFigurePress(object sender, EventArgs e);

}
public interface IServerChatCallback
{
    [OperationContract(IsOneWay = true)]
    void MsgCallback(string msg);
}

Далее вот класс с реализацией методов:

    const int mapSize = 8;
    const int cellSize = 50;


    public string GetPrevButColor() // заполняет поля цветом
    {
        if ((prevButton.Location.Y / cellSize % 2) != 0)
        {
            if ((prevButton.Location.X / cellSize % 2) == 0)
            {
                return "Gray";
            }
        }
        if ((prevButton.Location.Y / cellSize % 2) == 0)
        {
            if ((prevButton.Location.X / cellSize % 2) != 0)
            {
                return "Gray";
            }
        }
        return "White";
    }



    public void SwitchPlayer()
    {
        currentPlayer = currentPlayer == 1 ? 2 : 1;
        ResetGame();
    }

    public void ActivateButtons()
    {
        for (int i = 0; i < mapSize; i++)
        {
            for (int j = 0; j < mapSize; j++)
            {
                buttons[i, j].Enabled = true;
            }
        }
    }

    public void OnFigurePress(object sender, EventArgs e) // нажали кнопку
    {
        if (prevButton != null)
            prevButton.BackColor = GetPrevButColor(prevButton);

        pressedButton = sender as Button;

        if (map[pressedButton.Location.Y / cellSize, pressedButton.Location.X / cellSize] != 0 && map[pressedButton.Location.Y / cellSize, pressedButton.Location.X / cellSize] == currentPlayer)
        {
            CloseSteps();
            pressedButton.BackColor = Color.Red;
            DeactivateButtons();
            pressedButton.Enabled = true;
            countEatSteps = 0;
            if (pressedButton.Text == "D")
            {
                ShowSteps(pressedButton.Location.Y / cellSize, pressedButton.Location.X / cellSize, false);

            }
            else
            {
                ShowSteps(pressedButton.Location.Y / cellSize, pressedButton.Location.X / cellSize);
            }
            if (IsMoving)
            {
                CloseSteps();
                pressedButton.BackColor = GetPrevButColor(pressedButton);
                ShowPossibleSteps();
                IsMoving = false;
            }
            else
                IsMoving = true;

        }
        else
        {
            if (IsMoving)
            {


                isContunue = false;
                if (Math.Abs(pressedButton.Location.X / cellSize - prevButton.Location.X / cellSize) > 1)
                {
                    isContunue = true;
                    DeleteEaten(pressedButton, prevButton);
                }
                int temp = map[pressedButton.Location.Y / cellSize, pressedButton.Location.X / cellSize];
                map[pressedButton.Location.Y / cellSize, pressedButton.Location.X / cellSize] = map[prevButton.Location.Y / cellSize, prevButton.Location.X / cellSize];
                map[prevButton.Location.Y / cellSize, prevButton.Location.X / cellSize] = temp;
                pressedButton.Image = prevButton.Image;
                prevButton.Image = null;
                pressedButton.Text = prevButton.Text;
                prevButton.Text = "";
                SwitchButtonToCheat(pressedButton);
                countEatSteps = 0;
                IsMoving = false;
                CloseSteps();
                DeactivateButtons();
                if (pressedButton.Text == "D")
                    ShowSteps(pressedButton.Location.Y / cellSize, pressedButton.Location.X / cellSize, false);
                else ShowSteps(pressedButton.Location.Y / cellSize, pressedButton.Location.X / cellSize);
                if (countEatSteps == 0 || !isContunue)
                {
                    CloseSteps();
                    SwitchPlayer();
                    ShowPossibleSteps();
                    isContunue = false;
                }
                else if (isContunue)
                {
                    pressedButton.BackColor = Color.Red;
                    pressedButton.Enabled = true;
                    IsMoving = true;
                }
            }
        }

        prevButton = pressedButton;
    }

Вот, также у меня есть клиент, это winforms в нём как я понял, я должен обращаться к методам через client.название метода, которое помечено operationContract, ну проблема в том, что у меня в методах задействованы кнопки, а сервис не знает что это за кнопки, ведь кнопки есть только в клиенте и ещё например метод, который CreateMap, то есть он создаёт карту, он ведь может быть просто в клиенте, его не нужно в сервисе иметь? Ведь когда один человек откроет клиент, у него создастся поле с шашками и другой человек откроет свой клиент и у того создастся поле с шашками, а дальше уже их взаимодействие должно быть через сервис, я правильно понимаю? вот код клиента:

public partial class PlayingForm : Form, ICheckersServiceCallback
    {
        bool isConnected = false;
        CheckersServiceClient client;
        int ID;

        public PlayingForm()
        {
            InitializeComponent();
            
            blackFigure = new Bitmap(new Bitmap(@"C:\Users\amelent\source\repos\Сheckers\Сheckers\Sprites\b.png"), new Size(cellSize - 10, cellSize - 10));
            whiteFigure = new Bitmap(new Bitmap(@"C:\Users\amelent\source\repos\Сheckers\Сheckers\Sprites\w.png"), new Size(cellSize - 10, cellSize - 10));

            this.Text = "Checkers";

            Init();
        }
        void ConnectUser()
        {
            if (!isConnected)
            {
                client = new CheckersServiceClient(new System.ServiceModel.InstanceContext(this));
                ID = client.Connect(tbUserName.Text);
                tbUserName.Enabled = false;
                btnConDiscon.Text = "Disconnect";
                isConnected = true;
            }
        }

        void DisconnectUser()
        {
            if (isConnected)
            {
                client.DisConnect(ID);
                client = null;
                tbUserName.Enabled = true;
                btnConDiscon.Text = "Connect";
                isConnected = false;
            }

        }
        private void btnConDiscon_Click(object sender, EventArgs e)
        {
            if (isConnected)
            {
                DisconnectUser();
            }
            else
            {
                ConnectUser();
            }
        }

        public void MsgCallback(string msg)
        {
            LbxMsg.Items.Add(msg);
        }

        private void PlayingForm_FormClosing(object sender, FormClosingEventArgs e)
        {
            DisconnectUser();
        }

        private void tbxMsg_KeyDown(object sender, KeyEventArgs e)
        {
            if (e.KeyCode == Keys.Enter)
            {
                if (client != null)
                {
                    client.SendMsg(tbxMsg.Text, ID);
                    tbxMsg.Text = string.Empty;
                }
            }
        }






        //############
        const int mapSize = 8;
        const int cellSize = 50;

        int currentPlayer;

        List<Button> simpleSteps = new List<Button>();

        int countEatSteps = 0;
        Button prevButton;
        Button pressedButton;
        bool isContunue = false;

        bool IsMoving;

        int[,] map = new int[mapSize, mapSize];
        Button[,] buttons = new Button[mapSize, mapSize];

        Image whiteFigure;
        Image blackFigure;

        public void Init()
        {

            currentPlayer = 1;
            IsMoving = false;
            prevButton = null;

            map = new int[mapSize, mapSize]{
                { 0,1,0,1,0,1,0,1},
                { 1,0,1,0,1,0,1,0},
                { 0,1,0,1,0,1,0,1},
                { 0,0,0,0,0,0,0,0},
                { 0,0,0,0,0,0,0,0},
                { 2,0,2,0,2,0,2,0},
                { 0,2,0,2,0,2,0,2},
                { 2,0,2,0,2,0,2,0}
            };

            CreateMap();
        }
        public Color GetPrevButColor(Button prevButton) // заполняет поля цветом
        {
            if ((prevButton.Location.Y / cellSize % 2) != 0)
            {
                if ((prevButton.Location.X / cellSize % 2) == 0)
                {
                    return Color.Gray;
                }
            }
            if ((prevButton.Location.Y / cellSize % 2) == 0)
            {
                if ((prevButton.Location.X / cellSize % 2) != 0)
                {
                    return Color.Gray;
                }
            }
            return Color.White;
        }



        public void CreateMap() // Создание карты и добавление шашек
        {
            this.Width = (mapSize + 1) * cellSize;
            this.Height = (mapSize + 1) * cellSize;


            for (int i = 0; i < mapSize; i++)
            {
                for (int j = 0; j < mapSize; j++)
                {
                    Button button = new Button();
                    button.Location = new Point(j * cellSize, i * cellSize);
                    button.Size = new Size(cellSize, cellSize);
                    //button.Click += new EventHandler(OnFigurePress);
                    if (map[i, j] == 1)
                    {
                        button.Image = whiteFigure;
                    }
                    else if (map[i, j] == 2)
                    {
                        button.Image = blackFigure;
                    }

                    button.BackColor = GetPrevButColor(button);
                    button.ForeColor = Color.Red;

                    buttons[i, j] = button;

                    this.Controls.Add(button);
                }
            }
        }

Ответы (0 шт):