private void ExitB_Click(object sender, RoutedEventArgs e) { try { Client.ClientDisconnect(Username); this.Close(); } catch (TimeoutException) { timer.Stop(); ConnIndicator.Fill = System.Windows.Media.Brushes.Red; online = false; MessageBox.Show(" connection unstable , it took to long to get a response, unable to connect try again later", Username + " connection unstable"); this.Close(); } catch (CommunicationObjectFaultedException) { timer.Stop(); ConnIndicator.Fill = System.Windows.Media.Brushes.Red; online = false; MessageBox.Show(" connection failed , this game is canceled", Username + " connection unstable"); this.Close(); } catch (Exception ex) { timer.Stop(); ConnIndicator.Fill = System.Windows.Media.Brushes.Red; online = false; MessageBox.Show(ex.ToString(), Username); this.Close(); } }
private void Window_Closing(object sender, System.ComponentModel.CancelEventArgs e) { timer.Stop(); ConnIndicator.Fill = System.Windows.Media.Brushes.Red; if (mainWindow != null) { mainWindow.Close(); } try { if (online) { Client.ClientDisconnect(Username); } } catch (TimeoutException) { MessageBox.Show(" connection unstable , it took to long to get a response, unable to connect try again later", Username + " connection unstable"); } catch (CommunicationObjectFaultedException) { MessageBox.Show(" connection failed , this game is canceled", Username + " connection unstable"); } catch (Exception ex) { MessageBox.Show(ex.ToString(), Username); } }
/*back to dashboard*/ private void BTDB_Click(object sender, RoutedEventArgs e) { try { Client.ClientDisconnect(Username);//remove player from wating list ClientCallback callback1 = new ClientCallback(); ServiceClient client1 = new ServiceClient(new InstanceContext(callback1)); Dashboard mainWindow = new Dashboard(client1, callback1, Username); mainWindow.Title = Username; this.Close(); mainWindow.Show(); } catch (TimeoutException) { timer.Stop(); ConnIndicator.Fill = System.Windows.Media.Brushes.Red; online = false; MessageBox.Show(" connection unstable , it took to long to get a response, unable to connect try again later", Username + " connection unstable"); this.Close(); } catch (CommunicationObjectFaultedException) { timer.Stop(); ConnIndicator.Fill = System.Windows.Media.Brushes.Red; online = false; MessageBox.Show(" connection failed , this game is canceled", Username + " connection unstable"); this.Close(); } catch (Exception ex) { timer.Stop(); ConnIndicator.Fill = System.Windows.Media.Brushes.Red; online = false; MessageBox.Show(ex.ToString(), Username); this.Close(); } }