diff --git a/MainWindow.xaml.cs b/MainWindow.xaml.cs index ff37544..50ed552 100644 --- a/MainWindow.xaml.cs +++ b/MainWindow.xaml.cs @@ -76,14 +76,24 @@ namespace KTVApp { PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(name)); } - + /// + /// 當使用者點擊 Rectangle 物件時會觸發此事件 + /// + /// + /// private void Rectangle_MouseDown(object sender, MouseButtonEventArgs e) { + // 將 sender 轉換為 Rectangle 類型 var rect = sender as Rectangle; + + // 透過 DataContext 獲取關聯的 Room 物件 var room = rect.DataContext as Room; - // Open a new window and pass the room information + // 根據傳入的房間資料創建新的 RoomDetailsWindow 實例 + // 並且傳遞房間資訊 (room) 以及 TCP 服務器 (_tcpServer) 給該視窗 var roomDetailsWindow = new RoomDetailsWindow(room, _tcpServer); + + // 顯示新創建的 RoomDetailsWindow roomDetailsWindow.Show(); }