Article | 70002013 |
Type | HowTo |
Product | Engine |
Version | 8000 |
Date Added | 6/29/2021 12:00:00 AM |
Fixed | 9.9002.0.5 (6/29/2021 12:00:00 AM) |
Submitted by | Ricardo Eira |
Summary
How can I set the initial background of Vectordraw
Solution
Setting the background of Vectordraw can be performed using the following 3 events.
public Form1() { InitializeComponent(); //Note that the InitializeDocument event must be added here and not in the Form_Load event of the Form. The other two events can be initialized at the Form Load. vdFramedControl.BaseControl.InitializeDocument += BaseControl_InitializeDocument; } void SetBkColor(vdDocument document) { if (document == null) return; document.Background = Color.DeepSkyBlue; document.ActiveLayOut.BkGradientColor = Color.White; document.ActiveLayOut.BkGradientAngle = 90 * (Math.PI / 180); if (!VectorDraw.Render.vdRender.IsColorEmpty(document.ActiveLayOut.BkGradientColor)) { Graphics gr = document.GlobalRenderProperties.GraphicsContext.MemoryGraphics; Rectangle rc = new Rectangle(new Point(0, 0), document.GlobalRenderProperties.GraphicsContext.MemoryBitmap.Size); rc.Inflate(1, 1); System.Drawing.Drawing2D.LinearGradientBrush br = new System.Drawing.Drawing2D.LinearGradientBrush(rc, document.Background, document.ActiveLayOut.BkGradientColor, (float)VectorDraw.Geometry.Globals.RadiansToDegrees(document.ActiveLayOut.BkGradientAngle)); br.WrapMode = System.Drawing.Drawing2D.WrapMode.Tile; gr.FillRectangle(br, rc); } else { document.GlobalRenderProperties.GraphicsContext.Clear(document.Background); } document.GlobalRenderProperties.GraphicsContext.ControlGraphics.DrawImageUnscaled(document.GlobalRenderProperties.GraphicsContext.MemoryBitmap, new Point(0, 0)); } private void BaseControl_InitializeDocument(vdDocument document) { SetBkColor(document); } void doc_OnAfterOpenDocument(object sender) { vdDocument mdoc = sender as vdDocument; SetBkColor(mdoc); } void doc_OnAfterNewDocument(object sender) { vdDocument mdoc = sender as vdDocument; SetBkColor(mdoc); } <\pre>