Zoom in CADImage in C#

Discuss and ask questions about CAD DLL (CAD Image DLL, CAD Importer DLL).

Moderators: SDS, support, admin

Post Reply
walter
Posts: 6
Joined: 25 Oct 2006, 18:51

Zoom in CADImage in C#

Post by walter » 25 Oct 2006, 19:03

im making an aplication with the CADimage.dll (eval version, for now) and i want to use a zoom y some particular area (under the mouse) but i dont know what to do, because using fscale the draw goes to the upper left corner.
can anyone help me, do someone understand me, im from argenina and i dont speak inglish wel :D

walter

walter
Posts: 6
Joined: 25 Oct 2006, 18:51

Post by walter » 25 Oct 2006, 19:13

ups, i forgot to say that the dll version is 3, and i download the version 5 that has getcadcoord but i dont know how to use it

support
Posts: 3254
Joined: 30 Mar 2005, 11:36
Contact:

Post by support » 27 Oct 2006, 17:19

Hello Walter,

We have added zooming by mouse wheel like in AutoCAD to the C# demo application. Updated package of <b>CADImage.DLL</b> is available on: http://www.cadsofttools.com/download/cadimage.zip

The folowing code was added to the modul <b>Form1.cs</b>:

Code: Select all

<font color="blue">public</font id="blue"> fmCADImage()
{
  <font color="green">//
  // Required for Windows Form Designer support
  //</font id="green">
  InitializeComponent();
 <font color="green"> //the following line is new</font id="green">
  <font color="blue">this</font id="blue">.MouseWheel += <font color="blue">new</font id="blue"> MouseEventHandler(MouseZoom);
  <font color="green">//
  // TODO: Add any constructor code after InitializeComponent call
  //</font id="green">
}

<font color="blue">private void</font id="blue"> menuItem14_Click(<font color="blue">object</font id="blue"> sender, System.EventArgs e)
{
  <font color="blue">for</font id="blue">(<font color="blue">int</font id="blue"> i = 0; i < MainMenu1.MenuItems[1].MenuItems.Count; i++)
  MainMenu1.MenuItems[1].MenuItems[i].Checked = <font color="blue">false</font id="blue">;
  (sender <font color="blue">as</font id="blue"> MenuItem).Checked = ! (sender <font color="blue">as</font id="blue"> MenuItem).Checked;
  fScale = Convert.ToInt32((sender <font color="blue">as</font id="blue"> MenuItem).Text);
  <font color="green">//the following two lines are new</font id="green">
  DLLWin32Import.FX = 0;
  DLLWin32Import.FY = 0;

  panel1.Invalidate();
}
<font color="green">//the following method is new</font id="green">
<font color="blue">private void</font id="blue"> MouseZoom(<font color="blue">object</font id="blue"> sender, System.Windows.Forms.MouseEventArgs e)
{
  <font color="blue">float</font id="blue"> prev_scale = fScale;
  prev_scale = fScale;
  fScale += e.Delta/12; 
  <font color="blue">float</font id="blue"> fs = fScale / prev_scale;

  DLLWin32Import.FX =  (<font color="blue">int</font id="blue">)((DLLWin32Import.FX - e.X) * Math.Abs(fs) + e.X);
  DLLWin32Import.FY =  (<font color="blue">int</font id="blue">)((DLLWin32Import.FY - e.Y) * Math.Abs(fs) + e.Y);

  panel1.Invalidate();			
} 
Sergey.
Please post questions to the forum or write to support@cadsofttools.com

walter
Posts: 6
Joined: 25 Oct 2006, 18:51

Post by walter » 30 Oct 2006, 22:55

hello and thanks for your answer.
Now im trying to selec, parts from the drawing, and to know which part i select to show some info in a ... textbox.
is there a way to "select" or to know in which figure im clicking?
thanks again
--------------------------
gracias por su respuesta-
ahora estoy tratando de "seleccionar", partes del dibujo, y tratando de saber q parte he seleccionado para mostrar algun comentario en un textbox.
hay alguna forma de seleccionar o saber donde estoy clickeando?
gracias nuevamente

Post Reply