Пример #1
0
        public static void SaveMessage(MucMessage message)
        {
            try
            {
                Dictionary<string, object> values = message.GetData();

                if (message.DateTime.DateTime.Value != null)
                {
                    if (!MucMessageExists(message.Sender, message.DateTime.DateTime.Value))
                    {
                        Insert(values, "Message", false, _connection);
                    }
                }
            }

            catch (Exception e)
            {
                Events.Instance.OnEvent(e, new EventError(e.Message, null));
            }
        }
        private void SelectItem(MucMessage item)
        {
            if (App.CheckAccessSafe())
            {
                _inlineSearch.NotFound = true;

                if (item != null)
                {
                    foreach (Block block in _flowViewer.Document.Blocks)
                    {
                        Section section = block as Section;

                        if (section != null)
                        {
                            foreach (Block sectionBlock in section.Blocks)
                            {
                                if (sectionBlock.DataContext == item)
                                {
                                    sectionBlock.BringIntoView();

                                    SelectText(sectionBlock as Paragraph, _textToSearch);

                                    _inlineSearch.NotFound = false;

                                    break;
                                }
                            }
                        }

                        if (!_inlineSearch.NotFound)
                        {
                            break;
                        }
                    }
                }
            }
            else
            {
                App.InvokeSafe(DispatcherPriority.Send, new SelectItemCallback(SelectItem), item);
            }
        }
 private void _mucRoom_OnClickMucContact(MucMessage mucMessage)
 {
     if (!string.IsNullOrEmpty(mucMessage.Sender))
     {
         _text.Text = ReplaceNick(_text.Text, mucMessage.Sender);
         _text.Focus();
         _text.CaretIndex = _text.Text.Length;
     }
 }
        private object SearchInList(ref bool stop, object param)
        {
            lock (_textsLock)
            {
                if (_texts == null)
                {
                    _texts = new List<KeyValuePair<string, MucMessage>>();

                    lock (_mucRoom.Messages._syncObject)
                    {
                        foreach (MucMessage mucMessage in _mucRoom.Messages)
                        {
                            if (!string.IsNullOrEmpty(mucMessage.Body))
                            {
                                _texts.Add(
                                    new KeyValuePair<string, MucMessage>(mucMessage.Body.ToUpper().Trim(), mucMessage));
                            }
                        }
                    }
                }
            }

            MucMessage found = null;

            _textToSearch = (string) param;

            string toFound = ((string) param).ToUpper();

            bool searchNext = (_lastSearch == toFound);

            _lastSearch = toFound;

            if (searchNext && _lastFoundItem != null)
            {
                bool fromHere = false;

                foreach (KeyValuePair<string, MucMessage> body in _texts)
                {
                    if (stop)
                    {
                        return null;
                    }

                    if (fromHere && body.Key.Contains(toFound))
                    {
                        found = body.Value;
                        break;
                    }

                    if (_lastFoundItem == body.Value)
                    {
                        fromHere = true;
                    }
                }
            }
            else
            {
                foreach (KeyValuePair<string, MucMessage> body in _texts)
                {
                    if (stop)
                    {
                        return null;
                    }

                    if (((string) param) == String.Empty)
                    {
                        return null;
                    }

                    if (body.Key.Contains(toFound))
                    {
                        found = body.Value;
                        break;
                    }
                }
            }

            _lastFoundItem = found;
            return found;
        }