Article | 60000924 |
Type | HowTo |
Product | Engine |
Version | 6 |
Date Added | 7/24/2009 |
Submitted by | Matt |
Keywords |
As you know the VDF components are Windows Forms components and not WPF components. So you will have to use a container in order to add a VDF component in your WPF application. This is a WindowsFormsHost container, see more information in MSDN.
You can create a new simple WPF sample in VS2008 C# (do not check Client-only Framework subset option) or in VS2010 C# (choose .NET Framework 4 and not .NET Framework 4 Client Profile), in the Window add some buttons and a WindowsFormHost control. In the first button click event use a code like :
public vdControls.vdFramedControl vdFramedControl1; // Define a VDF componentand in the other button click event a code like :
private void button2_Click(object sender, RoutedEventArgs e)
{
if (isCreated || (vdFramedControl1!=null))
{ //draw some lines
vdFramedControl1.BaseControl.ActiveDocument.CommandAction.CmdLine(null);
}
else MessageBox.Show("VDF Framed control isn't created");
}
And also add code for a simple event:
void ActiveDocument_OnAfterAddItem(object obj) // A VDF document event
{
VectorDraw.Professional.vdPrimaries.vdFigure fig = (VectorDraw.Professional.vdPrimaries.vdFigure)obj;
if (fig != null)
{
MessageBox.Show(fig._TypeName + " with handle : " + fig.Handle.ToString() + " created.");
}
}
The first button will create a VDF Framed control inside the WindowsFormsHost and the second button will ask the user to draw some lines. With every line added to the document the event OnAfterAddItem will fire displaying the handle of the vdLine that was just created.
Make sure that the project has a license.licx file that contain the VDF component inside, in this project it should have a line like:
vdControls.vdFramedControl, vdFramedControl, Version=6.1.6019.0, Culture=neutral, PublicKeyToken=54eac14e23c9ee53
This will "instruct" the Microsoft's license compiler (LC.EXE) to add to the application the necessary licensing information. The 6.1.6019.0 in the example above is the VDF version that is installed the development machine and in your case can alter. Make sure that the Licenses.licx file has in the Build Action property the value Embedded Resource.
Client Profile Frameworks 3.5 and 4, will not work with VDF components as System.Drawing.Design is not available to these frameworks