예제 #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 SaveHistroyMethod(object obj)
        {
            ThreadParameter           para = (ThreadParameter)obj;
            IMessengerConversationWnd wnd  = para.IMWindow as IMessengerConversationWnd;
            string history = string.Empty;

            while (isRuning)
            {
                try
                {
                    if (wnd != null &&
                        !string.IsNullOrEmpty(wnd.History) &&
                        (savedMessageWordsCount != wnd.History.Length))
                    {
                        history = wnd.History;
                        savedMessageWordsCount = history.Length;

                        if (this.SaveHistroyEvent != null)
                        {
                            lock (this.SaveHistroyEvent)
                            {
                                this.SaveHistroyEvent(this, history);
                            }
                        }
                    }
                }
                catch (COMException comExp)
                {
                    //logger.Warn(exp);
                    Console.WriteLine(comExp);
                }
                catch (Exception exp)
                {
                    logger.Error(exp);
                    this.isRuning = false;
                }
                Thread.Sleep(200);
            }

            para.doneEvent.Set();
        }
예제 #4
0
 public MessengerConversationWindow(IMessengerConversationWnd window) => this._window = window;