diff options
| author | Lucas Faria Mendes <lucas.fariamo08@gmail.com> | 2026-03-30 13:35:25 +0000 |
|---|---|---|
| committer | Lucas Faria Mendes <lucas.fariamo08@gmail.com> | 2026-03-30 13:35:25 +0000 |
| commit | 674ca83ba9243a9e95a7568c797668dab6aee26a (patch) | |
| tree | 4a905b3fb1d827665a34d63f67bc5559f8e7235b /Gestor.Application/ViewModels/Relatorios/DialogPrintViewModel.cs | |
| download | gestor-674ca83ba9243a9e95a7568c797668dab6aee26a.tar.gz gestor-674ca83ba9243a9e95a7568c797668dab6aee26a.zip | |
feat: upload files
Diffstat (limited to 'Gestor.Application/ViewModels/Relatorios/DialogPrintViewModel.cs')
| -rw-r--r-- | Gestor.Application/ViewModels/Relatorios/DialogPrintViewModel.cs | 193 |
1 files changed, 193 insertions, 0 deletions
diff --git a/Gestor.Application/ViewModels/Relatorios/DialogPrintViewModel.cs b/Gestor.Application/ViewModels/Relatorios/DialogPrintViewModel.cs new file mode 100644 index 0000000..537bed2 --- /dev/null +++ b/Gestor.Application/ViewModels/Relatorios/DialogPrintViewModel.cs @@ -0,0 +1,193 @@ +using Gestor.Application.Helpers;
+using Gestor.Application.Servicos.Configuracoes;
+using Gestor.Application.ViewModels.Generic;
+using Gestor.Model.Common;
+using Gestor.Model.Domain.Relatorios;
+using System;
+using System.Collections.Generic;
+using System.Diagnostics;
+using System.Linq;
+using System.Reflection;
+using System.Runtime.CompilerServices;
+using System.Threading.Tasks;
+
+namespace Gestor.Application.ViewModels.Relatorios
+{
+ public class DialogPrintViewModel : BaseViewModel
+ {
+ private bool _carregando;
+
+ private ConfiguracaoImpressao _configuracoes;
+
+ private List<string> _tamanhos = new List<string>()
+ {
+ "GRANDE",
+ "MÉDIO",
+ "PEQUENO"
+ };
+
+ private bool _orientacaoImpressaoPortrait;
+
+ private bool _orientacaoImpressaoLandscape;
+
+ private string _tamanhoFonte = "PEQUENO";
+
+ private Relatorio _relatorio
+ {
+ get;
+ set;
+ }
+
+ private Type _tipo
+ {
+ get;
+ set;
+ }
+
+ public bool Carregando
+ {
+ get
+ {
+ return this._carregando;
+ }
+ set
+ {
+ this._carregando = value;
+ base.OnPropertyChanged("Carregando");
+ }
+ }
+
+ public ConfiguracaoImpressao Configuracoes
+ {
+ get
+ {
+ return this._configuracoes;
+ }
+ set
+ {
+ this._configuracoes = value;
+ base.OnPropertyChanged("Configuracoes");
+ }
+ }
+
+ public bool OrientacaoImpressao
+ {
+ get;
+ set;
+ }
+
+ public bool OrientacaoImpressaoLandscape
+ {
+ get
+ {
+ return this._orientacaoImpressaoLandscape;
+ }
+ set
+ {
+ this._orientacaoImpressaoLandscape = value;
+ base.OnPropertyChanged("OrientacaoImpressaoLandscape");
+ }
+ }
+
+ public bool OrientacaoImpressaoPortrait
+ {
+ get
+ {
+ return this._orientacaoImpressaoPortrait;
+ }
+ set
+ {
+ this._orientacaoImpressaoPortrait = value;
+ base.OnPropertyChanged("OrientacaoImpressaoPortrait");
+ }
+ }
+
+ public string TamanhoFonte
+ {
+ get
+ {
+ return this._tamanhoFonte;
+ }
+ set
+ {
+ this._tamanhoFonte = value;
+ if (value == "MÉDIO")
+ {
+ this.Configuracoes.set_TamanhoFonte(6);
+ }
+ else if (value == "GRANDE")
+ {
+ this.Configuracoes.set_TamanhoFonte(5);
+ }
+ else
+ {
+ this.Configuracoes.set_TamanhoFonte(7);
+ }
+ base.OnPropertyChanged("TamanhoFonte");
+ }
+ }
+
+ public List<string> Tamanhos
+ {
+ get
+ {
+ return this._tamanhos;
+ }
+ set
+ {
+ this._tamanhos = value;
+ base.OnPropertyChanged("Tamanhos");
+ }
+ }
+
+ public DialogPrintViewModel(Relatorio relatorio, Type tipo)
+ {
+ this._relatorio = relatorio;
+ this._tipo = tipo;
+ }
+
+ public async Task Carregar()
+ {
+ List<ParametrosRelatorio> list = await (new ConfuguracoesServico()).BuscarParametros(this._relatorio);
+ if (list == null || list.Count == 0)
+ {
+ list = this._tipo.GetProperties(BindingFlags.Instance | BindingFlags.Public).Select<PropertyInfo, ParametrosRelatorio>((PropertyInfo x) => {
+ ParametrosRelatorio parametrosRelatorio = new ParametrosRelatorio();
+ parametrosRelatorio.set_Campo(x.Name);
+ parametrosRelatorio.set_Header(x.GetDescriptionAttribute());
+ parametrosRelatorio.set_Tipo(x.GetTypeAttribute());
+ parametrosRelatorio.set_Relatorio(this._relatorio);
+ parametrosRelatorio.set_Width(0);
+ parametrosRelatorio.set_Ordem(0);
+ return parametrosRelatorio;
+ }).ToList<ParametrosRelatorio>();
+ }
+ List<ParametrosRelatorio> parametrosRelatorios = list;
+ parametrosRelatorios.ForEach((ParametrosRelatorio x) => x.set_Selecionado(true));
+ ConfiguracaoImpressao configuracaoImpressao = new ConfiguracaoImpressao();
+ configuracaoImpressao.set_TamanhoFonte(7);
+ configuracaoImpressao.set_Campos(list);
+ configuracaoImpressao.set_OrientacaoImpressao(new bool?(false));
+ this.Configuracoes = configuracaoImpressao;
+ }
+
+ public void Selecionar()
+ {
+ if (this.Carregando)
+ {
+ return;
+ }
+ ConfiguracaoImpressao configuracoes = this.Configuracoes;
+ if (configuracoes == null)
+ {
+ return;
+ }
+ List<ParametrosRelatorio> campos = configuracoes.get_Campos();
+ if (campos == null)
+ {
+ return;
+ }
+ campos.ForEach((ParametrosRelatorio x) => x.set_Selecionado(!x.get_Selecionado()));
+ }
+ }
+}
\ No newline at end of file |