1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-04-03 17:56:21 +03:00
occt/samples/CSharp/WPF/MaterialDlg.xaml.cs
vdn d1a2fee8ed 0024147: Update of CSharp sample
Overall revision of of CSharp sample code:
- Pure C++ project "OCC" deleted as unnecessary
- C++/CLI project "shell" renamed to OCCTProxy and refactored to implement all required interface to OCCT functionality.
- In About dialog, date corrected in Copyright statement
- CSharp files re-layouted with 2 spaces indentation
- ReadMe converted to MarkDown format and revised
- Generation of names of views refactored to avoid calling C++ level
- Project files corrected to run on 64-bit systems
- Batch scripts refactored to use OCCT default configuration

WPF front-end added to demonstrate usage of OCCT in WPF applications.
WPF sample was modified, operation Export has been fixed
Exception "Cannot create this file", which appeared by export to image format, has been corrected.
Option "Export image to .xwd" removed.
2013-10-25 13:45:47 +04:00

101 lines
2.5 KiB
C#

using System;
using System.Collections.Generic;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
namespace IE_WPF
{
public enum Material
{
Brass,
Bronze,
Copper,
Gold,
Pewter,
Plaster,
Plastic,
Silver
}
/// <summary>
/// Interaction logic for MaterialDlg.xaml
/// </summary>
public partial class MaterialDlg : Window
{
public MaterialDlg( OCCTProxy theView )
{
this.InitializeComponent();
if ( theView == null )
{
MessageBox.Show( "Fatal Error during the graphic initialisation", "Error!" );
}
View = theView;
SetInitialState();
}
public OCCTProxy View { get; private set; }
private void PlasterBtn_Checked( object sender, RoutedEventArgs e )
{
View.SetMaterial( (int)Material.Plaster );
View.UpdateCurrentViewer();
}
private void BrassBtn_Checked( object sender, RoutedEventArgs e )
{
View.SetMaterial( (int)Material.Brass );
View.UpdateCurrentViewer();
}
private void BronzeBtn_Checked( object sender, RoutedEventArgs e )
{
View.SetMaterial( (int)Material.Bronze );
View.UpdateCurrentViewer();
}
private void CopperBtn_Checked( object sender, RoutedEventArgs e )
{
View.SetMaterial( (int)Material.Copper );
View.UpdateCurrentViewer();
}
private void GoldBtn_Checked( object sender, RoutedEventArgs e )
{
View.SetMaterial( (int)Material.Gold );
View.UpdateCurrentViewer();
}
private void PewterBtn_Checked( object sender, RoutedEventArgs e )
{
View.SetMaterial( (int)Material.Pewter );
View.UpdateCurrentViewer();
}
private void PlasticBtn_Checked( object sender, RoutedEventArgs e )
{
View.SetMaterial( (int)Material.Plastic );
View.UpdateCurrentViewer();
}
private void SilverBtn_Checked( object sender, RoutedEventArgs e )
{
View.SetMaterial( (int)Material.Silver );
View.UpdateCurrentViewer();
}
private void SetInitialState()
{
// TODO
}
}
}