Пример #1
0
        public void SetupScintilla(AppSettings s)
        {
            var theme = ThemeManager.Inst.CurrentThemeSet;

            NoteEdit.Lexer = Lexer.Container;

            NoteEdit.CaretForeColor          = theme.Get <ColorRef>("scintilla.caret:foreground").ToDCol();
            NoteEdit.CaretLineBackColor      = theme.Get <ColorRef>("scintilla.caret:background").ToDCol();
            NoteEdit.CaretLineBackColorAlpha = theme.Get <int>("scintilla.caret:background_alpha");
            NoteEdit.CaretLineVisible        = theme.Get <bool>("scintilla.caret:visible");

            NoteEdit.SetSelectionForeColor(theme.Get <bool>("scintilla.selection:override_foreground"), theme.Get <ColorRef>("scintilla.selection:foreground").ToDCol());
            NoteEdit.SetSelectionBackColor(true, theme.Get <ColorRef>("scintilla.selection:background").ToDCol());            // https://sourceforge.net/p/scintilla/bugs/538/

            NoteEdit.WhitespaceSize = theme.Get <int>("scintilla.whitespace:size");
            NoteEdit.ViewWhitespace = s.SciShowWhitespace ? WhitespaceMode.VisibleAlways : WhitespaceMode.Invisible;
            NoteEdit.ViewEol        = s.SciShowEOL;
            NoteEdit.SetWhitespaceForeColor(!theme.Get <ColorRef>("scintilla.whitespace:color").IsTransparent, theme.Get <ColorRef>("scintilla.whitespace:color").ToDCol());
            NoteEdit.SetWhitespaceBackColor(!theme.Get <ColorRef>("scintilla.whitespace:background").IsTransparent, theme.Get <ColorRef>("scintilla.whitespace:background").ToDCol());

            UpdateMargins(s);
            NoteEdit.BorderStyle = BorderStyle.None;

            NoteEdit.Markers[ScintillaHighlighter.STYLE_MARKER_LIST_ON].DefineRgbaImage(theme.GetDBitmapResource("margin_check_on.png"));
            NoteEdit.Markers[ScintillaHighlighter.STYLE_MARKER_LIST_OFF].DefineRgbaImage(theme.GetDBitmapResource("margin_check_off.png"));
            NoteEdit.Markers[ScintillaHighlighter.STYLE_MARKER_LIST_MIX].DefineRgbaImage(theme.GetDBitmapResource("margin_check_mix.png"));


            NoteEdit.MultipleSelection = s.SciMultiSelection;
            NoteEdit.MouseSelectionRectangularSwitch = s.SciRectSelection;
            NoteEdit.AdditionalSelectionTyping       = s.SciRectSelection;
            NoteEdit.VirtualSpaceOptions             = s.SciRectSelection ? VirtualSpace.RectangularSelection : VirtualSpace.None;
            NoteEdit.EndAtLastLine = !s.SciScrollAfterLastLine;

            var fnt = string.IsNullOrWhiteSpace(s.NoteFontFamily) ? FontNameToFontFamily.StrDefaultValue : s.NoteFontFamily;

            NoteEdit.Font = new Font(fnt, (int)s.NoteFontSize);

            _highlighterDefault.SetUpStyles(NoteEdit, s);

            NoteEdit.WrapMode = s.SciWordWrap ? WrapMode.Whitespace : WrapMode.None;

            NoteEdit.HScrollBar = theme.Get <bool>("scintilla.scrollbar_h:visible");
            NoteEdit.VScrollBar = theme.Get <bool>("scintilla.scrollbar_v:visible");

            NoteEdit.ZoomChanged -= ZoomChanged;
            NoteEdit.ZoomChanged += ZoomChanged;

            NoteEdit.UseTabs  = s.SciUseTabs;
            NoteEdit.TabWidth = s.SciTabWidth * 2;

            NoteEdit.ReadOnly = s.IsReadOnlyMode || VM?.SelectedNote?.IsLocked == true;

            NoteEdit.ClearCmdKey(Keys.Control | Keys.D);             // SCI_SELECTIONDUPLICATE

            ResetScintillaScrollAndUndo();

            ForceNewHighlighting(s);
        }
Пример #2
0
        public void SetupScintilla(AppSettings s)
        {
            var theme = ThemeManager.Inst.CurrentTheme;

            NoteEdit.Lexer = Lexer.Container;

            NoteEdit.CaretForeColor          = theme.Get <ColorRef>("scintilla.caret:foreground").ToDCol();
            NoteEdit.CaretLineBackColor      = theme.Get <ColorRef>("scintilla.caret:background").ToDCol();
            NoteEdit.CaretLineBackColorAlpha = theme.Get <int>("scintilla.caret:background_alpha");
            NoteEdit.CaretLineVisible        = theme.Get <bool>("scintilla.caret:visible");

            NoteEdit.WhitespaceSize = theme.Get <int>("scintilla.whitespace:size");
            NoteEdit.ViewWhitespace = s.SciShowWhitespace ? WhitespaceMode.VisibleAlways : WhitespaceMode.Invisible;
            NoteEdit.SetWhitespaceForeColor(!theme.Get <ColorRef>("scintilla.whitespace:color").IsTransparent, theme.Get <ColorRef>("scintilla.whitespace:color").ToDCol());
            NoteEdit.SetWhitespaceBackColor(!theme.Get <ColorRef>("scintilla.whitespace:background").IsTransparent, theme.Get <ColorRef>("scintilla.whitespace:background").ToDCol());

            UpdateMargins(s);
            NoteEdit.BorderStyle = BorderStyle.FixedSingle;

            NoteEdit.Markers[ScintillaHighlighter.STYLE_MARKER_LIST_OFF].DefineRgbaImage(Properties.Resources.ui_off);

            NoteEdit.Markers[ScintillaHighlighter.STYLE_MARKER_LIST_ON].DefineRgbaImage(Properties.Resources.ui_on);

            NoteEdit.MultipleSelection = s.SciMultiSelection;
            NoteEdit.MouseSelectionRectangularSwitch = s.SciMultiSelection;
            NoteEdit.AdditionalSelectionTyping       = s.SciMultiSelection;
            NoteEdit.VirtualSpaceOptions             = s.SciMultiSelection ? VirtualSpace.RectangularSelection : VirtualSpace.None;
            NoteEdit.EndAtLastLine = !s.SciScrollAfterLastLine;

            var fnt = string.IsNullOrWhiteSpace(s.NoteFontFamily) ? FontNameToFontFamily.StrDefaultValue : s.NoteFontFamily;

            NoteEdit.Font = new Font(fnt, (int)s.NoteFontSize);

            _highlighterDefault.SetUpStyles(NoteEdit, s);

            NoteEdit.WrapMode = s.SciWordWrap ? WrapMode.Whitespace : WrapMode.None;

            NoteEdit.ZoomChanged -= ZoomChanged;
            NoteEdit.ZoomChanged += ZoomChanged;

            NoteEdit.UseTabs  = s.SciUseTabs;
            NoteEdit.TabWidth = s.SciTabWidth * 2;

            NoteEdit.ReadOnly = s.IsReadOnlyMode;

            ResetScintillaScrollAndUndo();

            ForceNewHighlighting(s);
        }