Exemple #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();
            }
        }
Exemple #2
0
        void DrawTestEditor(GraphicsCache cache, string text)
        {
            if (FilterViewInfo.Owner.OwnerControl.FocusedItem == this &&
                FilterViewInfo.Owner.OwnerControl.ActiveEditor != null)
            {
                return;
            }
            ClauseNode node = FilterViewInfo.Owner as ClauseNode;

            if (node == null)
            {
                return;
            }
            RepositoryItem ri = node.OwnerControl.GetRepositoryItem(node).Clone() as RepositoryItem;

            ri.BorderStyle = FilterViewInfo.Owner.OwnerControl.FocusedItem == this ? DevExpress.XtraEditors.Controls.BorderStyles.Default : DevExpress.XtraEditors.Controls.BorderStyles.NoBorder;
            BaseEditPainter  p  = ri.CreatePainter();
            BaseEditViewInfo vi = ri.CreateViewInfo();

            vi.EditValue = this.TextElement.Text;
            vi.PaintAppearance.Assign(FilterViewInfo.Owner.OwnerControl.FilterViewInfo.PaintAppearance);
            vi.Bounds = LabelInfoHelper.GetEditorBoundsByElement(this);
            vi.CalcViewInfo(cache.Graphics);
            p.Draw(new ControlGraphicsInfoArgs(vi, cache, vi.Bounds));
        }
Exemple #3
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);
        }
Exemple #4
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));
         }
     }
 }
Exemple #5
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));
        }
Exemple #6
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);
            }
        }