Пример #1
0
        private void Connection_StrangerFound(object sender, StrangerFoundEventArgs e)
        {
            Application.Current.Dispatcher.Invoke(() =>
            {
                ChatBox.IsEnabled = true;
                ChatBox.Focus();

                MessageLog.AddPresence(true, e.StrangerInfo.FlaggedAsUnpleasant);
                StatusTextBlock.Text = LocaleSelector.GetLocaleString("StatusIndicator_StrangerIdle");

                Toolbar.FlagStrangerButton.IsEnabled           = true;
                Toolbar.DisconnectFromStrangerButton.IsEnabled = true;
                Toolbar.RequestRandomTopicButton.IsEnabled     = true;
            });
        }
Пример #2
0
        private void Connection_ConversationEnded(object sender, ConversationEndedEventArgs e)
        {
            Application.Current.Dispatcher.Invoke(() =>
            {
                if (!e.DisconnectInfo.IsReminder)
                {
                    MessageLog.AddPresence(false);
                }

                ChatBox.Clear();
                ChatBox.IsEnabled = false;

                StatusTextBlock.Text = LocaleSelector.GetLocaleString("StatusIndicator_ConnectedToServer");

                Toolbar.DisconnectFromStrangerButton.IsEnabled = false;
                Toolbar.SearchForStrangerButton.IsEnabled      = true;
                Toolbar.FlagStrangerButton.IsEnabled           = false;
                Toolbar.RequestRandomTopicButton.IsEnabled     = false;
            });
        }
Пример #3
0
        private void FillMessageLog(string path)
        {
            Application.Current.Dispatcher.Invoke(() =>
            {
                using (var sr = new StreamReader(path))
                {
                    var array = sr.ReadToEnd().Split('\n');

                    foreach (var s in array)
                    {
                        object item;
                        try
                        {
                            item = Presence.Parse(s);
                        }
                        catch
                        {
                            try
                            {
                                item = Message.Parse(s);
                            }
                            catch
                            {
                                try
                                {
                                    item = Topic.Parse(s);
                                }
                                catch
                                {
                                    return;
                                }
                            }
                        }

                        if (item is Presence)
                        {
                            var p = item as Presence;
                            MessageLog.AddPresence(p.Connect);
                        }

                        if (item is Message)
                        {
                            var m = item as Message;
                            MessageLog.AddMessage(
                                new ObcyProtoRev.Protocol.Client.Message(
                                    m.Body,
                                    -1,
                                    -1,
                                    MessageType.Chat
                                    ),
                                m.Incoming,
                                m.Timestamp.FromUnixTimestamp()
                                );
                        }

                        if (item is Topic)
                        {
                            var t = item as Topic;
                            MessageLog.AddTopic(
                                new ObcyProtoRev.Protocol.Client.Message(
                                    t.Body,
                                    0,
                                    0,
                                    MessageType.Topic
                                    )
                                );
                        }
                    }
                }
            });
        }