| Article | 60000716 |
| Type | HowTo |
| Product | Engine |
| Date Added | 12/18/2008 12:00:00 AM |
| Fixed | (12/18/2008 12:00:00 AM) |
| Submitted by | Pushpak |
Summary
How can I change the color of the Viewport when the user activates it by double-click ?
Solution
In the "Collections" sample add the ActionLayoutActivated event and write a code like (see also the comments) :
VectorDraw.Professional.vdObjects.
vdColor oldcolor = new VectorDraw.Professional.vdObjects.vdColor(); // there will store the color before the "highlight"VectorDraw.Professional.vdObjects.vdHandle deactivated_Viewport_handle = new VectorDraw.Professional.vdObjects.vdHandle(); // The handle of the Viewport we changed
void ActiveDocument_ActionLayoutActivated(object sender, VectorDraw.Professional.vdPrimaries.vdLayout deactivated, VectorDraw.Professional.vdPrimaries.vdLayout activated)
{// fires when the Layout or the Viewport changes
if (activated.ActiveViewPort == null) // Run when MODEL is activated that happens when the viewport is activated or user returns to Model.
{
if (deactivated.ActiveViewPort != null) // the deactiveted vieport is the one that the use dbl-clicked
{
oldcolor.CopyFrom(deactivated.ActiveViewPort.PenColor); // store the color
deactivated.ActiveViewPort.PenColor.SystemColor = Color.Red; // change the color
deactivated.ActiveViewPort.Update();
deactivated.ActiveViewPort.Invalidate();
deactivated_Viewport_handle = deactivated.ActiveViewPort.Handle; // store the handle
}
if ((deactivated.ActiveViewPort == null) && (deactivated_Viewport_handle.Value != 0)) // This happens when the Viewport is not "active"
{//create a vdViewport and set it to the viewport that was deactivated
VectorDraw.Professional.vdFigures.vdViewport deactiViewport = new VectorDraw.Professional.vdFigures.vdViewport();
deactiViewport= vdFramedControl1.BaseControl.ActiveDocument.FindFromHandle(deactivated_Viewport_handle, typeof(VectorDraw.Professional.vdPrimaries.vdFigure)) as VectorDraw.Professional.vdFigures.vdViewport;
deactiViewport.PenColor.CopyFrom(oldcolor); // change the color back
if (deactiViewport.ClipObj != null)
{
deactiViewport.ClipObj.PenColor.CopyFrom(oldcolor); // to the ClipObj too
deactiViewport.ClipObj.Update();
deactiViewport.ClipObj.Invalidate();
}
deactiViewport.Update();
deactiViewport.Invalidate();
deactivated_Viewport_handle= new VectorDraw.Professional.vdObjects.vdHandle(0); // set the handle to 0
}
}
}
