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