summaryrefslogtreecommitdiff
path: root/Decompiler/Gestor.Application.Views.Ferramentas/CadastroEmailView.cs
diff options
context:
space:
mode:
Diffstat (limited to 'Decompiler/Gestor.Application.Views.Ferramentas/CadastroEmailView.cs')
-rw-r--r--Decompiler/Gestor.Application.Views.Ferramentas/CadastroEmailView.cs407
1 files changed, 407 insertions, 0 deletions
diff --git a/Decompiler/Gestor.Application.Views.Ferramentas/CadastroEmailView.cs b/Decompiler/Gestor.Application.Views.Ferramentas/CadastroEmailView.cs
new file mode 100644
index 0000000..bf93bab
--- /dev/null
+++ b/Decompiler/Gestor.Application.Views.Ferramentas/CadastroEmailView.cs
@@ -0,0 +1,407 @@
+using System;
+using System.CodeDom.Compiler;
+using System.Collections.Generic;
+using System.ComponentModel;
+using System.Diagnostics;
+using System.IO;
+using System.Linq;
+using System.Text.RegularExpressions;
+using System.Threading.Tasks;
+using System.Windows;
+using System.Windows.Controls;
+using System.Windows.Controls.Primitives;
+using System.Windows.Input;
+using System.Windows.Markup;
+using System.Windows.Threading;
+using Gestor.Application.Componentes;
+using Gestor.Application.Helpers;
+using Gestor.Application.ViewModels.Ferramentas;
+using Gestor.Common.Validation;
+using Gestor.Model.Common;
+using Gestor.Model.Domain.Ferramentas;
+using Gestor.Model.Domain.Generic;
+
+namespace Gestor.Application.Views.Ferramentas;
+
+public class CadastroEmailView : UserControl, IComponentConnector
+{
+ internal DataGrid CredenciaisGrid;
+
+ internal MenuItem SalvarApoliceButton;
+
+ internal MenuItem CancelarApoliceButton;
+
+ internal MenuItem MaisOpcoesButton;
+
+ internal TextBox DescricaoBox;
+
+ internal TextBox HeaderBox;
+
+ internal ComboBox TipoBox;
+
+ internal TextBox PortaBox;
+
+ internal TextBox DominioBox;
+
+ internal TextBox EmailBox;
+
+ internal CustomPasswordBox SenhaBox;
+
+ internal TextBox LoginBox;
+
+ internal TextBlock CabecalhoTitulo;
+
+ internal WebEditor Cabecalho;
+
+ internal TextBlock AssinaturaTitulo;
+
+ internal WebEditor Assinatura;
+
+ private bool _contentLoaded;
+
+ public CadastroEmailViewModel ViewModel { get; set; }
+
+ public CadastroEmailView()
+ {
+ ((FrameworkElement)this).Tag = "CADASTRO DE E-MAIL";
+ ViewModel = new CadastroEmailViewModel();
+ ((FrameworkElement)this).DataContext = ViewModel;
+ InitializeComponent();
+ Dispatcher dispatcher = ((DispatcherObject)this).Dispatcher;
+ if (dispatcher != null)
+ {
+ dispatcher.BeginInvoke((DispatcherPriority)7, (Delegate)new Action(ContentLoad));
+ }
+ }
+
+ private async void ContentLoad()
+ {
+ ViewModel.Loading(isLoading: true);
+ await ViewModel.SelecionaCredenciais();
+ ViewModel.Loading(isLoading: false);
+ }
+
+ private void Incluir_OnClick(object sender, RoutedEventArgs e)
+ {
+ ((UIElement)Assinatura).Visibility = (Visibility)0;
+ ((UIElement)AssinaturaTitulo).Visibility = (Visibility)0;
+ ViewModel.Incluir();
+ ValidarTela();
+ }
+
+ private async void Cancelar_OnClick(object sender, RoutedEventArgs e)
+ {
+ ViewModel.Loading(isLoading: true);
+ await ViewModel.CancelarAlteracao();
+ Assinatura.Initialize();
+ ((UIElement)Assinatura).Visibility = (Visibility)2;
+ ((UIElement)AssinaturaTitulo).Visibility = (Visibility)2;
+ Cabecalho.Initialize();
+ ((UIElement)Cabecalho).Visibility = (Visibility)2;
+ ((UIElement)CabecalhoTitulo).Visibility = (Visibility)2;
+ ViewModel.Loading(isLoading: false);
+ ScrollToItem();
+ }
+
+ private void ScrollToItem()
+ {
+ if (((Selector)CredenciaisGrid).SelectedItem != null)
+ {
+ ((UIElement)CredenciaisGrid).UpdateLayout();
+ CredenciaisGrid.ScrollIntoView(((Selector)CredenciaisGrid).SelectedItem);
+ }
+ }
+
+ private async void Salvar_OnClick(object sender, RoutedEventArgs e)
+ {
+ ViewModel.Loading(isLoading: true);
+ ViewModel.SelectedCredencial.Assinatura = ReplaceLocalImages(Assinatura.GetHtml());
+ ViewModel.SelectedCredencial.Cabecalho = ReplaceLocalImages(Cabecalho.GetHtml());
+ List<KeyValuePair<string, string>> list = await ViewModel.Salvar();
+ ((DependencyObject)(object)this).ValidateFields(list);
+ bool num = list == null || list.Count == 0;
+ ViewModel.Loading(isLoading: false);
+ if (num)
+ {
+ ((UIElement)Assinatura).Visibility = (Visibility)2;
+ ((UIElement)AssinaturaTitulo).Visibility = (Visibility)2;
+ ((UIElement)Cabecalho).Visibility = (Visibility)2;
+ ((UIElement)CabecalhoTitulo).Visibility = (Visibility)2;
+ ScrollToItem();
+ }
+ else
+ {
+ await ViewModel.ShowMessage(list, ViewModel.ErroCamposInvalidos, "OK");
+ }
+ }
+
+ public string ReplaceLocalImages(string mailBody)
+ {
+ string[] array = (from Match m in Regex.Matches(mailBody, "<img(.*?)src=\"file:(///).*?>", RegexOptions.IgnoreCase)
+ select m.Groups[0].Value).ToArray();
+ for (int i = 0; i < array.Length; i++)
+ {
+ string value = Regex.Match(array[i], "(?<=src=\")(.*?)(?=\")", RegexOptions.IgnoreCase).Value;
+ string text = Regex.Match(value, "file:(///).*\\.(.*)", RegexOptions.IgnoreCase).Groups[2].Value;
+ if (text == "jpg")
+ {
+ text = "jpeg";
+ }
+ if (Uri.IsWellFormedUriString(value, UriKind.Absolute))
+ {
+ Uri uri = new Uri(value);
+ if (File.Exists(uri.LocalPath))
+ {
+ mailBody = mailBody.Replace(value, "data:image/" + text + ";base64," + Convert.ToBase64String(File.ReadAllBytes(uri.LocalPath)));
+ }
+ }
+ }
+ return mailBody;
+ }
+
+ private void Alterar_OnClick(object sender, RoutedEventArgs e)
+ {
+ ((UIElement)Assinatura).Visibility = (Visibility)0;
+ ((UIElement)AssinaturaTitulo).Visibility = (Visibility)0;
+ ((UIElement)Cabecalho).Visibility = (Visibility)0;
+ ((UIElement)CabecalhoTitulo).Visibility = (Visibility)0;
+ ViewModel.Alterar(alterar: true);
+ ValidarTela();
+ ((DomainBase)ViewModel.SelectedCredencial).Initialize();
+ }
+
+ private async void Excluir_OnClick(object sender, RoutedEventArgs e)
+ {
+ await ViewModel.Excluir();
+ ScrollToItem();
+ }
+
+ private void AutoCompleteBox_Populating(object sender, PopulatingEventArgs e)
+ {
+ e.Cancel = true;
+ ViewModel.Filtrar(ValidationHelper.RemoveDiacritics(e.Parameter.Trim())).ContinueWith(delegate(Task<List<Credencial>> searchResult)
+ {
+ //IL_000f: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0014: Unknown result type (might be due to invalid IL or missing references)
+ if (searchResult.Result != null)
+ {
+ AutoCompleteBox val = (AutoCompleteBox)sender;
+ val.ItemsSource = searchResult.Result;
+ val.PopulateComplete();
+ }
+ }, TaskScheduler.FromCurrentSynchronizationContext());
+ }
+
+ private void AutoCompleteBox_OnTextChanged(object sender, RoutedEventArgs e)
+ {
+ //IL_0001: Unknown result type (might be due to invalid IL or missing references)
+ if (string.IsNullOrWhiteSpace(((AutoCompleteBox)sender).Text))
+ {
+ ViewModel.FiltrarCredenciais("");
+ }
+ }
+
+ private void AbrirLog_OnClick(object sender, RoutedEventArgs e)
+ {
+ ViewModel.AbrirLog((TipoTela)17, ((DomainBase)ViewModel.SelectedCredencial).Id);
+ }
+
+ private async void ButtonBase_OnClick(object sender, RoutedEventArgs e)
+ {
+ ViewModel.Loading(isLoading: true);
+ bool num = await ViewModel.EnviarTesteEmail();
+ ViewModel.Loading(isLoading: false);
+ if (num)
+ {
+ ViewModel.ToggleSnackBar("E-MAIL ENVIADO COM SUCESSO.");
+ }
+ }
+
+ private void ValidarTela()
+ {
+ if (ViewModel.SelectedCredencial != null)
+ {
+ List<KeyValuePair<string, string>> errorMessages = ViewModel.SelectedCredencial.Validate();
+ ((DependencyObject)(object)this).ValidateFields(errorMessages, focusField: false);
+ }
+ }
+
+ private void Tipo_OnSelectionChanged(object sender, SelectionChangedEventArgs e)
+ {
+ //IL_0001: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0012: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0015: Unknown result type (might be due to invalid IL or missing references)
+ //IL_001a: Unknown result type (might be due to invalid IL or missing references)
+ if ((TipoEmail?)((Selector)(ComboBox)sender).SelectedItem == (TipoEmail?)0 && ViewModel.SelectedCredencial.Email != null && ViewModel.SelectedCredencial.Email.Contains("@gmail.com"))
+ {
+ EmailBox.Text = "";
+ }
+ }
+
+ private void EmailBox_OnLostKeyboardFocus(object sender, KeyboardFocusChangedEventArgs e)
+ {
+ //IL_0001: Unknown result type (might be due to invalid IL or missing references)
+ if (((TextBox)sender).Text.Contains("@gmail.com"))
+ {
+ ((Selector)TipoBox).SelectedItem = (object)(TipoEmail)1;
+ }
+ }
+
+ [DebuggerNonUserCode]
+ [GeneratedCode("PresentationBuildTasks", "4.0.0.0")]
+ public void InitializeComponent()
+ {
+ if (!_contentLoaded)
+ {
+ _contentLoaded = true;
+ Uri uri = new Uri("/Gestor.Application;component/views/ferramentas/cadastroemailview.xaml", UriKind.Relative);
+ Application.LoadComponent((object)this, uri);
+ }
+ }
+
+ [DebuggerNonUserCode]
+ [GeneratedCode("PresentationBuildTasks", "4.0.0.0")]
+ internal Delegate _CreateDelegate(Type delegateType, string handler)
+ {
+ return Delegate.CreateDelegate(delegateType, this, handler);
+ }
+
+ [DebuggerNonUserCode]
+ [GeneratedCode("PresentationBuildTasks", "4.0.0.0")]
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ void IComponentConnector.Connect(int connectionId, object target)
+ {
+ //IL_0066: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0072: Unknown result type (might be due to invalid IL or missing references)
+ //IL_007c: Expected O, but got Unknown
+ //IL_007d: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0089: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0093: Expected O, but got Unknown
+ //IL_0096: Unknown result type (might be due to invalid IL or missing references)
+ //IL_00a0: Expected O, but got Unknown
+ //IL_00a2: Unknown result type (might be due to invalid IL or missing references)
+ //IL_00ae: Unknown result type (might be due to invalid IL or missing references)
+ //IL_00b8: Expected O, but got Unknown
+ //IL_00ba: Unknown result type (might be due to invalid IL or missing references)
+ //IL_00c6: Unknown result type (might be due to invalid IL or missing references)
+ //IL_00d0: Expected O, but got Unknown
+ //IL_00d3: Unknown result type (might be due to invalid IL or missing references)
+ //IL_00dd: Expected O, but got Unknown
+ //IL_00ea: Unknown result type (might be due to invalid IL or missing references)
+ //IL_00f4: Expected O, but got Unknown
+ //IL_00f7: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0101: Expected O, but got Unknown
+ //IL_010e: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0118: Expected O, but got Unknown
+ //IL_011a: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0126: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0130: Expected O, but got Unknown
+ //IL_0133: Unknown result type (might be due to invalid IL or missing references)
+ //IL_013d: Expected O, but got Unknown
+ //IL_013f: Unknown result type (might be due to invalid IL or missing references)
+ //IL_014b: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0155: Expected O, but got Unknown
+ //IL_0157: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0163: Unknown result type (might be due to invalid IL or missing references)
+ //IL_016d: Expected O, but got Unknown
+ //IL_0170: Unknown result type (might be due to invalid IL or missing references)
+ //IL_017a: Expected O, but got Unknown
+ //IL_017d: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0187: Expected O, but got Unknown
+ //IL_018a: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0194: Expected O, but got Unknown
+ //IL_01a1: Unknown result type (might be due to invalid IL or missing references)
+ //IL_01ab: Expected O, but got Unknown
+ //IL_01ae: Unknown result type (might be due to invalid IL or missing references)
+ //IL_01b8: Expected O, but got Unknown
+ //IL_01bb: Unknown result type (might be due to invalid IL or missing references)
+ //IL_01c5: Expected O, but got Unknown
+ //IL_01c8: Unknown result type (might be due to invalid IL or missing references)
+ //IL_01d2: Expected O, but got Unknown
+ //IL_01df: Unknown result type (might be due to invalid IL or missing references)
+ //IL_01e9: Expected O, but got Unknown
+ //IL_01f9: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0203: Expected O, but got Unknown
+ //IL_0206: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0210: Expected O, but got Unknown
+ //IL_0220: Unknown result type (might be due to invalid IL or missing references)
+ //IL_022a: Expected O, but got Unknown
+ switch (connectionId)
+ {
+ case 1:
+ ((AutoCompleteBox)target).Populating += new PopulatingEventHandler(AutoCompleteBox_Populating);
+ ((AutoCompleteBox)target).TextChanged += new RoutedEventHandler(AutoCompleteBox_OnTextChanged);
+ break;
+ case 2:
+ CredenciaisGrid = (DataGrid)target;
+ break;
+ case 3:
+ ((MenuItem)target).Click += new RoutedEventHandler(Incluir_OnClick);
+ break;
+ case 4:
+ ((MenuItem)target).Click += new RoutedEventHandler(Alterar_OnClick);
+ break;
+ case 5:
+ SalvarApoliceButton = (MenuItem)target;
+ SalvarApoliceButton.Click += new RoutedEventHandler(Salvar_OnClick);
+ break;
+ case 6:
+ CancelarApoliceButton = (MenuItem)target;
+ CancelarApoliceButton.Click += new RoutedEventHandler(Cancelar_OnClick);
+ break;
+ case 7:
+ ((MenuItem)target).Click += new RoutedEventHandler(Excluir_OnClick);
+ break;
+ case 8:
+ MaisOpcoesButton = (MenuItem)target;
+ break;
+ case 9:
+ ((MenuItem)target).Click += new RoutedEventHandler(ButtonBase_OnClick);
+ break;
+ case 10:
+ ((MenuItem)target).Click += new RoutedEventHandler(AbrirLog_OnClick);
+ break;
+ case 11:
+ DescricaoBox = (TextBox)target;
+ break;
+ case 12:
+ HeaderBox = (TextBox)target;
+ break;
+ case 13:
+ TipoBox = (ComboBox)target;
+ ((Selector)TipoBox).SelectionChanged += new SelectionChangedEventHandler(Tipo_OnSelectionChanged);
+ break;
+ case 14:
+ PortaBox = (TextBox)target;
+ break;
+ case 15:
+ DominioBox = (TextBox)target;
+ break;
+ case 16:
+ EmailBox = (TextBox)target;
+ ((UIElement)EmailBox).LostKeyboardFocus += new KeyboardFocusChangedEventHandler(EmailBox_OnLostKeyboardFocus);
+ break;
+ case 17:
+ SenhaBox = (CustomPasswordBox)target;
+ break;
+ case 18:
+ LoginBox = (TextBox)target;
+ break;
+ case 19:
+ CabecalhoTitulo = (TextBlock)target;
+ break;
+ case 20:
+ Cabecalho = (WebEditor)target;
+ break;
+ case 21:
+ AssinaturaTitulo = (TextBlock)target;
+ break;
+ case 22:
+ Assinatura = (WebEditor)target;
+ break;
+ default:
+ _contentLoaded = true;
+ break;
+ }
+ }
+}