Skip to main content

ReadOnlyCustomMarkCollection.GetByVisualInfo(CustomMarkVisualInfo) Method

Obtains a custom mark by its visual info available in the RichEditControl.CustomMarkDraw event handler.

Namespace: DevExpress.XtraRichEdit.API.Native

Assembly: DevExpress.RichEdit.v24.1.Core.dll

NuGet Packages: DevExpress.RichEdit.Core, DevExpress.Win.Navigation

Declaration

CustomMark GetByVisualInfo(
    CustomMarkVisualInfo customMarkVisualInfo
)

Parameters

Name Type Description
customMarkVisualInfo DevExpress.XtraRichEdit.Layout.Export.CustomMarkVisualInfo

A DevExpress.XtraRichEdit.Layout.Export.CustomMarkVisualInfo object. A collection of such objects is accessible using the RichEditCustomMarkDrawEventArgs.VisualInfoCollection property.

Returns

Type Description
CustomMark

A CustomMark object that is the target custom mark.

Example

This code snippet illustrates the use of the CustomMarkCollection.Create method and the RichEditControl.CustomMarkDraw event, to add a mark to the selection and draw its visual representation.

using DevExpress.XtraRichEdit.API.Native;
using DevExpress.XtraRichEdit.Layout.Export;
using System.Drawing.Drawing2D;
        private void btn_Mark_Click(object sender, EventArgs e)
        {
            Document doc = richEditControl1.Document;
            CustomMark m = doc.CustomMarks.Create(doc.Selection.Start, Color.DarkOrange);   
        }

        private void richEditControl1_CustomMarkDraw(object sender, DevExpress.XtraRichEdit.RichEditCustomMarkDrawEventArgs e)
        {        
            foreach (CustomMarkVisualInfo info in e.VisualInfoCollection)
            {
                Document doc = richEditControl1.Document;
                CustomMark mark = doc.CustomMarks.GetByVisualInfo(info);
                e.Graphics.SmoothingMode = SmoothingMode.AntiAlias;

                Color curColor = (Color)info.UserData;
                if (mark.Position < doc.Selection.Start) curColor = Color.Green;
                    Pen p = new Pen(curColor, 3);
                    p.StartCap = LineCap.Flat;
                    p.EndCap = LineCap.ArrowAnchor;
                    e.Graphics.DrawLine(p, new Point(0 , info.Bounds.Y), info.Bounds.Location);
            }
        }
See Also