public MainWindow(string nickname, string addressFirstReceiver, string portFirstReceiver, ChatUDPController chatUDPController) { InitializeComponent(); this.nickname = nickname; this.addressFirstReceiver = addressFirstReceiver; this.portFirstReceiver = portFirstReceiver; //populateChatrooms(); messagesOfSelectedChatroom = new ObservableCollection <Message>(); Chatroom c1 = new Chatroom(""); chatrooms.Add(c1); //peers.Add(nickname); listBoxChatrooms.ItemsSource = chatrooms; listBoxChatrooms.SelectedItem = chatrooms[0]; /*messagesOfSelectedChatroom = chatrooms[0].messages;*/ listViewMessages.ItemsSource = messagesOfSelectedChatroom; listBoxParticipants.ItemsSource = peers; this.chatUDPController = chatUDPController; //new ChatUDPController(); }
/*private MainWindow mainWindow; * private ChatUDPController chatUDPController; * private LinkedList<Chatroom> chatrooms;*/ /*public App() * { * chatrooms = new LinkedList<Chatroom>(); * * Chatroom defaultChannelChatroom = new Chatroom(""); * chatrooms.AddLast(defaultChannelChatroom); * * chatUDPController = new ChatUDPController(); * }*/ private void ApplicationStart(object sender, StartupEventArgs e) { Current.ShutdownMode = ShutdownMode.OnExplicitShutdown; var connexionWindow = new ConnexionWindow(); if (connexionWindow.ShowDialog() == false) { ChatUDPController chatUDPController = new ChatUDPController(connexionWindow.nickname, connexionWindow.addressFirstReceiver, connexionWindow.portFirstReceiver); var mainWindow = new MainWindow(connexionWindow.nickname, connexionWindow.addressFirstReceiver, connexionWindow.portFirstReceiver, chatUDPController); /*ChatUDPController chatUDPController = new ChatUDPController("thais", "192.168.56.1", "2323"); * var mainWindow = new MainWindow("thais", "192.168.56.1", "2323", chatUDPController);*/ chatUDPController.mainWindow = mainWindow; Current.ShutdownMode = ShutdownMode.OnMainWindowClose; Current.MainWindow = mainWindow; mainWindow.Show(); } else { MessageBox.Show("Unable to load data.", "Error", MessageBoxButton.OK); Current.Shutdown(-1); } }