private void Window_Closing(object sender, System.ComponentModel.CancelEventArgs e) { if (message != null) { message.Close(); message = null; } if (disconnect) { agent.SendPacket((byte)TcpCommands.ClientBye); agent.Disconnect(); agent.Dispose(); } }
private void Window_Closing(object sender, System.ComponentModel.CancelEventArgs e) { if (!close) { e.Cancel = true; var mes1 = new Message("Предупреждение", "Вы действительно хотите выйти?"); mes1.CreateQuestioningDialog(new DialogManager(this, Dispatcher), () => { if (save) { mes1.Close(); var mes2 = new Message("Предупреждение", "Сохранить воспаминания?"); mes2.CreateQuestioningDialog(new DialogManager(this, Dispatcher), () => { Record(); close = true; Close(); }, () => { close = true; Close(); }); } else { close = true; Close(); } }, () => { return; }); } else { agent.SendPacket((byte)TcpCommands.ClientBye); agent.Disconnect(); agent.Dispose(); } }