Exemplo n.º 1
0
        private void AppendText(string text)
        {
            int selectionStart = SelectionStart;

            TextOutgoing   = TextOutgoing.Insert(selectionStart, text);
            SelectionStart = selectionStart + text.Length;
            ShouldFocus    = true;
        }
Exemplo n.º 2
0
        private void DoSend()
        {
            if (string.IsNullOrEmpty(TextOutgoing) || !ChatContact.EnableSend)
            {
                return;
            }

            // Отсылаем сообщение с отбрасыванием пробелом по краям
            var message = _model.Send(ChatContact.ID, TextOutgoing.Trim());

            DisplayMessage(message);

            ShouldScroll = true;
            TextOutgoing = "";
            ShouldFocus  = true;
        }
Exemplo n.º 3
0
        private void DoTag(object obj)
        {
            try
            {
                string tagName = (string)obj;

                int selectionLength = SelectionLength;

                string param;
                if (SelectionLength > 0)
                {
                    // Запомним выделенный текст
                    param = TextOutgoing.Substring(SelectionStart, SelectionLength);

                    // Удалим выделенный текст
                    int selectionStart = SelectionStart;
                    TextOutgoing   = TextOutgoing.Remove(SelectionStart, SelectionLength);
                    SelectionStart = selectionStart;
                }
                else
                {
                    param = "";
                }

                // Обернем выделенный текст в тег
                string tag = _model.GetTag(tagName, param);

                // Добавим в текущее место
                AppendText(tag);

                // Вернем выделение
                SelectionStart -= tag.Length - tag.IndexOf("]") - 1;
                SelectionLength = selectionLength;
            }
            catch (Exception ex)
            {
                ex.Process(ErrorHandlingLevels.Tray);
            }
        }