diff options
Diffstat (limited to 'Decompiler/Gestor.Application.Views.Financeiro/ExtratoWindow.cs')
| -rw-r--r-- | Decompiler/Gestor.Application.Views.Financeiro/ExtratoWindow.cs | 562 |
1 files changed, 562 insertions, 0 deletions
diff --git a/Decompiler/Gestor.Application.Views.Financeiro/ExtratoWindow.cs b/Decompiler/Gestor.Application.Views.Financeiro/ExtratoWindow.cs new file mode 100644 index 0000000..15ac4d9 --- /dev/null +++ b/Decompiler/Gestor.Application.Views.Financeiro/ExtratoWindow.cs @@ -0,0 +1,562 @@ +using System; +using System.CodeDom.Compiler; +using System.ComponentModel; +using System.Diagnostics; +using System.Runtime.InteropServices; +using System.Threading; +using System.Threading.Tasks; +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 System.Windows.Threading; +using Gestor.Application.Helpers; +using Gestor.Application.ViewModels.Financeiro; +using Gestor.Common.Validation; +using MaterialDesignThemes.Wpf; + +namespace Gestor.Application.Views.Financeiro; + +public class ExtratoWindow : Window, IComponentConnector +{ + 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; + } + + private bool _buttonClickable; + + public ExtratoContaViewModel ViewModel; + + internal WindowChrome WindowChrome; + + internal Grid MinimizeButton; + + internal Grid MaximizeButton; + + internal Grid CloseButton; + + internal ProgressBar ProgressRing; + + internal ComboBox ContaBox; + + internal DatePicker InicioBox; + + internal DatePicker FimBox; + + internal DataGrid LancamentoGrid; + + internal TextBlock NaoHaDados; + + internal Snackbar Snackbar; + + private bool _contentLoaded; + + 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); + + 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); + } + + public ExtratoWindow(long id = 0L) + { + ViewModel = new ExtratoContaViewModel(id); + ((FrameworkElement)this).DataContext = ViewModel; + InitializeComponent(); + Dispatcher dispatcher = ((DispatcherObject)this).Dispatcher; + if (dispatcher != null) + { + dispatcher.BeginInvoke((DispatcherPriority)7, (Delegate)new Action(ContentLoad)); + } + string text = ApplicationHelper.Versao.ToString(); + ViewModel.Head = Recursos.Usuario.Nome + " - " + Recursos.Empresa.Nome + ", VOCÊ ESTÁ EM RELATÓRIOS DE CONTA CORRENTE | VERSÃO GESTOR " + text; + } + + private void ContentLoad() + { + //IL_000d: Unknown result type (might be due to invalid IL or missing references) + //IL_0017: Expected O, but got Unknown + //IL_0024: Unknown result type (might be due to invalid IL or missing references) + //IL_002e: Expected O, but got Unknown + //IL_003b: Unknown result type (might be due to invalid IL or missing references) + //IL_0045: Expected O, but got Unknown + //IL_0052: Unknown result type (might be due to invalid IL or missing references) + //IL_005c: Expected O, but got Unknown + //IL_0069: Unknown result type (might be due to invalid IL or missing references) + //IL_0073: Expected O, but got Unknown + //IL_0080: Unknown result type (might be due to invalid IL or missing references) + //IL_008a: Expected O, but got Unknown + //IL_0097: Unknown result type (might be due to invalid IL or missing references) + //IL_00a1: Expected O, but got Unknown + //IL_00ae: Unknown result type (might be due to invalid IL or missing references) + //IL_00b8: Expected O, but got Unknown + //IL_00dc: Unknown result type (might be due to invalid IL or missing references) + //IL_00e6: Expected O, but got Unknown + //IL_00f3: Unknown result type (might be due to invalid IL or missing references) + //IL_00fd: Expected O, but got Unknown + ((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); + ((UIElement)InicioBox).LostKeyboardFocus += new KeyboardFocusChangedEventHandler(DatePicker_OnLostKeyboardFocus); + ((UIElement)InicioBox).PreviewKeyDown += new KeyEventHandler(DatePicker_PreviewKeyDown); + InicioBox.SelectedDateChanged += Periodo_OnSelectedDateChanged; + ((UIElement)FimBox).LostKeyboardFocus += new KeyboardFocusChangedEventHandler(DatePicker_OnLostKeyboardFocus); + ((UIElement)FimBox).PreviewKeyDown += new KeyEventHandler(DatePicker_PreviewKeyDown); + FimBox.SelectedDateChanged += Periodo_OnSelectedDateChanged; + } + + private void Periodo_OnSelectedDateChanged(object sender, SelectionChangedEventArgs e) + { + ViewModel.LimparRelatorio(); + } + + 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 void SnackbarMessage_ActionClick(object sender, RoutedEventArgs e) + { + Snackbar.IsActive = false; + } + + public void ToggleSnackBar(string message, bool active = true) + { + ((ContentControl)Snackbar.Message).Content = message; + Snackbar.IsActive = active; + if (active) + { + Task.Factory.StartNew(CloseSlackBar); + } + } + + private void CloseSlackBar() + { + Thread.Sleep(3000); + Dispatcher dispatcher = ((DispatcherObject)App.ProgressRing).Dispatcher; + if (dispatcher != null) + { + dispatcher.BeginInvoke((DispatcherPriority)4, (Delegate)(Action)delegate + { + ToggleSnackBar("", active: false); + }); + } + } + + private void DatePicker_PreviewKeyDown(object sender, KeyEventArgs e) + { + //IL_0001: Unknown result type (might be due to invalid IL or missing references) + //IL_0007: Invalid comparison between Unknown and I4 + //IL_000b: Unknown result type (might be due to invalid IL or missing references) + if ((int)e.Key == 6) + { + ((DatePicker)sender).Text = Funcoes.GetNetworkTime().Date.ToString("dd/MM/yyyy"); + } + } + + private void DatePicker_OnLostKeyboardFocus(object sender, KeyboardFocusChangedEventArgs 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) + DatePicker val = (DatePicker)sender; + val.Text = ValidationHelper.FormatDate(val.Text); + } + + private async void GerarResultados_OnClick(object sender, RoutedEventArgs e) + { + if (ValidationHelper.ValidateDate(ValidationHelper.FormatDate(InicioBox.Text))) + { + InicioBox.SelectedDate = DateTime.Parse(ValidationHelper.FormatDate(InicioBox.Text)); + } + if (ValidationHelper.ValidateDate(ValidationHelper.FormatDate(FimBox.Text))) + { + FimBox.SelectedDate = DateTime.Parse(ValidationHelper.FormatDate(FimBox.Text)); + } + if (!InicioBox.SelectedDate.HasValue || !FimBox.SelectedDate.HasValue) + { + await ViewModel.ShowMessage("NECESSÁRIO PREENCHER O PERIODO INICIAL E FINAL PARA O FILTRO."); + return; + } + if (InicioBox.SelectedDate > FimBox.SelectedDate) + { + await ViewModel.ShowMessage("A DATA FINAL NÃO PODE SER MENOR QUE A DATA INICIAL DO FILTRO."); + return; + } + ((UIElement)ProgressRing).Visibility = (Visibility)0; + ViewModel.IsEnabled = false; + await ViewModel.GerarRelatorio(); + ViewModel.IsEnabled = true; + ((UIElement)ProgressRing).Visibility = (Visibility)2; + } + + private async void Imprimir_OnClick(object sender, RoutedEventArgs e) + { + await ViewModel.Print(); + } + + private async void ExportarExcel_OnClick(object sender, RoutedEventArgs e) + { + await ViewModel.GerarExcel(); + } + + private void DataAtual_OnDoubleClick(object sender, RoutedEventArgs e) + { + //IL_0001: Unknown result type (might be due to invalid IL or missing references) + ((DatePicker)sender).SelectedDate = Funcoes.GetNetworkTime().Date; + } + + [DebuggerNonUserCode] + [GeneratedCode("PresentationBuildTasks", "4.0.0.0")] + public void InitializeComponent() + { + if (!_contentLoaded) + { + _contentLoaded = true; + Uri uri = new Uri("/Gestor.Application;component/views/financeiro/extratowindow.xaml", UriKind.Relative); + Application.LoadComponent((object)this, uri); + } + } + + [DebuggerNonUserCode] + [GeneratedCode("PresentationBuildTasks", "4.0.0.0")] + internal Delegate _CreateDelegate(Type delegateType, string handler) + { + return Delegate.CreateDelegate(delegateType, this, handler); + } + + [DebuggerNonUserCode] + [GeneratedCode("PresentationBuildTasks", "4.0.0.0")] + [EditorBrowsable(EditorBrowsableState.Never)] + void IComponentConnector.Connect(int connectionId, object target) + { + //IL_0067: Unknown result type (might be due to invalid IL or missing references) + //IL_0071: 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_00a2: Unknown result type (might be due to invalid IL or missing references) + //IL_00ac: 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_00dd: Unknown result type (might be due to invalid IL or missing references) + //IL_00e7: 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_0118: Unknown result type (might be due to invalid IL or missing references) + //IL_0122: Expected O, but got Unknown + //IL_0125: Unknown result type (might be due to invalid IL or missing references) + //IL_012f: Expected O, but got Unknown + //IL_0132: Unknown result type (might be due to invalid IL or missing references) + //IL_013c: Expected O, but got Unknown + //IL_013f: Unknown result type (might be due to invalid IL or missing references) + //IL_0149: Expected O, but got Unknown + //IL_0156: Unknown result type (might be due to invalid IL or missing references) + //IL_0160: Expected O, but got Unknown + //IL_016d: Unknown result type (might be due to invalid IL or missing references) + //IL_0177: Expected O, but got Unknown + //IL_017a: Unknown result type (might be due to invalid IL or missing references) + //IL_0184: Expected O, but got Unknown + //IL_0191: Unknown result type (might be due to invalid IL or missing references) + //IL_019b: Expected O, but got Unknown + //IL_01a8: Unknown result type (might be due to invalid IL or missing references) + //IL_01b2: Expected O, but got Unknown + //IL_01b4: Unknown result type (might be due to invalid IL or missing references) + //IL_01c0: Unknown result type (might be due to invalid IL or missing references) + //IL_01ca: Expected O, but got Unknown + //IL_01cc: Unknown result type (might be due to invalid IL or missing references) + //IL_01d8: Unknown result type (might be due to invalid IL or missing references) + //IL_01e2: Expected O, but got Unknown + //IL_01e4: Unknown result type (might be due to invalid IL or missing references) + //IL_01f0: Unknown result type (might be due to invalid IL or missing references) + //IL_01fa: Expected O, but got Unknown + //IL_01fd: Unknown result type (might be due to invalid IL or missing references) + //IL_0207: Expected O, but got Unknown + //IL_020a: Unknown result type (might be due to invalid IL or missing references) + //IL_0214: Expected O, but got Unknown + //IL_0217: Unknown result type (might be due to invalid IL or missing references) + //IL_0221: Expected O, but got Unknown + //IL_0223: Unknown result type (might be due to invalid IL or missing references) + //IL_022f: Unknown result type (might be due to invalid IL or missing references) + //IL_0239: Expected O, but got Unknown + switch (connectionId) + { + case 1: + ((FrameworkElement)(ExtratoWindow)target).Initialized += Window_OnInitialized; + break; + case 2: + WindowChrome = (WindowChrome)target; + break; + case 3: + MinimizeButton = (Grid)target; + ((UIElement)MinimizeButton).MouseLeftButtonDown += new MouseButtonEventHandler(TopControls_OnMouseLeftButtonDown); + ((UIElement)MinimizeButton).MouseLeftButtonUp += new MouseButtonEventHandler(TopControls_OnMouseLeftButtonUp); + break; + case 4: + MaximizeButton = (Grid)target; + ((UIElement)MaximizeButton).MouseLeftButtonDown += new MouseButtonEventHandler(TopControls_OnMouseLeftButtonDown); + ((UIElement)MaximizeButton).MouseLeftButtonUp += new MouseButtonEventHandler(TopControls_OnMouseLeftButtonUp); + break; + case 5: + CloseButton = (Grid)target; + ((UIElement)CloseButton).MouseLeftButtonDown += new MouseButtonEventHandler(TopControls_OnMouseLeftButtonDown); + ((UIElement)CloseButton).MouseLeftButtonUp += new MouseButtonEventHandler(TopControls_OnMouseLeftButtonUp); + break; + case 6: + ProgressRing = (ProgressBar)target; + break; + case 7: + ContaBox = (ComboBox)target; + break; + case 8: + InicioBox = (DatePicker)target; + ((UIElement)InicioBox).LostKeyboardFocus += new KeyboardFocusChangedEventHandler(DatePicker_OnLostKeyboardFocus); + ((Control)InicioBox).MouseDoubleClick += new MouseButtonEventHandler(DataAtual_OnDoubleClick); + break; + case 9: + FimBox = (DatePicker)target; + ((UIElement)FimBox).LostKeyboardFocus += new KeyboardFocusChangedEventHandler(DatePicker_OnLostKeyboardFocus); + ((Control)FimBox).MouseDoubleClick += new MouseButtonEventHandler(DataAtual_OnDoubleClick); + break; + case 10: + ((MenuItem)target).Click += new RoutedEventHandler(GerarResultados_OnClick); + break; + case 11: + ((MenuItem)target).Click += new RoutedEventHandler(Imprimir_OnClick); + break; + case 12: + ((MenuItem)target).Click += new RoutedEventHandler(ExportarExcel_OnClick); + break; + case 13: + LancamentoGrid = (DataGrid)target; + break; + case 14: + NaoHaDados = (TextBlock)target; + break; + case 15: + Snackbar = (Snackbar)target; + break; + case 16: + ((SnackbarMessage)target).ActionClick += new RoutedEventHandler(SnackbarMessage_ActionClick); + break; + default: + _contentLoaded = true; + break; + } + } +} |