Refers to Eyeshot 10.0.991 and greater.
The 3D graphics drawing in the Eyeshot native WPF control is not as fast as the Windows Forms one. Basically, we all need to blame Microsoft and their D3DImage WPF control implementation. The main reason behind this issue is the number of additional passes that D3DImage WPF control needs to do to allow composition with the rest of the WPF elements.
A more technical discussion can be found on the threads below:
- WPFHost sample flickering on window resize
- Direct3D11 performances
- WPF control issues
- Need SharpDXElement alternative. Workaround to SharpDX WPF flickering.
Today, we can offer a workaround to push the WPF control frame rate to the limit: Immediate mode rendering. It can be controlled using the following property (available only in Eyeshot WPF control):
design1.Renderer = rendererType.OpenGL;
or
design1.Renderer = rendererType.Direct3D;
Clearly, with WPF immediate mode, you will not be able to combine (overlap or blend) the Eyeshot control with any other WPF control of your application.
Current Limitations
- Drag & drop
- Dock & undock
- Context Menu
- Custom mouse cursors
- GridSplitter (see CopyAndPaste sample)
- Missing "Preview" native mouse events (e.g. PreviewMouseDown)
Code Fixes
Listed below are some tricks to make your code work also with the Immediate mode rendering.
Replace
RenderContextUtility.ConvertPoint(e.GetPosition(design1))
with
RenderContextUtility.ConvertPoint(design1.GetMousePosition(e))
Replace
if (e.LeftButton == MouseButtonState.Pressed && e.ClickCount == 2)
with
if (e.ChangedButton == System.Windows.Input.MouseButton.Left && design1.GetMouseClicks(e) == 2)
Replace
design1.Focus()
with
design1.SetFocus()
For the context menu, you can define it via XAML and enable it in this way:
using System.Windows.Controls;
using System.Windows.Input;
public class MyModel : devDept.Eyeshot.Model
{
protected override void OnMouseDown(MouseButtonEventArgs e)
{
if (e.ChangedButton == System.Windows.Input.MouseButton.Right && ContextMenu != null)
{
ContextMenu.Visibility = System.Windows.Visibility.Visible;
ContextMenu.IsOpen = true;
}
else
{
base.OnMouseDown(e);
}
}
}
Comments
Please sign in to leave a comment.