﻿<common:PageBase
    x:Class="FeedbackApp.UIF.Views.NewIssuePage"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local="using:FeedbackApp.UIF.Views"
    xmlns:common="using:FeedbackApp.Common"
    xmlns:conv="using:FeedbackApp.Converters"
    x:Name="pageRoot"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    mc:Ignorable="d"
    xmlns:sampleData="using:FeedbackApp.UIF.SampleData"
    d:DataContext="{d:DesignInstance 
        Type=sampleData:MockNewFeedbackVM, 
        IsDesignTimeCreatable=True}">
    <common:PageBase.Resources>
        <ResourceDictionary>
            <ResourceDictionary.MergedDictionaries>
                <ResourceDictionary Source="UIFStyles.xaml"/>
            </ResourceDictionary.MergedDictionaries>
            <conv:ReverseEnumToVisibilityConverter x:Key="ReverseEnumToVisibilityConverter"/>
            <conv:EnumToVisibilityConverter x:Key="EnumToVisibilityConverter"/>
            <conv:BooleanToVisibilityConverter x:Key="BooleanToVisibilityConverter"/>
            <conv:LoadingStateToBooleanConverter x:Key="LoadingStateToBooleanConverter"/>
            <conv:LoadingStateToVisibilityConverter x:Key="LoadingStateToVisibilityConverter"/>

            <ResourceDictionary.ThemeDictionaries>
                <ResourceDictionary x:Key="Default">
                    <SolidColorBrush x:Key="MainBG" Color="White"/>
                </ResourceDictionary>
                <ResourceDictionary x:Key="HighContrast">
                    <SolidColorBrush x:Key="MainBG" Color="{ThemeResource SystemColorWindowColor}"/>
                </ResourceDictionary>
            </ResourceDictionary.ThemeDictionaries>

        </ResourceDictionary>
    </common:PageBase.Resources>
    <Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">

        <StackPanel Visibility="{Binding IsInRepro, Converter={StaticResource BooleanToVisibilityConverter}}"
                            VerticalAlignment="Center" HorizontalAlignment="Center" Canvas.ZIndex="2">
            <Border BorderThickness="1, 1, 1, 1" BorderBrush="#C4C4C4" Background="{ThemeResource MainBG}" Padding="15">
                <StackPanel Orientation="Vertical">
                    <TextBlock TextWrapping="Wrap" x:Uid="/FeedbackApp.Resources/UIF_Shared_ReproStopTextBoxLabel" HorizontalAlignment="Left" FontSize="14.667" Margin="0,5,0,20"
                            Text="Reproduce the Problem" Style="{StaticResource BaseTextBlockStyle}" />
                    <StackPanel Margin="0, 0, 0, 0" Orientation="Horizontal" HorizontalAlignment="Right">
                        <Button x:ConnectionId='3' x:Name="DoneReproButton" x:Uid="/FeedbackApp.Resources/UIF_ReproStopButton" Command="{Binding LaunchReproUICommand}"
                                Margin="0, 0, 0, 0" HorizontalAlignment="Left" VerticalAlignment="Center"                                 Content="DoneReproduce" Style="{StaticResource UIFButton}"/>
                        <Button x:ConnectionId='4' x:Name="CancelReproButton" x:Uid="/FeedbackApp.Resources/UIF_ReproCancelButton" Command="{Binding LaunchCancelReproCommand}"
                                Margin="10, 0, 0, 0" HorizontalAlignment="Left" VerticalAlignment="Center"                                   Content="CancelReproduce" Style="{StaticResource UIFButton}"/>
                    </StackPanel>
                </StackPanel>                  
            </Border>
        </StackPanel>

        <Grid>
            <Grid.ChildrenTransitions>
                <TransitionCollection>
                    <EntranceThemeTransition/>
                </TransitionCollection>
            </Grid.ChildrenTransitions>
            <Grid.RowDefinitions>
                <RowDefinition Height="Auto"/>
                <RowDefinition Height="Auto"/>
                <RowDefinition Height="*"/>
            </Grid.RowDefinitions>

            <!-- Error for combobox -->
            <Grid Style="{StaticResource ErrorBox}" Margin="0, -2, 0, 0" Grid.Row="0"
                            Visibility="{Binding DisplayComboBoxError,  Converter={StaticResource BooleanToVisibilityConverter}}" >
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="*"/>
                </Grid.ColumnDefinitions>
                <Grid.RowDefinitions>
                    <RowDefinition Height="Auto"/>
                </Grid.RowDefinitions>
                <TextBlock Style="{StaticResource ErrorLabel}"
                               x:Uid="/FeedbackApp.Resources/UIF_Shared_ComboBoxError"
                               Text="Error Message"
                               HorizontalAlignment="Left"
                               VerticalAlignment="Center"/>
            </Grid>
            
            <!-- Message for offline mode-->
            <Grid Style="{StaticResource ErrorBox}" Visibility="{Binding IsInOfflineMode,  Converter={StaticResource BooleanToVisibilityConverter}}"
                  Grid.Row="1">
                <TextBlock Style="{StaticResource ErrorLabel}"
                               x:Uid="/FeedbackApp.Resources/UIF_NewIssuePage_error_message"
                               Text="Sorry...we're not able to show you search results right now...but you can still send us new feedback."
                               HorizontalAlignment="Left"
                               VerticalAlignment="Center"/>
            </Grid>
            
            <ScrollViewer Grid.Row="2" VerticalScrollMode="Auto" Height="Auto">
                <Grid>

                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="1.5*"/>
                        <ColumnDefinition Width="7*"/>
                        <ColumnDefinition Width="1.5*"/>
                    </Grid.ColumnDefinitions>

                    <Grid Grid.Column="0" Grid.Row="0" Background="{ThemeResource GrayBG}">
                    </Grid>


                    <Frame Name="NewIssueControls" IsEnabled="True" Background="{ThemeResource GrayBG}" Grid.Column="1" Grid.Row="0">
                        <Frame.Resources>
                            <ResourceDictionary>
                                <ResourceDictionary.ThemeDictionaries>
                                    <ResourceDictionary x:Key="Default">
                                        <SolidColorBrush x:Key="SubmitBoxBG" Color="#C4C4C4"/>
                                        <SolidColorBrush x:Key="ArrowStroke" Color="White"/>
                                        <SolidColorBrush x:Key="MainBG" Color="White"/>
                                    </ResourceDictionary>
                                    <ResourceDictionary x:Key="HighContrast">
                                        <SolidColorBrush x:Key="SubmitBoxBG" Color="{ThemeResource SystemColorWindowColor}"/>
                                        <SolidColorBrush x:Key="ArrowStroke" Color="{ThemeResource SystemColorWindowColor}"/>
                                        <SolidColorBrush x:Key="MainBG" Color="{ThemeResource SystemColorWindowColor}"/>
                                    </ResourceDictionary>
                                </ResourceDictionary.ThemeDictionaries>
                            </ResourceDictionary>
                        </Frame.Resources>
                        <StackPanel>

			    <StackPanel MinHeight="45" Margin="0, 10, 0, 0">
                            <HyperlinkButton x:Name="backButton" Command="{Binding NavigationHelper.GoBackCommand, ElementName=pageRoot}"
                             x:Uid="/FeedbackApp.Resources/UIF_FeedbackPage_GoBackButton"
                             Foreground="{ThemeResource LinkColor}" FontWeight="Normal" 
                                             Style="{StaticResource TextBlockButtonStyle}" 
			     Visibility="{Binding IsInOfflineMode, Converter={StaticResource ReverseBooleanToVisibilityConverter}}"/>
			    </StackPanel>

                            <!-- Main Body -->
                            <StackPanel Background="{ThemeResource MainBG}" Margin="0, 0, 0, 30">
                                <Border BorderThickness="1, 1, 1, 0" BorderBrush="#C4C4C4">

                                    <StackPanel Margin="20, 10, 20, 20">
                                        <TextBlock x:Name="pageTitle" x:Uid="/FeedbackApp.Resources/UIF_NewIssuePage_Title" Style="{StaticResource PageHeaderPrefixText}" 
                                                VerticalAlignment="Bottom" Text="New feedback"  TextWrapping="NoWrap" TextTrimming="None" 
                                               FontSize="35" Foreground="{ThemeResource BlueTextColor}"/>

                                        <!-- Radio boxes Problem/Suggestion -->
                                        <StackPanel Margin="0,15,0,0" Orientation="Vertical">
                                            <TextBlock x:Uid="/FeedbackApp.Resources/UIF_Shared_SelectingFeedbackType" Text="This feedback is a"  Margin="0,0,0,10" Style="{StaticResource FeedbackSubTitle}"/>

                                            <StackPanel Orientation="Horizontal">
                                                <RadioButton x:Name="SuggestionButton" x:Uid="/FeedbackApp.Resources/UIF_Shared_SuggestionRadioButton" 
                                     GroupName="SelectionFeedbackTypeGroup" IsChecked="True" Margin="0, 0, 10, 0"/>
                                                <RadioButton x:Name="ProblemButton" x:Uid="/FeedbackApp.Resources/UIF_Shared_ProblemRadioButton" 
                                     GroupName="SelectionFeedbackTypeGroup" IsChecked="{Binding IsProblem, Mode=TwoWay}"/>
                                            </StackPanel>
                                        </StackPanel>


                                        <!-- Textbox -->
                                        <Grid Margin="0, 20, 0, 0" >
                                            <Grid.ColumnDefinitions>
                                                <ColumnDefinition Width="*"/>
                                                <ColumnDefinition Width="Auto"/>
                                            </Grid.ColumnDefinitions>
                                            
                                            <TextBox Text="{Binding Description, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" TextWrapping="Wrap" VerticalAlignment="Stretch" HorizontalAlignment="Stretch"
        		                                MaxHeight="500"	x:Uid="/FeedbackApp.Resources/UIF_NewIssuePage_UserDetails" AcceptsReturn="True" MinHeight="73" PlaceholderText="Give us more info?"
                                                     Grid.Column="0"/>
                                        </Grid>
                                        
                                        <TextBlock TextWrapping="Wrap" x:Uid="/FeedbackApp.Resources/UIF_NewIssuePage_FeedbackIsPublic" HorizontalAlignment="Right" FontSize="12" Margin="0,0,0,10" 
                                        Text="Note your comments are public" Style="{StaticResource BaseTextBlockStyle}" FontWeight="SemiLight" Foreground="#666666"/>

                                        <!-- Comboboxes -->
                                        <Grid>
                                            <Grid.RowDefinitions>
                                                <RowDefinition Height="Auto"/>
                                                <RowDefinition Height="Auto"/>
                                            </Grid.RowDefinitions>
                                            <TextBlock x:Uid="/FeedbackApp.Resources/UIF_NewIssuePage_CategorySelection" HorizontalAlignment="Left"
                                                   Style="{StaticResource FeedbackSubTitle}" Grid.Row="0"/>
                                            <StackPanel Margin="0, 10, 0, 0" Orientation="Horizontal" Grid.Row="1" x:Name="ComboStackPanel">
                                                <ComboBox ItemsSource="{Binding Areas}"
                                                  SelectedItem="{Binding SelectedAreaItem, Mode=TwoWay}"
                                                  DisplayMemberPath="Category.categoryName"
                                                  x:Name="L1CategoryCombo" MinWidth="200" Margin="0, 10, 15, 0"
                                                  Width="Auto" VerticalAlignment="Bottom" HorizontalAlignment="Left"
                                                  x:Uid="/FeedbackApp.Resources/UIF_NewIssuePage_select_category"
                                              ItemContainerStyle="{StaticResource ComboBoxItemStyle}" FontSize="13"/>

                                                <ComboBox ItemsSource="{Binding SelectedAreaItem.Features}" x:Name="L2CategoryCombo"
                                                          Width="Auto" VerticalAlignment="Bottom" HorizontalAlignment="Left" Margin="0, 10, 0, 0" MinWidth="200"
                                                          SelectedValue="{Binding FeatureItem, Mode=TwoWay}"
                                                          ItemContainerStyle="{StaticResource ComboBoxItemStyle}" FontSize="13"
                                                          x:Uid="/FeedbackApp.Resources/UIF_NewIssuePage_select_subcategory"
                                                          IsEnabled="{Binding IsSelectedAreaItemSelected, Mode=TwoWay}"/>
                                            </StackPanel>
                                        </Grid>


                                        <StackPanel Margin="0,20,0,0" Orientation="Vertical" Visibility="{Binding IsInternalUser, Converter={StaticResource BooleanToVisibilityConverter}}">
                                            <TextBlock x:Uid="/FeedbackApp.Resources/UIF_Shared_InternalOnly" Text="Internal Only" Margin="0,0,0,10" HorizontalAlignment="Left" 
                                             Style="{StaticResource FeedbackSubTitle}"/>
                                            <CheckBox x:Uid="/FeedbackApp.Resources/UIF_Shared_CheckBox_FeedbackIsBug" Content="Check here if the feedback is a bug"
                                            IsChecked="{Binding IsBug, Mode=TwoWay}" />
                                            <CheckBox x:Uid="/FeedbackApp.Resources/UIF_Shared_CheckBox_FeedbackIsLocIssue" Content="This is a text/localization issue"
                                            IsChecked="{Binding IsLocIssue, Mode=TwoWay}"/>
                                        </StackPanel>

                                        <StackPanel Margin="0, 0, 0, 0" Orientation="Vertical" Grid.Column="1" x:Name="UploadButtonStackPanel">
                                            <Button x:Uid="/FeedbackApp.Resources/UIF_AttachAFileButton"
                                                HorizontalAlignment="Left" VerticalAlignment="Center" Margin="0, 10, 0, 0" Command="{Binding AttachACaptureCommand}"/>
                                            <TextBlock TextWrapping="Wrap" x:Uid="/FeedbackApp.Resources/UIF_AttachAFileButtonLabel" HorizontalAlignment="Left" FontSize="12" Margin="4,0,0,10" 
                                                    Text="(500 MB limit)" Style="{StaticResource BaseTextBlockStyle}" FontWeight="SemiLight" Foreground="#666666"/>
                                        </StackPanel>

                                        <ItemsControl x:Name="UploadScreenshotItemsControl" ItemTemplate="{StaticResource UploadScreenshotItemTemplate}"
                                  ItemsSource="{Binding UploadScreenshots, Mode=TwoWay}"  ItemsPanel="{StaticResource ScreenshotsItemsPanel}" Margin="0,0,0,0"
                                                      Visibility="{Binding DeviceType, Converter={StaticResource EnumToVisibilityConverter}, ConverterParameter=Microsoft.Windows.Internal.Feedback.FeedbackDeviceFormFactors.Analog}"/>

                                        <Grid>
                                            <Grid.ColumnDefinitions>
                                                <ColumnDefinition Width="Auto"/>
                                                <ColumnDefinition Width="Auto"/>
                                            </Grid.ColumnDefinitions>
                                            <StackPanel Margin="0, 0, 0, 0" Orientation="Horizontal" Grid.Column="0" x:Name="ButtonStackPanel">
                                                <Button x:Uid="/FeedbackApp.Resources/UIF_ScreenshotButton" Command="{Binding LaunchScreenshotUICommand}"
                                                HorizontalAlignment="Left" VerticalAlignment="Center" Margin="0, 13, 0, 0" Visibility="{Binding IsInScreenShotMode, Converter={StaticResource ReverseBooleanToVisibilityConverter}}" Content="Screenshot"/>
                                            </StackPanel>
                                        </Grid>

                                        <ItemsControl x:Name="ScreenshotItemsControl" ItemTemplate="{StaticResource ScreenshotItemTemplate}"
                                  ItemsSource="{Binding Screenshots, Mode=TwoWay}"  ItemsPanel="{StaticResource ScreenshotsItemsPanel}" Margin="0,13,0,7"/>

                                        

                                        <StackPanel Margin="0,0,0,0" Orientation="Vertical" Visibility="{Binding IsReproProblem, Converter={StaticResource BooleanToVisibilityConverter}}"
                                                    x:Name="ReproStackPanel">
                                            <TextBlock TextWrapping="Wrap" x:Uid="/FeedbackApp.Resources/UIF_Shared_ReproProblemTextBoxLabel" HorizontalAlignment="Left" FontSize="14.667" Margin="0,5,0,10" 
                                               Text="Reproduce the Problem" Style="{StaticResource BaseTextBlockStyle}" FontWeight="Normal"/>                                      
                                            <Button x:ConnectionId='2' x:Name="ReproButton" x:Uid="/FeedbackApp.Resources/UIF_ReproStartButton" Command="{Binding LaunchReproUICommand}"
                                               HorizontalAlignment="Left" VerticalAlignment="Center"                             Content="Reproduce" />
                                        </StackPanel>

                                        <Grid Margin="0,13,0,0" Visibility="{Binding IsTraceFileCollected, Converter={StaticResource BooleanToVisibilityConverter}}" HorizontalAlignment="Left">
                                            <Image Source="/Assets/Folder.png" Stretch="Fill" Height="100" Width="80"  VerticalAlignment="Top" HorizontalAlignment="Right"/>
                                            <Button x:ConnectionId='1' x:Name="DeleteTraceButton" Command="{Binding DeleteTraceCommand}" Height="40" Width="40" Padding="-20, 0, -20, 0"
                                                                                      Background="Transparent" HorizontalAlignment="Right" VerticalAlignment="Top" Margin="-7"
                                                    x:Uid="/FeedbackApp.Resources/UIF_Shared_DeleteButton">
                                                <Image Source="/Assets/Close.png" VerticalAlignment="Center" HorizontalAlignment="Center" 
                                                       Stretch="Fill" Height="55" Width="55"/>
                                            </Button>                                           
                                        </Grid>
                                    </StackPanel>


                                </Border>

                                <Border BorderThickness="1, 0, 1, 1" BorderBrush="#C4C4C4">
                                    <Grid Background="{ThemeResource SubmitBoxBG}" Height="80">
                                        <Polygon Points="0,0 15,15, 30,0" Stroke="{ThemeResource ArrowStroke}" Fill="{ThemeResource ArrowStroke}" HorizontalAlignment="Center"/>
                                        <Button Command="{Binding SubmitFeedbackCommand}" CommandParameter="{StaticResource FalseBoolean}"
        					                  x:Uid="/FeedbackApp.Resources/UIF_NewIssuePage_Submit" HorizontalAlignment="Center" VerticalAlignment="Center" 
        					                  IsEnabled="{Binding SubmitState, ConverterParameter=NotLoading, Converter={StaticResource LoadingStateToBooleanConverter}}"
        					                  Margin="0" Content="Submit" MinWidth="100" Width="Auto" Style="{StaticResource UIFButton}" MinHeight="40"/>
                                        <StackPanel Orientation="Horizontal" HorizontalAlignment="Left" VerticalAlignment="Center" Margin="10,0,0,0"
        					                      Visibility="{Binding SubmitState, ConverterParameter=Loading, Converter={StaticResource LoadingStateToVisibilityConverter}}">
                                            <ProgressRing HorizontalAlignment="Left"
        						                          VerticalAlignment="Center"
        						                          IsActive="{Binding SubmitState, ConverterParameter=Loading, Converter={StaticResource LoadingStateToBooleanConverter}}" />
                                            <TextBlock x:Uid="/FeedbackApp.Resources/UIF_Shared_SubmitLoadingText" Margin="5,3,5,0" FontSize="14.667" VerticalAlignment="Bottom"
        						                       Text="Sending"/>
                                        </StackPanel>
                                    </Grid>
                                </Border>

                            </StackPanel>
                        </StackPanel>
                    </Frame>

                    <Grid Grid.Column="2" Grid.Row="0" Background="{ThemeResource GrayBG}">

                    </Grid>
                </Grid>



            </ScrollViewer>

        </Grid>

    </Grid>

</common:PageBase>

