private void barButtonItem1_ItemClick(object sender, DevExpress.Xpf.Bars.ItemClickEventArgs e) { Document doc = richEditControl1.Document; // Create a custom mark at the caret position and attach arbitrary data to the mark. // In this example the data specifies the color that will be used to draw the mark. CustomMark m = doc.CustomMarks.Create(doc.Selection.Start, new SolidColorBrush(Colors.Orange)); }
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; } using (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); } } }
private void richEditControl1_CustomMarkDraw(object sender, CustomMarkDrawEventArgs e) { Canvas surface = LayoutHelper.FindElementByName(richEditControl1, "Surface") as Canvas; if (surface == null) { return; } GeneralTransform transform = surface.TransformToVisual(richEditControl1); RectangleGeometry clip = new RectangleGeometry() { Rect = new Rect(transform.Transform(new Point(0, 0)), surface.RenderSize) }; richEditCanvas.Children.Clear(); richEditCanvas.Clip = clip; foreach (CustomMarkVisualInfo info in e.VisualInfoCollection) { Document doc = richEditControl1.Document; CustomMark mark = doc.CustomMarks.GetByVisualInfo(info); // Get a brush associated with the mark. Brush curBrush = info.UserData as Brush; // Use a different brush to draw custom marks located above the caret. if (mark.Position < doc.Selection.Start) { curBrush = new SolidColorBrush(Colors.Green); } Rectangle rect = new Rectangle(); rect.Width = 2; rect.Height = info.Bounds.Height; rect.Fill = curBrush; Canvas.SetLeft(rect, info.Bounds.X); Canvas.SetTop(rect, info.Bounds.Y); richEditCanvas.Children.Add(rect); } }
private void richEditControl1_CustomMarkDraw(object sender, DevExpress.Xpf.RichEdit.CustomMarkDrawEventArgs e) { if (!richEditControl1.IsLoaded) { return; } Canvas surface = richEditControl1.Template.FindName("Surface", richEditControl1) as Canvas; if (!surface.IsLoaded) { return; } GeneralTransform transform = surface.TransformToVisual(richEditControl1); RectangleGeometry clip = new RectangleGeometry(new Rect(transform.Transform(new Point(0, 0)), surface.RenderSize)); richEditCanvas.Children.Clear(); richEditCanvas.Clip = clip; foreach (CustomMarkVisualInfo info in e.VisualInfoCollection) { Document doc = richEditControl1.Document; CustomMark mark = doc.CustomMarks.GetByVisualInfo(info); // Get a brush associated with the mark. Brush curBrush = info.UserData as Brush; // Use a different brush to draw custom marks located above the caret. if (mark.Position < doc.Selection.Start) { curBrush = Brushes.Green; } Rectangle rect = new Rectangle(); rect.Width = 2; rect.Height = info.Bounds.Height; rect.Fill = curBrush; Canvas.SetLeft(rect, info.Bounds.X); Canvas.SetTop(rect, info.Bounds.Y); richEditCanvas.Children.Add(rect); } }
private void btn_Mark_Click(object sender, EventArgs e) { Document doc = richEditControl1.Document; CustomMark m = doc.CustomMarks.Create(doc.Selection.Start, Color.DarkOrange); }