Skip to content

Commit e1987fa

Browse files
Added WinForms Control, and example project. Build issues fixed.
-Created D3D11Host for WinForms -Converted SharpDXExample to WinForms -Issue where CLI project wouldn't build when switching to and from a .Net Framework configuration has been fixed by automating the cleaning/restoring steps via a targets file.
1 parent c83087c commit e1987fa

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+2279
-170
lines changed

ConfigCache/PreviousConfig.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Debug_v4.7

Examples/WPF/SharpDXExample/MainWindow.xaml

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,18 +6,19 @@
66
xmlns:local="clr-namespace:Example1"
77
xmlns:DirectX="clr-namespace:GfxControls.WPF.DirectX;assembly=GfxControls.WPF"
88
mc:Ignorable="d"
9-
Title="D3D11Host SharpDX Example" Height="450" Width="800">
9+
Title="D3D11Host SharpDX WPF Example" Height="450" Width="800">
1010
<Grid>
1111
<Grid.ColumnDefinitions>
12-
<ColumnDefinition Width="*"/>
12+
<ColumnDefinition Width="147*"/>
13+
<ColumnDefinition Width="653*"/>
1314
</Grid.ColumnDefinitions>
1415
<Grid.RowDefinitions>
1516
<RowDefinition Height="30"/>
1617
<RowDefinition Height="*"/>
1718
<RowDefinition Height="30"/>
1819
</Grid.RowDefinitions>
19-
<TextBlock x:Name="LabelTop" Text="Example1: Rotating Cube" FontSize="16" HorizontalAlignment="Center"/>
20-
<DirectX:D3D11Host x:Name="dxHost" Grid.Row="1" />
21-
<TextBlock x:Name="LabelBottom" Text="" Grid.Row="2" FontSize="16" HorizontalAlignment="Center" />
20+
<TextBlock x:Name="LabelTop" Text="SharpDX WPF Example" FontSize="16" HorizontalAlignment="Left" Grid.Column="1" Margin="173,0,0,0"/>
21+
<DirectX:D3D11Host x:Name="dxHost" Grid.Row="1" Grid.ColumnSpan="2" />
22+
<TextBlock x:Name="LabelBottom" Text="" Grid.Row="1" FontSize="16" HorizontalAlignment="Left" Grid.Column="1" Margin="253,374,0,0" Grid.RowSpan="2" />
2223
</Grid>
2324
</Window>

Examples/WPF/SharpDXExample/MainWindow.xaml.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@
1717
using Matrix = SharpDX.Matrix;
1818
using Point = System.Windows.Point;
1919
using Size = GfxControls.Size;
20+
using System.Runtime.InteropServices.JavaScript;
21+
using System.Windows.Interop;
2022

2123
//https://github.com/sharpdx/SharpDX-Samples/blob/master/Desktop/Direct3D11/MiniCube/Program.cs
2224
namespace Example1
@@ -93,13 +95,13 @@ private void Initialize()
9395
stopwatch.Start();
9496

9597
dxHost.Resized += DxHost_Resized;
96-
dxHost.MouseMove += DxWindow_MouseMove;
97-
dxHost.MouseWheel += DxWindow_MouseWheel;
98+
dxHost.MouseMove += DxHost_MouseMove;
99+
dxHost.MouseWheel += DxHost_MouseWheel;
98100

99101
InitializeGraphics();
100102
}
101103

102-
private void DxWindow_MouseWheel(object sender, System.Windows.Input.MouseWheelEventArgs e)
104+
private void DxHost_MouseWheel(object sender, System.Windows.Input.MouseWheelEventArgs e)
103105
{
104106
// Adjust zoom factor with mouse wheel
105107
zoomFactor -= e.Delta * zoomSpeed;
@@ -108,10 +110,8 @@ private void DxWindow_MouseWheel(object sender, System.Windows.Input.MouseWheelE
108110
SetViewMatrix();
109111
}
110112

111-
private void DxWindow_MouseMove(object sender, System.Windows.Input.MouseEventArgs e)
113+
private void DxHost_MouseMove(object sender, System.Windows.Input.MouseEventArgs e)
112114
{
113-
IInputElement? element = sender as IInputElement;
114-
115115
if (stopwatch!.ElapsedMilliseconds - lastMoveEvent > 16)
116116
{
117117
//// TODO: GetPosition always returning same result unless break after.

Examples/WPF/SharpDXExample/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,8 @@ private void Initialize()
6363
stopwatch.Start();
6464

6565
dxHost.Resized += DxHost_Resized;
66-
dxHost.MouseMove += DxWindow_MouseMove;
67-
dxHost.MouseWheel += DxWindow_MouseWheel;
66+
dxHost.MouseMove += DxHost_MouseMove;
67+
dxHost.MouseWheel += DxHost_MouseWheel;
6868

6969
InitializeGraphics();
7070
}

Examples/WinForms/SharpDXExample/Form1.Designer.cs

Lines changed: 88 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)