cart: empty [ Login ]

Zoom and Pan Buttons

1 
patg1
1/29/2019 2:37 AM
Hi Wout, Would adding buttons be possible to implement in the WebApplicationExampleCS?
Code:
<p> <asp:Button ID="btnRegenerateImage" runat="server" Text="Regenerate Image" style="margin-top:10pt;margin-bottom:10pt;"/> <asp:Button ID="Button1" runat="server" Text="Pan Up" /> <asp:Button ID="Button2" runat="server" Text="Pan Down" /> <asp:Button ID="Button3" runat="server" Text="Pan Left" /> <asp:Button ID="Button4" runat="server" Text="Pan Right" /> <asp:Button ID="Button5" runat="server" Text="Zoom In" /> <asp:Button ID="Button6" runat="server" Text="Zoom Out" /> <asp:Button ID="Button7" runat="server" Text="Zoom All" /> </p>
I don't believe mouse panning and zooming is possible, but buttons may work for most. If this is possible what might be the best approach? Thanks, Pat
Wout
1/29/2019 9:21 AM
Hi Pat, Yes that's possible. You could use the SimpleTransformationProvider2D class to do the zooming/panning and use StoreStateTo/RestoreStateFrom to store the
Visual Basic Code:
SimpleTransformationProvider2D
state in a dictionary, and serialize the dictionary to an invisible ASP.NET field. - Wout
patg1
1/29/2019 6:14 PM
Ok thanks, I couldn't find a SimpleTransformationProvider2D example, but I did come up with a super simple fix in WebApplicationExampleCS. I modify the "Size" argument the window model-to-bitmap conversion "CreateAutoSizedBitmap()". A little crude, but at least the user can view the bitmap in better detail and higher resolution.
C# Code:
// Create a CAD drawing. You can also read this e.g. from a file. DxfModel model = CreateDrawing(width, height); // Is it possible to do something here. Need to zoom/pan into a small portion of the "model" (preferred)??? // Convert the CAD drawing to a bitmap. using (Bitmap bitmap = ImageExporter.CreateAutoSizedBitmap( model, Matrix4D.Identity, GraphicsConfig.WhiteBackgroundCorrectForBackColor, SmoothingMode.HighQuality, // new Size(500, 400) // Default size (original). new Size(xCoord, yCoord) // Dynamically scale model window "xCoord" and "yCoord" (super simple fix).
1