Example #1
0
		private void OnRoomCreated(ChatRoom room)
		{
			var item = new RoomItem(room);

			item.Users.AddRange(Client.GetAuthors(room));

			_chatRooms.Add(item);
		}
Example #2
0
		private void ChatControl_OnLoaded()
		{
			var client = Client;

			client.AuthorAdded += OnAuthorAdded;
			client.AuthorDeleted += OnAuthorDeleted;
			client.JoinAccepted += OnJoinAccepted;
			client.JoinRejected += OnJoinRejected;
			client.JoinSended += OnJoinSended;
			client.LoggedIn += OnLoggedIn;
			client.LoggedOut += OnLoggedOut;
			client.MessageCreated += OnMessageCreated;
			client.MessageUpdated += OnMessageUpdated;
			client.MessageDeleted += OnMessageDeleted;
			client.RoomCreated += OnRoomCreated;
			client.RoomDeleted += OnRoomDeleted;
			client.RoomUpdated += OnRoomUpdated;

			var cmdSvc = ConfigManager.GetService<IStudioCommandService>();

			cmdSvc.Register<LoggedInCommand>(this, false, cmd =>
			{
				IsEnabled = true;

				var rooms = _chatRooms.ToDictionary(i => i.Room, i => i);

				foreach (var room in client.AllRooms)
				{
					var item = rooms.TryGetValue(room);

					if (item != null)
					{
						rooms.Remove(room);
						continue;
					}
					
					item = new RoomItem(room);
					item.Users.AddRange(client.GetAuthors(room));
					_chatRooms.Add(item);
				}

				_chatRooms.RemoveRange(rooms.Values);
				UpdateTitle();
			});
			cmdSvc.Register<LoggedOutCommand>(this, false, cmd =>
			{
				IsEnabled = false;
				UpdateTitle();
			});

			IsEnabled = ConfigManager.GetService<AuthenticationClient>().IsLoggedIn;
			UpdateTitle();

			if (IsEnabled)
				return;

			var res = new MessageBoxBuilder()
					.Owner(this)
					.Text(LocalizedStrings.Str3207)
					.Warning()
					.YesNo()
					.Show();

			if (res == MessageBoxResult.Yes)
				cmdSvc.Process(this, new LogInCommand());
		}
Example #3
0
        private void ChatControl_OnLoaded()
        {
            var client = Client;

            client.AuthorAdded    += OnAuthorAdded;
            client.AuthorDeleted  += OnAuthorDeleted;
            client.JoinAccepted   += OnJoinAccepted;
            client.JoinRejected   += OnJoinRejected;
            client.JoinSended     += OnJoinSended;
            client.LoggedIn       += OnLoggedIn;
            client.LoggedOut      += OnLoggedOut;
            client.MessageCreated += OnMessageCreated;
            client.MessageUpdated += OnMessageUpdated;
            client.MessageDeleted += OnMessageDeleted;
            client.RoomCreated    += OnRoomCreated;
            client.RoomDeleted    += OnRoomDeleted;
            client.RoomUpdated    += OnRoomUpdated;

            var cmdSvc = ConfigManager.GetService <IStudioCommandService>();

            cmdSvc.Register <LoggedInCommand>(this, false, cmd =>
            {
                IsEnabled = true;

                var rooms = _chatRooms.ToDictionary(i => i.Room, i => i);

                foreach (var room in client.AllRooms)
                {
                    var item = rooms.TryGetValue(room);

                    if (item != null)
                    {
                        rooms.Remove(room);
                        continue;
                    }

                    item = new RoomItem(room);
                    item.Users.AddRange(client.GetAuthors(room));
                    _chatRooms.Add(item);
                }

                _chatRooms.RemoveRange(rooms.Values);
                UpdateTitle();
            });
            cmdSvc.Register <LoggedOutCommand>(this, false, cmd =>
            {
                IsEnabled = false;
                UpdateTitle();
            });

            IsEnabled = ConfigManager.GetService <AuthenticationClient>().IsLoggedIn;
            UpdateTitle();

            if (IsEnabled)
            {
                return;
            }

            var res = new MessageBoxBuilder()
                      .Owner(this)
                      .Text(LocalizedStrings.Str3207)
                      .Warning()
                      .YesNo()
                      .Show();

            if (res == MessageBoxResult.Yes)
            {
                cmdSvc.Process(this, new LogInCommand());
            }
        }