Навеяно постом orangy :) Принимаются предложения по усовершенствованию
Example #1
0
        private void CustomInitializeComponent()
        {
            // init data
            _forumsComboBox.InitForumsComboBox(_messageInfo.ForumId);

            if (_formMode == MessageFormMode.Add || _formMode == MessageFormMode.Reply)
            {
                if (_formMode == MessageFormMode.Add)
                {
                    _subjectTextBox.Text = _messageInfo.Subject;
                    ActiveControl        = _subjectTextBox;
                }

                if (_formMode == MessageFormMode.Reply)
                {
                    _forumsComboBox.Enabled = false;
                    _quoteAnalyzer          = new QuoteAnalyzer(_messageInfo.Message);
                    _subjectTextBox.Text    = JanusFormatMessage.ReSubj(_messageInfo.Subject);
                    ActiveControl           = _messageEditor;
                }

                _messageEditor.Text = _messageInfo.Message;
            }

            if (_formMode == MessageFormMode.Edit)
            {
                _subjectTextBox.Text = _messageInfo.Subject;
                _messageEditor.Text  = _messageInfo.Message;
                ActiveControl        = _messageEditor;
            }

            _fromUserLabel.Text = Config.Instance.Login;

            Bounds = Config.Instance.MessageFormBounds.Bounds;
            if (Config.Instance.MessageFormBounds.Maximized)
            {
                WindowState = FormWindowState.Maximized;
            }

            // style
            var font = new Font("Courier New", 9F);

            _messageEditor.TextStyles.AddRange(new[]
            {
                new TextStyle("Default", 0, font, Color.Black, Color.White, false, CaseMode.Mixed, true, false,
                              PredefinedStyle.None),
                new TextStyle("Quoted text level 1", 1, font, Color.FromArgb(0, 92, 0), Color.White, false,
                              CaseMode.Mixed, true, false, PredefinedStyle.None),
                new TextStyle("Quotes prefix", 2, font, Color.FromArgb(0, 64, 96), Color.White, false,
                              CaseMode.Mixed, true, false, PredefinedStyle.None),
                new TextStyle("Known tags", 3, font, Color.DarkGreen, Color.LightGray, false, CaseMode.Mixed,
                              true, false, PredefinedStyle.None),
                new TextStyle("Smiles", 4, font, Color.DarkBlue, Color.LightGray, false, CaseMode.Mixed, true,
                              false, PredefinedStyle.None),
                new TextStyle("Unknown tag", 5, font, Color.DarkRed, Color.LightGray, false, CaseMode.Mixed,
                              true, false, PredefinedStyle.None),
                new TextStyle("TagContent", 6, font, Color.Black, Color.LemonChiffon, true, CaseMode.Mixed,
                              true, false, PredefinedStyle.None),
                new TextStyle("PredefinedBraceLight", 34, font, Color.Blue, Color.White, false, CaseMode.Mixed,
                              true, false, PredefinedStyle.BraceLight),
                new TextStyle("PredefinedBraceBad", 35, font, Color.Red, Color.White, false, CaseMode.Mixed,
                              true, false, PredefinedStyle.BraceBad),
                new TextStyle("PredefinedDefault", 32, font, Color.Black, Color.White, false, CaseMode.Mixed,
                              true, false, PredefinedStyle.Default),
                new TextStyle("Quoted text level 2", 10, font, Color.Green, Color.White, false, CaseMode.Mixed,
                              true, false, PredefinedStyle.None),
                new TextStyle("Quoted text level 3", 11, font, Color.FromArgb(0, 160, 0), Color.White, false,
                              CaseMode.Mixed, true, false, PredefinedStyle.None)
            });
            foreach (var style in _messageEditor.TextStyles.Cast <TextStyle>())
            {
                _messageEditor.SetStyleCharset(style.Number, ScintillaCharset.Russian);
            }

            _subjectTextBox.Modified = false;
            _messageEditor.ClearUndoBuffer();             // Savepoint also set by this call
            OnIsModifiedChanged();
            _messageEditor.MultipleSelection         = true;
            _messageEditor.AdditionalSelectionTyping = true;

            StyleConfig.StyleChange += OnStyleChanged;
            UpdateStyle();
        }
Example #2
0
        private void CustomInitializeComponent()
        {
            // init data
            _forumsComboBox.InitForumsComboBox(_messageInfo.ForumId);

            if (_formMode == MessageFormMode.Add || _formMode == MessageFormMode.Reply)
            {
                if (_formMode == MessageFormMode.Add)
                {
                    _subjectTextBox.Text = _messageInfo.Subject;
                    ActiveControl = _subjectTextBox;
                }

                if (_formMode == MessageFormMode.Reply)
                {
                    _forumsComboBox.Enabled = false;
                    _quoteAnalyzer = new QuoteAnalyzer(_messageInfo.Message);
                    _subjectTextBox.Text = JanusFormatMessage.ReSubj(_messageInfo.Subject);
                    ActiveControl = _messageEditor;
                }

                _messageEditor.Text = _messageInfo.Message;
            }

            if (_formMode == MessageFormMode.Edit)
            {
                _subjectTextBox.Text = _messageInfo.Subject;
                _messageEditor.Text = _messageInfo.Message;
                ActiveControl = _messageEditor;
            }

            _fromUserLabel.Text = Config.Instance.Login;

            Bounds = Config.Instance.MessageFormBounds.Bounds;
            if (Config.Instance.MessageFormBounds.Maximized)
                WindowState = FormWindowState.Maximized;

            // style
            var font = new Font("Courier New", 9F);
            _messageEditor.TextStyles.AddRange(new[]
                {
                    new TextStyle("Default", 0, font, Color.Black, Color.White, false, CaseMode.Mixed, true, false,
                        PredefinedStyle.None),
                    new TextStyle("Quoted text level 1", 1, font, Color.FromArgb(0, 92, 0), Color.White, false,
                        CaseMode.Mixed, true, false, PredefinedStyle.None),
                    new TextStyle("Quotes prefix", 2, font, Color.FromArgb(0, 64, 96), Color.White, false,
                        CaseMode.Mixed, true, false, PredefinedStyle.None),
                    new TextStyle("Known tags", 3, font, Color.DarkGreen, Color.LightGray, false, CaseMode.Mixed,
                        true, false, PredefinedStyle.None),
                    new TextStyle("Smiles", 4, font, Color.DarkBlue, Color.LightGray, false, CaseMode.Mixed, true,
                        false, PredefinedStyle.None),
                    new TextStyle("Unknown tag", 5, font, Color.DarkRed, Color.LightGray, false, CaseMode.Mixed,
                        true, false, PredefinedStyle.None),
                    new TextStyle("TagContent", 6, font, Color.Black, Color.LemonChiffon, true, CaseMode.Mixed,
                        true, false, PredefinedStyle.None),
                    new TextStyle("PredefinedBraceLight", 34, font, Color.Blue, Color.White, false, CaseMode.Mixed,
                        true, false, PredefinedStyle.BraceLight),
                    new TextStyle("PredefinedBraceBad", 35, font, Color.Red, Color.White, false, CaseMode.Mixed,
                        true, false, PredefinedStyle.BraceBad),
                    new TextStyle("PredefinedDefault", 32, font, Color.Black, Color.White, false, CaseMode.Mixed,
                        true, false, PredefinedStyle.Default),
                    new TextStyle("Quoted text level 2", 10, font, Color.Green, Color.White, false, CaseMode.Mixed,
                        true, false, PredefinedStyle.None),
                    new TextStyle("Quoted text level 3", 11, font, Color.FromArgb(0, 160, 0), Color.White, false,
                        CaseMode.Mixed, true, false, PredefinedStyle.None)
                });
            foreach (var style in _messageEditor.TextStyles.Cast<TextStyle>())
                _messageEditor.SetStyleCharset(style.Number, ScintillaCharset.Russian);

            _subjectTextBox.Modified = false;
            _messageEditor.ClearUndoBuffer(); // Savepoint also set by this call
            OnIsModifiedChanged();
            _messageEditor.MultipleSelection = true;
            _messageEditor.AdditionalSelectionTyping = true;

            StyleConfig.StyleChange += OnStyleChanged;
            UpdateStyle();
        }