protected override void ProcessMessage(Common.Notification.EnumNotificationMessage <object, ViewModel.HallWindowAction> message) { HallWindowViewModel hallWindowVM = DataContext as HallWindowViewModel; switch (message.Action) { case HallWindowAction.ApplicationShutdown: if (webWindow != null) { CloseWebWindow(webWindow); webWindow = null; } if (roomWindow != null) { roomWindow.Close(); } if (registerWindow != null) { registerWindow.Close(); } Close(); break; case HallWindowAction.CloseRoomWindow: if (roomWindow != null) { roomWindow.Close(); } break; case HallWindowAction.AlreadyInRoom: ShowWebWindow(webWindow, false); if (MessageBox.Show(Messages.AlreadyInRoom, Text.Warning, MessageBoxButton.YesNo) == MessageBoxResult.Yes) { if (roomWindow != null) { roomWindow.Close(); hallVM.Me.RoomWindowVM = null; } int roomId = (int)message.Content; if (roomId != null) { hallVM.EnterRoom(roomId); } } ShowWebWindow(webWindow, true); break; case HallWindowAction.EnterRoomSucceeded: RoomWindowViewModel roomWindowVM = message.Content as RoomWindowViewModel; roomWindow = new RoomWindow(roomWindowVM, this) as RoomWindow; roomWindow.Closed += roomWindow_Closed; roomWindow.StateChanged += roomWindow_StateChanged; roomWindow.Show(); //Hide(); //ShowWebWindow(webWindow, false); break; case HallWindowAction.EnterRoomFailed: MessageBox.Show(Messages.EnterRoomFailed); break; case HallWindowAction.Register: RegisterWindowViewModel vm = message.Content as RegisterWindowViewModel; if (vm != null) { registerWindow = new RegisterWindow(vm) { Owner = this }; ShowWebWindow(webWindow, false); registerWindow.ShowDialog(); ShowWebWindow(webWindow, true); } break; case HallWindowAction.RegisterUserIdNotAvailable: ShowWebWindow(webWindow, false); MessageBox.Show(Messages.NoRegisterUserIdAvailable); ShowWebWindow(webWindow, true); break; case HallWindowAction.RegisterSuccess: if (registerWindow != null) { registerWindow.Close(); } User user = message.Content as User; if (user != null) { webWindow.CallJavaScript("SetLoginUser", user.Id, user.Password); } ShowWebWindow(webWindow, true); break; case HallWindowAction.RegisterCancel: if (registerWindow != null) { registerWindow.Close(); } ShowWebWindow(webWindow, true); break; case HallWindowAction.OpenConfigurationWindow: hallWindowVM.ApplicationVM.ConfigurationWindowVM = new ConfigurationWindowViewModel(); ShowWebWindow(webWindow, false); ConfigurationWindow configurationWindow = new ConfigurationWindow(hallWindowVM.ApplicationVM.ConfigurationWindowVM); configurationWindow.Owner = this; configurationWindow.ShowDialog(); ShowWebWindow(webWindow, true); break; case HallWindowAction.SwitchUser: ShowWebWindow(webWindow, false); if (MessageBox.Show(Text.SwitchUserConfirm, Text.Prompt, MessageBoxButton.YesNo) == MessageBoxResult.Yes) { hallWindowVM.ApplicationVM.SwitchUser(); webWindow.CallJavaScript("SwitchUser"); } ShowWebWindow(webWindow, true); break; default: break; } }
protected override void ProcessMessage(Common.Notification.EnumNotificationMessage<object, ViewModel.HallWindowAction> message) { HallWindowViewModel hallWindowVM = DataContext as HallWindowViewModel; switch (message.Action) { case HallWindowAction.ApplicationShutdown: if (webWindow != null) { CloseWebWindow(webWindow); webWindow = null; } if (roomWindow != null) { roomWindow.Close(); } if (registerWindow != null) { registerWindow.Close(); } Close(); break; case HallWindowAction.CloseRoomWindow: if (roomWindow != null) { roomWindow.Close(); } break; case HallWindowAction.AlreadyInRoom: ShowWebWindow(webWindow, false); if(MessageBox.Show(Messages.AlreadyInRoom,Text.Warning,MessageBoxButton.YesNo) == MessageBoxResult.Yes) { if(roomWindow != null) { roomWindow.Close(); hallVM.Me.RoomWindowVM = null; } int roomId =(int)message.Content; if (roomId != null) { hallVM.EnterRoom(roomId); } } ShowWebWindow(webWindow, true); break; case HallWindowAction.EnterRoomSucceeded: RoomWindowViewModel roomWindowVM = message.Content as RoomWindowViewModel; roomWindow = new RoomWindow(roomWindowVM,this) as RoomWindow; roomWindow.Closed += roomWindow_Closed; roomWindow.StateChanged += roomWindow_StateChanged; roomWindow.Show(); //Hide(); //ShowWebWindow(webWindow, false); break; case HallWindowAction.EnterRoomFailed: MessageBox.Show(Messages.EnterRoomFailed); break; case HallWindowAction.Register: RegisterWindowViewModel vm = message.Content as RegisterWindowViewModel; if (vm != null) { registerWindow = new RegisterWindow(vm) { Owner = this }; ShowWebWindow(webWindow, false); registerWindow.ShowDialog(); ShowWebWindow(webWindow, true); } break; case HallWindowAction.RegisterUserIdNotAvailable: ShowWebWindow(webWindow, false); MessageBox.Show(Messages.NoRegisterUserIdAvailable); ShowWebWindow(webWindow, true); break; case HallWindowAction.RegisterSuccess: if (registerWindow != null) { registerWindow.Close(); } User user = message.Content as User; if (user != null) { webWindow.CallJavaScript("SetLoginUser", user.Id, user.Password); } ShowWebWindow(webWindow, true); break; case HallWindowAction.RegisterCancel: if (registerWindow != null) { registerWindow.Close(); } ShowWebWindow(webWindow, true); break; case HallWindowAction.OpenConfigurationWindow: hallWindowVM.ApplicationVM.ConfigurationWindowVM = new ConfigurationWindowViewModel(); ShowWebWindow(webWindow, false); ConfigurationWindow configurationWindow = new ConfigurationWindow(hallWindowVM.ApplicationVM.ConfigurationWindowVM); configurationWindow.Owner = this; configurationWindow.ShowDialog(); ShowWebWindow(webWindow, true); break; case HallWindowAction.SwitchUser: ShowWebWindow(webWindow,false); if (MessageBox.Show(Text.SwitchUserConfirm, Text.Prompt, MessageBoxButton.YesNo) == MessageBoxResult.Yes) { hallWindowVM.ApplicationVM.SwitchUser(); webWindow.CallJavaScript("SwitchUser"); } ShowWebWindow(webWindow, true); break; default: break; } }
protected override void ProcessMessage(Common.Notification.EnumNotificationMessage<object, LoginWindowAction> message) { switch (message.Action) { case LoginWindowAction.LoginSuccess: break; case LoginWindowAction.InvalidToken: MessageBox.Show(Messages.InvalidToken, Text.Error, MessageBoxButton.OK, MessageBoxImage.Error); break; case LoginWindowAction.UserBlocked: string blockName = message.Content as string; MessageBox.Show(string.Format(Messages.UserBlocked, blockName), Text.Error, MessageBoxButton.OK, MessageBoxImage.Error); break; case LoginWindowAction.CacheLoaded: initUserInfo(); HallWindow hallWnd = new HallWindow(); hallWnd.Show(); this.Close(); break; case LoginWindowAction.Register: RegisterWindowViewModel vm = message.Content as RegisterWindowViewModel; if (vm != null) { registerWnd = new RegisterWindow(vm){Owner = this}; registerWnd.ShowDialog(); } break; case LoginWindowAction.RegisterSuccess: if (registerWnd != null) { registerWnd.Close(); } User user = message.Content as User; if (user != null) { hallVM.ApplicationVM.ProfileVM.LastLoginVM.UserId = user.Id.ToString(); hallVM.ApplicationVM.ProfileVM.LastLoginVM.Password = user.Password; hallVM.ApplicationVM.ProfileVM.LastLoginVM.IconPath = DefaultHeaderIcon; } break; case LoginWindowAction.RegisterUserIdNotAvailable: MessageBox.Show(Messages.NoRegisterUserIdAvailable); break; case LoginWindowAction.RegisterCancel: if (registerWnd != null) registerWnd.Close(); break; default: break; } }