コード例 #1
0
ファイル: ChatUser.cs プロジェクト: WIND4IK/AGENTIK
 public bool Equals(ChatUser other)
 {
     if (ReferenceEquals(other, null)) {
         return false;
     }
     if (ReferenceEquals(this, other)) {
         return true;
     }
     if (GetType() != other.GetType()) {
         return false;
     }
     return (Bare == other.Bare);
 }
コード例 #2
0
ファイル: MainWindow.xaml.cs プロジェクト: WIND4IK/AGENTIK
 private void RosterManagerOnRosterItem(object sender, Item ri)
 {
     try {
         if ((ri.JID.Bare != _jid.Bare) && !(from t in _users select t.Bare).Contains<string>(ri.JID.Bare)) {
             Application.Current.Dispatcher.Invoke(() => {
                     var userName = GetUserName(ri.JID.Bare);
                     var item = new ChatUser {
                         Bare = ri.JID.Bare,
                         Name = userName ?? ri.JID.User,
                         Image = _errorImage
                     };
                     _users.Add(item);
                     FilterText = string.Empty;
                     usersListView.Items.Refresh();
                 }, DispatcherPriority.Normal);
         }
     }
     catch (Exception exception) {
         _log.Error(exception);
     }
 }
コード例 #3
0
ファイル: MainWindow.xaml.cs プロジェクト: WIND4IK/AGENTIK
 private void JabberClientOnMessage(object sender, Message msg)
 {
     try
     {
         Application.Current.Dispatcher.Invoke(() =>
         {
             if (!(from t in _users select t.Bare).Contains<string>(msg.From.Bare))
             {
                 var user = new ChatUser
                 {
                     Bare = msg.From.Bare,
                     Name = msg.From.User
                 };
                 _currentUser = user;
                 _users.Add(_currentUser);
             }
             else
             {
                 _currentUser = _users.First(t => t.Bare.Equals(msg.From.Bare));
             }
             notifyIcon.Tag = _currentUser;
             var viewChatUser = GetViewChatUser(_currentUser);
             CreateChatWindow();
             var item = new ChatMessage(_currentUser.Name)
             {
                 Text = msg.Body,
                 From = _currentUser.Bare
             };
             viewChatUser.Messages.Add(item);
             if (((_chatWindow == null) || !_chatWindow.IsActive) ||
                 (_chatWindow.IsActive && !_chatWindow.SelectedViewChatUser.Equals(viewChatUser)))
             {
                 _currentUser.Image = _messageImage;
                 ShowGifForMessage(true);
                 ShowMessageNotification(item);
                 PlaySound();
             }
             Helper.SaveToFile(item);
         });
     }
     catch (Exception exception)
     {
         _log.Error(exception);
     }
 }
コード例 #4
0
ファイル: MainWindow.xaml.cs プロジェクト: WIND4IK/AGENTIK
 private ViewChatUser GetViewChatUser(ChatUser chatUser)
 {
     try {
         ViewChatUser user;
         if (!_allViewChatUsers.ContainsKey(chatUser.Bare)) {
             user = new ViewChatUser {
                 JabberClient = _jabberClient,
                 ChatUser = chatUser,
                 Messages = new ObservableCollection<ChatMessage>()
             };
             _allViewChatUsers.Add(chatUser.Bare, user);
         }
         else {
             user = _allViewChatUsers[chatUser.Bare];
         }
         return user;
     }
     catch (Exception exception) {
         _log.Error(exception);
         return null;
     }
 }
コード例 #5
0
 public void LoadArchive()
 {
     try {
         var path = Path.Combine(Directory.GetCurrentDirectory(), "History");
         if (Directory.Exists(path)) {
             _users.Clear();
             var enumerable = from t in Directory.GetFiles(path)
                                                       select new FileInfo(t) into t
                                                       orderby t.LastWriteTime descending
                                                       select t;
             foreach (var info in enumerable) {
                 var jid = new JID(Path.GetFileNameWithoutExtension(info.FullName));
                 var item = new ChatUser {
                     Bare = jid.Bare,
                     Name = jid.User
                 };
                 _users.Add(item);
             }
             FilterText = _filterText;
         }
     }
     catch (Exception exception) {
         _log.Error(exception);
     }
 }