Beispiel #1
0
        public List <FontChanges> GetTextWithFontInfo()
        {
            lock (this) {
                if (_changes == null)
                {
                    _changes = new List <FontChanges>();
                    string s = CurrentString;

                    FontChanges fc = new FontChanges(-1, 0, new CharDisplayInfo(-1, 0, 0, 0));
                    for (int i = 0; i < _styles.Length && i < s.Length; i++)
                    {
                        if (!_styles[i].AreSame(fc.FandS))
                        {
                            fc = new FontChanges(i, 1, _styles[i]);
                            fc.AddChar(s[i]);
                            _changes.Add(fc);
                        }
                        else
                        {
                            fc.Count++;
                            fc.AddChar(s[i]);
                        }
                    }
                }

                return(_changes);
            }
        }
Beispiel #2
0
        public List<FontChanges> GetTextWithFontInfo() {
            lock (this) {
                if (_changes == null)
                {
                    _changes = new List<FontChanges>();
                    string s = CurrentString;

                    FontChanges fc = new FontChanges(-1, 0, new CharDisplayInfo(-1, 0, 0, 0));
                    for (int i = 0; i < _styles.Length && i < s.Length; i++)
                    {
                        if (!_styles[i].AreSame(fc.FandS))
                        {
                            fc = new FontChanges(i, 1, _styles[i]);
                            fc.AddChar(s[i]);
                            _changes.Add(fc);
                        }
                        else
                        {
                            fc.Count++;
                            fc.AddChar(s[i]);
                        }
                    }
                }

                return _changes;

            }
        }
        public void setStyle(CharDisplayInfo fs, FontChanges fc, FormattedText ft, DrawingContext dc)
        {
            int startPos = fc.Offset + fc.StartCol;

            if ((fs.Style & (int)ZStyles.BOLDFACE_STYLE) > 0)
            {
                ft.SetFontWeight(FontWeights.Bold, startPos, fc.Count);
            }

            int rectColor = -1;
            ColorType type = ColorType.Foreground;

            if ((fs.Style & (int)ZStyles.REVERSE_STYLE) > 0)
            {
                ft.SetFontWeight(FontWeights.Bold, startPos, fc.Count);
                ft.SetForegroundBrush(ZColorCheck.ZColorToBrush(fs.BackgroundColor, ColorType.Background), startPos, fc.Count);

                rectColor = fs.ForegroundColor;
            }
            else
            {
                ft.SetForegroundBrush(ZColorCheck.ZColorToBrush(fs.ForegroundColor, ColorType.Foreground), startPos, fc.Count);
                if (fs.BackgroundColor > 1 && fs.BackgroundColor != bColor)
                {
                    rectColor = fs.BackgroundColor;
                    type = ColorType.Background;
                }
            }

            if ((fs.Style & (int)ZStyles.EMPHASIS_STYLE) > 0)
            {
                ft.SetFontStyle(FontStyles.Italic, startPos, fc.Count);
            }

            if ((fs.Style & (int)ZStyles.FIXED_WIDTH_STYLE) > 0)
            {
                ft.SetFontFamily(_fixedFont.Family, startPos, fc.Count);
            }

            if (dc != null && rectColor != -1)
            {
                Brush b = ZColorCheck.ZColorToBrush(rectColor, type);

                dc.DrawRectangle(b, null,
                    new Rect(fc.StartCol * charWidth, fc.Line * charHeight,
                        fc.Count * charWidth, charHeight));
            }
        }