<Page
    x:Class="Microsoft.PowerToys.Settings.UI.Views.VideoConferencePage"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:controls="using:Microsoft.PowerToys.Settings.UI.Controls"
    xmlns:converters="using:Microsoft.Toolkit.Uwp.UI.Converters" 
    xmlns:muxc="using:Microsoft.UI.Xaml.Controls"
    mc:Ignorable="d">

    <Page.Resources>
        <converters:StringVisibilityConverter x:Name="EmptyToCollapsedConverter" EmptyValue="Collapsed" NotEmptyValue="Visible"/>
        <converters:BoolToObjectConverter x:Key="BoolToVisibilityConverter" TrueValue="Collapsed" FalseValue="Visible"/>
    </Page.Resources>
    
    <controls:SettingsPageControl x:Uid="VideoConference"
                                  ModuleImageSource="ms-appx:///Assets/Modules/VideoConference.png">
        <controls:SettingsPageControl.ModuleContent>

            <StackPanel Orientation="Vertical">
            
                <controls:Setting x:Uid="VideoConference_Enable" IsEnabled="{ Binding Mode=OneWay, Path=IsElevated }">
                    <controls:Setting.Icon>
                        <BitmapIcon UriSource="ms-appx:///Assets/FluentIcons/FluentIconsVideoConferenceMute.png" ShowAsMonochrome="False" />
                    </controls:Setting.Icon>
                    <controls:Setting.ActionContent>
                        <ToggleSwitch IsOn="{Binding Mode=TwoWay, Path=IsEnabled}" x:Uid="ToggleSwitch"/>
                    </controls:Setting.ActionContent>
                </controls:Setting>
                <muxc:InfoBar
                    Severity="Warning"
                    x:Uid="VideoConference_RunAsAdminRequired"
                    IsOpen="True"
                    IsTabStop="True"
                    IsClosable="False"
                    Visibility="{Binding Mode=OneWay, Path=IsElevated, Converter={StaticResource BoolToVisibilityConverter}}" />
                
                <controls:SettingsGroup x:Uid="VideoConference_Shortcuts" IsEnabled="{Binding Mode=OneWay, Path=IsEnabled}">
                    <controls:Setting x:Uid="VideoConference_CameraAndMicrophoneMuteHotkeyControl_Header">
                        <controls:Setting.ActionContent>
                            <controls:ShortcutControl HotkeySettings="{x:Bind Path=ViewModel.CameraAndMicrophoneMuteHotkey, Mode=TwoWay}"
                                                            MinWidth="{StaticResource SettingActionControlMinWidth}"/>
                        </controls:Setting.ActionContent>
                    </controls:Setting>

                    <controls:Setting x:Uid="VideoConference_MicrophoneMuteHotkeyControl_Header">
                        <controls:Setting.ActionContent>
                            <controls:ShortcutControl HotkeySettings="{x:Bind Path=ViewModel.MicrophoneMuteHotkey, Mode=TwoWay}"
                                                      MinWidth="{StaticResource SettingActionControlMinWidth}"/>
                        </controls:Setting.ActionContent>
                    </controls:Setting>

                    <controls:Setting x:Uid="VideoConference_CameraMuteHotkeyControl_Header">
                        <controls:Setting.ActionContent>
                            <controls:ShortcutControl HotkeySettings="{x:Bind Path=ViewModel.CameraMuteHotkey, Mode=TwoWay}"
                                                      MinWidth="{StaticResource SettingActionControlMinWidth}"/>
                        </controls:Setting.ActionContent>
                    </controls:Setting>

                </controls:SettingsGroup>

                <controls:SettingsGroup x:Uid="VideoConference_Microphone" IsEnabled="{Binding Mode=OneWay, Path=IsEnabled}">

                    <controls:Setting x:Uid="VideoConference_SelectedMicrophone" Icon="&#xE720;">
                        <controls:Setting.ActionContent>
                            <ComboBox MinWidth="{StaticResource SettingActionControlMinWidth}"
                                      SelectedIndex="{Binding Path=SelectedMicrophoneIndex, Mode=TwoWay}"
                                      ItemsSource="{Binding MicrophoneNames, Mode=OneTime}"/>
                        </controls:Setting.ActionContent>
                    </controls:Setting>
                </controls:SettingsGroup>


                <controls:SettingsGroup x:Uid="VideoConference_Camera" IsEnabled="{Binding Mode=OneWay, Path=IsEnabled}">

                    <controls:SettingExpander IsExpanded="True">
                        <controls:SettingExpander.Header>
                            <controls:Setting x:Uid="VideoConference_SelectedCamera" Icon="&#xE960;">
                                <controls:Setting.ActionContent>
                                    <ComboBox MinWidth="{StaticResource SettingActionControlMinWidth}"
                                              SelectedIndex="{Binding Path=SelectedCameraIndex, Mode=TwoWay}"
                                              ItemsSource="{Binding CameraNames, Mode=OneTime}"
                                              IsEnabled="{ Binding Mode=TwoWay, Path=IsEnabled}"/>
                                </controls:Setting.ActionContent>
                            </controls:Setting>
                        </controls:SettingExpander.Header>
                        <controls:SettingExpander.Content>
                            <StackPanel Orientation="Vertical">
                                <controls:Setting x:Uid="VideoConference_CameraOverlayImagePathHeader" Style="{StaticResource ExpanderContentSettingStyle}">
                                    <controls:Setting.ActionContent>
                                        <StackPanel Orientation="Vertical">
                                            <StackPanel Orientation="Horizontal" HorizontalAlignment="Right">
                                                <Button x:Uid="VideoConference_CameraOverlayImageBrowse"
                                                        Command="{Binding Mode=OneWay, Path=SelectOverlayImage}" />

                                                <Button x:Uid="VideoConference_CameraOverlayImageClear"
                                                        Margin="8,0,0,0"
                                                        Visibility="{Binding Path=CameraImageOverlayPath, Mode=OneWay, Converter={StaticResource EmptyToCollapsedConverter}}"
                                                        Command="{Binding Mode=OneWay, Path=ClearOverlayImage}"/>
                                                                    
                                            </StackPanel>
                                          
                                        </StackPanel>
                                    </controls:Setting.ActionContent>
                                </controls:Setting>
                                <Border CornerRadius="4" Visibility="{Binding Path=CameraImageOverlayPath, Mode=OneWay, Converter={StaticResource EmptyToCollapsedConverter}}" Margin="56, 8, 40, 20" HorizontalAlignment="Right" MaxHeight="100">
                                    <Image x:Uid="VideoConference_CameraOverlayImageAlt"
                                           ToolTipService.ToolTip="{Binding Mode=OneWay, Path=CameraImageOverlayPath}"
                                           Source="{Binding Mode=OneWay, Path=CameraImageOverlayPath}"/>
                                </Border>
                            </StackPanel>
                        </controls:SettingExpander.Content>
                    </controls:SettingExpander>

                </controls:SettingsGroup>




                <controls:SettingsGroup x:Uid="VideoConference_Toolbar" IsEnabled="{Binding Mode=OneWay, Path=IsEnabled}">

                    <controls:SettingExpander IsExpanded="True">
                        <controls:SettingExpander.Header>
                            <controls:Setting x:Uid="VideoConference_ToolbarPosition" Icon="&#xEC12;">
                                <controls:Setting.ActionContent>
                                    <ComboBox MinWidth="{StaticResource SettingActionControlMinWidth}" SelectedIndex="{ Binding Mode=TwoWay, Path=ToolbarPostionIndex}">
                                        <ComboBoxItem x:Uid="VideoConference_ToolbarPosition_TopLeftCorner"/>
                                        <ComboBoxItem x:Uid="VideoConference_ToolbarPosition_TopCenter"/>
                                        <ComboBoxItem x:Uid="VideoConference_ToolbarPosition_TopRightCorner"/>
                                        <ComboBoxItem x:Uid="VideoConference_ToolbarPosition_BottomLeftCorner"/>
                                        <ComboBoxItem x:Uid="VideoConference_ToolbarPosition_BottomCenter"/>
                                        <ComboBoxItem x:Uid="VideoConference_ToolbarPosition_BottomRightCorner"/>
                                    </ComboBox>
                                </controls:Setting.ActionContent>
                            </controls:Setting>
                        </controls:SettingExpander.Header>
                        <controls:SettingExpander.Content>
                            <StackPanel Orientation="Vertical">
                                <controls:Setting x:Uid="VideoConference_ToolbarMonitor" Style="{StaticResource ExpanderContentSettingStyle}">
                                    <controls:Setting.ActionContent>
                                        <ComboBox MinWidth="{StaticResource SettingActionControlMinWidth}" SelectedIndex="{ Binding Mode=TwoWay, Path=ToolbarMonitorIndex}">
                                            <ComboBoxItem x:Uid="VideoConference_ToolbarMonitor_Main"/>
                                            <ComboBoxItem x:Uid="VideoConference_ToolbarMonitor_All"/>
                                        </ComboBox>
                                    </controls:Setting.ActionContent>
                                </controls:Setting>
                                <Rectangle Style="{StaticResource ExpanderSeparatorStyle}" />

                                <CheckBox x:Uid="VideoConference_HideToolbarWhenUnmuted" IsChecked="{x:Bind Mode=TwoWay, Path=ViewModel.HideToolbarWhenUnmuted}" Margin="{StaticResource ExpanderSettingMargin}" />
                            </StackPanel>
                        </controls:SettingExpander.Content>
                    </controls:SettingExpander>

                </controls:SettingsGroup>
            </StackPanel>
        </controls:SettingsPageControl.ModuleContent>

        <controls:SettingsPageControl.PrimaryLinks>
            <controls:PageLink x:Uid="LearnMore_VCM" Link="https://aka.ms/PowerToysOverview_VideoConference"/>
        </controls:SettingsPageControl.PrimaryLinks>
    </controls:SettingsPageControl>
</Page>
