Inheritance: System.EventArgs
コード例 #1
0
ファイル: RoomViewModel.cs プロジェクト: Nowsoud/TCPChat
        private void ClientReceiveMessage(object sender, ReceiveMessageEventArgs e)
        {
            if (e.RoomName != Name)
            return;

              MainViewModel.Dispatcher.BeginInvoke(new Action<ReceiveMessageEventArgs>(args =>
              {
            var senderUser = MainViewModel.AllUsers.Single(uvm => uvm.Info.Nick == args.Sender);

            switch (args.Type)
            {
              case MessageType.Common:
            AddMessage(args.MessageId, senderUser, args.Message);
            break;

              case MessageType.File:
            AddFileMessage(senderUser, (FileDescription)args.State);
            break;
            }

            if (Name != MainViewModel.SelectedRoom.Name)
              Updated = true;

            MainViewModel.Alert();
              }), e);
        }
コード例 #2
0
ファイル: RoomViewModel.cs プロジェクト: Nirklav/TCPChat
        private void ClientReceiveMessage(ReceiveMessageEventArgs e)
        {
            if (e.RoomName != Name)
            return;

              switch (e.Type)
              {
            case MessageType.Common:
              AddMessage(e.MessageId, e.Time, e.Sender, e.Message);
              break;

            case MessageType.File:
              AddFileMessage(e.Time, e.Sender, e.FileId);
              break;
              }

              if (Name != mainViewModel.SelectedRoom.Name)
            Updated = true;

              mainViewModel.Alert();
        }
コード例 #3
0
ファイル: MainViewModel.cs プロジェクト: viktortat/TCPChat
    private void ClientReceiveMessage(object sender, ReceiveMessageEventArgs e)
    {
      if (e.Type != MessageType.System && e.Type != MessageType.Private)
        return;

      Dispatcher.BeginInvoke(new Action<ReceiveMessageEventArgs>(args =>
      {
        switch (args.Type)
        {
          case MessageType.Private:
            using (var client = ClientModel.Get())
            {
              UserViewModel senderUser = AllUsers.Single(uvm => string.Equals(uvm.Info.Nick, args.Sender));
              UserViewModel receiverUser = AllUsers.Single(uvm => string.Equals(uvm.Info.Nick, client.User.Nick));
              SelectedRoom.AddPrivateMessage(senderUser, receiverUser, args.Message);
            }
            break;

          case MessageType.System:
            SelectedRoom.AddSystemMessage(args.Message);
            break;
        }

        Alert();
      }), e);
    }
コード例 #4
0
ファイル: MainViewModel.cs プロジェクト: Nirklav/TCPChat
        private void ClientReceiveMessage(ReceiveMessageEventArgs e)
        {
            if (e.Type != MessageType.System && e.Type != MessageType.Private)
            return;

              switch (e.Type)
              {
            case MessageType.Private:
              SelectedRoom.AddPrivateMessage(e.Sender, ClientModel.Client.Id, e.Message);
              break;

            case MessageType.System:
              SelectedRoom.AddSystemMessage(Localizer.Instance.Localize(e.SystemMessage, e.SystemMessageFormat));
              break;
              }

              Alert();
        }
コード例 #5
0
        private void OnReceiveMessage(object sender, ReceiveMessageEventArgs args)
        {
            if (args.Type != MessageType.File)
            return;

              var file = args.State as FileDescription;
              if (file == null)
            return;

              var downaladDirectory = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "downloads");
              if (!Directory.Exists(downaladDirectory))
            Directory.CreateDirectory(downaladDirectory);

              var path = Path.Combine(downaladDirectory, file.Name);

              if (NeedDownload(file.Name))
              {
            RemoveFile(file.Name);
            Model.API.DownloadFile(path, ServerModel.MainRoomName, file);
              }
        }