通過一些代碼行可以指導VDF組件在OnDrawBackground事件中使用調色板的背景顏色,
比如:
// the form conatins a vdFramedControl and a Button bool isOnSVGSave = false; // use this global boolean in the form and make it true just before saving the SVG and then again to false after save is finishedprivate void button1_Click(object sender, EventArgs e){ vdDocument doc = vdFramedControl.BaseControl.ActiveDocument; doc.Open(@"C:\test\simple1.vdml"); // open a test file doc.Palette.Background = Color.LightYellow; doc.Palette.Forground = Color.DarkSlateGray; .......... isOnSVGSave = true; //set this flag to true before saving SVG doc.OnDrawBackground += new vdDocument.DrawBackgroundEventHandler(doc_OnDrawBackground); // enable the event doc.SaveAs(@"c:\test\svg1.svg"); // save the SVG doc.OnDrawBackground -= new vdDocument.DrawBackgroundEventHandler(doc_OnDrawBackground); // disable the event isOnSVGSave = false;//set this flag back to false after saving SVG} void doc_OnDrawBackground(object sender, vdRender render, ref bool cancel){ if (isOnSVGSave && render!=null && render is RenderFormats.SvgRender) { cancel = true; // you need to pass this as tru render.Clear(vdFramedControl.BaseControl.ActiveDocument.Palette.Background); // clear the render and use the Palette’s Background color! }}
登錄 慧都網發表評論