Exemplo n.º 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);
            }
        }
Exemplo n.º 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);
            }
        }
Exemplo n.º 3
0
        static void Main(string[] args)
        {
            try
            {
                Console.WriteLine($"******* Program Started at {DateTime.Now}");
                _messenger = new Messenger();
                IMessengerContactAdvanced localUser =
                    (IMessengerContactAdvanced)_messenger.GetContact(_messenger.MySigninName, _messenger.MyServiceId);


                IMessengerContacts        _contacts = (IMessengerContacts)_messenger.MyContacts;
                IMessengerContactAdvanced _contact;

                Console.WriteLine("Contact list for the local user:"******"\t{0}", _contact.FriendlyName);
                    DisplayContactPresence(_contact);
                    InsertContactInfo((IMessengerContactAdvanced)_contact);
                }


                _messenger.OnContactStatusChange +=
                    new DMessengerEvents_OnContactStatusChangeEventHandler(_messenger_OnContactStatusChange);
                _messenger.OnMyStatusChange +=
                    new DMessengerEvents_OnMyStatusChangeEventHandler(_messenger_OnMyStatusChange);

                if (localUser != null)
                {
                    DisplayContactPresence(localUser);
                }
                Console.WriteLine("\nPress Enter key to exit the application.\n");
                Console.ReadLine();


                _messenger.OnContactStatusChange -=
                    new DMessengerEvents_OnContactStatusChangeEventHandler(_messenger_OnContactStatusChange);
                _messenger.OnMyStatusChange -=
                    new DMessengerEvents_OnMyStatusChangeEventHandler(_messenger_OnMyStatusChange);


                System.Runtime.InteropServices.Marshal.ReleaseComObject(_messenger);
                _messenger = null;
                System.Runtime.InteropServices.Marshal.ReleaseComObject(localUser);
                localUser = null;
            }
            catch (Exception ex)
            {
                Console.WriteLine($"ERROR: An error occurred in status tracker.\n{ex}");
            }
            finally
            {
                Console.WriteLine("******** Program Ended at {0}", DateTime.Now);
            }
        }
Exemplo n.º 4
0
        /// <summary>
        /// Converts <paramref name="contacts"/> to a more friendly <see cref="MessengerContact[]"/>.
        /// </summary>
        /// <param name="contacts">The contacts that should be converted</param>
        /// <returns>Converted Contacts</returns>
        internal static MessengerContact[] ToArray(IMessengerContacts contacts)
        {
            var list = new List <MessengerContact>();

            for (int i = 0; i < contacts.Count; i++)
            {
                list.Add(new MessengerContact(contacts.Item(i)));
            }
            return(list.ToArray());
        }
        public List <CustomContacts> GetAllEmailsWithFiendlyName()
        {
            List <CustomContacts> lstContacts       = new List <CustomContacts>();
            IMessengerContacts    messengerContacts = (IMessengerContacts)communicator.MyContacts;

            foreach (IMessengerContact acontact in messengerContacts)
            {
                CustomContacts aContact = new CustomContacts();
                aContact.ContactName    = acontact.FriendlyName.ToString();
                aContact.ContactEmailId = acontact.SigninName.ToString();
                lstContacts.Add(aContact);
            }
            return(lstContacts);
        }