示例#1
0
 private void setTextForRich(Khendys.Controls.ExRichTextBox obj, string question)
 {
     if (question != null && Utility.Base64Decode(question).Contains("\\rtf1\\ansi"))
     {
         obj.Rtf = Utility.Base64Decode(question);
     }
     else if (question != null && question.Length > 0)
     {
         obj.Rtf = @"{\rtf1\ansi\ansicpg1252\deff0\deflang16393{\fonttbl{\f0\fnil\fcharset0 Microsoft Sans Serif;}}\viewkind4\uc1\pard\f0\fs20" + question + @"}";
     }
 }
        //private int _findex = 0;
        //private Color bgcolour = Color.White;
        //[System.Runtime.InteropServices.DllImport("user32.dll")]
        //private static extern IntPtr SendMessage(IntPtr window, int message, int wparam, int lparam);
        //const int WM_VSCROLL = 0x115;
        //const int SB_BOTTOM = 7;
        ////[System.Runtime.InteropServices.DllImport("user32.dll")]
        ////static extern IntPtr SendMessage(IntPtr hWnd, UInt32 Msg, Int32 wParam, Int32 lParam);
        ////const int WM_USER = 0x400;
        ////const int EM_HIDESELECTION = WM_USER + 63;
        public RichTextBoxPrinter(METAboltInstance instance, ExRichTextBox textBox)
        {
            rtb = textBox;

            this.instance = instance;
            config = this.instance.Config;

            hideSmileys = config.CurrentConfig.ChatSmileys;
            config.ConfigApplied += new EventHandler<ConfigAppliedEventArgs>(Config_ConfigApplied);

            //rtb.BackColor = bgcolour = config.CurrentConfig.BgColour;

            if (config.CurrentConfig.HeaderFont != null)
            {
                headerfont = config.CurrentConfig.HeaderFont;
                headerfontstyle = config.CurrentConfig.HeaderFontStyle;
                headerfontsize = config.CurrentConfig.HeaderFontSize;
                bkcolour = config.CurrentConfig.HeaderBackColour;
            }

            switch (headerfontstyle.ToLower(CultureInfo.CurrentCulture))
            {
                case "bold":
                    fontsy = FontStyle.Bold;
                    break;
                case "italic":
                    fontsy = FontStyle.Italic;
                    break;
                default:
                    fontsy = FontStyle.Regular;
                    break;
            }

            if (config.CurrentConfig.TextFont != null)
            {
                textfont = config.CurrentConfig.TextFont;
                textfontstyle = config.CurrentConfig.TextFontStyle;
                textfontsize = config.CurrentConfig.TextFontSize;
            }

            switch (textfontstyle.ToLower(CultureInfo.CurrentCulture))
            {
                case "bold":
                    fontst = FontStyle.Bold;
                    break;
                case "italic":
                    fontst = FontStyle.Italic;
                    break;
                default:
                    fontst = FontStyle.Regular;
                    break;
            }
        }