summaryrefslogtreecommitdiff
path: root/Decompiler/Gestor.Application.Views.Relatorios/SinteticoView.cs
diff options
context:
space:
mode:
Diffstat (limited to 'Decompiler/Gestor.Application.Views.Relatorios/SinteticoView.cs')
-rw-r--r--Decompiler/Gestor.Application.Views.Relatorios/SinteticoView.cs509
1 files changed, 509 insertions, 0 deletions
diff --git a/Decompiler/Gestor.Application.Views.Relatorios/SinteticoView.cs b/Decompiler/Gestor.Application.Views.Relatorios/SinteticoView.cs
new file mode 100644
index 0000000..0cde0a8
--- /dev/null
+++ b/Decompiler/Gestor.Application.Views.Relatorios/SinteticoView.cs
@@ -0,0 +1,509 @@
+using System;
+using System.CodeDom.Compiler;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.ComponentModel;
+using System.Diagnostics;
+using System.Linq;
+using System.Runtime.InteropServices;
+using System.Windows;
+using System.Windows.Controls;
+using System.Windows.Forms;
+using System.Windows.Input;
+using System.Windows.Interop;
+using System.Windows.Markup;
+using System.Windows.Media;
+using System.Windows.Shapes;
+using System.Windows.Shell;
+using Gestor.Application.Helpers;
+using Gestor.Application.Model;
+using Gestor.Application.ViewModels.Relatorios;
+using Gestor.Model.Domain.Relatorios;
+
+namespace Gestor.Application.Views.Relatorios;
+
+public class SinteticoView : Window, IComponentConnector, IStyleConnector
+{
+ private enum MonitorOptions : uint
+ {
+ MonitorDefaulttoprimary = 1u,
+ MonitorDefaulttonearest
+ }
+
+ public struct Point
+ {
+ public int X;
+
+ public int Y;
+
+ public Point(int x, int y)
+ {
+ X = x;
+ Y = y;
+ }
+ }
+
+ private struct Minmaxinfo
+ {
+ private readonly MainWindow.Point ptReserved;
+
+ public Point ptMaxSize;
+
+ public Point ptMaxPosition;
+
+ private readonly MainWindow.Point ptMinTrackSize;
+
+ private readonly MainWindow.Point ptMaxTrackSize;
+ }
+
+ [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)]
+ private class Monitorinfo
+ {
+ private readonly int cbSize = Marshal.SizeOf(typeof(Monitorinfo));
+
+ public readonly Rect rcMonitor;
+
+ public readonly Rect rcWork;
+
+ private readonly int dwFlags;
+ }
+
+ public struct Rect
+ {
+ public int Left;
+
+ public int Top;
+
+ public int Right;
+
+ public int Bottom;
+ }
+
+ internal SinteticoViewModel ViewModel;
+
+ private bool _buttonClickable;
+
+ private ListSortDirection _ascending;
+
+ private string _member;
+
+ internal WindowChrome WindowChrome;
+
+ internal TextBlock SubTitulo;
+
+ internal Grid MinimizeButton;
+
+ internal Grid MaximizeButton;
+
+ internal Grid CloseButton;
+
+ internal TabControl Tab;
+
+ private bool _contentLoaded;
+
+ public DateTime? DateStart { get; set; }
+
+ public DateTime? DateFinal { get; set; }
+
+ private IntPtr WindowProc(IntPtr hwnd, int msg, IntPtr wParam, IntPtr lParam, ref bool handled)
+ {
+ if (msg == 36)
+ {
+ WmGetMinMaxInfo(lParam);
+ }
+ return IntPtr.Zero;
+ }
+
+ private void WmGetMinMaxInfo(IntPtr lParam)
+ {
+ //IL_0002: Unknown result type (might be due to invalid IL or missing references)
+ ((FrameworkElement)this).MaxHeight = Screen.FromHandle(new WindowInteropHelper((Window)(object)this).Handle).WorkingArea.Height;
+ GetCursorPos(out var lpPoint);
+ IntPtr hMonitor = MonitorFromPoint(new MainWindow.Point(0, 0), MonitorOptions.MonitorDefaulttoprimary);
+ Monitorinfo monitorinfo = new Monitorinfo();
+ if (GetMonitorInfo(hMonitor, monitorinfo))
+ {
+ IntPtr intPtr = MonitorFromPoint(lpPoint, MonitorOptions.MonitorDefaulttonearest);
+ Minmaxinfo structure = (Minmaxinfo)Marshal.PtrToStructure(lParam, typeof(Minmaxinfo));
+ if (hMonitor.Equals((object?)(nint)intPtr))
+ {
+ structure.ptMaxPosition.X = monitorinfo.rcWork.Left;
+ structure.ptMaxPosition.Y = monitorinfo.rcWork.Top;
+ structure.ptMaxSize.X = monitorinfo.rcWork.Right - monitorinfo.rcWork.Left;
+ structure.ptMaxSize.Y = monitorinfo.rcWork.Bottom - monitorinfo.rcWork.Top;
+ }
+ else
+ {
+ structure.ptMaxPosition.X = monitorinfo.rcMonitor.Left;
+ structure.ptMaxPosition.Y = monitorinfo.rcMonitor.Top;
+ structure.ptMaxSize.X = monitorinfo.rcMonitor.Right - monitorinfo.rcMonitor.Left;
+ structure.ptMaxSize.Y = monitorinfo.rcMonitor.Bottom - monitorinfo.rcMonitor.Top;
+ }
+ Marshal.StructureToPtr(structure, lParam, fDeleteOld: true);
+ }
+ }
+
+ [DllImport("user32.dll")]
+ [return: MarshalAs(UnmanagedType.Bool)]
+ private static extern bool GetCursorPos(out MainWindow.Point lpPoint);
+
+ [DllImport("user32.dll", SetLastError = true)]
+ private static extern IntPtr MonitorFromPoint(MainWindow.Point pt, MonitorOptions dwFlags);
+
+ [DllImport("user32.dll")]
+ private static extern bool GetMonitorInfo(IntPtr hMonitor, Monitorinfo lpmi);
+
+ public SinteticoView(List<Sintetico> sintetico, string relatorio, DateTime? inicio, DateTime? fim)
+ {
+ //IL_00d5: Unknown result type (might be due to invalid IL or missing references)
+ //IL_00df: Expected O, but got Unknown
+ //IL_00ec: Unknown result type (might be due to invalid IL or missing references)
+ //IL_00f6: Expected O, but got Unknown
+ //IL_0103: Unknown result type (might be due to invalid IL or missing references)
+ //IL_010d: Expected O, but got Unknown
+ //IL_011a: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0124: Expected O, but got Unknown
+ //IL_0131: Unknown result type (might be due to invalid IL or missing references)
+ //IL_013b: Expected O, but got Unknown
+ //IL_0148: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0152: Expected O, but got Unknown
+ ViewModel = new SinteticoViewModel(sintetico, relatorio);
+ ((FrameworkElement)this).DataContext = ViewModel;
+ InitializeComponent();
+ SubTitulo.Text = "VALORES BASEADOS NA RELAÇÃO EMITIDA ANTERIORMENTE - INICIO: " + inicio?.ToString("dd/MM/yyyy") + " FIM: " + fim?.ToString("dd/MM/yyyy");
+ DateStart = inicio ?? DateTime.MinValue;
+ DateFinal = fim ?? DateTime.MinValue;
+ ((UIElement)MinimizeButton).MouseEnter += new MouseEventHandler(TopControls_OnMouseEnter);
+ ((UIElement)MinimizeButton).MouseLeave += new MouseEventHandler(TopControls_OnMouseLeave);
+ ((UIElement)MaximizeButton).MouseEnter += new MouseEventHandler(TopControls_OnMouseEnter);
+ ((UIElement)MaximizeButton).MouseLeave += new MouseEventHandler(TopControls_OnMouseLeave);
+ ((UIElement)CloseButton).MouseEnter += new MouseEventHandler(TopControls_OnMouseEnter);
+ ((UIElement)CloseButton).MouseLeave += new MouseEventHandler(TopControls_OnMouseLeave);
+ }
+
+ private void TopControls_OnMouseLeftButtonDown(object sender, MouseButtonEventArgs e)
+ {
+ //IL_0008: Unknown result type (might be due to invalid IL or missing references)
+ //IL_000e: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0030: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0035: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0024: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0029: Unknown result type (might be due to invalid IL or missing references)
+ //IL_003f: Expected O, but got Unknown
+ _buttonClickable = true;
+ ((Panel)(Grid)sender).Background = (Brush)((((FrameworkElement)(Grid)sender).Name == "CloseButton") ? new SolidColorBrush(Colors.Red) : new SolidColorBrush(Colors.DimGray));
+ }
+
+ private void TopControls_OnMouseLeftButtonUp(object sender, MouseButtonEventArgs e)
+ {
+ //IL_000f: Unknown result type (might be due to invalid IL or missing references)
+ if (_buttonClickable)
+ {
+ ((object)this).GetType().GetMethod(((FrameworkElement)(Grid)sender).Name + "_Click")?.Invoke(this, null);
+ }
+ }
+
+ private static void TopControls_OnMouseEnter(object sender, MouseEventArgs e)
+ {
+ //IL_0001: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0007: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0029: Unknown result type (might be due to invalid IL or missing references)
+ //IL_002e: Unknown result type (might be due to invalid IL or missing references)
+ //IL_001d: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0022: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0038: Expected O, but got Unknown
+ //IL_0039: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0044: Expected O, but got Unknown
+ //IL_004e: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0053: Unknown result type (might be due to invalid IL or missing references)
+ //IL_005d: Expected O, but got Unknown
+ ((Panel)(Grid)sender).Background = (Brush)((((FrameworkElement)(Grid)sender).Name == "CloseButton") ? new SolidColorBrush(Colors.IndianRed) : new SolidColorBrush(Colors.Gray));
+ DependencyObject child = VisualTreeHelper.GetChild((DependencyObject)(Grid)sender, 0);
+ Path val = (Path)(object)((child is Path) ? child : null);
+ if (val != null)
+ {
+ ((Shape)val).Stroke = (Brush)new SolidColorBrush(Colors.White);
+ }
+ }
+
+ private void TopControls_OnMouseLeave(object sender, MouseEventArgs e)
+ {
+ //IL_0008: Unknown result type (might be due to invalid IL or missing references)
+ //IL_000d: 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_001c: Expected O, but got Unknown
+ //IL_001d: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0028: Expected O, but got Unknown
+ //IL_0032: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0037: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0041: Expected O, but got Unknown
+ _buttonClickable = false;
+ ((Panel)(Grid)sender).Background = (Brush)new SolidColorBrush(Colors.Transparent);
+ DependencyObject child = VisualTreeHelper.GetChild((DependencyObject)(Grid)sender, 0);
+ Path val = (Path)(object)((child is Path) ? child : null);
+ if (val != null)
+ {
+ ((Shape)val).Stroke = (Brush)new SolidColorBrush(Colors.White);
+ }
+ }
+
+ public void MinimizeButton_Click()
+ {
+ ((Window)this).WindowState = (WindowState)1;
+ }
+
+ public void MaximizeButton_Click()
+ {
+ //IL_0002: Unknown result type (might be due to invalid IL or missing references)
+ ((Window)this).WindowState = (WindowState)(((int)((Window)this).WindowState == 0) ? 2 : 0);
+ }
+
+ public void CloseButton_Click()
+ {
+ ((Window)this).Close();
+ }
+
+ protected sealed override void OnStateChanged(EventArgs e)
+ {
+ //IL_0002: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0008: Invalid comparison between Unknown and I4
+ //IL_000e: Unknown result type (might be due to invalid IL or missing references)
+ //IL_001f: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0025: Invalid comparison between Unknown and I4
+ //IL_002c: Unknown result type (might be due to invalid IL or missing references)
+ //IL_003d: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0043: Invalid comparison between Unknown and I4
+ //IL_0058: Unknown result type (might be due to invalid IL or missing references)
+ //IL_005e: Invalid comparison between Unknown and I4
+ ((Control)this).BorderThickness = new Thickness((double)(((int)((Window)this).WindowState != 2) ? 1 : 0));
+ WindowChrome.ResizeBorderThickness = new Thickness((double)(((int)((Window)this).WindowState != 2) ? 4 : 0));
+ WindowChrome.CaptionHeight = (((int)((Window)this).WindowState == 2) ? 33 : 30);
+ ViewModel.MaximizeRestore = (((int)((Window)this).WindowState == 2) ? Geometry.Parse((string)Application.Current.Resources[(object)"Restore"]) : Geometry.Parse((string)Application.Current.Resources[(object)"Maximize"]));
+ ((Window)this).OnStateChanged(e);
+ }
+
+ private void Window_OnInitialized(object sender, EventArgs e)
+ {
+ //IL_0001: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0006: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0023: Unknown result type (might be due to invalid IL or missing references)
+ //IL_002d: Expected O, but got Unknown
+ WindowInteropHelper val = new WindowInteropHelper((Window)(object)this);
+ val.EnsureHandle();
+ HwndSource obj = HwndSource.FromHwnd(val.Handle);
+ if (obj != null)
+ {
+ obj.AddHook(new HwndSourceHook(WindowProc));
+ }
+ }
+
+ private async void Imprimir_OnClick(object sender, RoutedEventArgs e)
+ {
+ MenuItem val = (MenuItem)sender;
+ if (val != null && ((FrameworkElement)val).DataContext != null)
+ {
+ SinteticoSource sinteticoSource = (SinteticoSource)((FrameworkElement)val).DataContext;
+ if (DateStart != DateTime.MinValue)
+ {
+ sinteticoSource.DateStart = DateStart;
+ sinteticoSource.DateFinal = DateFinal;
+ }
+ await ViewModel.Print(sinteticoSource);
+ }
+ }
+
+ private async void ImprimirUnicaPagina_OnClick(object sender, RoutedEventArgs e)
+ {
+ MenuItem val = (MenuItem)sender;
+ if (val != null && ((FrameworkElement)val).DataContext != null)
+ {
+ SinteticoSource sinteticoSource = (SinteticoSource)((FrameworkElement)val).DataContext;
+ if (DateStart != DateTime.MinValue)
+ {
+ sinteticoSource.DateStart = DateStart;
+ sinteticoSource.DateFinal = DateFinal;
+ }
+ await ViewModel.PrintUnica(sinteticoSource);
+ }
+ }
+
+ private void AjustaNome(SinteticoSource source)
+ {
+ foreach (ValorSintetico listum in source.Lista)
+ {
+ if (!string.IsNullOrEmpty(listum.Porcentagem) && !listum.Indice.Contains(listum.Porcentagem))
+ {
+ listum.Indice = listum.Indice + " - " + listum.Porcentagem + "%";
+ }
+ }
+ }
+
+ private async void ExportarPdf_OnClick(object sender, RoutedEventArgs e)
+ {
+ MenuItem val = (MenuItem)sender;
+ if (val != null && ((FrameworkElement)val).DataContext != null)
+ {
+ SinteticoSource sintetico = (SinteticoSource)((FrameworkElement)val).DataContext;
+ await ViewModel.GerarPdf(sintetico);
+ }
+ }
+
+ private async void ExportarExcel_OnClick(object sender, RoutedEventArgs e)
+ {
+ MenuItem val = (MenuItem)sender;
+ if (val != null && ((FrameworkElement)val).DataContext != null)
+ {
+ SinteticoSource sintetico = (SinteticoSource)((FrameworkElement)val).DataContext;
+ await ViewModel.GerarExcel(sintetico);
+ }
+ }
+
+ private void DataGrid_Sorting(object sender, DataGridSortingEventArgs e)
+ {
+ //IL_0001: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0007: Expected O, but got Unknown
+ DataGrid val = (DataGrid)sender;
+ if (val == null || ((FrameworkElement)val).DataContext == null)
+ {
+ return;
+ }
+ if (_member == ((DataGridColumnEventArgs)e).Column.SortMemberPath)
+ {
+ _ascending = ((_ascending == ListSortDirection.Ascending) ? ListSortDirection.Descending : ListSortDirection.Ascending);
+ }
+ else
+ {
+ _ascending = ListSortDirection.Ascending;
+ }
+ if (!(((ItemsControl)val).ItemsSource is ObservableCollection<ValorSintetico> observableCollection))
+ {
+ return;
+ }
+ IQueryable<ValorSintetico> source = observableCollection.AsQueryable();
+ List<ValorSintetico> list = ((_ascending == ListSortDirection.Ascending) ? source.OrderBy(((DataGridColumnEventArgs)e).Column.SortMemberPath).ToList() : source.OrderByDescending(((DataGridColumnEventArgs)e).Column.SortMemberPath).ToList()).OrderBy((ValorSintetico x) => x.Indice == "TOTAL").ToList();
+ observableCollection.Clear();
+ foreach (ValorSintetico item in list)
+ {
+ observableCollection.Add(item);
+ }
+ ViewModel.OnPropertyChanged("DataGrid_Sorting");
+ _member = ((DataGridColumnEventArgs)e).Column.SortMemberPath;
+ e.Handled = true;
+ }
+
+ [DebuggerNonUserCode]
+ [GeneratedCode("PresentationBuildTasks", "4.0.0.0")]
+ public void InitializeComponent()
+ {
+ if (!_contentLoaded)
+ {
+ _contentLoaded = true;
+ Uri uri = new Uri("/Gestor.Application;component/views/relatorios/sinteticoview.xaml", UriKind.Relative);
+ Application.LoadComponent((object)this, uri);
+ }
+ }
+
+ [DebuggerNonUserCode]
+ [GeneratedCode("PresentationBuildTasks", "4.0.0.0")]
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ void IComponentConnector.Connect(int connectionId, object target)
+ {
+ //IL_0043: Unknown result type (might be due to invalid IL or missing references)
+ //IL_004d: Expected O, but got Unknown
+ //IL_0050: Unknown result type (might be due to invalid IL or missing references)
+ //IL_005a: Expected O, but got Unknown
+ //IL_005d: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0067: Expected O, but got Unknown
+ //IL_0074: Unknown result type (might be due to invalid IL or missing references)
+ //IL_007e: Expected O, but got Unknown
+ //IL_008b: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0095: Expected O, but got Unknown
+ //IL_0098: Unknown result type (might be due to invalid IL or missing references)
+ //IL_00a2: Expected O, but got Unknown
+ //IL_00af: Unknown result type (might be due to invalid IL or missing references)
+ //IL_00b9: Expected O, but got Unknown
+ //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_0101: Unknown result type (might be due to invalid IL or missing references)
+ //IL_010b: 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
+ switch (connectionId)
+ {
+ case 1:
+ ((FrameworkElement)(SinteticoView)target).Initialized += Window_OnInitialized;
+ break;
+ case 2:
+ WindowChrome = (WindowChrome)target;
+ break;
+ case 3:
+ SubTitulo = (TextBlock)target;
+ break;
+ case 4:
+ MinimizeButton = (Grid)target;
+ ((UIElement)MinimizeButton).MouseLeftButtonDown += new MouseButtonEventHandler(TopControls_OnMouseLeftButtonDown);
+ ((UIElement)MinimizeButton).MouseLeftButtonUp += new MouseButtonEventHandler(TopControls_OnMouseLeftButtonUp);
+ break;
+ case 5:
+ MaximizeButton = (Grid)target;
+ ((UIElement)MaximizeButton).MouseLeftButtonDown += new MouseButtonEventHandler(TopControls_OnMouseLeftButtonDown);
+ ((UIElement)MaximizeButton).MouseLeftButtonUp += new MouseButtonEventHandler(TopControls_OnMouseLeftButtonUp);
+ break;
+ case 6:
+ CloseButton = (Grid)target;
+ ((UIElement)CloseButton).MouseLeftButtonDown += new MouseButtonEventHandler(TopControls_OnMouseLeftButtonDown);
+ ((UIElement)CloseButton).MouseLeftButtonUp += new MouseButtonEventHandler(TopControls_OnMouseLeftButtonUp);
+ break;
+ case 7:
+ Tab = (TabControl)target;
+ break;
+ default:
+ _contentLoaded = true;
+ break;
+ }
+ }
+
+ [DebuggerNonUserCode]
+ [GeneratedCode("PresentationBuildTasks", "4.0.0.0")]
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ void IStyleConnector.Connect(int connectionId, object target)
+ {
+ //IL_001e: Unknown result type (might be due to invalid IL or missing references)
+ //IL_002a: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0034: Expected O, but got Unknown
+ //IL_0036: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0042: Unknown result type (might be due to invalid IL or missing references)
+ //IL_004c: Expected O, but got Unknown
+ //IL_004e: Unknown result type (might be due to invalid IL or missing references)
+ //IL_005a: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0064: Expected O, but got Unknown
+ //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_007e: Unknown result type (might be due to invalid IL or missing references)
+ //IL_008a: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0094: Expected O, but got Unknown
+ switch (connectionId)
+ {
+ case 8:
+ ((MenuItem)target).Click += new RoutedEventHandler(Imprimir_OnClick);
+ break;
+ case 9:
+ ((MenuItem)target).Click += new RoutedEventHandler(ExportarPdf_OnClick);
+ break;
+ case 10:
+ ((MenuItem)target).Click += new RoutedEventHandler(ExportarExcel_OnClick);
+ break;
+ case 11:
+ ((MenuItem)target).Click += new RoutedEventHandler(ImprimirUnicaPagina_OnClick);
+ break;
+ case 12:
+ ((DataGrid)target).Sorting += new DataGridSortingEventHandler(DataGrid_Sorting);
+ break;
+ }
+ }
+}