Inheritance: ViewModelBase
Beispiel #1
0
        public bool EnterRoom()
        {
            Room room;

            if (CurrentSeat != null)
            {
                if (!ExitRoom())
                {
                    return(false);
                }
            }
            if (_IsSuccess(Connection.EnterRoom(_currentRoom.Id, false, null, out room)))
            {
                CurrentRoom = new RoomViewModel()
                {
                    Room = room
                };
                Trace.Assert(CurrentSeat != null, "Successfully joined a room, but do not find myself in the room");
                return(true);
            }
            return(false);
        }
Beispiel #2
0
 /// <summary>
 /// Updates all rooms in the lobby.
 /// </summary>
 public void UpdateRooms()
 {
     var result = _connection.GetRooms(_loginToken, false);
     Rooms.Clear();
     bool found = false;
     foreach (var room in result)
     {
         var model = new RoomViewModel() { Room = room };
         Rooms.Add(model);
         if (CurrentRoom != null && room.Id == CurrentRoom.Id)
         {
             found = true;
             CurrentRoom = model;
         }
     }
     if (!found)
     {
         CurrentRoom = null;
     }
 }
Beispiel #3
0
 public void NotifyRoomUpdate(int id, Room room)
 {
     Application.Current.Dispatcher.BeginInvoke((ThreadStart)delegate()
     {
         var result = Rooms.FirstOrDefault(r => r.Id == id);
         if (result != null)
         {
             result.Room = room;
         }
         else
         {
             Rooms.Add(new RoomViewModel() { Room = room });
         }
         if (CurrentRoom.Id == id)
         {
             CurrentRoom = new RoomViewModel() { Room = room };
         }
     });
 }
Beispiel #4
0
 public bool EnterRoom()
 {
     Room room;
     if (CurrentSeat != null)
     {
         if (!ExitRoom()) return false;
     }
     if (_IsSuccess(Connection.EnterRoom(_loginToken, _currentRoom.Id, false, null, out room)))
     {
         CurrentRoom = new RoomViewModel() { Room = room };
         Trace.Assert(CurrentSeat != null, "Successfully joined a room, but do not find myself in the room");
         return true;
     }
     return false;
 }
Beispiel #5
0
 /// <summary>
 /// Creates and enters a new room.
 /// </summary>
 public void CreateRoom()
 {
     var room = _connection.CreateRoom(_loginToken);
     if (room != null)
     {
         CurrentRoom = new RoomViewModel() { Room = room };
         UpdateRooms();
         Trace.Assert(CurrentSeat != null, "Successfully created a room, but do not find myself in the room");
     }
 }
Beispiel #6
0
 public void EnterRoom()
 {
     Room room;
     if (_connection.EnterRoom(_loginToken, _currentRoom.Id, false, null, out room) == RoomOperationResult.Success)
     {
         CurrentRoom = new RoomViewModel() { Room = room };
         CurrentSeat = CurrentRoom.Seats.FirstOrDefault(s => s.Account != null && s.Account.Id == CurrentAccount.Id);
         Trace.Assert(CurrentSeat != null, "Successfully joined a room, but do not find myself in the room");
     }
 }
Beispiel #7
0
 /// <summary>
 /// Creates and enters a new room.
 /// </summary>
 public void CreateRoom()
 {
     var room = _connection.CreateRoom(_loginToken);
     if (room != null)
     {
         CurrentRoom = new RoomViewModel() { Room = room };
         CurrentSeat = CurrentRoom.Seats.FirstOrDefault(s => s.Account != null && s.Account.Id == CurrentAccount.Id);
         Trace.Assert(CurrentSeat != null, "Successfully created a room, but do not find myself in the room");
     }
 }