예제 #1
0
 private void SearchForm_FormClosed(object sender, FormClosedEventArgs e)
 {
     if (richTextBox != null && !richTextBox.IsDisposed)
     {
         int pos = IRCRichTextBox.GetVScrollPos(richTextBox);
         if (saver.Left > -1)
             saver.Paste();
         this.richTextBox.DeselectAll();
         IRCRichTextBox.SetVScrollPos(richTextBox, pos);
     }
 }
예제 #2
0
        private void chatRTB_MouseClick(object sender, MouseEventArgs e)
        {
            int  left = 0, right = 0;
            bool b = GetToken(chatRTB, e.Location, out left, out right, IsNickChar, IsNick);

            if (b) // Выделено имя (юзера?)
            {
                string name = chatRTB.Text.Substring(left + 1, right - left - 1);
                if (HasPerson(name))
                {
                    this.irtbPrintMessage.RichTextBox.SelectedText = String.Format("{0}, ", name);
                    //this.irtbPrintMessage.Text += name + ", ";
                    this.irtbPrintMessage.SelectionStart += this.irtbPrintMessage.SelectionLength;//this.irtbPrintMessage.Text.Length;
                    this.irtbPrintMessage.SelectionLength = 0;
                    this.irtbPrintMessage.SetFocus();

                    return;
                }
            }

            var viewModel = (CIRCeSession)this.DataContext;

            if (viewModel.HasChatListeners())
            {
                int index = chatRTB.GetCharIndexFromPosition(e.Location);
                //int lindex = chatRTB.GetLineFromCharIndex(index);
                int start = index;//chatRTB.GetFirstCharIndexFromLine(lindex);
                while (start > 0 && chatRTB.Text[start] != '\n')
                {
                    start--;
                }
                int end = index;// chatRTB.GetFirstCharIndexFromLine(lindex + 1);
                while (end < chatRTB.TextLength && chatRTB.Text[end] != '\n')
                {
                    end++;
                }
                var relIndex = index;
                var line     = IRCRichTextBox.GenerateCodes(chatRTB, ref relIndex, start, end + 1, false)[0];
                viewModel.OnChatClicked(line, relIndex);
            }
        }
예제 #3
0
        private void irtbPrintMessage_InnerMouseWheel(object sender, MouseEventArgs e)
        {
            int pos = IRCRichTextBox.GetVScrollPos(this.chatRTB);

            IRCRichTextBox.SetVScrollPos(this.chatRTB, pos - e.Delta / 5);
        }
예제 #4
0
        /// <summary>
        /// Добавить текст сообщения в окно сообщений
        /// </summary>
        /// <param name="msgText">Текст сообщения</param>
        /// <param name="defColor">Цвет по умолчанию</param>
        /// <param name="putTime">Указать ли время добавления сообщения</param>
        /// <param name="messageType">Тип публикуемого сообщения</param>
        public virtual void PutMessage(string msgText, Color defColor, bool putTime, MessageType messageType)
        {
            if (InvokeRequired)
            {
                var del = new Action <string, Color, bool, MessageType>(PutMessage);
                BeginInvoke(del, msgText, defColor, putTime, messageType);
            }
            else
            {
                if (this.IsDisposed)
                {
                    return;
                }
                if ((Form.ActiveForm == null || (this.Main as MDIParent).GetActiveChild() != this) && messageType == MessageType.Replic)
                {
                    if (reading)
                    {
                        reading = false;
                        if (this.chatRTB.TextLength > 0 && UISettings.Default.ShowReadSplitters)
                        {
                            LogMode oldMode = this.logMode;
                            this.logMode = LogMode.None;
                            Echo(MDIChildPrivate.ReadSplitterString);
                            this.logMode = oldMode;
                        }
                    }
                    try
                    {
                        var flashing = UISettings.Default.FlashingParams;
                        switch (flashing.FlashingMode)
                        {
                        case FlashMode.Full:
                            bool found = false;
                            if (flashing.UseBlackList)
                            {
                                string[] black = flashing.BlackList.Split(new string[] { Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries);

                                foreach (var item in black)
                                {
                                    if (msgText.Contains(item))
                                    {
                                        found = true;
                                        break;
                                    }
                                }
                            }
                            if (!found)
                            {
                                Main.Flash();
                            }
                            break;

                        case FlashMode.Meduim:
                            if (flashing.FlashOnNick)
                            {
                                if (msgText.Length > 2 && msgText.IndexOf(ServerWindow.Nick, 2) > -1)
                                {
                                    Main.Flash();
                                    break;
                                }
                            }
                            if (!flashing.UseWhiteList)
                            {
                                break;
                            }
                            string[] white = flashing.WhiteList.Split(new string[] { Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries);
                            found = false;
                            foreach (var item in white)
                            {
                                if (msgText.Contains(item))
                                {
                                    found = true;
                                    break;
                                }
                            }
                            if (found)
                            {
                                Main.Flash();
                            }
                            break;
                        }
                    }
                    catch (ArgumentException) { }
                }

                string add = putTime && UISettings.Default.DateTimeFormat.Length > 0 ? DateTime.Now.ToString(UISettings.Default.DateTimeFormat) + " " : string.Empty;
                string msg = add + msgText + Environment.NewLine;
                try
                {
                    if (chatRTB != null)
                    {
                        IRCRichTextBox.SetText(chatRTB, msg, defColor, UISettings.Default.ChatFont);
                    }
                    if (this.Main != null && this != (this.Main as MDIParent).GetActiveChild())
                    {
                        myNode.ForeColor = Color.Violet;
                    }
                    Log(add + msgText, defColor);
                }
                catch (Exception e)
                {
                    MessageBox.Show(msgText + " " + e.ToString());
                }
            }
        }