70001568 I want set different highlight color to the first object of selection set

Article 70001568
Type HowTo
Product Engine
Version 7
Date Added 6/26/2019
Fixed 8.8003.0.1 (6/26/2019)
Submitted by Song KiSoo


Can I have multiple highlight color? I want to highlight objects when they selected. And I want set different highlight color to the first object of selection set.


This can only be done in the OnDrawFigure event, where you can check if this objected selected is in the temporary selection or not in in this case draw this with another color, like:

private void button1_Click(object sender, EventArgs e)
    vdDocument doc = vdFramed1.BaseControl.ActiveDocument;
    doc.FreezeEntityDrawEvents.Push(false); //Enable draw events
    doc.OnDrawFigure+=new vdDocument.FigureDrawEventHandler(doc_OnDrawFigure); //add the event andler
void doc_OnDrawFigure(object sender, VectorDraw.Render.vdRender render, ref bool cancel)
    if (sender == null) return;
    vdDocument doc = vdFramed1.BaseControl.ActiveDocument;
    vdSelection selected = doc.Selections.FindName("VDRAW_TEMPORARY_SELSET"); // get the selection that contains the items
    if (selected == null || selected.Count < 1) return;

    vdFigure fig = sender as vdFigure;
    if (fig==null) return;
    if (selected.FindItem(fig))  // if the fig is in this selection (is selected)
        double pix_size = render.PixelSize;
        if (ReferenceEquals(fig, selected[0]))
        { // push a different color to the render if this object is the first selected
            render.PushPenstyle(Color.Red, 4*pix_size); 
            render.PushPenstyle(Color.Yellow, 1*pix_size);
        doc.FreezeEntityDrawEvents.Push(true); // disable the event as fig.Draw() will make it fire again
        fig.Draw(render);  // draw the object with the penstyle pushed before
        doc.FreezeEntityDrawEvents.Pop(); // pop the event..... ALL PUSH must be followed by POP
        render.PopPenstyle(); //pop the penstyle ..... ALL PUSH must be followed by POP
        cancel = true; // do not allow vdraw to draw this item it is already draw by fig.Draw() above
        cancel = false;

Send comments on this topic.