using System; using System.Collections.Generic; using System.Linq; using System.Reflection; using System.Threading.Tasks; using Gestor.Application.Helpers; using Gestor.Application.Servicos.Configuracoes; using Gestor.Application.ViewModels.Generic; using Gestor.Model.Common; using Gestor.Model.Domain.Relatorios; namespace Gestor.Application.ViewModels.Relatorios; public class DialogPrintViewModel : BaseViewModel { private bool _carregando; private ConfiguracaoImpressao _configuracoes; private List _tamanhos = new List { "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 _carregando; } set { _carregando = value; OnPropertyChanged("Carregando"); } } public ConfiguracaoImpressao Configuracoes { get { return _configuracoes; } set { _configuracoes = value; OnPropertyChanged("Configuracoes"); } } public List Tamanhos { get { return _tamanhos; } set { _tamanhos = value; OnPropertyChanged("Tamanhos"); } } public bool OrientacaoImpressaoPortrait { get { return _orientacaoImpressaoPortrait; } set { _orientacaoImpressaoPortrait = value; OnPropertyChanged("OrientacaoImpressaoPortrait"); } } public bool OrientacaoImpressaoLandscape { get { return _orientacaoImpressaoLandscape; } set { _orientacaoImpressaoLandscape = value; OnPropertyChanged("OrientacaoImpressaoLandscape"); } } public bool OrientacaoImpressao { get; set; } public string TamanhoFonte { get { return _tamanhoFonte; } set { _tamanhoFonte = value; if (!(value == "MÉDIO")) { if (!(value == "GRANDE")) { Configuracoes.TamanhoFonte = 7; } else { Configuracoes.TamanhoFonte = 5; } } else { Configuracoes.TamanhoFonte = 6; } OnPropertyChanged("TamanhoFonte"); } } public DialogPrintViewModel(Relatorio relatorio, Type tipo) { //IL_003e: Unknown result type (might be due to invalid IL or missing references) _relatorio = relatorio; _tipo = tipo; } public async Task Carregar() { List list = await new ConfuguracoesServico().BuscarParametros(_relatorio); if (list == null || list.Count == 0) { list = ((IEnumerable)_tipo.GetProperties(BindingFlags.Instance | BindingFlags.Public)).Select((Func)((PropertyInfo x) => new ParametrosRelatorio { Campo = x.Name, Header = x.GetDescriptionAttribute(), Tipo = x.GetTypeAttribute(), Relatorio = _relatorio, Width = 0, Ordem = 0 })).ToList(); } list.ForEach(delegate(ParametrosRelatorio x) { x.Selecionado = true; }); Configuracoes = new ConfiguracaoImpressao { TamanhoFonte = 7, Campos = list, OrientacaoImpressao = false }; } public void Selecionar() { if (Carregando) { return; } ConfiguracaoImpressao configuracoes = Configuracoes; if (configuracoes != null) { configuracoes.Campos?.ForEach(delegate(ParametrosRelatorio x) { x.Selecionado = !x.Selecionado; }); } } }