Jump to content
  • Advertisement
Sign in to follow this  

Need to understand the event-triggering in this SharpDX program

This topic is 968 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I'm trying to learn SharpDX by using an example program (http://sharpdxwpf.codeplex.com/SourceControl/latest#SharpDX.WPF.sln) ... it creates a quadrant of 4 shaded triangles using 4 different approaches and it just runs by itself redrawing the graphics. It runs continuously and seems to be event-driven because I continuously hit breakpoints in event handlers (see below) but I don't understand what triggers these events. In the XAML it has . . .


. . .

<dxc:DXElement Grid.Column="0" Grid.Row="0" x:Name="dxview10"/>
<Image Grid.Column="1" Grid.Row="0" x:Name="img"/>
<dxc:DXElement Grid.Column="0" Grid.Row="1" x:Name="dxview11"/>
<dxc:DXElement Grid.Column="1" Grid.Row="1" x:Name="dxview2d"/>


. . . Where DXElement's declaration and constructor look like this . . .


public class DXElement : FrameworkElement, INotifyPropertyChanged

public DXElement()
base.SnapsToDevicePixels = true;
m_renderTimer = new Stopwatch();
m_surface = new DXImageSource();
m_surface.IsFrontBufferAvailableChanged += delegate
if (!m_isReallyLoopRendering && m_surface.IsFrontBufferAvailable)
IsVisibleChanged += delegate { UpdateReallyLoopRendering(); };


The rest of DXElement is just brief event handlers. Here's one example:

protected override void OnRender(DrawingContext dc)
dc.DrawImage(Surface, new Rect(RenderSize));

Notice the "override". I'm assuming that one of the parent classes of DXElement ( FrameworkElement or INotifyPropertyChanged ) are already listening for these events. But what's triggering these events? (e.g., OnRender(), OnLoopRendering(), etc) They seem to be the engine that runs the program. How can I track what causes events like this to fire in a WPF program? If I set a breakpoint at them I see them getting hit, but they're called from the framwework, e.g.,

SharpDX.WPF.dll!SharpDX.WPF.DXElement.OnRender(System.Windows.Media.DrawingContext dc) Line 153 C# PresentationCore.dll!System.Windows.UIElement.Arrange(System.Windows.Rect finalRect) Unknown PresentationFramework.dll!System.Windows.Controls.Grid.ArrangeOverride(System.Windows.Size arrangeSize) Unknown PresentationFramework.dll!System.Windows.FrameworkElement.ArrangeCore(System.Windows.Rect finalRect) Unknown PresentationCore.dll!System.Windows.UIElement.Arrange(System.Windows.Rect finalRect) Unknown PresentationFramework.dll!MS.Internal.Helper.ArrangeElementWithSingleChild(System.Windows.UIElement element, System.Windows.Size arrangeSize) Unknown PresentationFramework.dll!System.Windows.Controls.ContentPresenter.ArrangeOverride(System.Windows.Size arrangeSize) Unknown


... so I don't understand what the program is doing to make these events happen. How do I figure that out?   Thanks in advance for any help!  (and if you'd like 200 reputation points on Stack Overflow, I've also posted it there with a bonus at http://stackoverflow.com/questions/36651696/need-to-understand-the-event-triggering-in-this-wpf-program )


Edited by plnelson

Share this post

Link to post
Share on other sites

As far as my understanding, regardless of platform or framework, you can't debug something unless you have a .pdb file that hold all the symbolic information for the associated (Microsoft based aka WPF and DirectX) module. So no, you can't tell where it is getting triggered at specifically, BUT if you read the stack information, it is being triggered by a WPF control called ContentPresenter, if that helps at all...


MSDN states for .ArrangeOverride from type FrameworkElement, "When overridden in a derived class, positions child elements and determines a size for a FrameworkElement derived class"


So my guess is that the size change for the element is triggering an invalidate or refresh call of some sort in order to redraw the content(which makes sense).


I may be presuming to much, if someone is more knowledgeable please correct me.

Edited by ExErvus

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!