Exemple #1
0
        //    public Brush BackgroundBrush{get;set;}

        public BackgroundStyle(CwFCTB _Fctb, Brush backgroundBrush)
        {
            _Fctb.SetStyleLayerIndex(this);


            // this.BackgroundBrush = backgroundBrush;
            IsExportable = true;
        }
Exemple #2
0
        //   public ForeStyle(FontStyle fontStyle)
        public ForeStyle(CwFCTB _Fctb, FontStyle fontStyle) : base(null, null, fontStyle)
        {
            //  Fctb.SetStyleLayerIndex(this);
            _Fctb.SetStyleLayerIndex(this);

            //    this.ForeBrush = foreBrush;
            //  this.BackgroundBrush = backgroundBrush;
            this.FontStyle = fontStyle;
            stringFormat   = new StringFormat(StringFormatFlags.MeasureTrailingSpaces);
        }
Exemple #3
0
        public override void Draw(Graphics gr, Point position, Range range)
        {
            //   ushort _nData =  range.tb.TextSource[range.FromLine][range.Start.iChar].nCustomData;
            ushort _nData     = CwRange.fGetStyleData(range);
            char   _nBackData = (char)((_nData & 0x00F0) >> 4);

            //draw background
            Brush backgroundBrush = CwFCTB.fGetBrush(_nBackData);

            if (backgroundBrush != Brushes.Black) // TODO or same as background color
            {
                Rectangle rect = new Rectangle(position.X, position.Y, (range.End.iChar - range.Start.iChar) * range.tb.CharWidth + 1, range.tb.CharHeight);
                if (rect.Width == 0)
                {
                    return;
                }


                gr.FillRectangle(backgroundBrush, rect);
            }
        }
Exemple #4
0
        public override void Draw(Graphics gr, Point position, Range range)
        {
            ushort _nData     = CwRange.fGetStyleData(range);
            char   _nForeData = (char)((_nData & 0x000F));



            //draw background
            // if (BackgroundBrush != null)
            //      gr.FillRectangle(BackgroundBrush, position.X, position.Y, (range.End.iChar - range.Start.iChar) * range.tb.CharWidth, range.tb.CharHeight);
            //draw chars
            using (var f = new Font(range.tb.Font, FontStyle))
            {
                Line  line = range.tb[range.Start.iLine];
                float dx   = range.tb.CharWidth;
                float y    = position.Y + range.tb.LineInterval / 2;
                float x    = position.X - range.tb.CharWidth / 3;

                /*
                 * Brush  ForeBrush  = CwFCTB.fGetBrush(_nForeData);
                 * if (ForeBrush == null)
                 *   ForeBrush = new SolidBrush(range.tb.ForeColor);
                 *
                 * //  ForeBrush = Brushes.Blue;
                 * if (range.tb.ImeAllowed)
                 * {
                 *   //IME mode
                 *   for (int i = range.Start.iChar; i < range.End.iChar; i++)
                 *   {
                 *       SizeF size = FastColoredTextBox.GetCharSize(f, line[i].c);
                 *
                 *       var gs = gr.Save();
                 *       float k = size.Width > range.tb.CharWidth + 1 ? range.tb.CharWidth/size.Width : 1;
                 *       gr.TranslateTransform(x, y + (1 - k)*range.tb.CharHeight/2);
                 *       gr.ScaleTransform(k, (float) Math.Sqrt(k));
                 *       gr.DrawString(line[i].c.ToString(), f, ForeBrush, 0, 0, stringFormat);
                 *       gr.Restore(gs);
                 *       x += dx;
                 *
                 *   }
                 * }else {
                 */


                //         gr.DrawString(   range.Text, f, ForeBrush, x, y, stringFormat);


                TextRenderer.DrawText(gr, range.Text, f, new Point((int)x, (int)y), CwFCTB.fGetColor(_nForeData), Color.Transparent);


                /*
                 * //classic mode
                 * for (int i = range.Start.iChar; i < range.End.iChar; i++) {
                 *  //draw char
                 *  gr.DrawString(line[i].c.ToString(), f, ForeBrush, x, y, stringFormat);
                 *  x += dx;
                 * }
                 */


                //  }

                //  gr.Dispose();
                f.Dispose();
            }
        }