Article | 41024253 |
Type | HowTo |
Product | Engine |
Version | 5.1.1.1041 |
Date Added | 6/26/2006 |
Submitted by | Gregory D. Heil |
Keywords |
How can I make a cmdImage that way that the image is visible while choosing the insertion point ?
- The user should select an image they wish to insert into the drawing. Once the image has been chosen, it should be displayed next to the mouse cursor while the user is selecting the spot to insert the image. Once the left mouse button is clicked down, the Image should be placed in that location.
The problem is, when I do the command "ScreenRender.DrawImage()" it will leave a trail of the image as you draw the mouse cursor around, as if there is an issue with the screen refreshing or something. Because, when you zoom in and out, the trail will disappear, but until the screen somehow gets re-drawn the image trail will stay there.
The following is an example of the code:
void imageSelected(string picturePath)
{
DrawImage = true;
vd.CommandAction.CmdImage(picturePath, "USER");
DrawImage = false;
}
if (e.action == VdConstCmdActions.CMDGETPOINT && DrawImage)
{
object picture = vd.Utility.GetFilePicture(Loc);
vd.ScreenRender.DrawImage(picture, e.currentPoint, 1, 0);
}
public string LocImg = @"c:\windows\Prairie Wind.bmp";
public bool DrawImage = false;
public string imgHandle = "";
private void button1_Click(object sender, EventArgs e)
{
VD.CommandAction.Undo("BEGIN");
VDProLib5.vdImage img = VD.ActiveDocument.Entities.AddImage(LocImg, new object[] { 0, 0, 0 }, 1);
imgHandle = img.Handle;
DrawImage = true;
object loc = VD.Utility.GetPoint();
DrawImage = false;
if (loc==null) {
img.Deleted = true;
} else {
img.InsertionPoint = loc;
}
img.Invalidate();
VD.CommandAction.Undo("END");
}private void Form1_Load(object sender, EventArgs e)
{ VD.UndoMode = true; }private void VD_CommandActionDraw(object sender, AxVDProLib5._DVdrawEvents_CommandActionDrawEvent e)
{
if ((e.action == VDProLib5.VdConstCmdActions.CMDGETPOINT) && (DrawImage)){
VDProLib5.vdImage img = VD.ActiveDocument.GetFromHandle(imgHandle) as VDProLib5.vdImage;
img.Invalidate();
img.InsertionPoint = e.currentPoint.Value;
e.render.DrawEntity(img); }
}