Ejemplo n.º 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();
            }
        }
Ejemplo n.º 2
0
        public static int GetFullWidth(Node node, ControlGraphicsInfoArgs info, FilterControlLabelInfo labelInfo, Font font, StringFormat format)
        {
            int ret = 0;

            for (int i = 0; i < labelInfo.Texts.Count; i++)
            {
                ret += GetElementWidth(LabelInfoHelper.EditorItem(node.OwnerControl, labelInfo.Texts[i]), labelInfo.Texts[i].Text, info.Cache, font, format);
            }
            return(ret);
        }
Ejemplo n.º 3
0
 int GetStringWidth(Graphics graphics, string drawText, Font font)
 {
     if (drawText.Length == 0)
     {
         return(0);
     }
     using (GraphicsCache cache = new GraphicsCache(graphics))
     {
         using (StringFormat format = CreateStringFormat())
         {
             format.FormatFlags |= StringFormatFlags.MeasureTrailingSpaces;
             return(LabelInfoHelper.GetElementWidth(LabelInfoHelper.EditorItem(this), drawText, cache, font, format));
         }
     }
 }
Ejemplo n.º 4
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);
            }
        }