コード例 #1
0
        private void IMWindowCreated(object sender, IMWindowCreatedEventArgs e)
        {
            try
            {
                OCMessageWindow           windows   = new OCMessageWindow();
                IMessengerWindow          pIMWindow = (IMessengerWindow)e.pIMWindow;
                IMessengerConversationWnd wnd       = (IMessengerConversationWnd)pIMWindow;
                windows.WindowHWND = e.pIMWindow.GetHashCode().ToString();
                windows.BeginTime  = DateTime.Now;

                IMessengerContacts contacts = (IMessengerContacts)wnd.Contacts;

                for (int i = 0; i < contacts.Count; i++)
                {
                    windows.ContactsList.Add(((IMessengerContact)contacts.Item(i)).SigninName);
                }

                messageWindowList.Add(windows);
                windows.Run(pIMWindow);
                windows.SaveHistroyEvent += windows_SaveHistroyEvent;
            }
            catch (Exception exception)
            {
                logger.Error(exception);
            }
        }
コード例 #2
0
        private void IMWindowContactAdded(object sender, IMWindowContactAddedEventArgs e)
        {
            try
            {
                string                    winID     = e.pIMWindow.GetHashCode().ToString();
                IMessengerWindow          pIMWindow = (IMessengerWindow)e.pIMWindow;
                IMessengerConversationWnd wnd       = (IMessengerConversationWnd)pIMWindow;
                IMessengerContacts        contacts  = (IMessengerContacts)wnd.Contacts;

                if (contacts.Count > 1)
                {
                    List <string> list = new List <string>(contacts.Count);

                    for (int i = 0; i < contacts.Count; i++)
                    {
                        list.Add(((IMessengerContact)contacts.Item(i)).SigninName);
                    }

                    OCMessageWindow windows = GetMessageWindow(winID);
                    windows.ContactsList.AddRange(list.Where(f => !windows.ContactsList.Contains(f)));
                }
            }
            catch (Exception exception)
            {
                logger.Error(exception);
            }
        }
コード例 #3
0
        private void windows_SaveHistroyEvent(object sender, string message)
        {
            OCMessageWindow window = sender as OCMessageWindow;

            if (window != null)
            {
                if (EMPTYMESSAGE.IsMatch(message))
                {
                    return;
                }

                string[] array = new string[window.ContactsList.Count];
                window.ContactsList.CopyTo(array);
                messageStore.SaveMessage(window.BeginTime, message, array);
            }
        }
コード例 #4
0
 private void IMWindowDestroyed(object sender, IMWindowDestroyedEventArgs e)
 {
     try
     {
         OCMessageWindow window = GetMessageWindow(e.pIMWindow.GetHashCode().ToString());
         if (window != null)
         {
             window.Stop();
             messageWindowList.Remove(window);
         }
         else
         {
             Console.WriteLine("Cannot retrieve IMWindow");
         }
     }
     catch (Exception exception)
     {
         logger.Error(exception);
     }
 }