SuRGeoNix / Flyleaf

Media Player .NET Library for WinUI 3/ WPF/WinForms (based on FFmpeg/DirectX)
GNU Lesser General Public License v3.0
708 stars 97 forks source link

Settings Dialog and Popup Menu Not Show in flwpf:FlyleafME #481

Closed HamidLaktarash closed 2 months ago

HamidLaktarash commented 2 months ago

currently I use 3.7.28 version. in my app, I use bellow <flwpf:FlyleafME x:Name="flyleafControl" Player="{Binding Player}"/> which load FlyleafLib.Controls.WPF\Themes\FlyleafME.xaml as default Video View I don`t want use your custom Video View in MainWindow.xaml that contains more feature like Messages, Status, Subtitles everything works fine.

now I update to 3.7.50. with your custom Video View in MainWindow.xaml everything is OK. below code is your code in MainWindow.xaml:

<!--Video View-->
                    <Grid Grid.Row="1" x:Name="PART_ContextMenuOwner" ContextMenu="{StaticResource PopUpMenu}">
                        <Grid.Style>
                            <Style TargetType="{x:Type Grid}">
                                <Setter Property="Visibility" Value="Collapsed" d:Value="Visible"/>
                                <Style.Triggers>
                                    <DataTrigger Binding="{Binding Tag.MediaViewer}" Value="Video">
                                        <Setter Property="Visibility" Value="Visible"/>
                                    </DataTrigger>
                                </Style.Triggers>
                            </Style>
                        </Grid.Style>
                        <TextBlock VerticalAlignment="Top" HorizontalAlignment="Left" Padding="4" Margin="10 -40 0 0" d:Text="00:00:00.000 / 01:42:23.913" FontWeight="Bold" FontSize="14" Foreground="{DynamicResource MaterialDesign.Brush.Secondary}">
                            <TextBlock.Background>
                                <SolidColorBrush Color="{Binding Player.Config.Video.BackgroundColor}" Opacity="0.15"/>
                            </TextBlock.Background>
                            <TextBlock.Style>
                                <Style TargetType="{x:Type TextBlock}">
                                    <Setter Property="Visibility" Value="Collapsed"/>
                                    <Style.Triggers>
                                        <DataTrigger Binding="{Binding Player.Activity.Mode}" Value="Active" d:Value="{x:Null}">
                                            <Setter Property="Visibility" Value="Visible"/>
                                        </DataTrigger>
                                    </Style.Triggers>
                                </Style>
                            </TextBlock.Style>
                        <Run Text="{Binding Player.CurTime, Mode=OneWay, Converter={StaticResource TicksToTimeSpan}, StringFormat={}{0:hh\\:mm\\:ss\\.fff}}"/>
                        <Run Text="/"/>
                        <Run Text="{Binding Player.Duration, Mode=OneWay, Converter={StaticResource TicksToTimeSpan}, StringFormat={}{0:hh\\:mm\\:ss\\.fff}}"/>
                        </TextBlock>

                        <!--Messages-->
                        <TextBlock VerticalAlignment="Top" HorizontalAlignment="Right" Padding="4" Margin="0 10 10 0" FontWeight="Bold" d:Text="Volume 50%" FontSize="14" Text="{Binding Tag.Msg}" Foreground="{DynamicResource MaterialDesign.Brush.Secondary}">
                            <TextBlock.Background>
                                <SolidColorBrush Color="{Binding Player.Config.Video.BackgroundColor}" Opacity="0.15"/>
                            </TextBlock.Background>
                            <TextBlock.Style>
                                <Style TargetType="{x:Type TextBlock}">
                                    <Setter Property="Visibility" Value="Visible"/>
                                    <Style.Triggers>
                                        <DataTrigger Binding="{Binding Player.Activity.Mode}" Value="Idle" d:Value="{x:Null}">
                                            <Setter Property="Visibility" Value="Collapsed"/>
                                        </DataTrigger>
                                        <Trigger Property="Text" Value="">
                                            <Setter Property="Visibility" Value="Collapsed"/>
                                        </Trigger>
                                    </Style.Triggers>
                                </Style>
                            </TextBlock.Style>
                        </TextBlock>

                        <!--Status-->
                        <TextBlock VerticalAlignment="Top" HorizontalAlignment="Right" Padding="4" Margin="0 -40 10 0" FontWeight="Bold" d:Text="Playing" FontSize="18" Text="{Binding Player.Status}" Foreground="{DynamicResource MaterialDesign.Brush.Secondary}">
                            <TextBlock.Background>
                                <SolidColorBrush Color="{Binding Player.Config.Video.BackgroundColor}" Opacity="0.15"/>
                            </TextBlock.Background>
                            <TextBlock.Style>
                                <Style TargetType="{x:Type TextBlock}">
                                    <Setter Property="Visibility" Value="Collapsed"/>
                                    <Style.Triggers>
                                        <DataTrigger Binding="{Binding Player.Activity.Mode}" Value="Active" d:Value="{x:Null}">
                                            <Setter Property="Visibility" Value="Visible"/>
                                        </DataTrigger>
                                    </Style.Triggers>
                                </Style>
                            </TextBlock.Style>
                        </TextBlock>

                        <!--Pop Up Dialog (Settings/Set Values)-->
                        <materialDesign:DialogHost x:Name="PART_DialogSettings" OverlayBackground="{x:Null}"/>

                        <!--Subtitles-->
                        <flwpf:OutlinedTextBlock Stroke="{Binding Player.Config.Video.BackgroundColor, Converter={StaticResource ColorToBrush}}" 
                         ClipToBounds="False"
                         Fill="{Binding UIConfig.SubsFontColor, Converter={StaticResource ColorToBrush}}"
                         StrokePosition="Outside"
                         StrokeThicknessInitial="{Binding UIConfig.SubsStrokeThickness}"
                         Margin="{Binding UIConfig.SubsMargin2}"
                         VerticalAlignment="Bottom"
                         HorizontalAlignment="Center"
                         TextAlignment="Center"
                         TextWrapping="Wrap"
                         FontFamily="{Binding UIConfig.SubsFontFamily}"
                         FontSizeInitial="{Binding UIConfig.SubsFontSize}"
                         FontWeight="{Binding UIConfig.SubsFontWeight}"
                         FontStyle="{Binding UIConfig.SubsFontStyle}"
                         Text="{Binding Player.Subtitles.SubsText}">
                        </flwpf:OutlinedTextBlock>

                        <!--Flyleaf Bar-->
                        <flwpf:FlyleafBar x:Name="FLBar" Player="{Binding Player}" Margin="-2 0 -2 0"/>
                    </Grid>

but in this new version (3.7.50) when I replace your custom Video View with <flwpf:FlyleafME x:Name="flyleafControl" Player="{Binding Player}"/> Settings Dialog and Popup Menu does not show. other feature works fine. in 3.7.28 version this problem does not exist. if you want, I can send you my project!!! To understand my problem better

HamidLaktarash commented 2 months ago

few days ago I debug your code and I find out FlyleafME.cs in Initialize() method:

popUpMenu       = ((FrameworkElement)Overlay.Template.FindName("PART_ContextMenuOwner", Overlay))?.ContextMenu;
dialogSettings  = (DialogHost)Overlay.Template.FindName("PART_DialogSettings", Overlay);

both variable evaluate with NULL Reason? I can`t understand

below code is your FlyleafME.xaml

<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
                    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
                    mc:Ignorable="d"

                    xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes"
                    xmlns:fl="clr-namespace:FlyleafLib.Controls.WPF;assembly=FlyleafLib"
                    xmlns:flwpf="clr-namespace:FlyleafLib.Controls.WPF">

    <Style x:Key="FlyleafMEDefault" TargetType="{x:Type flwpf:FlyleafME}" BasedOn="{StaticResource {x:Type fl:FlyleafHost}}">
        <Setter Property="KeyBindings" Value="Both"/>
        <Setter Property="OverlayTemplate">
            <Setter.Value>
                <ControlTemplate>
                    <Border>
                        <Border.Resources>
                            <ResourceDictionary>
                                <ResourceDictionary.MergedDictionaries>
                                    <ResourceDictionary Source="pack://application:,,,/FlyleafLib.Controls.WPF;component/Resources/MaterialDesign.xaml"/>
                                    <ResourceDictionary Source="pack://application:,,,/FlyleafLib.Controls.WPF;component/Resources/Converters.xaml"/>
                                    <ResourceDictionary Source="pack://application:,,,/FlyleafLib.Controls.WPF;component/Resources/PopUpMenu.xaml"/>
                                </ResourceDictionary.MergedDictionaries>
                            </ResourceDictionary>
                        </Border.Resources>
                        <Grid x:Name="PART_ContextMenuOwner" ContextMenu="{StaticResource PopUpMenu}">
                            <!--Pop Up Dialog (Settings/Set Values)-->
                            <materialDesign:DialogHost x:Name="PART_DialogSettings" OverlayBackground="{x:Null}"/>

                            <!--Debug Info-->
                            <fl:PlayerDebug VerticalAlignment="Center" HorizontalAlignment="Center" Player="{Binding Player}" BoxColor="#AA000000" HeaderColor="White" InfoColor="{DynamicResource MaterialDesign.Brush.Primary.Light}" ValueColor="{DynamicResource MaterialDesign.Brush.Secondary.Light}" Visibility="{Binding ShowDebug, Converter={StaticResource BooleanToVisibility}, FallbackValue=Collapsed, TargetNullValue=Collapsed}"/>

                            <!--Flyleaf Bar-->
                            <flwpf:FlyleafBar Player="{Binding Player}"/>
                        </Grid>
                    </Border>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

</ResourceDictionary>
HamidLaktarash commented 2 months ago

Hello bro. see reported bug in your own project: Please run Tests\FlyleafMultiPlayer (WPF) project Settings and popupMenu does not open. My Target RunTime is .NET6

SuRGeoNix commented 2 months ago

This caused by this commit https://github.com/SuRGeoNix/Flyleaf/commit/ca20c51a564c4f7dde0dc476f6761a131626e923 I will review this