From 674ca83ba9243a9e95a7568c797668dab6aee26a Mon Sep 17 00:00:00 2001 From: Lucas Faria Mendes Date: Mon, 30 Mar 2026 10:35:25 -0300 Subject: feat: upload files --- .../Views/Ferramentas/EtiquetaView.cs | 157 +++++++++++++++++++++ 1 file changed, 157 insertions(+) create mode 100644 Gestor.Application/Views/Ferramentas/EtiquetaView.cs (limited to 'Gestor.Application/Views/Ferramentas/EtiquetaView.cs') diff --git a/Gestor.Application/Views/Ferramentas/EtiquetaView.cs b/Gestor.Application/Views/Ferramentas/EtiquetaView.cs new file mode 100644 index 0000000..985ed97 --- /dev/null +++ b/Gestor.Application/Views/Ferramentas/EtiquetaView.cs @@ -0,0 +1,157 @@ +using Gestor.Application.ViewModels.Ferramentas; +using Gestor.Application.Views.Generic; +using Gestor.Common.Validation; +using Gestor.Model.Domain.Seguros; +using System; +using System.CodeDom.Compiler; +using System.Collections.Generic; +using System.ComponentModel; +using System.Diagnostics; +using System.Runtime.CompilerServices; +using System.Threading.Tasks; +using System.Windows; +using System.Windows.Controls; +using System.Windows.Input; +using System.Windows.Markup; + +namespace Gestor.Application.Views.Ferramentas +{ + public class EtiquetaView : BaseUserControl, IComponentConnector + { + internal EtiquetaViewModel ViewModel; + + internal System.Windows.Controls.AutoCompleteBox AutoCompleteBox; + + internal ProgressBar ProgressRing; + + internal System.Windows.Controls.DataGrid DataGrid; + + internal Grid Botoes; + + internal ComboBox CboTipoEtiqueta; + + private bool _contentLoaded; + + [DebuggerNonUserCode] + [GeneratedCode("PresentationBuildTasks", "4.0.0.0")] + internal Delegate _CreateDelegate(Type delegateType, string handler) + { + return Delegate.CreateDelegate(delegateType, this, handler); + } + + public EtiquetaView(List list, bool apenasCliente) + { + this.ViewModel = new EtiquetaViewModel(); + base.DataContext = this.ViewModel; + this.InitializeComponent(); + this.CboTipoEtiqueta.IsEnabled = !apenasCliente; + this.CarregarClientes(list, apenasCliente); + } + + private void AutoCompleteBox_OnTextChanged(object sender, RoutedEventArgs e) + { + if (!string.IsNullOrWhiteSpace(((System.Windows.Controls.AutoCompleteBox)sender).get_Text())) + { + return; + } + this.ViewModel.FiltrarApolice(""); + } + + private void AutoCompleteBox_Populating(object sender, PopulatingEventArgs e) + { + if (e.get_Parameter().Length < 3) + { + return; + } + e.set_Cancel(true); + this.ViewModel.Filtrar(ValidationHelper.RemoveDiacritics(e.get_Parameter().Trim())).ContinueWith((Task> searchResult) => { + if (searchResult.Result == null) + { + return; + } + System.Windows.Controls.AutoCompleteBox autoCompleteBox = (System.Windows.Controls.AutoCompleteBox)sender; + autoCompleteBox.set_ItemsSource(searchResult.Result); + autoCompleteBox.PopulateComplete(); + }, TaskScheduler.FromCurrentSynchronizationContext()); + } + + private async void CarregarClientes(List list, bool apenasCliente) + { + this.ProgressRing.Visibility = System.Windows.Visibility.Visible; + this.DataGrid.Visibility = System.Windows.Visibility.Collapsed; + this.Botoes.IsEnabled = false; + this.AutoCompleteBox.IsEnabled = false; + await this.ViewModel.CarregarDados(list, apenasCliente); + this.ProgressRing.Visibility = System.Windows.Visibility.Collapsed; + this.DataGrid.Visibility = System.Windows.Visibility.Visible; + this.Botoes.IsEnabled = true; + this.AutoCompleteBox.IsEnabled = true; + } + + private void Emitir_OnClick(object sender, RoutedEventArgs e) + { + this.ViewModel.EmitirEtiquetas(); + } + + [DebuggerNonUserCode] + [GeneratedCode("PresentationBuildTasks", "4.0.0.0")] + public void InitializeComponent() + { + if (this._contentLoaded) + { + return; + } + this._contentLoaded = true; + System.Windows.Application.LoadComponent(this, new Uri("/Gestor.Application;component/views/ferramentas/etiquetaview.xaml", UriKind.Relative)); + } + + [DebuggerNonUserCode] + [EditorBrowsable(EditorBrowsableState.Never)] + [GeneratedCode("PresentationBuildTasks", "4.0.0.0")] + void System.Windows.Markup.IComponentConnector.Connect(int connectionId, object target) + { + switch (connectionId) + { + case 1: + { + this.AutoCompleteBox = (System.Windows.Controls.AutoCompleteBox)target; + this.AutoCompleteBox.add_Populating(new PopulatingEventHandler(this, EtiquetaView.AutoCompleteBox_Populating)); + this.AutoCompleteBox.add_TextChanged(new RoutedEventHandler(this.AutoCompleteBox_OnTextChanged)); + return; + } + case 2: + { + this.ProgressRing = (ProgressBar)target; + return; + } + case 3: + { + this.DataGrid = (System.Windows.Controls.DataGrid)target; + return; + } + case 4: + { + this.Botoes = (Grid)target; + return; + } + case 5: + { + EtiquetaView etiquetaView = this; + ((TextBox)target).PreviewTextInput += new TextCompositionEventHandler(etiquetaView.SomenteNumeros); + return; + } + case 6: + { + this.CboTipoEtiqueta = (ComboBox)target; + return; + } + case 7: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.Emitir_OnClick); + return; + } + } + this._contentLoaded = true; + } + } +} \ No newline at end of file -- cgit v1.2.3