Source

main / Source / Excel / Excel.AddIn / Excel.AddIn / View / Usercontrols / GetIdentifierControl.xaml

<UserControl
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:local="clr-namespace:DataUp.Excel.Addin"
    mc:Ignorable="d"
    x:Class="DataUp.Excel.Addin.GetIdentifierControl"
    x:Name="UserControl"
    d:DesignWidth="640" d:DesignHeight="450" Width="350" MinHeight="290" MaxHeight="450">

    <UserControl.Resources>
        <ResourceDictionary>
            <ResourceDictionary.MergedDictionaries>
                <ResourceDictionary Source="../../Resources/Styles.xaml"/>
            </ResourceDictionary.MergedDictionaries>
            <BooleanToVisibilityConverter x:Key="VisibilityConverter"></BooleanToVisibilityConverter>
        </ResourceDictionary>
    </UserControl.Resources>

    <Grid x:Name="LayoutRoot" >
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="*"/>
            <RowDefinition Height="Auto"/>
        </Grid.RowDefinitions>
        <TextBlock Text="Get Identifier" Style="{DynamicResource DescriptionTextStyle}" Margin="10,5,10,0" Foreground="{DynamicResource LabelForeground}"/>
        <StackPanel Grid.Row="1" Margin="{DynamicResource ControlMargin}" HorizontalAlignment="Left">
            <StackPanel Style="{DynamicResource StackItemPanel}" Orientation="Vertical" >
                <TextBlock Text="Repository Name" Style="{DynamicResource LabelStyle}" HorizontalAlignment="Left">
                    <Run Text="*" Style="{DynamicResource RunLabelErrorStyle}"/>
                </TextBlock>
                <StackPanel Orientation="Horizontal">
                    <ComboBox ItemsSource="{Binding RepositoryList}" DisplayMemberPath="RepositoryName"
                              SelectedItem="{Binding RepositoryDetailsViewModel, Mode=TwoWay, ValidatesOnDataErrors=True, NotifyOnValidationError=True}"
                              x:Name="comboBoxRepositories" Style="{DynamicResource MetroCombobox}" Margin="{DynamicResource VerticaltopMargin}"/>

                    <ContentControl IsEnabled="{Binding ElementName=comboBoxRepositories,Path=(Validation.HasError),Mode=OneWay}" 
                                Style="{DynamicResource ErrorContentControl}" Content="{Binding ElementName=comboBoxRepositories ,Path=(Validation.Errors).CurrentItem.ErrorContent}"/>
                </StackPanel>
            </StackPanel>

            <StackPanel Style="{DynamicResource StackItemPanel}" Orientation="Vertical" Visibility="{Binding RepositoryDetailsViewModel.IsPasswordRequired, Converter={StaticResource VisibilityConverter}}">
                <TextBlock Text="Username" Style="{DynamicResource LabelStyle}" HorizontalAlignment="Left">
                    <Run Text="*" Style="{DynamicResource RunLabelErrorStyle}"/>
                </TextBlock>
                <StackPanel Orientation="Horizontal">
                    <TextBox x:Name="txtUserName" Text="{Binding RepositoryDetailsViewModel.UserName, Mode=TwoWay, UpdateSourceTrigger=LostFocus, ValidatesOnDataErrors=True, NotifyOnValidationError=True}"
                         Style="{DynamicResource TextBoxStyle}" Margin="{DynamicResource VerticaltopMargin}" />
                    <ContentControl IsEnabled="{Binding ElementName=txtUserName,Path=(Validation.HasError),Mode=OneWay}" 
                                Style="{DynamicResource ErrorContentControl}" Content="{Binding ElementName=txtUserName ,Path=(Validation.Errors).CurrentItem.ErrorContent}"/>
                </StackPanel>
            </StackPanel>
            <StackPanel Style="{DynamicResource StackItemPanel}" Orientation="Vertical" Visibility="{Binding RepositoryDetailsViewModel.IsPasswordRequired, Converter={StaticResource VisibilityConverter}}">
                <TextBlock Text="password" Style="{DynamicResource LabelStyle}" HorizontalAlignment="Left">
                    <Run Text="*" Style="{DynamicResource RunLabelErrorStyle}"/>
                </TextBlock>
                <StackPanel Orientation="Horizontal">
                    <PasswordBox x:Name="txtPassword" Style="{DynamicResource PasswordBoxStyle}" Margin="{DynamicResource VerticaltopMargin}"
                             local:PasswordHelper.BindPassword="true"
                             local:PasswordHelper.BoundPassword="{Binding Path=RepositoryDetailsViewModel.UserPassword, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged, ValidatesOnDataErrors=True, NotifyOnValidationError=True}" />
                    <ContentControl IsEnabled="{Binding ElementName=txtPassword,Path=(Validation.HasError),Mode=OneWay}" 
                                Style="{DynamicResource ErrorContentControl}" Content="{Binding ElementName=txtPassword ,Path=(Validation.Errors).CurrentItem.ErrorContent}"/>
                </StackPanel>
            </StackPanel>

            <StackPanel Style="{DynamicResource StackItemPanel}" Orientation="Horizontal" >
                <CheckBox Content="I accept" IsChecked="{Binding RepositoryDetailsViewModel.IsAgreementAccepted, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" />

                <Button Style="{DynamicResource HyperlinkButton}" Margin="2,5,0,0" Content="User Agreement" Command="{Binding RepositoryDetailsViewModel.GetUserAgreementCommand}"/>
            </StackPanel>
            <Border Margin="0,5" CornerRadius="4" BorderBrush="#FFe7e7e7" Background="White" BorderThickness="1" MaxHeight="75" SnapsToDevicePixels="True" Visibility="{Binding RepositoryDetailsViewModel.ShowUserAgreement, Converter={StaticResource VisibilityConverter}}">
                <ScrollViewer ScrollViewer.HorizontalScrollBarVisibility="Disabled" ScrollViewer.VerticalScrollBarVisibility="Auto" >
                    <TextBlock Margin="3" FontSize="12" Style="{DynamicResource AutoLabelStyle}" Text="{Binding RepositoryDetailsViewModel.UserAgreement}" TextWrapping="Wrap" />
                </ScrollViewer>
            </Border>

            <TextBlock Text="{Binding ErrorMessage}" Style="{DynamicResource ErrorLabelStyle}" 
                       Visibility="{Binding ShowError, Converter={StaticResource VisibilityConverter}}"/>
        </StackPanel>
        <StackPanel  Grid.Row="2" Style="{DynamicResource ButtonContainer}" >
            <Button Content="OK" Style="{DynamicResource GreenButton}" Command="{Binding GetIdentifierCommand}"/>
            <Button Content="CANCEL" Style="{DynamicResource GrayButton}" Command="{Binding CancelCommand}"/>
        </StackPanel>
    </Grid>
</UserControl>