Interaction logic for WhisperWindow.xaml
Inheritance: MahApps.Metro.Controls.MetroWindow
Beispiel #1
0
        public WhisperWindow FindOrCreateWhisperWindow(Conversation conversation, Participant participant, string info)
        {
            WhisperWindow window = FindWhisperWindow(conversation, participant);

            if (window == null)
            {
                window = new WhisperWindow(conversation, participant, seriousBusiness, info);
                _whisperWindows.Add(window);

                window.Closed += (s, e) => { _whisperWindows.Remove(window); };
                window.Show();
            }

            return window;
        }
Beispiel #2
0
        public WhisperWindow FindOrCreateWhisperWindow(Conversation conversation, Participant participant, string info)
        {
            WhisperWindow window = FindWhisperWindow(conversation, participant);

            if (window == null)
            {
                window = new WhisperWindow(conversation, participant, seriousBusiness, info);
                _whisperWindows.Add(window);

                window.Closed += (s, e) => { _whisperWindows.Remove(window); };
                window.Show();
            }

            return(window);
        }
        public SeriousBusinessCat(MainWindow main)
        {
            this._main = main;

            this.whisperCat = new WhisperCat(this);

            try
            {
#if DEBUG
                var _testWhisper = new WhisperWindow(null, null, null, "Your key: 12345\r\nTheir key: 6789A");

                _testWhisper.AddWhisper(new Whisper(true, "testing a really really long message, at least it seems pretty long, but i guess it is really not that long to begin with", "cipher1"));
                _testWhisper.AddWhisper(new Whisper(false, "okay, looks good", "cipher2"));
                _testWhisper.AddWhisper(new Whisper(true, "glad you think so, you jerk", "cipher3"));
                _testWhisper.Show();
#endif


                //Start the conversation
                automation = LyncClient.GetAutomation();
                client     = LyncClient.GetClient();

                ConversationManager conversationManager = client.ConversationManager;
                conversationManager.ConversationAdded   += ConversationManager_ConversationAdded;
                conversationManager.ConversationRemoved += ConversationManager_ConversationRemoved;
                //conversationManager.ConversationAdded += new EventHandler<ConversationManagerEventArgs>(conversationManager_ConversationAdded);

                _main.lbConversations.ItemsSource = _conversations;

                RefreshConversations(true);

                try
                {
                    _selfUserName = client.Self.Contact.GetContactInformation(ContactInformationType.PrimaryEmailAddress).ToString();
                    if (_selfUserName.Contains("@"))
                    {
                        _selfUserName = _selfUserName.Split('@')[0];
                    }
                    _selfUserNameLast = _selfUserName;
                    if (_selfUserNameLast.Contains('.'))
                    {
                        _selfUserNameLast = _selfUserNameLast.Split('.')[1];
                    }
                }
                catch (Exception)
                {
                    // ignore
                }
            }
            catch (LyncClientException lyncClientException)
            {
                MessageBox.Show("Failed to connect to Lync: " + lyncClientException.ToString());
                Console.Out.WriteLine(lyncClientException);
            }
            catch (SystemException systemException)
            {
                if (Util.IsLyncException(systemException))
                {
                    // Log the exception thrown by the Lync Model API.
                    MessageBox.Show("Failed to connect to Lync with system error: " + systemException.ToString());
                    Console.WriteLine("Error: " + systemException);
                }
                else
                {
                    // Rethrow the SystemException which did not come from the Lync Model API.
                    throw;
                }
            }
        }
        public SeriousBusinessCat(MainWindow main)
        {
            this._main = main;

            this.whisperCat = new WhisperCat(this);

            try
            {
#if DEBUG
                var _testWhisper = new WhisperWindow(null, null, null, "Your key: 12345\r\nTheir key: 6789A");
     
                _testWhisper.AddWhisper(new Whisper(true, "testing a really really long message, at least it seems pretty long, but i guess it is really not that long to begin with", "cipher1"));
                _testWhisper.AddWhisper(new Whisper(false, "okay, looks good", "cipher2"));
                _testWhisper.AddWhisper(new Whisper(true, "glad you think so, you jerk", "cipher3"));
                _testWhisper.Show();
#endif


                //Start the conversation
                automation = LyncClient.GetAutomation();
                client = LyncClient.GetClient();

                ConversationManager conversationManager = client.ConversationManager;
                conversationManager.ConversationAdded += ConversationManager_ConversationAdded;
                conversationManager.ConversationRemoved += ConversationManager_ConversationRemoved;
                //conversationManager.ConversationAdded += new EventHandler<ConversationManagerEventArgs>(conversationManager_ConversationAdded);

                _main.lbConversations.ItemsSource = _conversations;

                RefreshConversations(true);

                try
                {
                    _selfUserName = client.Self.Contact.GetContactInformation(ContactInformationType.PrimaryEmailAddress).ToString();
                    if (_selfUserName.Contains("@"))
                    {
                        _selfUserName = _selfUserName.Split('@')[0];
                    }
                    _selfUserNameLast = _selfUserName;
                    if (_selfUserNameLast.Contains('.'))
                    {
                        _selfUserNameLast = _selfUserNameLast.Split('.')[1];
                    }
                }
                catch (Exception)
                {
                    // ignore
                }
            }
            catch (LyncClientException lyncClientException)
            {
                MessageBox.Show("Failed to connect to Lync: " + lyncClientException.ToString());
                Console.Out.WriteLine(lyncClientException);
            }
            catch (SystemException systemException)
            {
                if (Util.IsLyncException(systemException))
                {
                    // Log the exception thrown by the Lync Model API.
                    MessageBox.Show("Failed to connect to Lync with system error: " + systemException.ToString());
                    Console.WriteLine("Error: " + systemException);
                }
                else
                {
                    // Rethrow the SystemException which did not come from the Lync Model API.
                    throw;
                }
            }
        }