home
products
contribute
download
documentation
forum
Home
Forums
New posts
Search forums
What's new
New posts
All posts
Latest activity
Members
Registered members
Current visitors
Donate
Log in
Register
What's new
Search
Search
Search titles only
By:
New posts
Search forums
Search titles only
By:
Menu
Log in
Register
Navigation
Install the app
Install
More options
Contact us
Close Menu
Forums
MediaPortal 2
Submit: Code Patches
Seek by clicking on video progress bar
Contact us
RSS
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an
alternative browser
.
Reply to thread
Message
<blockquote data-quote="osre" data-source="post: 1117063" data-attributes="member: 150866"><p>Ok, it's working now:</p><p></p><p>my XAML lokks like this:</p><p>[CODE=XML]<?xml version="1.0" encoding="utf-8"?></p><p><Screen</p><p> xmlns="www.team-mediaportal.com/2008/mpf/directx"</p><p> xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"></p><p></p><p> <Screen.Resources></p><p> <Model x:Key="Model" Id="F4FC1599-F412-40d0-82BF-46FC352E93BE"/></p><p> <!-- GUI-Test-Model --></p><p> </Screen.Resources></p><p></p><p> <Grid x:Name="Grid"</p><p> PreviewMouseDown="{CommandStencil Source={StaticResource Model}, Path=PreviewMouseDownHandler}"</p><p> MouseDown="{CommandStencil Source={StaticResource Model}, Path=MouseDownHandler}"></p><p> <Grid.ColumnDefinitions></p><p> <ColumnDefinition Width="*"/></p><p> <ColumnDefinition Width="*"/></p><p> </Grid.ColumnDefinitions></p><p> <Grid.RowDefinitions></p><p> <RowDefinition Height="*"/></p><p> <RowDefinition Height="*"/></p><p> </Grid.RowDefinitions></p><p> </p><p> <Border Grid.Column="0" Grid.Row="0" Margin="20" Background="Yellow"</p><p> PreviewMouseDown="{CommandStencil Source={StaticResource Model}, Path=PreviewMouseDownHandler}"</p><p> MouseDown="{CommandStencil Source={StaticResource Model}, Path=MouseDownHandler}"</p><p> x:Name="Yellow"></p><p> <StackPanel Margin="10"></p><p> <Border Margin="10" Background="Red" x:Name="RenInYellow"</p><p> PreviewMouseDown="{CommandStencil Source={StaticResource Model}, Path=PreviewMouseDownHandler}"</p><p> MouseDown="{CommandStencil Source={StaticResource Model}, Path=MouseDownHandler}"></p><p> <Label HorizontalAlignment="Center" VerticalAlignment="Center"</p><p> Content="Red in yellow"/></p><p> </Border></p><p> <Border Margin="10" Background="Green" x:Name="GreenInYellow"</p><p> PreviewMouseDown="{CommandStencil Source={StaticResource Model}, Path=PreviewMouseDownHandler}"</p><p> MouseDown="{CommandStencil Source={StaticResource Model}, Path=MouseDownHandler}"></p><p> <Label HorizontalAlignment="Center" VerticalAlignment="Center"</p><p> Content="Green in yellow"/></p><p> </Border></p><p> </StackPanel></p><p> </Border></p><p> </Grid></p><p></p><p></Screen>[/CODE]</p><p></p><p>The model looks like this:</p><p>[CODE=C#]public void PreviewMouseDownHandler(object sender, MouseButtonEventArgs e)</p><p> {</p><p> Debug.Print("PreviewMouseDownHandler sender={0}; Source={1}; OriginalSource={2}", sender, e.Source, e.OriginalSource);</p><p> }</p><p></p><p> public void MouseDownHandler(object sender, MouseButtonEventArgs e)</p><p> {</p><p> Debug.Print("MouseDownHandler sender={0}; Source={1}; OriginalSource={2}", sender, e.Source, e.OriginalSource);</p><p> }[/CODE]</p><p></p><p>When I click on the yellow area I get this output:</p><p>[code]PreviewMouseDownHandler sender=Grid, Name: 'Grid', ElementState: Running; Source=Grid, Name: 'Grid', ElementState: Running; OriginalSource=StackPanel, ElementState: Running</p><p>PreviewMouseDownHandler sender=Border, Name: 'Yellow', ElementState: Running; Source=Border, Name: 'Yellow', ElementState: Running; OriginalSource=StackPanel, ElementState: Running</p><p>MouseDownHandler sender=Border, Name: 'Yellow', ElementState: Running; Source=Border, Name: 'Yellow', ElementState: Running; OriginalSource=StackPanel, ElementState: Running</p><p>MouseDownHandler sender=Grid, Name: 'Grid', ElementState: Running; Source=Grid, Name: 'Grid', ElementState: Running; OriginalSource=StackPanel, ElementState: Running</p><p>[/code]</p><p>My "Hit testing" seems to return the StackPanel, even that it is transparent, and the Yellow Border should be the original source.</p><p>Currently I missuse the OnMouseMove method for hittesting <img src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7" class="smilie smilie--sprite smilie--sprite27" alt=":whistle:" title="Whistling :whistle:" loading="lazy" data-shortname=":whistle:" /></p><p></p><p>When I click on the green area I get this:</p><p>[code]PreviewMouseDownHandler sender=Grid, Name: 'Grid', ElementState: Running; Source=Grid, Name: 'Grid', ElementState: Running; OriginalSource=Border, Name: 'GreenInYellow', ElementState: Running</p><p>PreviewMouseDownHandler sender=Border, Name: 'Yellow', ElementState: Running; Source=Border, Name: 'Yellow', ElementState: Running; OriginalSource=Border, Name: 'GreenInYellow', ElementState: Running</p><p>PreviewMouseDownHandler sender=Border, Name: 'GreenInYellow', ElementState: Running; Source=Border, Name: 'GreenInYellow', ElementState: Running; OriginalSource=Border, Name: 'GreenInYellow', ElementState: Running</p><p>MouseDownHandler sender=Border, Name: 'GreenInYellow', ElementState: Running; Source=Border, Name: 'GreenInYellow', ElementState: Running; OriginalSource=Border, Name: 'GreenInYellow', ElementState: Running</p><p>MouseDownHandler sender=Border, Name: 'Yellow', ElementState: Running; Source=Border, Name: 'Yellow', ElementState: Running; OriginalSource=Border, Name: 'GreenInYellow', ElementState: Running</p><p>MouseDownHandler sender=Grid, Name: 'Grid', ElementState: Running; Source=Grid, Name: 'Grid', ElementState: Running; OriginalSource=Border, Name: 'GreenInYellow', ElementState: Running</p><p>[/code]</p><p></p><p>The events in UIElement are defined like this (without the class handlers):</p><p>[CODE=C#] public static readonly RoutedEvent PreviewMouseDownEvent = EventManager.RegisterRoutedEvent(</p><p> "PreviewMouseDown", RoutingStrategy.Tunnel, typeof(MouseButtonEventHandler), typeof(UIElement));</p><p></p><p> // Provide CLR accessors for the event</p><p> public event MouseButtonEventHandler PreviewMouseDown</p><p> {</p><p> add { AddHandler(PreviewMouseDownEvent, value); }</p><p> remove { RemoveHandler(PreviewMouseDownEvent, value); }</p><p> }</p><p> public static readonly RoutedEvent MouseDownEvent = EventManager.RegisterRoutedEvent(</p><p> "MouseDown", RoutingStrategy.Bubble, typeof(MouseButtonEventHandler), typeof(UIElement));</p><p></p><p> // Provide CLR accessors for the event</p><p> public event MouseButtonEventHandler MouseDown</p><p> {</p><p> add { AddHandler(MouseDownEvent, value); }</p><p> remove { RemoveHandler(MouseDownEvent, value); }</p><p> }</p><p>[/CODE]</p><p></p><p>For anyone who knows WPF, this should be straight forward.</p><p>What's missing you might ask:</p><p>- Proper event invocation</p><p>- Hit testing</p><p>- Adding all the events (and invoke them)</p><p>That's it I guess.</p></blockquote><p></p>
[QUOTE="osre, post: 1117063, member: 150866"] Ok, it's working now: my XAML lokks like this: [CODE=XML]<?xml version="1.0" encoding="utf-8"?> <Screen xmlns="www.team-mediaportal.com/2008/mpf/directx" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"> <Screen.Resources> <Model x:Key="Model" Id="F4FC1599-F412-40d0-82BF-46FC352E93BE"/> <!-- GUI-Test-Model --> </Screen.Resources> <Grid x:Name="Grid" PreviewMouseDown="{CommandStencil Source={StaticResource Model}, Path=PreviewMouseDownHandler}" MouseDown="{CommandStencil Source={StaticResource Model}, Path=MouseDownHandler}"> <Grid.ColumnDefinitions> <ColumnDefinition Width="*"/> <ColumnDefinition Width="*"/> </Grid.ColumnDefinitions> <Grid.RowDefinitions> <RowDefinition Height="*"/> <RowDefinition Height="*"/> </Grid.RowDefinitions> <Border Grid.Column="0" Grid.Row="0" Margin="20" Background="Yellow" PreviewMouseDown="{CommandStencil Source={StaticResource Model}, Path=PreviewMouseDownHandler}" MouseDown="{CommandStencil Source={StaticResource Model}, Path=MouseDownHandler}" x:Name="Yellow"> <StackPanel Margin="10"> <Border Margin="10" Background="Red" x:Name="RenInYellow" PreviewMouseDown="{CommandStencil Source={StaticResource Model}, Path=PreviewMouseDownHandler}" MouseDown="{CommandStencil Source={StaticResource Model}, Path=MouseDownHandler}"> <Label HorizontalAlignment="Center" VerticalAlignment="Center" Content="Red in yellow"/> </Border> <Border Margin="10" Background="Green" x:Name="GreenInYellow" PreviewMouseDown="{CommandStencil Source={StaticResource Model}, Path=PreviewMouseDownHandler}" MouseDown="{CommandStencil Source={StaticResource Model}, Path=MouseDownHandler}"> <Label HorizontalAlignment="Center" VerticalAlignment="Center" Content="Green in yellow"/> </Border> </StackPanel> </Border> </Grid> </Screen>[/CODE] The model looks like this: [CODE=C#]public void PreviewMouseDownHandler(object sender, MouseButtonEventArgs e) { Debug.Print("PreviewMouseDownHandler sender={0}; Source={1}; OriginalSource={2}", sender, e.Source, e.OriginalSource); } public void MouseDownHandler(object sender, MouseButtonEventArgs e) { Debug.Print("MouseDownHandler sender={0}; Source={1}; OriginalSource={2}", sender, e.Source, e.OriginalSource); }[/CODE] When I click on the yellow area I get this output: [code]PreviewMouseDownHandler sender=Grid, Name: 'Grid', ElementState: Running; Source=Grid, Name: 'Grid', ElementState: Running; OriginalSource=StackPanel, ElementState: Running PreviewMouseDownHandler sender=Border, Name: 'Yellow', ElementState: Running; Source=Border, Name: 'Yellow', ElementState: Running; OriginalSource=StackPanel, ElementState: Running MouseDownHandler sender=Border, Name: 'Yellow', ElementState: Running; Source=Border, Name: 'Yellow', ElementState: Running; OriginalSource=StackPanel, ElementState: Running MouseDownHandler sender=Grid, Name: 'Grid', ElementState: Running; Source=Grid, Name: 'Grid', ElementState: Running; OriginalSource=StackPanel, ElementState: Running [/code] My "Hit testing" seems to return the StackPanel, even that it is transparent, and the Yellow Border should be the original source. Currently I missuse the OnMouseMove method for hittesting :whistle: When I click on the green area I get this: [code]PreviewMouseDownHandler sender=Grid, Name: 'Grid', ElementState: Running; Source=Grid, Name: 'Grid', ElementState: Running; OriginalSource=Border, Name: 'GreenInYellow', ElementState: Running PreviewMouseDownHandler sender=Border, Name: 'Yellow', ElementState: Running; Source=Border, Name: 'Yellow', ElementState: Running; OriginalSource=Border, Name: 'GreenInYellow', ElementState: Running PreviewMouseDownHandler sender=Border, Name: 'GreenInYellow', ElementState: Running; Source=Border, Name: 'GreenInYellow', ElementState: Running; OriginalSource=Border, Name: 'GreenInYellow', ElementState: Running MouseDownHandler sender=Border, Name: 'GreenInYellow', ElementState: Running; Source=Border, Name: 'GreenInYellow', ElementState: Running; OriginalSource=Border, Name: 'GreenInYellow', ElementState: Running MouseDownHandler sender=Border, Name: 'Yellow', ElementState: Running; Source=Border, Name: 'Yellow', ElementState: Running; OriginalSource=Border, Name: 'GreenInYellow', ElementState: Running MouseDownHandler sender=Grid, Name: 'Grid', ElementState: Running; Source=Grid, Name: 'Grid', ElementState: Running; OriginalSource=Border, Name: 'GreenInYellow', ElementState: Running [/code] The events in UIElement are defined like this (without the class handlers): [CODE=C#] public static readonly RoutedEvent PreviewMouseDownEvent = EventManager.RegisterRoutedEvent( "PreviewMouseDown", RoutingStrategy.Tunnel, typeof(MouseButtonEventHandler), typeof(UIElement)); // Provide CLR accessors for the event public event MouseButtonEventHandler PreviewMouseDown { add { AddHandler(PreviewMouseDownEvent, value); } remove { RemoveHandler(PreviewMouseDownEvent, value); } } public static readonly RoutedEvent MouseDownEvent = EventManager.RegisterRoutedEvent( "MouseDown", RoutingStrategy.Bubble, typeof(MouseButtonEventHandler), typeof(UIElement)); // Provide CLR accessors for the event public event MouseButtonEventHandler MouseDown { add { AddHandler(MouseDownEvent, value); } remove { RemoveHandler(MouseDownEvent, value); } } [/CODE] For anyone who knows WPF, this should be straight forward. What's missing you might ask: - Proper event invocation - Hit testing - Adding all the events (and invoke them) That's it I guess. [/QUOTE]
Insert quotes…
Verification
Post reply
Forums
MediaPortal 2
Submit: Code Patches
Seek by clicking on video progress bar
Contact us
RSS
Top
Bottom