コード例 #1
0
ファイル: rooms.xaml.cs プロジェクト: Retivykh-Serg/Dixit
        private void connectToRoom_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                Room selecterdRoom = (Room)roomsDataGrid.SelectedItem;
                if (selecterdRoom.status > 0)
                {
                    txt.Text = "Игра уже началась! Вы не можете подключиться";
                    if (w.IsSoundEnabled) soundPlay(new Uri(@"sounds\\warning.mp3", UriKind.Relative), null);
                    return;
                }
                if (selecterdRoom.status == 0)
                {
                    passed = false;
                    if (selecterdRoom.password == "") passed = true;
                    else
                    {
                        pass p = new pass(this, selecterdRoom.password);
                        p.ShowDialog();
                    }

                    if (passed)
                    {
                        w.isAdmin = false;
                        Data msgToSend = new Data();
                        msgToSend.cmdCommand = Command.connectToGame;
                        msgToSend.gameToConnectRoomName = selecterdRoom.roomName;

                        if (!w.client.Send(msgToSend))
                        {
                            this.Close();
                            return;
                        }

                        this.Hide();
                        w.Show();
                        w.buttonTaskOK.IsEnabled = false;
                        w.buttonTaskOK.Content = "Ожидание. . .";
                        w.Title += " [" + selecterdRoom.roomName + " | " + selecterdRoom.maxScores.ToString() + " ]";
                        if (w.IsSoundEnabled)
                            soundPlay(new Uri(@"sounds\\connect.mp3", UriKind.Relative), null);
                    }
                    else
                    {
                        txt.Text = "Неверный пароль!";
                        if (w.IsSoundEnabled) soundPlay(new Uri(@"sounds\\warning.mp3", UriKind.Relative), null);
                    }
                }

            }
            catch { }
        }
コード例 #2
0
ファイル: rooms.xaml.cs プロジェクト: serg-the-engineer/Dixit
        private void connectToRoom_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                Room selecterdRoom = (Room)roomsDataGrid.SelectedItem;
                if (selecterdRoom.status > 0)
                {
                    txt.Text = "Игра уже началась! Вы не можете подключиться";
                    if (w.IsSoundEnabled)
                    {
                        soundPlay(new Uri(@"sounds\\warning.mp3", UriKind.Relative), null);
                    }
                    return;
                }
                if (selecterdRoom.status == 0)
                {
                    passed = false;
                    if (selecterdRoom.password == "")
                    {
                        passed = true;
                    }
                    else
                    {
                        pass p = new pass(this, selecterdRoom.password);
                        p.ShowDialog();
                    }


                    if (passed)
                    {
                        w.isAdmin = false;
                        Data msgToSend = new Data();
                        msgToSend.cmdCommand            = Command.connectToGame;
                        msgToSend.gameToConnectRoomName = selecterdRoom.roomName;

                        if (!w.client.Send(msgToSend))
                        {
                            this.Close();
                            return;
                        }

                        this.Hide();
                        w.Show();
                        w.buttonTaskOK.IsEnabled = false;
                        w.buttonTaskOK.Content   = "Ожидание. . .";
                        w.Title += " [" + selecterdRoom.roomName + " | " + selecterdRoom.maxScores.ToString() + " ]";
                        if (w.IsSoundEnabled)
                        {
                            soundPlay(new Uri(@"sounds\\connect.mp3", UriKind.Relative), null);
                        }
                    }
                    else
                    {
                        txt.Text = "Неверный пароль!";
                        if (w.IsSoundEnabled)
                        {
                            soundPlay(new Uri(@"sounds\\warning.mp3", UriKind.Relative), null);
                        }
                    }
                }
            }
            catch { }
        }