Draw Diagram on an Existing User Control


Author
Message
Nevron Support
Nevron Support
Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)
Group: Administrators
Posts: 3.1K, Visits: 4.2K

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
Joe Marino
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
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


GO

Merge Selected

Merge into selected topic...



Merge into merge target...



Merge into a specific topic ID...




Similar Topics

Reading This Topic

Login

Explore
Messages
Mentions
Search