From 1f4e14b2e973ee7de337fd4866d9a5ceff5cb6d1 Mon Sep 17 00:00:00 2001 From: Lucas Faria Mendes Date: Mon, 30 Mar 2026 10:38:18 -0300 Subject: chore: location --- .../Gestor.Application/Drawers/ImpostoDrawer.cs | 296 +++++++++++++++++++++ 1 file changed, 296 insertions(+) create mode 100644 Codemerx/Gestor.Application/Drawers/ImpostoDrawer.cs (limited to 'Codemerx/Gestor.Application/Drawers/ImpostoDrawer.cs') diff --git a/Codemerx/Gestor.Application/Drawers/ImpostoDrawer.cs b/Codemerx/Gestor.Application/Drawers/ImpostoDrawer.cs new file mode 100644 index 0000000..648e160 --- /dev/null +++ b/Codemerx/Gestor.Application/Drawers/ImpostoDrawer.cs @@ -0,0 +1,296 @@ +using Gestor.Application; +using Gestor.Application.Helpers; +using Gestor.Application.ViewModels.Drawer; +using Gestor.Application.ViewModels.Generic; +using Gestor.Model.Domain.Generic; +using MaterialDesignThemes.Wpf; +using System; +using System.CodeDom.Compiler; +using System.Collections.Generic; +using System.ComponentModel; +using System.Diagnostics; +using System.Runtime.CompilerServices; +using System.Threading; +using System.Threading.Tasks; +using System.Windows; +using System.Windows.Controls; +using System.Windows.Controls.Primitives; +using System.Windows.Markup; +using System.Windows.Threading; + +namespace Gestor.Application.Drawers +{ + public class ImpostoDrawer : UserControl, IComponentConnector + { + private readonly int _tipo; + + private readonly long _id; + + internal System.Windows.Controls.ProgressBar ProgressBar; + + internal TextBlock TitleBox; + + internal ComboBox SeguradoraBox; + + internal ComboBox SeguradoraAlternativaBox; + + internal ComboBox RamoBox; + + internal DataGrid ArquivoGrid; + + internal Snackbar SnackbarImposto; + + private bool _contentLoaded; + + public ImpostoViewModel ViewModel + { + get; + set; + } + + [DebuggerNonUserCode] + [GeneratedCode("PresentationBuildTasks", "4.0.0.0")] + internal Delegate _CreateDelegate(Type delegateType, string handler) + { + return Delegate.CreateDelegate(delegateType, this, handler); + } + + public ImpostoDrawer(int tipo, long id) + { + this._tipo = tipo; + this._id = id; + this.ViewModel = new ImpostoViewModel(); + base.DataContext = this.ViewModel; + this.InitializeComponent(); + System.Windows.Threading.Dispatcher dispatcher = base.Dispatcher; + if (dispatcher == null) + { + return; + } + dispatcher.BeginInvoke(DispatcherPriority.Render, new Action(this.ContentLoad)); + } + + private void Alterar_OnClick(object sender, RoutedEventArgs e) + { + this.ViewModel.AlterarImposto(); + } + + private async void Cancelar_OnClick(object sender, RoutedEventArgs e) + { + await this.ViewModel.Cancelar(); + } + + private void CloseSlackBar() + { + Thread.Sleep(5000); + System.Windows.Threading.Dispatcher dispatcher = App.ProgressRing.Dispatcher; + if (dispatcher == null) + { + return; + } + dispatcher.BeginInvoke(DispatcherPriority.Background, new Action(() => this.Toggle("", false))); + } + + private async void ContentLoad() + { + this.ViewModel.Carregando = true; + await this.ViewModel.Carregar(this._tipo, this._id); + this.SeguradoraBox.SelectionChanged += new SelectionChangedEventHandler(this.Indice_OnSelectionChanged); + this.SeguradoraAlternativaBox.SelectionChanged += new SelectionChangedEventHandler(this.Indice_OnSelectionChanged); + this.RamoBox.SelectionChanged += new SelectionChangedEventHandler(this.Indice_OnSelectionChanged); + this.ViewModel.Carregando = false; + } + + private void Fechar_OnClick(object sender, RoutedEventArgs e) + { + this.ViewModel.CloseDrawer(); + } + + private void Incluir_OnClick(object sender, RoutedEventArgs e) + { + this.ViewModel.Incluir(); + } + + private async void Indice_OnSelectionChanged(object sender, SelectionChangedEventArgs e) + { + if (!this.ViewModel.Carregando) + { + this.ViewModel.Carregando = true; + await this.ViewModel.Carregar((long)0); + this.ViewModel.Carregando = false; + } + } + + [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/drawers/impostodrawer.xaml", UriKind.Relative)); + } + + private void Log_OnClick(object sender, RoutedEventArgs e) + { + this.ViewModel.AbrirLog(56, this.ViewModel.SelectedImposto.get_Id()); + } + + private async void Salvar_OnClick(object sender, RoutedEventArgs e) + { + bool flag; + this.ViewModel.Carregando = true; + List> keyValuePairs = await this.ViewModel.Salvar(); + this.ValidateFields(keyValuePairs, true); + flag = (keyValuePairs == null ? true : keyValuePairs.Count == 0); + this.ViewModel.Carregando = false; + if (!flag) + { + await this.ViewModel.ShowMessage(keyValuePairs, this.ViewModel.ErroCamposInvalidos, "OK", ""); + } + else + { + this.Toggle("PARÂMETRO SALVO COM SUCESSO.", true); + } + } + + private void SnackbarMessage_ActionClick(object sender, RoutedEventArgs e) + { + this.SnackbarImposto.set_IsActive(false); + } + + private async void Status_OnSelectionChanged(object sender, SelectionChangedEventArgs e) + { + bool? nullable; + string str; + ListBox listBox = (ListBox)sender; + if (listBox.SelectedItem != null) + { + ImpostoViewModel viewModel = this.ViewModel; + if (listBox.SelectedIndex == 0) + { + nullable = new bool?(true); + } + else if (listBox.SelectedIndex == 1) + { + nullable = new bool?(false); + } + else + { + nullable = null; + } + viewModel.Ativo = nullable; + TextBlock titleBox = this.TitleBox; + if (listBox.SelectedIndex == 0) + { + str = "IMPOSTOS ATIVOS"; + } + else + { + str = (listBox.SelectedIndex == 1 ? "IMPOSTOS INATIVOS" : "TODOS IMPOSTOS"); + } + titleBox.Text = str; + await this.ViewModel.Carregar((long)0); + } + } + + [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.ProgressBar = (System.Windows.Controls.ProgressBar)target; + return; + } + case 2: + { + ((ListBox)target).SelectionChanged += new SelectionChangedEventHandler(this.Status_OnSelectionChanged); + return; + } + case 3: + { + ((Button)target).Click += new RoutedEventHandler(this.Fechar_OnClick); + return; + } + case 4: + { + this.TitleBox = (TextBlock)target; + return; + } + case 5: + { + this.SeguradoraBox = (ComboBox)target; + return; + } + case 6: + { + this.SeguradoraAlternativaBox = (ComboBox)target; + return; + } + case 7: + { + this.RamoBox = (ComboBox)target; + return; + } + case 8: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.Incluir_OnClick); + return; + } + case 9: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.Alterar_OnClick); + return; + } + case 10: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.Salvar_OnClick); + return; + } + case 11: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.Cancelar_OnClick); + return; + } + case 12: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.Log_OnClick); + return; + } + case 13: + { + this.ArquivoGrid = (DataGrid)target; + return; + } + case 14: + { + this.SnackbarImposto = (Snackbar)target; + return; + } + case 15: + { + ((SnackbarMessage)target).add_ActionClick(new RoutedEventHandler(this.SnackbarMessage_ActionClick)); + return; + } + } + this._contentLoaded = true; + } + + public void Toggle(string message, bool active = true) + { + this.SnackbarImposto.get_Message().Content = message; + this.SnackbarImposto.set_IsActive(active); + if (!active) + { + return; + } + Task.Factory.StartNew(new Action(this.CloseSlackBar)); + } + } +} \ No newline at end of file -- cgit v1.2.3