Profile Picture

Draw Diagram on an Existing User Control

Posted By Joe Marino 12 Years Ago
Author
Message
Nevron Support
Posted 12 Years Ago
View Quick Profile
Supreme Being

Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)

Group: Forum Members
Last Active: Last Week
Posts: 3,054, Visits: 4,009

Hi Joe,

Following is a drawing view subclass, that should be transparent:

public class NMyDrawingView : NDrawingView
{
    public NMyDrawingView()
    {
        //Set the default backcolor
        SetStyle(ControlStyles.SupportsTransparentBackColor, true);
        this.BackColor = Color.Transparent;
    }
    public override void DoPaint(PaintEventArgs e)
    {
        if (Document == null)
        {
            if (DesignMode)
            {
                PaintEmptyInDesignMode(e);
            }

            return;
        }

        if (LockRefresh)
            return;

        GraphicsState state;
        NPaintContext context;

        try
        {
            //e.Graphics.Clear(WindowBackColor);

            if (NeedsWindowBackgroundPaint(e))
            {
                state = e.Graphics.Save();
                context = ProvideViewPaintContext(e, PaintPass.Background);
                PaintWindowBackground(context);
                e.Graphics.Restore(state);
            }

            if (NeedsDocumentBackgroundPaint(e))
            {
                state = e.Graphics.Save();
                context = ProvideDocumentPaintContext(e, PaintPass.Background);
                PaintDocumentBackground(context);
                e.Graphics.Restore(state);
            }

            if (NeedsViewBackgroundPaint(e))
            {
                state = e.Graphics.Save();
                context = ProvideViewPaintContext(e, PaintPass.Background);
                PaintViewBackground(context);
                e.Graphics.Restore(state);
            }

            if (NeedsDocumentForegroundPaint(e))
            {
                state = e.Graphics.Save();
                context = ProvideDocumentPaintContext(e, PaintPass.Foreground);
                PaintDocumentForeground(context);
                e.Graphics.Restore(state);
            }

            if (NeedsViewForegroundPaint(e))
            {
                state = e.Graphics.Save();
                context = ProvideViewPaintContext(e, PaintPass.Foreground);
                PaintViewForeground(context);
                e.Graphics.Restore(state);
            }
        }
        catch (Exception ex)
        {
            Trace.WriteLine("Drawing view paint failed. Exception info follows: ");
            Trace.WriteLine("------------------------------------");
            Trace.WriteLine(" Message: " + ex.Message);
            Trace.WriteLine(" Stack Trace: " + ex.StackTrace);
            Trace.WriteLine("------------------------------------");
        }

        if (SmartPaintService != null)
        {
            SmartPaintService.Reset();
        }
    }
}

The DoPaint method does exactly what the default implementation is doing, but the commented line:

 //e.Graphics.Clear(WindowBackColor);

which actually makes the background entirely black, with the WindowBackColor is set to transparent.



Best Regards,
Nevron Support Team



Joe Marino
Posted 12 Years Ago
View Quick Profile
Forum Newbie

Forum Newbie (1 reputation)Forum Newbie (1 reputation)Forum Newbie (1 reputation)Forum Newbie (1 reputation)Forum Newbie (1 reputation)Forum Newbie (1 reputation)Forum Newbie (1 reputation)Forum Newbie (1 reputation)Forum Newbie (1 reputation)

Group: Forum Members
Last Active: 12 Years Ago
Posts: 1, Visits: 1

Is it possible to draw a diagram onto an existing user control?

I want to have the user interact with a diagram over a video control.

 

 

Thank You





Similar Topics


Reading This Topic