Example #1
0
        public override void Draw(GraphicsCache cache, Font font, Color foreColor, StringFormat format)
        {
            if (IsBreak)
            {
                return;
            }
            if (LabelInfoHelper.IsActionElement(this.InfoText.Text))
            {
                DrawButton(cache);
                return;
            }
            if (LabelInfoHelper.EditorItem(this))
            {
                DrawTestEditor(cache, this.InfoText.Text);
                return;
            }
            Font         activeFont = IsActive ? new Font(font, font.Style | FontStyle.Underline) : null;
            StringFormat sformat    = format == null?CreateStringFormat() : format;

            for (int i = 0; i < Count; i++)
            {
                Rectangle bounds = this[i].Bounds;
                bounds.Y = bounds.Y - ScrollTop;
                cache.DrawString(this[i].Text, IsActive ? activeFont : font, cache.GetSolidBrush(foreColor), bounds, sformat);
            }
            if (format == null)
            {
                sformat.Dispose();
            }
            if (activeFont != null)
            {
                activeFont.Dispose();
            }
        }
Example #2
0
        public static int GetElementWidth(bool editor, string text, GraphicsCache cache, Font font, StringFormat format)
        {
            int width = 0;

            if (LabelInfoHelper.IsActionElement(text))
            {
                width = LabelInfoHelper.ActionElementWidht;
            }
            else
            {
                if (!(cache.Paint is XPaintMixed))
                {
                    cache.Paint = new XPaintMixed();
                }
                width = (int)cache.CalcTextSize(text, font, format, 0).Width;
            }
            return(GetElementWidth(editor, width));
        }
Example #3
0
        public override void Calculate(Graphics graphics, Font font, int fontHeight, ref int x, ref int y)
        {
            if (InfoText.Text == "")
            {
                return;
            }
            if (IsBreak)
            {
                y += (GetLineHeight(font) >> 1);
                return;
            }
            string drawText = InfoText.Text;

            while (drawText.Length > 0)
            {
                string words = GetNextWords(graphics, drawText, font, Width - x, x == LabelInfoViewInfo.TextIndent);
                if (words == string.Empty)
                {
                    return;
                }
                int wordsWidth = 0;
                if (LabelInfoHelper.IsActionElement(this.InfoText.Text))
                {
                    wordsWidth = LabelInfoHelper.ActionElementWidht;
                }
                else
                {
                    wordsWidth = LabelInfoHelper.GetElementWidth(LabelInfoHelper.EditorItem(this), GetStringWidth(graphics, words, font));
                }
                FilterLabelInfoTextLineViewInfo item = new FilterLabelInfoTextLineViewInfo(words, location.X + x, location.Y + y, wordsWidth, fontHeight);
                list.Add(item);
                x += wordsWidth;
                if (x >= Width)
                {
                    y += GetLineHeight(font);
                    x  = LabelInfoViewInfo.TextIndent;
                }
                if (words == drawText)
                {
                    break;
                }
                drawText = drawText.Substring(words.Length, drawText.Length - words.Length);
            }
        }