Hello,
I would like a special functionality of UI interface displaing DWF file which is not avaliable with ADR.
I was wondering if there is an API that alows to specify area and magnification to render objects in this specified area to Bitmap/Visual
This ability would allow me to implement my own user interface and display.
I searched through new API guide however cannot find any reference to this feature or ability to pass parameters to PAN,ZOOM,ZOOMRECT commands (not by mouse or keyboard)
Thank you kindly
Paul
VS 2008 C#
.NET 3.5
ADR 2011
WPF interface
Solved! Go to Solution.
Solved by herbert.he. Go to Solution.
Thank you for your question.
ADR does not support to pass parameters to PAN,ZOOM,ZOOMRECT commands.
However, you can implement you special functionality following the steps:
1. Use property Content2.Extents to get the boundaries of specified object(s).
For 2D objects:
2. Calculate your specify area and magnification (specify view) base on the boundaries (IAdRect).
3. Set your specify 2D view to render obejcts via EPlotSection.SetView method.
For 3D bojects:
2. Define your specify EModelCamera object base on the boundaries (IAdCube).
3. Set you specify 3D view to render objects via EModelSection.Camera property.
Hope that helps.
Thank you herbert for precise answer.
I have done as you suggested and I am fairly happy with the results BUT, there is a huge problem with mine solution. When I use AxCExpressViewerControl directly it paints on the screen very fast, but when i use mine own control (which uses DrawToDC method) i is approximately 20-30 times slower. It is not a big deal for small drawings but for large ones time to render one frame is around 300ms (for my test large drawing) and my app is pretty laggy and unusable.
So my next question is:
Is there some way to "extract" AxCExpressViewerControl Graphics directly from control to achieve equal speed, or maybe force ActiveX control to paint on injected Device Context ?
I have tried workaround:
offscreen control + API BitBlt - very fast (10-20ms for my test large drawing) works for Windows 7/Vista but doesn't for Windows XP. (Windows XP paints only Desktop area and blank for offscreen)
SendMessage + WM_PRINT, - no success
API OleDraw - works but it is same slow speed as DrawToDC
have you got any suggestions ?
Thanks
Paul
Ok cancel that I did it just now.
I've got the solution. I managet to render whole map offscreen using API PrintWindow on W7 Vista and XP 🙂
PrintWindow using client area is not working correctly on XP but there is work around using SetWorldTranstorm to move Graphics area to the right position.
If some one else will search solution for this, here is how I did it.
1. Create Static Render manager class, which starts STA thread and in this thread creates Form wich contains ADR ActiveX Control. STA thread is required for ActiveX controls.
2. Move created window offscreen and use it to load DWF file
3. SetView to chanche viewing area (as herbert said)
4. use API "PrintWindow" to get ActiveX control graphic inside hosting form
<code>
/// method inside scope of Panel user Coontrol that contains AxCExpressViewerControl
// ensure thant ParentForm Handle is Created befor invoke this method by refering to ParentForm.Handle
// in other case InvokeRequired will fail
public void PrintWindow(Bitmap bitmap)
{
if (ParentForm.InvokeRequired)
{ // invoke from parent form thred to avoid cross thread exception
ParentForm.Invoke(new MethodInvoker(delegate() { PrintWindow(bitmap); }));
return;
}
IntPtr hWnd = this.ParentForm.Handle;
// get this panel offset inside Form
Point pointToClient = this.PointToClient(this.ParentForm.Location);
using (Graphics tmp = Graphics.FromImage(bitmap))
{
IntPtr gHDC = tmp.GetHdc();
// GDI32 & User32 are imported from pinvoke.net C# definitions
GDI32.SetGraphicsMode(gHDC, 2);
GDI32.XFORM F =
new GDI32.XFORM(1,0,0,1,pointToClient.X,pointToClient.Y);
// set wold transform to get only client area - beacause CM_CLIENTFLAG for PrintWindow method is shifting graphics wrong way in Windows XP
GDI32.SetWorldTransform(gHDC, ref F);
// Print whole window to graphics whit world transform
User32.PrintWindow(hWnd,gHDC , 0);
tmp.ReleaseHdc();
}
}
</code>
Does anyone knows how to reset the commands as they are totally strange.
now i need first to select erase then to click on the object..
also I cannot fin draw order when I select and object??
Please help
Best
O.
How do you "specify EModelCamera object base on the boundaries" in Javascript?
I have the extents of the object I want to zoom in on. How do I use these to set the camera boundaries?