<Window
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local="clr-namespace:NFe.AppTeste"
    xmlns:nfeclservicostipos="clr-namespace:NFe.Classes.Servicos.Tipos;assembly=NFe.Classes"
    xmlns:nfeclsidetipos="clr-namespace:NFe.Classes.Informacoes.Identificacao.Tipos;assembly=NFe.Classes"
    xmlns:nfceemit="clr-namespace:NFe.Classes.Informacoes.Emitente;assembly=NFe.Classes"
    xmlns:sys="clr-namespace:System;assembly=mscorlib"
    xmlns:scm="clr-namespace:System.ComponentModel;assembly=WindowsBase"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:net="clr-namespace:System.Net;assembly=System"
    xmlns:entidades="clr-namespace:DFe.Classes.Entidades;assembly=DFe.Classes"
    xmlns:flags="clr-namespace:DFe.Classes.Flags;assembly=DFe.Classes"
    xmlns:utils="clr-namespace:DFe.Utils;assembly=DFe.Utils"
    mc:Ignorable="d"
    x:Class="NFe.AppTeste.MainWindow"
    Title="Zeus Automação - Exemplo de uso da biblioteca de NFe/NFC-e" Height="800" Width="1094.789"
    WindowStartupLocation="CenterScreen"
    d:DataContext="{d:DesignInstance {x:Type local:ConfiguracaoApp}, IsDesignTimeCreatable=True}">
    <Window.Resources>
        <local:EnumParaBool x:Key="EnumParaBool" />
        <CollectionViewSource x:Key="EstadosWebService">
            <!--Coleção para ordernar o Enum que poderá ser usado em combos, listboxes, etc-->
            <CollectionViewSource.SortDescriptions>
                <scm:SortDescription />
            </CollectionViewSource.SortDescriptions>
            <CollectionViewSource.Source>
                <ObjectDataProvider
                    MethodName="GetValues"
                    ObjectType="{x:Type sys:Enum}">
                    <ObjectDataProvider.MethodParameters>
                        <x:Type TypeName="entidades:Estado" />
                    </ObjectDataProvider.MethodParameters>
                </ObjectDataProvider>
            </CollectionViewSource.Source>
        </CollectionViewSource>

        <CollectionViewSource x:Key="EstadosEmitente">
            <!--Coleção para ordernar o Enum que poderá ser usado em combos, listboxes, etc-->
            <CollectionViewSource.SortDescriptions>
                <scm:SortDescription />
            </CollectionViewSource.SortDescriptions>
            <CollectionViewSource.Source>
                <ObjectDataProvider
                    MethodName="GetNames"
                    ObjectType="{x:Type sys:Enum}">
                    <ObjectDataProvider.MethodParameters>
                        <x:Type TypeName="entidades:Estado" />
                    </ObjectDataProvider.MethodParameters>
                </ObjectDataProvider>
            </CollectionViewSource.Source>
        </CollectionViewSource>

        <CollectionViewSource x:Key="Crts">
            <!--Coleção para ordernar o Enum que poderá ser usado em combos, listboxes, etc-->
            <CollectionViewSource.Source>
                <ObjectDataProvider
                    MethodName="GetValues"
                    ObjectType="{x:Type sys:Enum}">
                    <ObjectDataProvider.MethodParameters>
                        <x:Type TypeName="nfceemit:CRT" />
                    </ObjectDataProvider.MethodParameters>
                </ObjectDataProvider>
            </CollectionViewSource.Source>
        </CollectionViewSource>
    </Window.Resources>
    <Grid>
        <GroupBox Header="Configurações" HorizontalAlignment="Left" Width="500" Margin="1,0,0,0">
            <StackPanel HorizontalAlignment="Left" Margin="0,10,-2,-12" Width="490" VerticalAlignment="Top">
                <TabControl VerticalAlignment="Top" Height="700">
                    <TabItem Header="Certificado">
                        <Grid Background="White">
                            <GroupBox Header="Certificado" HorizontalAlignment="Left" VerticalAlignment="Top"
                                      Width="450" Margin="0,10,0,0" Height="384">
                                <StackPanel>
                                    <StackPanel.Resources>
                                        <Style x:Key="TextBoxErro" TargetType="TextBox">
                                            <Style.Triggers>
                                                <Trigger Property="Validation.HasError" Value="true">
                                                    <Setter Property="ToolTip"
                                                            Value="{Binding RelativeSource={x:Static RelativeSource.Self}, Path=(Validation.Errors)[0].ErrorContent}" />
                                                </Trigger>
                                            </Style.Triggers>
                                        </Style>
                                    </StackPanel.Resources>

                                    <StackPanel Name="SpTipoCertificado" Margin="0,10,0,0">
                                        <Grid Height="75">
                                            <Label Content="Tipo do certificado:" HorizontalAlignment="Left"
                                                   Margin="1,0,0,0" />
                                            <StackPanel Orientation="Vertical"
                                                        Margin="120,6,0,5"
                                                        VerticalAlignment="Stretch"
                                                        HorizontalAlignment="Stretch">
                                                <RadioButton GroupName="TipoCertificado" Content="A1"
                                                             HorizontalAlignment="Left"
                                                             VerticalAlignment="Center"
                                                             IsChecked="{Binding CfgServico.Certificado.TipoCertificado, ConverterParameter={x:Static utils:TipoCertificado.A1Repositorio}, Converter={StaticResource EnumParaBool}, 
                                                                 NotifyOnValidationError=True, ValidatesOnDataErrors=True}" />
                                                <RadioButton GroupName="TipoCertificado" Content="A1 em arquivo"
                                                             HorizontalAlignment="Left"
                                                             VerticalAlignment="Center"
                                                             IsChecked="{Binding CfgServico.Certificado.TipoCertificado, ConverterParameter={x:Static utils:TipoCertificado.A1Arquivo}, Converter={StaticResource EnumParaBool}, 
                                                                 NotifyOnValidationError=True, ValidatesOnDataErrors=True}" />
                                                <RadioButton GroupName="TipoCertificado"
                                                             Content="A1 array de bytes do arquivo"
                                                             HorizontalAlignment="Left"
                                                             VerticalAlignment="Center"
                                                             IsChecked="{Binding CfgServico.Certificado.TipoCertificado, ConverterParameter={x:Static utils:TipoCertificado.A1ByteArray}, Converter={StaticResource EnumParaBool}, 
                                                                 NotifyOnValidationError=True, ValidatesOnDataErrors=True}" />
                                                <RadioButton GroupName="TipoCertificado" Content="A3"
                                                             HorizontalAlignment="Left"
                                                             VerticalAlignment="Center"
                                                             IsChecked="{Binding CfgServico.Certificado.TipoCertificado, ConverterParameter={x:Static utils:TipoCertificado.A3}, Converter={StaticResource EnumParaBool}, 
                                                                 NotifyOnValidationError=True, ValidatesOnDataErrors=True}" />
                                            </StackPanel>

                                        </Grid>
                                    </StackPanel>

                                    <StackPanel Name="SpSerie" Margin="0,10,0,0">
                                        <TextBlock Text="Número de Série" HorizontalAlignment="Left" Margin="10,0,0,0" />
                                        <StackPanel Orientation="Horizontal">
                                            <TextBox x:Name="TxtCertificado" HorizontalAlignment="Left" Height="23"
                                                     Margin="10,0,0,0" TextWrapping="Wrap" VerticalAlignment="Top"
                                                     Width="390"
                                                     Style="{StaticResource TextBoxErro}"
                                                     Text="{Binding CfgServico.Certificado.Serial, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged, ValidatesOnExceptions=True, ValidatesOnDataErrors=True, NotifyOnValidationError=True}" />
                                            <Button x:Name="BtnCertificado" Content="..." Width="21"
                                                    DockPanel.Dock="Right" Click="btnCertificado_Click"
                                                    Margin="10,0,0,0" />
                                        </StackPanel>
                                    </StackPanel>

                                    <StackPanel Name="SpArquivo" Margin="0,10,0,0">
                                        <TextBlock Text="Arquivo" HorizontalAlignment="Left" Margin="10,0,0,0" />
                                        <StackPanel Orientation="Horizontal">
                                            <TextBox x:Name="TxtArquivoCertificado" HorizontalAlignment="Left"
                                                     Height="23"
                                                     Margin="10,0,0,0" TextWrapping="Wrap" VerticalAlignment="Top"
                                                     Width="390"
                                                     Style="{StaticResource TextBoxErro}" />
                                            <Button x:Name="BtnArquivoCertificado" Content="..." Width="21"
                                                    DockPanel.Dock="Right" Margin="10,0,0,0"
                                                    Click="BtnArquivoCertificado_Click" />
                                        </StackPanel>
                                    </StackPanel>

                                    <StackPanel Margin="0,10,0,0">
                                        <TextBlock Text="Senha" HorizontalAlignment="Left" Margin="10,0,0,0" />
                                        <StackPanel Orientation="Horizontal">
                                            <TextBox x:Name="TxtSenhaCertificado" HorizontalAlignment="Left"
                                                     Height="23"
                                                     Margin="10,0,0,0" TextWrapping="Wrap" VerticalAlignment="Top"
                                                     Width="280"
                                                     Style="{StaticResource TextBoxErro}"
                                                     Text="{Binding CfgServico.Certificado.Senha, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged, ValidatesOnExceptions=True, ValidatesOnDataErrors=True, NotifyOnValidationError=True}" />
                                        </StackPanel>
                                    </StackPanel>

                                    <StackPanel Margin="0,10,0,0">
                                        <CheckBox Name="CbxManterDadosCert" Content="Manter certificado em cache"
                                                  HorizontalAlignment="Left"
                                                  VerticalAlignment="Top" Width="178"
                                                  IsChecked="{Binding CfgServico.Certificado.ManterDadosEmCache}"
                                                  Margin="10,0,0,0" />
                                    </StackPanel>
                                </StackPanel>
                            </GroupBox>
                        </Grid>
                    </TabItem>
                    <TabItem Header="Geral">
                        <Grid Background="White">
                            <StackPanel>
                                <GroupBox Header="Forma de Emissão" HorizontalAlignment="Left"
                                          VerticalAlignment="Top" Height="153" Margin="0,10,0,0">
                                    <Grid>
                                        <RadioButton Content="Normal" HorizontalAlignment="Left"
                                                     VerticalAlignment="Top" Margin="10,10,0,0"
                                                     IsChecked="{Binding CfgServico.tpEmis, ConverterParameter={x:Static nfeclsidetipos:TipoEmissao.teNormal}, Converter={StaticResource EnumParaBool}}" />
                                        <RadioButton Content="FSIA" HorizontalAlignment="Left"
                                                     VerticalAlignment="Top" Margin="139,10,0,0"
                                                     RenderTransformOrigin="0.118,0.6"
                                                     IsChecked="{Binding CfgServico.tpEmis, ConverterParameter={x:Static nfeclsidetipos:TipoEmissao.teFSIA}, Converter={StaticResource EnumParaBool}}" />
                                        <RadioButton Content="SCAN" HorizontalAlignment="Left"
                                                     VerticalAlignment="Top" Margin="10,40,0,0"
                                                     IsChecked="{Binding CfgServico.tpEmis, ConverterParameter={x:Static nfeclsidetipos:TipoEmissao.teSCAN}, Converter={StaticResource EnumParaBool}}"
                                                     IsEnabled="False" />
                                        <RadioButton Content="EPEC" HorizontalAlignment="Left"
                                                     VerticalAlignment="Top" Margin="139,40,0,0"
                                                     RenderTransformOrigin="0.118,0.6"
                                                     IsChecked="{Binding CfgServico.tpEmis, ConverterParameter={x:Static nfeclsidetipos:TipoEmissao.teEPEC}, Converter={StaticResource EnumParaBool}}" />
                                        <RadioButton Content="FSDA" HorizontalAlignment="Left"
                                                     VerticalAlignment="Top" Margin="10,70,0,0"
                                                     IsChecked="{Binding CfgServico.tpEmis, ConverterParameter={x:Static nfeclsidetipos:TipoEmissao.teFSDA}, Converter={StaticResource EnumParaBool}}" />
                                        <RadioButton Content="SVC-AN" HorizontalAlignment="Left"
                                                     VerticalAlignment="Top" Margin="139,70,0,0"
                                                     RenderTransformOrigin="0.118,0.6"
                                                     IsChecked="{Binding CfgServico.tpEmis, ConverterParameter={x:Static nfeclsidetipos:TipoEmissao.teSVCAN}, Converter={StaticResource EnumParaBool}}" />
                                        <RadioButton Content="SVC-RS" HorizontalAlignment="Left"
                                                     VerticalAlignment="Top" Margin="10,100,0,0"
                                                     IsChecked="{Binding CfgServico.tpEmis, ConverterParameter={x:Static nfeclsidetipos:TipoEmissao.teSVCRS}, Converter={StaticResource EnumParaBool}}" />
                                        <RadioButton Content="NFC-e OffLine" HorizontalAlignment="Left"
                                                     VerticalAlignment="Top" Margin="139,100,0,0"
                                                     RenderTransformOrigin="0.118,0.6"
                                                     IsChecked="{Binding CfgServico.tpEmis, ConverterParameter={x:Static nfeclsidetipos:TipoEmissao.teOffLine}, Converter={StaticResource EnumParaBool}}" />
                                    </Grid>
                                </GroupBox>

                                <GroupBox x:Name="GpbModeloDocumento" Header="Selecione o Tipo de Documento"
                                          Height="60" Margin="0,0,10,0">
                                    <Grid x:Name="GrdModeloDocumento">
                                        <Grid.ColumnDefinitions>
                                            <ColumnDefinition Width="150"></ColumnDefinition>
                                            <ColumnDefinition Width="*"></ColumnDefinition>
                                        </Grid.ColumnDefinitions>
                                        <RadioButton Grid.Column="0" x:Name="RbtNfe" Content="NFe"
                                                     HorizontalAlignment="Left" VerticalAlignment="Center"
                                                     IsChecked="{Binding CfgServico.ModeloDocumento, ConverterParameter={x:Static flags:ModeloDocumento.NFe}, Converter={StaticResource EnumParaBool}}" />
                                        <RadioButton Grid.Column="1" x:Name="RbtNfce" Content="NFCe"
                                                     HorizontalAlignment="Left" VerticalAlignment="Center"
                                                     IsChecked="{Binding CfgServico.ModeloDocumento, ConverterParameter={x:Static flags:ModeloDocumento.NFCe}, Converter={StaticResource EnumParaBool}}" />
                                    </Grid>
                                </GroupBox>

                                <GroupBox Header="Código de Segurança do Contribuinte" Margin="0,10,0,0" Width="450" HorizontalAlignment="Left">
                                    <StackPanel>
                                        <StackPanel Orientation="Horizontal">
                                            <Label Content="Identificador do CSC:" Grid.Column="0" />
                                            <TextBox Width="100"
                                                     Text="{Binding ConfiguracaoCsc.CIdToken}" Margin="5,0,0,0"/>
                                        </StackPanel>
                                        <StackPanel Margin="0,10,0,0" Orientation="Horizontal">
                                            <Label Content="CSC:"/>
                                            <TextBox Width="380" Text="{Binding ConfiguracaoCsc.Csc}"/>
                                        </StackPanel>
                                    </StackPanel>
                                </GroupBox>

                                <StackPanel Margin="10,10,0,0">
                                    <Label Content="Diretório dos Schemas" HorizontalAlignment="Left"
                                           VerticalAlignment="Top" Width="132" />
                                    <StackPanel Orientation="Horizontal" Margin="0,5,0,0">
                                        <TextBox x:Name="TxtDiretorioSchema" HorizontalAlignment="Left"
                                                 TextWrapping="Wrap" VerticalAlignment="Top"
                                                 Width="390"
                                                 Text="{Binding CfgServico.DiretorioSchemas, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
                                                 IsReadOnly="True" />
                                        <Button x:Name="BtnDiretorioSchema" Content="..." Width="21"
                                                DockPanel.Dock="Right" Click="BtnDiretorioSchema_Click" Margin="5,0,0,0" />
                                    </StackPanel>
                                </StackPanel>

                                <StackPanel Margin="10,10,0,0">
                                    <CheckBox Name="CbxSalvarXml" Content="Salvar arquivos XML's em:"
                                              HorizontalAlignment="Left"
                                              VerticalAlignment="Top" Width="178"
                                              IsChecked="{Binding CfgServico.SalvarXmlServicos}"
                                              Click="CbxSalvarXml_Click" />
                                    <StackPanel Margin="0,5,0,0" Orientation="Horizontal">
                                        <TextBox x:Name="TxtDiretorioXml" HorizontalAlignment="Left"
                                                 TextWrapping="Wrap" VerticalAlignment="Top" Width="390"
                                                 Text="{Binding CfgServico.DiretorioSalvarXml, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
                                                 IsReadOnly="True" />
                                        <Button x:Name="BtnDiretorioXml" Content="..." Width="21"
                                                DockPanel.Dock="Right" Click="BtnDiretorioXml_Click" Margin="5,0,0,0" />
                                    </StackPanel>

                                </StackPanel>
                            </StackPanel>
                        </Grid>
                    </TabItem>
                    <TabItem Header="WebService">
                        <Grid Background="White">
                            <GroupBox Header="WebService" HorizontalAlignment="Left" VerticalAlignment="Top"
                                      Width="450" Margin="10,10,0,0">
                                <StackPanel>
                                    <Label Content="Selecione a UF de Destino:" />
                                    <ComboBox x:Name="CmbUfDestino" IsSynchronizedWithCurrentItem="False"
                                              ItemsSource="{Binding Source={StaticResource EstadosWebService}}"
                                              SelectedItem="{Binding CfgServico.cUF}" />
                                    <GroupBox x:Name="GpbAmbiente" Header="Selecione o Ambiente de Destino" Height="50">
                                        <Grid x:Name="GrdAmbiente">
                                            <RadioButton x:Name="RbtAmbProducao" Content="Produção"
                                                         HorizontalAlignment="Left" VerticalAlignment="Top"
                                                         Margin="10,13,0,0"
                                                         IsChecked="{Binding CfgServico.tpAmb, ConverterParameter={x:Static nfeclsidetipos:TipoAmbiente.taProducao}, Converter={StaticResource EnumParaBool}}" />
                                            <RadioButton x:Name="RbtAmbHomologacao" Content="Homologação"
                                                         HorizontalAlignment="Left" VerticalAlignment="Top"
                                                         Margin="117,13,0,0"
                                                         IsChecked="{Binding CfgServico.tpAmb, ConverterParameter={x:Static nfeclsidetipos:TipoAmbiente.taHomologacao}, Converter={StaticResource EnumParaBool}}" />
                                        </Grid>
                                    </GroupBox>
                                    <GroupBox Header="Selecione a versão de cada serviço" Height="440">
                                        <GroupBox.Resources>
                                            <ResourceDictionary Source="Templates/Controles.xaml" />
                                        </GroupBox.Resources>

                                        <ScrollViewer VerticalScrollBarVisibility="Auto" Margin="0,10,0,0">
                                            <StackPanel>
                                                <ItemsControl Style="{StaticResource GridVersaoServico}">
                                                    <Label Grid.Column="0" Content="RecepcaoEventoCceCancelamento" />
                                                    <RadioButton Grid.Column="1"
                                                                 GroupName="RecepcaoEventoCceCancelamento"
                                                                 Content="1.0"
                                                                 VerticalAlignment="Center"
                                                                 IsChecked="{Binding CfgServico.VersaoRecepcaoEventoCceCancelamento, ConverterParameter={x:Static nfeclservicostipos:VersaoServico.ve100}, Converter={StaticResource EnumParaBool}}" />
                                                    <RadioButton Grid.Column="2"
                                                                 GroupName="RecepcaoEventoCceCancelamento"
                                                                 Content="2.0"
                                                                 VerticalAlignment="Center"
                                                                 IsChecked="{Binding CfgServico.VersaoRecepcaoEventoCceCancelamento, ConverterParameter={x:Static nfeclservicostipos:VersaoServico.ve200}, Converter={StaticResource EnumParaBool}}" />
                                                    <RadioButton Grid.Column="3"
                                                                 GroupName="RecepcaoEventoCceCancelamento"
                                                                 Content="3.1"
                                                                 VerticalAlignment="Center"
                                                                 IsChecked="{Binding CfgServico.VersaoRecepcaoEventoCceCancelamento, ConverterParameter={x:Static nfeclservicostipos:VersaoServico.ve310}, Converter={StaticResource EnumParaBool}}" />
                                                    <RadioButton Grid.Column="4"
                                                                 GroupName="RecepcaoEventoCceCancelamento"
                                                                 Content="4.0"
                                                                 VerticalAlignment="Center"
                                                                 IsChecked="{Binding CfgServico.VersaoRecepcaoEventoCceCancelamento, ConverterParameter={x:Static nfeclservicostipos:VersaoServico.ve400}, Converter={StaticResource EnumParaBool}}" />
                                                </ItemsControl>

                                                <ItemsControl Style="{StaticResource GridVersaoServico}">
                                                    <Label Grid.Column="0" Content="RecepcaoEventoEpec" />
                                                    <RadioButton Grid.Column="1" GroupName="RecepcaoEventoEpec"
                                                                 Content="1.0"
                                                                 VerticalAlignment="Center"
                                                                 IsChecked="{Binding CfgServico.VersaoRecepcaoEventoEpec, ConverterParameter={x:Static nfeclservicostipos:VersaoServico.ve100}, Converter={StaticResource EnumParaBool}}" />
                                                    <RadioButton Grid.Column="2" GroupName="RecepcaoEventoEpec"
                                                                 Content="2.0"
                                                                 VerticalAlignment="Center"
                                                                 IsChecked="{Binding CfgServico.VersaoRecepcaoEventoEpec, ConverterParameter={x:Static nfeclservicostipos:VersaoServico.ve200}, Converter={StaticResource EnumParaBool}}" />
                                                    <RadioButton Grid.Column="3" GroupName="RecepcaoEventoEpec"
                                                                 Content="3.1"
                                                                 VerticalAlignment="Center"
                                                                 IsChecked="{Binding CfgServico.VersaoRecepcaoEventoEpec, ConverterParameter={x:Static nfeclservicostipos:VersaoServico.ve310}, Converter={StaticResource EnumParaBool}}" />
                                                </ItemsControl>

                                                <ItemsControl Style="{StaticResource GridVersaoServico}">
                                                    <Label Grid.Column="0"
                                                           Content="RecepcaoEventoManifestacaoDestinatario" />
                                                    <RadioButton Grid.Column="1"
                                                                 GroupName="RecepcaoEventoManifestacaoDestinatario"
                                                                 Content="1.0"
                                                                 VerticalAlignment="Center"
                                                                 IsChecked="{Binding CfgServico.VersaoRecepcaoEventoManifestacaoDestinatario, ConverterParameter={x:Static nfeclservicostipos:VersaoServico.ve100}, Converter={StaticResource EnumParaBool}}" />
                                                    <RadioButton Grid.Column="2"
                                                                 GroupName="RecepcaoEventoManifestacaoDestinatario"
                                                                 Content="2.0"
                                                                 VerticalAlignment="Center"
                                                                 IsChecked="{Binding CfgServico.VersaoRecepcaoEventoManifestacaoDestinatario, ConverterParameter={x:Static nfeclservicostipos:VersaoServico.ve200}, Converter={StaticResource EnumParaBool}}" />
                                                    <RadioButton Grid.Column="3"
                                                                 GroupName="RecepcaoEventoManifestacaoDestinatario"
                                                                 Content="3.1"
                                                                 VerticalAlignment="Center"
                                                                 IsChecked="{Binding CfgServico.VersaoRecepcaoEventoManifestacaoDestinatario, ConverterParameter={x:Static nfeclservicostipos:VersaoServico.ve310}, Converter={StaticResource EnumParaBool}}" />
                                                </ItemsControl>

                                                <ItemsControl Style="{StaticResource GridVersaoServico}">
                                                    <Label Grid.Column="0" Content="NfeRecepcao" />
                                                    <RadioButton Grid.Column="1" GroupName="NfeRecepcao"
                                                                 Content="1.0"
                                                                 VerticalAlignment="Center"
                                                                 IsChecked="{Binding CfgServico.VersaoNfeRecepcao, ConverterParameter={x:Static nfeclservicostipos:VersaoServico.ve100}, Converter={StaticResource EnumParaBool}}" />
                                                    <RadioButton Grid.Column="2" GroupName="NfeRecepcao"
                                                                 Content="2.0"
                                                                 VerticalAlignment="Center"
                                                                 IsChecked="{Binding CfgServico.VersaoNfeRecepcao, ConverterParameter={x:Static nfeclservicostipos:VersaoServico.ve200}, Converter={StaticResource EnumParaBool}}" />
                                                    <RadioButton Grid.Column="3" GroupName="NfeRecepcao"
                                                                 Content="3.1"
                                                                 VerticalAlignment="Center"
                                                                 IsChecked="{Binding CfgServico.VersaoNfeRecepcao, ConverterParameter={x:Static nfeclservicostipos:VersaoServico.ve310}, Converter={StaticResource EnumParaBool}}" />
                                                </ItemsControl>

                                                <ItemsControl Style="{StaticResource GridVersaoServico}">
                                                    <Label Grid.Column="0" Content="NfeRetRecepcao" />
                                                    <RadioButton Grid.Column="1" GroupName="NfeRetRecepcao"
                                                                 Content="1.0"
                                                                 VerticalAlignment="Center"
                                                                 IsChecked="{Binding CfgServico.VersaoNfeRetRecepcao, ConverterParameter={x:Static nfeclservicostipos:VersaoServico.ve100}, Converter={StaticResource EnumParaBool}}" />
                                                    <RadioButton Grid.Column="2" GroupName="NfeRetRecepcao"
                                                                 Content="2.0"
                                                                 VerticalAlignment="Center"
                                                                 IsChecked="{Binding CfgServico.VersaoNfeRetRecepcao, ConverterParameter={x:Static nfeclservicostipos:VersaoServico.ve200}, Converter={StaticResource EnumParaBool}}" />
                                                    <RadioButton Grid.Column="3" GroupName="NfeRetRecepcao"
                                                                 Content="3.1"
                                                                 VerticalAlignment="Center"
                                                                 IsChecked="{Binding CfgServico.VersaoNfeRetRecepcao, ConverterParameter={x:Static nfeclservicostipos:VersaoServico.ve310}, Converter={StaticResource EnumParaBool}}" />
                                                </ItemsControl>

                                                <ItemsControl Style="{StaticResource GridVersaoServico}">
                                                    <Label Grid.Column="0" Content="NfeInutilizacao" />
                                                    <RadioButton Grid.Column="1" GroupName="NfeInutilizacao"
                                                                 Content="1.0"
                                                                 VerticalAlignment="Center"
                                                                 IsChecked="{Binding CfgServico.VersaoNfeInutilizacao, ConverterParameter={x:Static nfeclservicostipos:VersaoServico.ve100}, Converter={StaticResource EnumParaBool}}" />
                                                    <RadioButton Grid.Column="2" GroupName="NfeInutilizacao"
                                                                 Content="2.0"
                                                                 VerticalAlignment="Center"
                                                                 IsChecked="{Binding CfgServico.VersaoNfeInutilizacao, ConverterParameter={x:Static nfeclservicostipos:VersaoServico.ve200}, Converter={StaticResource EnumParaBool}}" />
                                                    <RadioButton Grid.Column="3" GroupName="NfeInutilizacao"
                                                                 Content="3.1"
                                                                 VerticalAlignment="Center"
                                                                 IsChecked="{Binding CfgServico.VersaoNfeInutilizacao, ConverterParameter={x:Static nfeclservicostipos:VersaoServico.ve310}, Converter={StaticResource EnumParaBool}}" />

                                                    <RadioButton Grid.Column="4" GroupName="NfeInutilizacao"
                                                                 Content="4.0"
                                                                 VerticalAlignment="Center"
                                                                 IsChecked="{Binding CfgServico.VersaoNfeInutilizacao, ConverterParameter={x:Static nfeclservicostipos:VersaoServico.ve400}, Converter={StaticResource EnumParaBool}}" />
                                                </ItemsControl>

                                                <ItemsControl Style="{StaticResource GridVersaoServico}">
                                                    <Label Grid.Column="0" Content="NfeConsultaProtocolo" />
                                                    <RadioButton Grid.Column="1" GroupName="NfeConsultaProtocolo"
                                                                 Content="1.0"
                                                                 VerticalAlignment="Center"
                                                                 IsChecked="{Binding CfgServico.VersaoNfeConsultaProtocolo, ConverterParameter={x:Static nfeclservicostipos:VersaoServico.ve100}, Converter={StaticResource EnumParaBool}}" />
                                                    <RadioButton Grid.Column="2" GroupName="NfeConsultaProtocolo"
                                                                 Content="2.0"
                                                                 VerticalAlignment="Center"
                                                                 IsChecked="{Binding CfgServico.VersaoNfeConsultaProtocolo, ConverterParameter={x:Static nfeclservicostipos:VersaoServico.ve200}, Converter={StaticResource EnumParaBool}}" />
                                                    <RadioButton Grid.Column="3" GroupName="NfeConsultaProtocolo"
                                                                 Content="3.1"
                                                                 VerticalAlignment="Center"
                                                                 IsChecked="{Binding CfgServico.VersaoNfeConsultaProtocolo, ConverterParameter={x:Static nfeclservicostipos:VersaoServico.ve310}, Converter={StaticResource EnumParaBool}}"
                                                                 Grid.ColumnSpan="2" />
                                                    <RadioButton Grid.Column="4" GroupName="NfeConsultaProtocolo"
                                                                 Content="4.0"
                                                                 VerticalAlignment="Center"
                                                                 IsChecked="{Binding CfgServico.VersaoNfeConsultaProtocolo, ConverterParameter={x:Static nfeclservicostipos:VersaoServico.ve400}, Converter={StaticResource EnumParaBool}}" />
                                                </ItemsControl>

                                                <ItemsControl Style="{StaticResource GridVersaoServico}">
                                                    <Label Grid.Column="0" Content="NfeStatusServico" />
                                                    <RadioButton Grid.Column="1" GroupName="NfeStatusServico"
                                                                 Content="1.0"
                                                                 VerticalAlignment="Center"
                                                                 IsChecked="{Binding CfgServico.VersaoNfeStatusServico, ConverterParameter={x:Static nfeclservicostipos:VersaoServico.ve100}, Converter={StaticResource EnumParaBool}}" />
                                                    <RadioButton Grid.Column="2" GroupName="NfeStatusServico"
                                                                 Content="2.0"
                                                                 VerticalAlignment="Center"
                                                                 IsChecked="{Binding CfgServico.VersaoNfeStatusServico, ConverterParameter={x:Static nfeclservicostipos:VersaoServico.ve200}, Converter={StaticResource EnumParaBool}}" />
                                                    <RadioButton Grid.Column="3" GroupName="NfeStatusServico"
                                                                 Content="3.1"
                                                                 VerticalAlignment="Center"
                                                                 IsChecked="{Binding CfgServico.VersaoNfeStatusServico, ConverterParameter={x:Static nfeclservicostipos:VersaoServico.ve310}, Converter={StaticResource EnumParaBool}}" />

                                                    <RadioButton Grid.Column="4" GroupName="NfeStatusServico"
                                                                 Content="4.0"
                                                                 VerticalAlignment="Center"
                                                                 IsChecked="{Binding CfgServico.VersaoNfeStatusServico, ConverterParameter={x:Static nfeclservicostipos:VersaoServico.ve400}, Converter={StaticResource EnumParaBool}}" />
                                                </ItemsControl>

                                                <ItemsControl Style="{StaticResource GridVersaoServico}">
                                                    <Label Grid.Column="0" Content="NfeConsultaCadastro" />
                                                    <RadioButton Grid.Column="1" GroupName="NfeConsultaCadastro"
                                                                 Content="1.0"
                                                                 VerticalAlignment="Center"
                                                                 IsChecked="{Binding CfgServico.VersaoNfeConsultaCadastro, ConverterParameter={x:Static nfeclservicostipos:VersaoServico.ve100}, Converter={StaticResource EnumParaBool}}" />
                                                    <RadioButton Grid.Column="2" GroupName="NfeConsultaCadastro"
                                                                 Content="2.0"
                                                                 VerticalAlignment="Center"
                                                                 IsChecked="{Binding CfgServico.VersaoNfeConsultaCadastro, ConverterParameter={x:Static nfeclservicostipos:VersaoServico.ve200}, Converter={StaticResource EnumParaBool}}" />
                                                    <RadioButton Grid.Column="3" GroupName="NfeConsultaCadastro"
                                                                 Content="3.1"
                                                                 VerticalAlignment="Center"
                                                                 IsChecked="{Binding CfgServico.VersaoNfeConsultaCadastro, ConverterParameter={x:Static nfeclservicostipos:VersaoServico.ve310}, Converter={StaticResource EnumParaBool}}"
                                                                 Grid.ColumnSpan="2" />

                                                    <RadioButton Grid.Column="4" GroupName="NfeConsultaCadastro"
                                                                 Content="4.0"
                                                                 VerticalAlignment="Center"
                                                                 IsChecked="{Binding CfgServico.VersaoNfeConsultaCadastro, ConverterParameter={x:Static nfeclservicostipos:VersaoServico.ve400}, Converter={StaticResource EnumParaBool}}" />
                                                </ItemsControl>

                                                <ItemsControl Style="{StaticResource GridVersaoServico}">
                                                    <Label Grid.Column="0" Content="NFeAutorizacao" />
                                                    <RadioButton Grid.Column="1" GroupName="NFeAutorizacao"
                                                                 Content="1.0"
                                                                 VerticalAlignment="Center"
                                                                 IsChecked="{Binding CfgServico.VersaoNFeAutorizacao, ConverterParameter={x:Static nfeclservicostipos:VersaoServico.ve100}, Converter={StaticResource EnumParaBool}}" />
                                                    <RadioButton Grid.Column="2" GroupName="NFeAutorizacao"
                                                                 Content="2.0"
                                                                 VerticalAlignment="Center"
                                                                 IsChecked="{Binding CfgServico.VersaoNFeAutorizacao, ConverterParameter={x:Static nfeclservicostipos:VersaoServico.ve200}, Converter={StaticResource EnumParaBool}}" />
                                                    <RadioButton Grid.Column="3" GroupName="NFeAutorizacao"
                                                                 Content="3.1"
                                                                 VerticalAlignment="Center"
                                                                 IsChecked="{Binding CfgServico.VersaoNFeAutorizacao, ConverterParameter={x:Static nfeclservicostipos:VersaoServico.ve310}, Converter={StaticResource EnumParaBool}}" />
                                                    <RadioButton Grid.Column="4" GroupName="NFeAutorizacao"
                                                                 Content="4.0"
                                                                 VerticalAlignment="Center"
                                                                 IsChecked="{Binding CfgServico.VersaoNFeAutorizacao, ConverterParameter={x:Static nfeclservicostipos:VersaoServico.ve400}, Converter={StaticResource EnumParaBool}}" />
                                                </ItemsControl>

                                                <ItemsControl Style="{StaticResource GridVersaoServico}">
                                                    <Label Grid.Column="0" Content="NFeRetAutorizacao" />
                                                    <RadioButton Grid.Column="1" GroupName="NFeRetAutorizacao"
                                                                 Content="1.0"
                                                                 VerticalAlignment="Center"
                                                                 IsChecked="{Binding CfgServico.VersaoNFeRetAutorizacao, ConverterParameter={x:Static nfeclservicostipos:VersaoServico.ve100}, Converter={StaticResource EnumParaBool}}" />
                                                    <RadioButton Grid.Column="2" GroupName="NFeRetAutorizacao"
                                                                 Content="2.0"
                                                                 VerticalAlignment="Center"
                                                                 IsChecked="{Binding CfgServico.VersaoNFeRetAutorizacao, ConverterParameter={x:Static nfeclservicostipos:VersaoServico.ve200}, Converter={StaticResource EnumParaBool}}" />
                                                    <RadioButton Grid.Column="3" GroupName="NFeRetAutorizacao"
                                                                 Content="3.1"
                                                                 VerticalAlignment="Center"
                                                                 IsChecked="{Binding CfgServico.VersaoNFeRetAutorizacao, ConverterParameter={x:Static nfeclservicostipos:VersaoServico.ve310}, Converter={StaticResource EnumParaBool}}" />
                                                    <RadioButton Grid.Column="4" GroupName="NFeRetAutorizacao"
                                                                 Content="4.0"
                                                                 VerticalAlignment="Center"
                                                                 IsChecked="{Binding CfgServico.VersaoNFeRetAutorizacao, ConverterParameter={x:Static nfeclservicostipos:VersaoServico.ve400}, Converter={StaticResource EnumParaBool}}" />
                                                </ItemsControl>

                                                <ItemsControl Style="{StaticResource GridVersaoServico}">
                                                    <Label Grid.Column="0" Content="NFeDistribuicaoDFe" />
                                                    <RadioButton Grid.Column="1" GroupName="NFeDistribuicaoDFe"
                                                                 Content="1.0"
                                                                 VerticalAlignment="Center"
                                                                 IsChecked="{Binding CfgServico.VersaoNFeDistribuicaoDFe, ConverterParameter={x:Static nfeclservicostipos:VersaoServico.ve100}, Converter={StaticResource EnumParaBool}}" />
                                                    <RadioButton Grid.Column="2" GroupName="NFeDistribuicaoDFe"
                                                                 Content="2.0"
                                                                 VerticalAlignment="Center"
                                                                 IsChecked="{Binding CfgServico.VersaoNFeDistribuicaoDFe, ConverterParameter={x:Static nfeclservicostipos:VersaoServico.ve200}, Converter={StaticResource EnumParaBool}}" />
                                                    <RadioButton Grid.Column="3" GroupName="NFeDistribuicaoDFe"
                                                                 Content="3.1"
                                                                 VerticalAlignment="Center"
                                                                 IsChecked="{Binding CfgServico.VersaoNFeDistribuicaoDFe, ConverterParameter={x:Static nfeclservicostipos:VersaoServico.ve310}, Converter={StaticResource EnumParaBool}}" />
                                                </ItemsControl>

                                                <ItemsControl Style="{StaticResource GridVersaoServico}">
                                                    <Label Grid.Column="0" Content="NfeConsultaDest" />
                                                    <RadioButton Grid.Column="1" GroupName="NfeConsultaDest"
                                                                 Content="1.0"
                                                                 VerticalAlignment="Center"
                                                                 IsChecked="{Binding CfgServico.VersaoNfeConsultaDest, ConverterParameter={x:Static nfeclservicostipos:VersaoServico.ve100}, Converter={StaticResource EnumParaBool}}" />
                                                    <RadioButton Grid.Column="2" GroupName="NfeConsultaDest"
                                                                 Content="2.0"
                                                                 VerticalAlignment="Center"
                                                                 IsChecked="{Binding CfgServico.VersaoNfeConsultaDest, ConverterParameter={x:Static nfeclservicostipos:VersaoServico.ve200}, Converter={StaticResource EnumParaBool}}" />
                                                    <RadioButton Grid.Column="3" GroupName="NfeConsultaDest"
                                                                 Content="3.1"
                                                                 VerticalAlignment="Center"
                                                                 IsChecked="{Binding CfgServico.VersaoNfeConsultaDest, ConverterParameter={x:Static nfeclservicostipos:VersaoServico.ve310}, Converter={StaticResource EnumParaBool}}" />
                                                </ItemsControl>

                                                <ItemsControl Style="{StaticResource GridVersaoServico}">
                                                    <Label Grid.Column="0" Content="NfeDownloadNF" />
                                                    <RadioButton Grid.Column="1" GroupName="NfeDownloadNF"
                                                                 Content="1.0"
                                                                 VerticalAlignment="Center"
                                                                 IsChecked="{Binding CfgServico.VersaoNfeDownloadNF, ConverterParameter={x:Static nfeclservicostipos:VersaoServico.ve100}, Converter={StaticResource EnumParaBool}}" />
                                                    <RadioButton Grid.Column="2" GroupName="NfeDownloadNF"
                                                                 Content="2.0"
                                                                 VerticalAlignment="Center"
                                                                 IsChecked="{Binding CfgServico.VersaoNfeDownloadNF, ConverterParameter={x:Static nfeclservicostipos:VersaoServico.ve200}, Converter={StaticResource EnumParaBool}}" />
                                                    <RadioButton Grid.Column="3" GroupName="NfeDownloadNF"
                                                                 Content="3.1"
                                                                 VerticalAlignment="Center"
                                                                 IsChecked="{Binding CfgServico.VersaoNfeDownloadNF, ConverterParameter={x:Static nfeclservicostipos:VersaoServico.ve310}, Converter={StaticResource EnumParaBool}}" />
                                                </ItemsControl>

                                                <ItemsControl Style="{StaticResource GridVersaoServico}">
                                                    <Label Grid.Column="0" Content="admCscNFCe" />
                                                    <RadioButton Grid.Column="1" GroupName="admCscNFCe"
                                                                 Content="1.0"
                                                                 VerticalAlignment="Center"
                                                                 IsChecked="{Binding CfgServico.VersaoNfceAministracaoCSC, ConverterParameter={x:Static nfeclservicostipos:VersaoServico.ve100}, Converter={StaticResource EnumParaBool}}" />
                                                    <RadioButton Grid.Column="2" GroupName="admCscNFCe"
                                                                 Content="2.0"
                                                                 VerticalAlignment="Center"
                                                                 IsChecked="{Binding CfgServico.VersaoNfceAministracaoCSC, ConverterParameter={x:Static nfeclservicostipos:VersaoServico.ve200}, Converter={StaticResource EnumParaBool}}" />
                                                    <RadioButton Grid.Column="3" GroupName="admCscNFCe"
                                                                 Content="3.1"
                                                                 VerticalAlignment="Center"
                                                                 IsChecked="{Binding CfgServico.VersaoNfceAministracaoCSC, ConverterParameter={x:Static nfeclservicostipos:VersaoServico.ve310}, Converter={StaticResource EnumParaBool}}" />
                                                </ItemsControl>
                                            </StackPanel>
                                        </ScrollViewer>

                                    </GroupBox>
                                    <GroupBox x:Name="GpbProtocolo" Header="Selecione o Protocolo de segurança"
                                              Height="50">
                                        <Grid x:Name="GrdGpbProtocolo">
                                            <RadioButton x:Name="RbtSsl3" Content="Ssl3"
                                                         HorizontalAlignment="Left" VerticalAlignment="Top"
                                                         Margin="10,13,0,0"
                                                         IsChecked="{Binding CfgServico.ProtocoloDeSeguranca, ConverterParameter={x:Static net:SecurityProtocolType.Ssl3}, Converter={StaticResource EnumParaBool}}" />
                                            <RadioButton x:Name="RbtTls" Content="Tls"
                                                         HorizontalAlignment="Left" VerticalAlignment="Top"
                                                         Margin="117,13,0,0"
                                                         IsChecked="{Binding CfgServico.ProtocoloDeSeguranca, ConverterParameter={x:Static net:SecurityProtocolType.Tls}, Converter={StaticResource EnumParaBool}}" />
                                            <RadioButton x:Name="RbtTls12" Content="Tls1.2"
                                                         HorizontalAlignment="Left" VerticalAlignment="Top"
                                                         Margin="196,13,0,0"
                                                         IsChecked="{Binding CfgServico.ProtocoloDeSeguranca, ConverterParameter={x:Static net:SecurityProtocolType.Tls12}, Converter={StaticResource EnumParaBool}}" />
                                        </Grid>
                                    </GroupBox>
                                    <StackPanel Height="30" Orientation="Horizontal">
                                        <Label Content="TimeOut (milisegundos)" HorizontalAlignment="Left"
                                               Margin="0,0,0,0" VerticalAlignment="Center" />
                                        <TextBox x:Name="TxtTimeOut" HorizontalAlignment="Left"
                                                 Margin="0,0,0,0" VerticalAlignment="Center" Width="134"
                                                 Text="{Binding CfgServico.TimeOut}" />
                                    </StackPanel>
                                </StackPanel>
                            </GroupBox>
                        </Grid>
                    </TabItem>
                    <TabItem Header="Emitente">
                        <Grid Background="White">
                            <Grid>
                                <Label Content="CNPJ" HorizontalAlignment="Left" Margin="10,5,0,0"
                                       VerticalAlignment="Top" RenderTransformOrigin="0.514,1.808" />
                                <TextBox x:Name="TxtEmitCnpj" HorizontalAlignment="Left" Height="23" Margin="10,31,0,0"
                                         TextWrapping="Wrap" VerticalAlignment="Top" Width="268"
                                         Text="{Binding Emitente.CNPJ, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" />
                                <Label Content="Incrição Estadual" HorizontalAlignment="Left" Margin="283,10,0,0"
                                       VerticalAlignment="Top" />
                                <TextBox x:Name="TxtEmitIe" HorizontalAlignment="Left" Height="23" Margin="283,31,0,0"
                                         TextWrapping="Wrap" VerticalAlignment="Top" Width="191"
                                         Text="{Binding Emitente.IE, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" />
                                <Label Content="Razão Social" HorizontalAlignment="Left" Margin="10,54,0,0"
                                       VerticalAlignment="Top" RenderTransformOrigin="0.556,2.625" />
                                <TextBox x:Name="TxtEmitRazao" HorizontalAlignment="Left" Height="23"
                                         Margin="10,80,0,0" TextWrapping="Wrap" VerticalAlignment="Top" Width="464"
                                         Text="{Binding Emitente.xNome, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" />
                                <Label Content="Fantasia" HorizontalAlignment="Left" Margin="10,103,0,0"
                                       VerticalAlignment="Top" RenderTransformOrigin="0.556,2.625" />
                                <TextBox x:Name="TxtEmitFantasia" HorizontalAlignment="Left" Height="23"
                                         Margin="10,130,0,0" TextWrapping="Wrap" VerticalAlignment="Top" Width="464"
                                         Text="{Binding Emitente.xFant, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" />
                            </Grid>
                            <Grid>
                                <Label Content="Fone" HorizontalAlignment="Left" Margin="10,155,0,0"
                                       VerticalAlignment="Top" />
                                <TextBox x:Name="TxtEmitFone" HorizontalAlignment="Left" Height="23"
                                         Margin="10,181,0,0" TextWrapping="Wrap" VerticalAlignment="Top" Width="322"
                                         Text="{Binding EnderecoEmitente.fone, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" />
                                <Label Content="CEP" HorizontalAlignment="Left" Margin="349,155,0,0"
                                       VerticalAlignment="Top" RenderTransformOrigin="0.467,-0.269" />
                                <TextBox x:Name="TxtEmitCep" HorizontalAlignment="Left" Height="23"
                                         Margin="349,181,0,0" TextWrapping="Wrap" VerticalAlignment="Top" Width="122"
                                         Text="{Binding EnderecoEmitente.CEP, Mode=TwoWay, UpdateSourceTrigger=LostFocus}" />
                                <Label Content="Logradouro" HorizontalAlignment="Left" Margin="10,204,0,0"
                                       VerticalAlignment="Top" />
                                <TextBox x:Name="TxtEmitLogradouro" HorizontalAlignment="Left" Height="23"
                                         Margin="10,231,0,0" TextWrapping="Wrap" VerticalAlignment="Top" Width="392"
                                         Text="{Binding EnderecoEmitente.xLgr, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" />
                                <Label Content="Número" HorizontalAlignment="Left" Margin="420,205,0,0"
                                       VerticalAlignment="Top" />
                                <TextBox x:Name="TxtEmitNumero" HorizontalAlignment="Left" Height="23"
                                         Margin="422,231,0,0" TextWrapping="Wrap" VerticalAlignment="Top" Width="52"
                                         Text="{Binding EnderecoEmitente.nro, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" />
                                <Label Content="Complemento" HorizontalAlignment="Left" Margin="10,254,0,0"
                                       VerticalAlignment="Top" />
                                <TextBox x:Name="TxtEmitComplemento" HorizontalAlignment="Left" Height="23"
                                         Margin="10,281,0,0" TextWrapping="Wrap" VerticalAlignment="Top" Width="223"
                                         Text="{Binding EnderecoEmitente.xCpl, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" />
                                <Label Content="Bairro" HorizontalAlignment="Left" Margin="248,254,0,0"
                                       VerticalAlignment="Top" />
                                <TextBox x:Name="TxtEmitBairro" HorizontalAlignment="Left" Height="23"
                                         Margin="248,280,0,0" TextWrapping="Wrap" VerticalAlignment="Top" Width="226"
                                         Text="{Binding EnderecoEmitente.xBairro, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" />
                                <Label Content="Cód Cidade" HorizontalAlignment="Left" Margin="10,305,0,0"
                                       VerticalAlignment="Top" />
                                <TextBox x:Name="TxtEmitCodCidade" HorizontalAlignment="Left" Height="23"
                                         Margin="10,331,0,0" TextWrapping="Wrap" VerticalAlignment="Top" Width="62"
                                         Text="{Binding EnderecoEmitente.cMun, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" />
                                <Label Content="Cidade" HorizontalAlignment="Left" Margin="77,304,0,0"
                                       VerticalAlignment="Top" RenderTransformOrigin="0.574,0.038" />
                                <TextBox x:Name="TxtEmitCidade" HorizontalAlignment="Left" Height="23"
                                         Margin="77,331,0,0" TextWrapping="Wrap" VerticalAlignment="Top" Width="286"
                                         Text="{Binding EnderecoEmitente.xMun, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" />
                                <Label Content="UF" HorizontalAlignment="Left" Margin="378,305,0,0"
                                       VerticalAlignment="Top" />
                                <ComboBox x:Name="CmbEmitUf" Height="23" Margin="378,331,10,218"
                                          ItemsSource="{Binding Source={StaticResource EstadosEmitente}}"
                                          SelectedItem="{Binding EnderecoEmitente.UF}" />
                            </Grid>
                            <ComboBox x:Name="CmbCrt" Height="23" Margin="10,384,10,164"
                                      ItemsSource="{Binding Source={StaticResource Crts}}"
                                      SelectedItem="{Binding Emitente.CRT}" />
                            <Label Content="CRT" HorizontalAlignment="Left" Margin="10,357,0,0"
                                   VerticalAlignment="Top" />
                        </Grid>
                    </TabItem>
                    <TabItem Header="E-mail">
                        <Grid Background="White">
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition Width="222*" />
                                <ColumnDefinition Width="263*" />
                            </Grid.ColumnDefinitions>
                            <Label Content="Servidor SMTP" HorizontalAlignment="Left" Margin="10,5,0,0"
                                   VerticalAlignment="Top" />
                            <TextBox HorizontalAlignment="Left" Height="23" Margin="10,31,0,0" TextWrapping="Wrap"
                                     Text="{Binding ConfiguracaoEmail.ServidorSmtp, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
                                     VerticalAlignment="Top" Width="395" Grid.ColumnSpan="2" RenderTransformOrigin="0.5,0.5" >
                                <TextBox.RenderTransform>
                                    <TransformGroup>
                                        <ScaleTransform/>
                                        <SkewTransform/>
                                        <RotateTransform Angle="0.177"/>
                                        <TranslateTransform/>
                                    </TransformGroup>
                                </TextBox.RenderTransform>
                            </TextBox>
                            <Label Content="Porta" HorizontalAlignment="Left" Margin="192,5,0,0"
                                   VerticalAlignment="Top" Grid.Column="1" />
                            <TextBox x:Name="TxtPorta" HorizontalAlignment="Left" Height="23"
                                     Text="{Binding ConfiguracaoEmail.Porta, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
                                     Margin="192,31,0,0" VerticalAlignment="Top" Width="60" Grid.Column="1" />
                            <Label Content="Usuário" HorizontalAlignment="Left" Margin="10,55,0,0"
                                   VerticalAlignment="Top" />
                            <TextBox HorizontalAlignment="Left" Height="23" Margin="10,81,0,0" TextWrapping="Wrap"
                                     Text="{Binding ConfiguracaoEmail.Email, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
                                     VerticalAlignment="Top" Width="351" Grid.ColumnSpan="2" />
                            <Label Content="Senha" HorizontalAlignment="Left" Margin="144,55,0,0"
                                   VerticalAlignment="Top" Grid.Column="1" />
                            <TextBox HorizontalAlignment="Left" Height="23" Margin="144,81,0,0" TextWrapping="Wrap"
                                     Text="{Binding ConfiguracaoEmail.Senha, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
                                     VerticalAlignment="Top" Width="108" Grid.Column="1" />
                            <Label Content="Assunto" HorizontalAlignment="Left" Margin="10,105,0,0"
                                   VerticalAlignment="Top" />
                            <TextBox HorizontalAlignment="Left" Height="23" Margin="10,131,0,0" TextWrapping="Wrap"
                                     Text="{Binding ConfiguracaoEmail.Assunto, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
                                     VerticalAlignment="Top" Width="464" Grid.ColumnSpan="2" />
                            <CheckBox Content="SMTP Exige conexão segura" HorizontalAlignment="Left"
                                      IsChecked="{Binding ConfiguracaoEmail.Ssl}"
                                      Margin="10,270,0,0" VerticalAlignment="Top" />
                            <TextBox HorizontalAlignment="Left" Height="166" Margin="10,329,0,0" TextWrapping="Wrap"
                                     AcceptsReturn="True"
                                     Text="{Binding ConfiguracaoEmail.Mensagem, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
                                     VerticalAlignment="Top" Width="464" Grid.ColumnSpan="2" />
                            <Label Content="Mensagem do Email" HorizontalAlignment="Left" Margin="10,298,0,0"
                                   VerticalAlignment="Top" />
                            <Label Content="Timeout (em millisegundos)" HorizontalAlignment="Left" Margin="10,159,0,0"
                                   VerticalAlignment="Top" Width="168" />
                            <TextBox HorizontalAlignment="Left" Height="23" Margin="10,185,0,0"
                                     Text="{Binding ConfiguracaoEmail.Timeout, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
                                     VerticalAlignment="Top" Width="154" />
                            <CheckBox Content="Envio assíncrono" HorizontalAlignment="Left"
                                      IsChecked="{Binding ConfiguracaoEmail.Assincrono}"
                                      Margin="10,230,0,0" VerticalAlignment="Top" />
                            <CheckBox Content="Enviar mensagem como HTML" HorizontalAlignment="Left"
                                      IsChecked="{Binding ConfiguracaoEmail.MensagemEmHtml}"
                                      Margin="10,250,0,0" VerticalAlignment="Top" />
                        </Grid>
                    </TabItem>
                    <TabItem Header="Impressão">
                        <Grid Background="White">

                            <GroupBox Header="LogoMarca" VerticalAlignment="Top" Margin="0,10,0,0">
                                <StackPanel Margin="0,0,0,12">
                                    <StackPanel Margin="0,10,0,0">
                                        <Label Content="Informe a logomarca a ser usada no DANFE"
                                               HorizontalAlignment="Left" VerticalAlignment="Top" />
                                        <WrapPanel Orientation="Horizontal">
                                            <Border BorderThickness="1" BorderBrush="Black" Height="100"
                                                    Width="250"
                                                    HorizontalAlignment="Left" VerticalAlignment="Top">
                                                <Image x:Name="LogoEmitente" />
                                            </Border>
                                            <StackPanel Margin="5" Width="35">
                                                <Button x:Name="BtnLogo" Content="..." VerticalAlignment="Top"
                                                        Click="btnLogo_Click" Height="35" />
                                                <Button x:Name="BtnRemoveLogo" Content="x" VerticalAlignment="Top"
                                                        Height="35" Click="btnRemoveLogo_Click" />
                                            </StackPanel>
                                        </WrapPanel>
                                    </StackPanel>
                                </StackPanel>
                            </GroupBox>

                        </Grid>
                    </TabItem>
                </TabControl>
                <DockPanel Dock="Bottom" Height="45">
                    <Button x:Name="BtnSalvar" Content="Salvar Configurações para arquivo" Width="203"
                            HorizontalAlignment="Center" VerticalAlignment="Center"
                            Height="27" Click="btnSalvar_Click" />
                </DockPanel>
            </StackPanel>
        </GroupBox>
        <TabControl Name="TabSuperior" Height="266" Margin="510,10,-0,0" VerticalAlignment="Top">
            <TabItem Header="NF-e/NFC-e">
                <Grid Background="White">
                    <Button x:Name="BtnStatusServico" Content="Status do Serviço" HorizontalAlignment="Left"
                            Margin="10,10,0,0" VerticalAlignment="Top" Width="177" Click="BtnStatusServico_Click" />
                    <Button x:Name="BtnCriareEnviar2" Content="Criar e Enviar 2.0" HorizontalAlignment="Left"
                            Margin="10,35,0,0" VerticalAlignment="Top" Width="177" Click="BtnCriareEnviar2_Click" />
                    <Button x:Name="BtnConsultaXml" Content="Consultar carregando XML" HorizontalAlignment="Left"
                            Margin="10,85,0,0" VerticalAlignment="Top" Width="177" Click="BtnConsultaXml_Click" />
                    <Button x:Name="BtnConsultaChave" Content="Consultar pela Chave" HorizontalAlignment="Left"
                            Margin="192,85,0,0" VerticalAlignment="Top" Width="177" Click="BtnConsultaChave_Click" />
                    <Button x:Name="BtnInutiliza" Content="Inutilizar Numeração" HorizontalAlignment="Left"
                            Margin="192,10,0,0"
                            VerticalAlignment="Top" Width="177" Click="BtnInutiliza_Click" />
                    <Button x:Name="BtnGerarNfe2" Content="Criar e Salvar XML 2.0" HorizontalAlignment="Left"
                            Margin="374,35,0,0" VerticalAlignment="Top" Width="177" Click="BtnGerarNfe2_Click" />
                    <Button x:Name="BtnConsultarReciboLote2" Content="Consultar Recibo Lote 2.0"
                            HorizontalAlignment="Left" Margin="192,35,0,0" VerticalAlignment="Top" Width="177"
                            Click="BtnConsultarReciboLote2_Click" />
                    <Button x:Name="BtnCriareEnviar3" Content="Criar e Enviar 3.0 Ou 4.0" HorizontalAlignment="Left"
                            Margin="10,60,0,0" VerticalAlignment="Top" Width="177" Click="BtnCriareEnviar3_Click" />
                    <Button x:Name="BtnConsultarReciboLote3" Content="Consultar Recibo Lote 3.0 Ou 4.0"
                            HorizontalAlignment="Left" Margin="192,60,0,0" VerticalAlignment="Top" Width="177"
                            Click="BtnConsultarReciboLote3_Click" />
                    <Button x:Name="BtnGerarNfe3" Content="Criar e Salvar XML 3.0" HorizontalAlignment="Left"
                            Margin="374,60,0,0" VerticalAlignment="Top" Width="177" Click="BtnGerarNfe3_Click" />
                    <Button x:Name="BtnCartaCorrecao" Content="Carta de correção" HorizontalAlignment="Left"
                            Margin="10,110,0,0" VerticalAlignment="Top" Width="177" Click="BtnCartaCorrecao_Click" />
                    <Button x:Name="BtnCancelarNFe" Content="Cancelar" HorizontalAlignment="Left"
                            Margin="192,110,0,0" VerticalAlignment="Top" Width="177" Click="BtnCancelarNFe_Click" />
                    <Button x:Name="BtnEnviaEpec" Content="Enviar EPEC" HorizontalAlignment="Left"
                            Margin="374,85,0,0" VerticalAlignment="Top" Width="177" Click="BtnEnviaEpec_Click" />
                    <Button x:Name="BtnConsultaEpec" Content="Consultar EPEC" HorizontalAlignment="Left"
                            Margin="374,110,0,0" VerticalAlignment="Top" Width="177" Click="BtnConsultaEpec_Click" />
                    <Button x:Name="BtnImportarXml" Content="Importar XML" HorizontalAlignment="Left"
                            Margin="374,10,0,0" VerticalAlignment="Top" Width="177" Click="BtnImportarXml_Click" />
                    <Button x:Name="BtnValida" Content="Validar" HorizontalAlignment="Left"
                            Margin="192,135,0,0" VerticalAlignment="Top" Width="177" Click="BtnValida_Click" />
                    <Button x:Name="BtnAssina" Content="Assinar" HorizontalAlignment="Left"
                            Margin="10,135,0,0" VerticalAlignment="Top" Width="177" Click="BtnAssina_Click" />
                    <Button x:Name="BtnAdicionaNfeproc" Content="Adicionar proc ao XML" HorizontalAlignment="Left"
                            Margin="374,135,0,0" VerticalAlignment="Top" Width="177" Click="BtnAdicionaNfeproc_Click" />
                    <Button x:Name="BtnCarregaXmlEnvia" Content="Carregar XML e Enviar" HorizontalAlignment="Left"
                            Margin="10,160,0,0" VerticalAlignment="Top" Width="177" Click="BtnCarregaXmlEnvia_Click" />
                    <Button x:Name="BtnConsultaCadastro" Content="Consultar Cadastro" HorizontalAlignment="Left"
                            Margin="192,160,0,0" VerticalAlignment="Top" Width="177" Click="BtnConsultaCadastro_Click" />
                    <Button x:Name="BtnDownlodNfe" Content="Downlod NFe" HorizontalAlignment="Left"
                            Margin="374,160,0,0" VerticalAlignment="Top" Width="177" Click="BtnDownlodNfe_Click" />
                    <Button x:Name="BtnAdminCsc" Content="Administrar CSC" HorizontalAlignment="Left"
                            Margin="192,185,0,0" VerticalAlignment="Top" Width="177" Click="BtnAdminCsc_Click" />
                    <Button x:Name="BtnEnviaEmail" Content="Enviar Email" Click="ButtonBase_OnClick"
                            HorizontalAlignment="Left" Margin="10,185,0,0" VerticalAlignment="Top" Width="177" />
                    <Button x:Name="btn_NFeDistribuicaoDFe" Content="NFe Distribuição DFe" HorizontalAlignment="Left"
                            Margin="374,185,0,0" VerticalAlignment="Top" Width="177" Height="20"
                            Click="btn_NFeDistribuicaoDFe_Click" />
                    <Button x:Name="BtnManifestacaoDestinatario" Content="Manifestação Destinatário"
                            HorizontalAlignment="Left" Margin="10,210,0,0" VerticalAlignment="Top" Width="177"
                            Height="20" Click="BtnManifestacaoDestinatario_Click" />
                    <Button x:Name="BtnCupom" Content="DANFE NFC-e nativo" HorizontalAlignment="Left"
                            Margin="192,210,0,0" VerticalAlignment="Top" Width="177" Height="20" Click="BtnCupom_Click"
                            RenderTransformOrigin="0.551,2.396" />
                </Grid>
            </TabItem>

        </TabControl>
        <TabControl Name="TabInferior" Margin="509,281,0,0">
            <TabItem Header="Envio">
                <Grid Background="#FFE5E5E5">
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="452*" />
                        <ColumnDefinition Width="17*" />
                        <ColumnDefinition Width="93*" />
                    </Grid.ColumnDefinitions>
                    <RichTextBox x:Name="RtbEnvioStr" Margin="0" VerticalScrollBarVisibility="Visible"
                                 IsReadOnly="True" Grid.ColumnSpan="3">
                        <FlowDocument />
                    </RichTextBox>
                </Grid>
            </TabItem>
            <TabItem Header="Retorno">
                <Grid Background="White">
                    <RichTextBox x:Name="RtbRetornoStr" Margin="0" VerticalScrollBarVisibility="Visible"
                                 IsReadOnly="True">
                        <FlowDocument />
                    </RichTextBox>
                </Grid>
            </TabItem>
            <TabItem Header="XML Retorno">
                <Grid Background="White">
                    <WebBrowser x:Name="WebXmlRetorno" />
                </Grid>
            </TabItem>
            <TabItem Header="Retorno Completo WS">
                <Grid Background="#FFE5E5E5">
                    <RichTextBox x:Name="RtbRetornoCompletoStr" Margin="0" VerticalScrollBarVisibility="Visible"
                                 IsReadOnly="True">
                        <FlowDocument />
                    </RichTextBox>
                </Grid>
            </TabItem>
            <TabItem Header="Dados Retorno">
                <Grid Background="#FFE5E5E5">
                    <RichTextBox x:Name="RtbDadosRetorno" Margin="0" VerticalScrollBarVisibility="Visible"
                                 IsReadOnly="True">
                        <FlowDocument />
                    </RichTextBox>
                </Grid>
            </TabItem>
            <TabItem Name="TabItemNfe" Header="NFe">
                <Grid Background="#FFE5E5E5">
                    <WebBrowser x:Name="WebXmlNfe" />
                </Grid>
            </TabItem>
        </TabControl>

    </Grid>
</Window>