0032137: Coding Rules - merge redundant .lxx files into header files within Package gp
[occt.git] / samples / CSharp / ReadMe.md
15534713 1OCCT CSharp sample {#samples_csharp_occt}
5c573e69 2==================
d1a2fee8 3
f3fb84ce 4This sample demonstrates how to use OCCT libraries in <b>.Net</b> application
5written using **CSharp** and **Windows Forms** or **Windows Presentation Foundation** (WPF).
d1a2fee8 6
f3fb84ce 7The connection between .Net and OCCT (C++) level is provided by proxy library
8**OCCProxy**, written in C++/CLI. The proxy library contains a single *ref* class
9encapsulating OCCT viewer and providing the functionality to manipulate this viewer
10and to import / export OCCT shapes from / to several supported CAD file formats (IGES, STEP, BREP).
d1a2fee8 11
f3fb84ce 12The sample implements two approaches to the development of a user interface with C#.
13Both applications provide the same functionality as the standard OCCT Import/Export sample.
14The first project is called *IE_WinForms* and uses Windows Forms for GUI.
15The second application is called *IE_WPF_WinForms* and uses Windows Presentation Foundation.
d1a2fee8 16
17Note a few important details:
f3fb84ce 19- OCCT template class *NCollection_Haft* is used to encapsulate C++ class into a field of *ref* class;
d1a2fee8 20
f3fb84ce 21- It is necessary to explicitly set the target platform for C# assemblies to *x86*
22 in project **Properties - Build** to work consistently on 64-bit systems with OCCT libraries built in 32-bit mode;
d1a2fee8 23
f3fb84ce 24- this sample demonstrates indirect method of wrapping C++ to C# using a manually
25 created proxy library. There is an alternative method of wrapping individual
26 OCCT classes to C# equivalents to make their full API available to a C# user
27 and to let the code be programmed on C# level similarly to C++ one. See the description
28 of **OCCT C# Wrapper** in **Advanced Samples and Tools** at
d1a2fee8 29 http://www.opencascade.org/support/products/advsamples
f3fb84ce 31- in WPF sample, **WinForms** control is used to encapsulate OCC viewer since WPF
32 does not provide the necessary interface to embed OpenGl view. Other possible
33 solution could be to render OpenGl scene in an off-screen buffer and to map it
34 to WPF control as an image. That approach would allow using all WPF features to
35 control the OCCT viewer.
d1a2fee8 36
f3fb84ce 37Run *msvc.bat* to start MS Visual Studio for building the sample.
15534713 38Note that project files are provided only for VS 2010, you can open them in
f3fb84ce 39newer versions of Visual Studio the using automatic converter.
d1a2fee8 40
f3fb84ce 41After conversion check option **Target framework** in the properties of C# projects
42(tab **Application**) to make sure that it corresponds to the version set in
43the properties of C++ projects (e.g. <b>.Net Framework 4.0</b> for VS 2010).
d1a2fee8 44
f3fb84ce 45Run *run_winforms.bat* or *run_wpf.bat* to launch the corresponding sample.
47Note that all batch scripts use the configuration defined in OCCT *custom.bat* file
d1a2fee8 48as default; you can provide arguments specifying VS version, bitness, and mode
49to override these settings, e.g.:
f3fb84ce 51 > msvc.bat vc10 win64 Debug