public RoomWindowViewModel(RoomViewModel roomVM) { this.RoomVM = roomVM; userVMs.SetValue(new System.Collections.ObjectModel.ObservableCollection<UserViewModel>()); privateMicUserVMs.SetValue(new System.Collections.ObjectModel.ObservableCollection<UserViewModel>()); secretMicUserVMs.SetValue(new System.Collections.ObjectModel.ObservableCollection<UserViewModel>()); fontFamilies.SetValue(new System.Collections.ObjectModel.ObservableCollection<string>()); fontSizes.SetValue(new System.Collections.ObjectModel.ObservableCollection<int>()); RoomCallback = new RoomServiceCallback(); RoomClient = new RoomServiceClient(RoomCallback, roomVM.ServiceIp, ApplicationVM.LocalCache.RoomServicePort); SetVideoSize(); }
public bool HasCommand(UserViewModel target, CommandViewModel cmd, RoomViewModel room) { if (RoleVM != null && target.RoleVM != null) { var rcv = RoleVM.RoleCommandVMs.FirstOrDefault(rc => rc.TargetRoleVM == target.RoleVM && rc.CommandVM == cmd); if (rcv != null) { if (rcv.IsManagerCommand) { return IsRoleInRoom(room, BuiltIns.RoomAdministratorRole); } return true; } } return false; }
public void EnterRoom(int roomId) { if (Me.RoomWindowVM != null) { Messenger.Default.Send <EnumNotificationMessage <object, HallWindowAction> >(new EnumNotificationMessage <object, HallWindowAction>(HallWindowAction.AlreadyInRoom, roomId)); return; } RoomViewModel roomVM = ApplicationVM.LocalCache.AllRoomVMs.FirstOrDefault(r => r.Id == roomId); if (roomVM != null) { roomVM.Enter(); } else { Messenger.Default.Send <EnumNotificationMessage <object, HallWindowAction> >(new EnumNotificationMessage <object, HallWindowAction>(HallWindowAction.RoomNotExist)); } }
public bool IsRoleInRoom(RoomViewModel room, Role role) { return(RoomRoleVMs != null && RoomRoleVMs.FirstOrDefault(rr => rr.RoomId == room.Id && rr.RoleId == role.Id) != null); }
private void BuildCache() { Cache.Images.ForEach(img => { AddImage(img); }); Cache.GiftGroups.ForEach(g => { GiftGroupViewModel giftGroupVM = new GiftGroupViewModel(g); LocalCache.AllGiftGroupVMs.Add(giftGroupVM); }); Cache.Gifts.ForEach(g => { GiftViewModel giftVM = new GiftViewModel(g); giftVM.Initialize(); LocalCache.AllGiftVMs.Add(giftVM); }); LocalCache.AllGiftGroupVMs.ForEach(g => { g.Initialize(); }); Cache.RoomGroups.ForEach(rg => { RoomGroupViewModel roomGroupVM = new RoomGroupViewModel(rg); LocalCache.AllRoomGroupVMs.Add(roomGroupVM); }); //Create all the RoomViewModels so that we can initialize the RoomVMs of RoomGroupVM Cache.Rooms.ForEach(r => { RoomViewModel roomVM = new RoomViewModel(r); roomVM.Initialize(); LocalCache.AllRoomVMs.Add(roomVM); }); LocalCache.AllRoomGroupVMs.ForEach(rgv => { rgv.Initialize(); }); Cache.Commands.ForEach(c => { if (c.Application_Id == ApplicationId || c.Application_Id == BuiltIns.AllApplication.Id) { CommandViewModel vm = new CommandViewModel(c); vm.Initialize(); LocalCache.AllCommandVMs.Add(vm); } }); Cache.Roles.ForEach(r => { if (r.Application_Id == ApplicationId || r.Application_Id == BuiltIns.AllApplication.Id) { RoleViewModel vm = new RoleViewModel(r); LocalCache.AllRoleVMs.Add(vm); } }); Cache.RoleCommands.ForEach(rc => { if (rc.Application_Id == ApplicationId || rc.Application_Id == BuiltIns.AllApplication.Id) { RoleCommandViewModel vm = new RoleCommandViewModel(rc); vm.Initialize(); LocalCache.AllRoleCommandVMs.Add(vm); } }); LocalCache.AllRoleVMs.ForEach(r => { r.Initialize(); }); Cache.RoomRoles.ForEach(rr => { RoomRoleViewModel vm = new RoomRoleViewModel(rr); vm.Initialize(); LocalCache.AllRoomRoleVMs.Add(vm); }); Cache.ExchangeRates.ForEach(er => { ExchangeRateViewModel vm = new ExchangeRateViewModel(er); LocalCache.AllExchangeRateVMs.Add(vm); }); }
public bool IsRoleInRoom(RoomViewModel room, Role role) { return RoomRoleVMs != null && RoomRoleVMs.FirstOrDefault(rr => rr.RoomId == room.Id && rr.RoleId == role.Id) != null; }
private void BuildCache() { Cache.Images.ForEach(img => { AddImage(img); }); Cache.GiftGroups.ForEach(g => { GiftGroupViewModel giftGroupVM = new GiftGroupViewModel(g); LocalCache.AllGiftGroupVMs.Add(giftGroupVM); }); Cache.Gifts.ForEach(g => { GiftViewModel giftVM = new GiftViewModel(g); giftVM.Initialize(); LocalCache.AllGiftVMs.Add(giftVM); }); LocalCache.AllGiftGroupVMs.ForEach(g => { g.Initialize(); }); Cache.RoomGroups.ForEach(rg => { RoomGroupViewModel roomGroupVM = new RoomGroupViewModel(rg); LocalCache.AllRoomGroupVMs.Add(roomGroupVM); }); //Create all the RoomViewModels so that we can initialize the RoomVMs of RoomGroupVM Cache.Rooms.ForEach(r => { RoomViewModel roomVM = new RoomViewModel(r); roomVM.Initialize(); LocalCache.AllRoomVMs.Add(roomVM); }); LocalCache.AllRoomGroupVMs.ForEach(rgv => { rgv.Initialize(); }); Cache.Commands.ForEach(c => { if (c.Application_Id == ApplicationId || c.Application_Id == BuiltIns.AllApplication.Id) { CommandViewModel vm = new CommandViewModel(c); vm.Initialize(); LocalCache.AllCommandVMs.Add(vm); } }); Cache.Roles.ForEach(r => { if (r.Application_Id == ApplicationId || r.Application_Id == BuiltIns.AllApplication.Id) { RoleViewModel vm = new RoleViewModel(r); LocalCache.AllRoleVMs.Add(vm); } }); Cache.RoleCommands.ForEach(rc => { if (rc.Application_Id == ApplicationId || rc.Application_Id == BuiltIns.AllApplication.Id) { RoleCommandViewModel vm = new RoleCommandViewModel(rc); vm.Initialize(); LocalCache.AllRoleCommandVMs.Add(vm); } }); LocalCache.AllRoleVMs.ForEach(r => { r.Initialize(); }); Cache.RoomRoles.ForEach(rr => { RoomRoleViewModel vm = new RoomRoleViewModel(rr); vm.Initialize(); LocalCache.AllRoomRoleVMs.Add(vm); }); Cache.ExchangeRates.ForEach(er => { ExchangeRateViewModel vm = new ExchangeRateViewModel(er); LocalCache.AllExchangeRateVMs.Add(vm); }); }