コード例 #1
0
        void ShowTransaltedText(string translatedMsg, Color color)
        {
            try
            {
                translatedMsg = translatedMsg.Trim(new char[] { ' ' });

                ChatRtb.AppendText(Environment.NewLine);
                ChatRtb.CaretPosition = ChatRtb.CaretPosition.DocumentEnd;

                if (_ChatWindowViewModel.SpacingCount > 0)
                {
                    string whiteSpaces = String.Empty;
                    for (int i = 0; i < _ChatWindowViewModel.SpacingCount; i++)
                    {
                        whiteSpaces += " ";
                    }
                    ChatRtb.AppendText(whiteSpaces);
                }

                Paragraph p = (ChatRtb.Document.Blocks.LastBlock) as Paragraph;
                p.Margin = new Thickness(0, _ChatWindowViewModel.LineBreakHeight, 0, 0);

                SolidColorBrush tmpColor = new SolidColorBrush(color);

                int nameInd = 0;
                if ((nameInd = translatedMsg.IndexOf(":")) > 0)
                {
                    string msgText = translatedMsg;
                    string name    = String.Empty;
                    string text    = String.Empty;

                    name = msgText.Substring(0, nameInd);
                    text = msgText.Substring(nameInd, msgText.Length - nameInd);

                    TextRange tr1 = new TextRange(ChatRtb.Document.ContentEnd, ChatRtb.Document.ContentEnd);
                    tr1.Text = name;
                    tr1.ApplyPropertyValue(TextElement.ForegroundProperty, tmpColor);
                    tr1.ApplyPropertyValue(TextElement.FontWeightProperty, FontWeights.Bold);

                    TextRange tr2 = new TextRange(ChatRtb.Document.ContentEnd, ChatRtb.Document.ContentEnd);
                    tr2.Text = text;
                    tr2.ApplyPropertyValue(TextElement.ForegroundProperty, tmpColor);
                    tr2.ApplyPropertyValue(TextElement.FontWeightProperty, FontWeights.Normal);//*/
                }
                else
                {
                    TextRange tr = new TextRange(ChatRtb.Document.ContentEnd, ChatRtb.Document.ContentEnd);
                    tr.Text = translatedMsg;

                    tr.ApplyPropertyValue(TextElement.ForegroundProperty, tmpColor);
                }

                ChatRtb.ScrollToEnd();
            }
            catch (Exception exc)
            {
                Logger.WriteLog(Convert.ToString(exc));
            }
        }
コード例 #2
0
        async Task OnLowLevelMousEvent(LowLevelMouseEventArgs ea)
        {
            if (ea.MouseMessages == MouseHooker.MouseMessages.WM_MOUSEWHEEL)
            {
                await this.UIThreadAsync(() =>
                {
                    if (!_TataruUIModel.IsChatClickThrough)
                    {
                        var bc = ((SolidColorBrush)this.Background).Color;
                        if (bc.A == 0)
                        {
                            var data      = ea.MouseEventFlags.mouseData;
                            uint fxdData  = ((data & 0xFFFF0000) >> 16);
                            uint realData = 0;

                            double MouseWheelScrollDelta = System.Windows.Forms.SystemInformation.MouseWheelScrollDelta;

                            string msg = String.Empty;

                            if (IsLowLevelMousOver(ea.MouseEventFlags.pt))
                            {
                                if (fxdData < 32000)
                                {
                                    realData = fxdData;

                                    int res = (int)Math.Round(realData / MouseWheelScrollDelta) * 2;
                                    for (int i = 0; i < res; i++)
                                    {
                                        ChatRtb.LineUp();
                                    }
                                }
                                else
                                {
                                    realData = 65536 - fxdData;

                                    int res = (int)Math.Round(realData / MouseWheelScrollDelta) * 2;
                                    for (int i = 0; i < res; i++)
                                    {
                                        ChatRtb.LineDown();
                                    }
                                }
                            }
                        }
                    }
                });
            }
        }
コード例 #3
0
        void ShowTransaltedText(string translatedMsg, Color color)
        {
            try
            {
                translatedMsg = translatedMsg.Trim(new char[] { ' ' });

                ChatRtb.AppendText(Environment.NewLine);
                ChatRtb.CaretPosition = ChatRtb.CaretPosition.DocumentEnd;

                if (_TataruUIModel.ParagraphSpaceCount > 0)
                {
                    string whiteSpaces = String.Empty;
                    for (int i = 0; i < _TataruUIModel.ParagraphSpaceCount; i++)
                    {
                        whiteSpaces += " ";
                    }
                    ChatRtb.AppendText(whiteSpaces);
                }

                Paragraph p = (ChatRtb.Document.Blocks.LastBlock) as Paragraph;
                p.Margin = new Thickness(0, _TataruUIModel.LineBreakeHeight, 0, 0);

                SolidColorBrush tmpColor = new SolidColorBrush(color);

                int nameInd = 0;
                if ((nameInd = translatedMsg.IndexOf(":")) > 0)
                {
                    string msgText = translatedMsg;
                    string name    = String.Empty;
                    string text    = String.Empty;

                    name = msgText.Substring(0, nameInd);
                    text = msgText.Substring(nameInd, msgText.Length - nameInd);

                    TextRange tr1 = new TextRange(ChatRtb.Document.ContentEnd, ChatRtb.Document.ContentEnd);
                    tr1.Text = name;
                    tr1.ApplyPropertyValue(TextElement.ForegroundProperty, tmpColor);
                    tr1.ApplyPropertyValue(TextElement.FontWeightProperty, FontWeights.Bold);

                    TextRange tr2 = new TextRange(ChatRtb.Document.ContentEnd, ChatRtb.Document.ContentEnd);
                    tr2.Text = text;
                    tr2.ApplyPropertyValue(TextElement.ForegroundProperty, tmpColor);
                    tr2.ApplyPropertyValue(TextElement.FontWeightProperty, FontWeights.Normal);//*/

                    /*
                     * Utils.TextPath textPath = new Utils.TextPath();
                     * textPath.Text = translatedMsg;
                     * textPath.Stroke = new SolidColorBrush(Color.FromArgb(255, 0, 0, 0));
                     * textPath.Fill = tmpColor;
                     * textPath.StrokeThickness = 0.1;
                     *
                     * var para = new Paragraph();
                     * para.Inlines.Add(textPath);
                     *
                     * ChatRtb.Document.Blocks.Add(para);//*/
                }
                else
                {
                    TextRange tr = new TextRange(ChatRtb.Document.ContentEnd, ChatRtb.Document.ContentEnd);
                    tr.Text = translatedMsg;

                    tr.ApplyPropertyValue(TextElement.ForegroundProperty, tmpColor);
                }

                ChatRtb.ScrollToEnd();
            }
            catch (Exception exc)
            {
                Logger.WriteLog(Convert.ToString(exc));
            }
        }