Пример #1
0
        private void Logout_Click(object sender, RoutedEventArgs e) //loguot
        {
            isLoggedOut = true;
            ClientCallback callback = new ClientCallback();

            try
            {
                GameServiceClient client = new GameServiceClient(
                    new InstanceContext(callback));
                client.ClientDisconnected(Username);
                MainWindow window = new MainWindow();
                this.Close();
                window.ShowDialog();
            }
            catch (FaultException <UserExistsFault> ex)
            {
                MessageBox.Show(ex.Detail.Message);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Пример #2
0
        private void Window_Closing(object sender, System.ComponentModel.CancelEventArgs e)
        {
            if (!isLoggedOut)
            {
                ClientCallback callback = new ClientCallback();
                try
                {
                    GameServiceClient client = new GameServiceClient(
                        new InstanceContext(callback));
                    client.ClientDisconnected(Username);
                }
                catch (FaultException <UserExistsFault> ex)
                {
                    MessageBox.Show(ex.Detail.Message);
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                }

                Environment.Exit(Environment.ExitCode);
            }
        }