using Gestor.Application; using Gestor.Application.Componentes; using Gestor.Application.ViewModels; using Gestor.Application.ViewModels.Generic; using System; using System.CodeDom.Compiler; using System.ComponentModel; using System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; using System.Threading.Tasks; using System.Windows; using System.Windows.Controls; using System.Windows.Controls.Primitives; using System.Windows.Input; using System.Windows.Markup; using System.Windows.Media; using System.Windows.Shapes; using System.Windows.Shell; using System.Windows.Threading; namespace Gestor.Application.Views { public class TutorialView : Window, IComponentConnector { public TutorialViewModel ViewModel; private bool _buttonClickable; internal System.Windows.Shell.WindowChrome WindowChrome; internal Grid CloseButton; internal Grid ProgressRing; internal Image ProgressBar; internal TextBox NomeBox; internal TextBox UserBox; internal CustomSenhaLoginBox PasswordBox; internal CustomSenhaLoginBox ConfirmacaoBox; private bool _contentLoaded; private Tuple PrimeiroAcesso { get; set; } [DebuggerNonUserCode] [GeneratedCode("PresentationBuildTasks", "4.0.0.0")] internal Delegate _CreateDelegate(Type delegateType, string handler) { return Delegate.CreateDelegate(delegateType, this, handler); } public TutorialView(Tuple primeiroacesso) { this.PrimeiroAcesso = primeiroacesso; this.ViewModel = new TutorialViewModel(); base.DataContext = this.ViewModel; this.InitializeComponent(); System.Windows.Threading.Dispatcher dispatcher = base.Dispatcher; if (dispatcher != null) { dispatcher.BeginInvoke(DispatcherPriority.Render, new Action(this.ContentLoad)); } else { } this.CloseButton.MouseEnter += new MouseEventHandler(TutorialView.TopControls_OnMouseEnter); this.CloseButton.MouseLeave += new MouseEventHandler(this.TopControls_OnMouseLeave); } public void CloseButton_Click() { base.Close(); } private async void Concluir_OnClick(object sender, RoutedEventArgs e) { this.ViewModel.EnableFields = false; this.Loading(true); bool flag = await this.ViewModel.Concluir(); this.Loading(false); this.ViewModel.EnableFields = true; if (!flag) { base.Close(); } else if (await this.ViewModel.VerificaAcesso()) { (new MainWindow()).Show(); base.Close(); } else { base.Close(); } } private void ConfirmacaoBox_LostFocus(object sender, RoutedEventArgs e) { this.ViewModel.ConfirmacaoSenha = this.ConfirmacaoBox.Text; } private async void ContentLoad() { string str = null; this.Loading(true); if (this.PrimeiroAcesso.Item1) { await this.ViewModel.VerificarUsuario(); } else { str = await this.ViewModel.CriarBanco(); } this.Loading(false); if (str == null) { str = await this.ViewModel.VerificaEmpresa(); if (str == null) { this.ViewModel.Fase1 = true; await this.ViewModel.IniciarConfiguracoes(); } else { await this.ViewModel.ShowMessage(str, "OK", "", false); } } else { await this.ViewModel.ShowMessage(str, "OK", "", false); } str = null; } private void DestativarTodasAsSeguradoras_OnClick(object sender, RoutedEventArgs e) { this.ViewModel.DesativarSeguradoras(); } private void DestativarTodosOsRamos_OnClick(object sender, RoutedEventArgs e) { this.ViewModel.DesativarRamos(); } [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/views/tutorialview.xaml", UriKind.Relative)); } private void Loading(bool loading) { if (loading) { TutorialViewModel viewModel = this.ViewModel; TutorialViewModel tutorialViewModel = this.ViewModel; int num = 0; bool flag = (bool)num; this.ViewModel.Fase3 = (bool)num; bool flag1 = flag; bool flag2 = flag1; tutorialViewModel.Fase2 = flag1; viewModel.Fase1 = flag2; } this.ViewModel.LoadingVisibility = loading; } protected override void OnRenderSizeChanged(SizeChangedInfo sizeInfo) { Size newSize; base.OnRenderSizeChanged(sizeInfo); if (sizeInfo.HeightChanged) { double top = base.Top; double height = sizeInfo.PreviousSize.Height; newSize = sizeInfo.NewSize; base.Top = top + (height - newSize.Height) / 2; } if (sizeInfo.WidthChanged) { double left = base.Left; double width = sizeInfo.PreviousSize.Width; newSize = sizeInfo.NewSize; base.Left = left + (width - newSize.Width) / 2; } } private void PasswordBox_LostFocus(object sender, RoutedEventArgs e) { this.ViewModel.Senha = this.PasswordBox.Text; } private async void ProsseguirFase1_OnClick(object sender, RoutedEventArgs e) { this.ViewModel.EnableFields = false; this.Loading(true); if (!await this.ViewModel.ValidarLogin()) { base.Close(); } this.Loading(false); this.ViewModel.EnableFields = true; } private async void ProsseguirFase2_OnClick(object sender, RoutedEventArgs e) { this.ViewModel.EnableFields = false; this.Loading(true); await this.ViewModel.ValidarSeguradoras(); this.Loading(false); this.ViewModel.EnableFields = true; } [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.WindowChrome = (System.Windows.Shell.WindowChrome)target; return; } case 2: { this.CloseButton = (Grid)target; this.CloseButton.MouseLeftButtonDown += new MouseButtonEventHandler(this.TopControls_OnMouseLeftButtonDown); this.CloseButton.MouseLeftButtonUp += new MouseButtonEventHandler(this.TopControls_OnMouseLeftButtonUp); return; } case 3: { this.ProgressRing = (Grid)target; return; } case 4: { this.ProgressBar = (Image)target; return; } case 5: { this.NomeBox = (TextBox)target; return; } case 6: { this.UserBox = (TextBox)target; return; } case 7: { this.PasswordBox = (CustomSenhaLoginBox)target; return; } case 8: { this.ConfirmacaoBox = (CustomSenhaLoginBox)target; return; } case 9: { ((RepeatButton)target).Click += new RoutedEventHandler(this.ProsseguirFase1_OnClick); return; } case 10: { ((RepeatButton)target).Click += new RoutedEventHandler(this.DestativarTodasAsSeguradoras_OnClick); return; } case 11: { ((RepeatButton)target).Click += new RoutedEventHandler(this.VoltarFase2_OnClick); return; } case 12: { ((RepeatButton)target).Click += new RoutedEventHandler(this.ProsseguirFase2_OnClick); return; } case 13: { ((RepeatButton)target).Click += new RoutedEventHandler(this.DestativarTodosOsRamos_OnClick); return; } case 14: { ((RepeatButton)target).Click += new RoutedEventHandler(this.VoltarFase3_OnClick); return; } case 15: { ((RepeatButton)target).Click += new RoutedEventHandler(this.Concluir_OnClick); return; } } this._contentLoaded = true; } private static void TopControls_OnMouseEnter(object sender, MouseEventArgs e) { ((Grid)sender).Background = (((Grid)sender).Name == "CloseButton" ? new SolidColorBrush(Colors.IndianRed) : new SolidColorBrush(Colors.Gray)); Path child = VisualTreeHelper.GetChild((Grid)sender, 0) as Path; if (child != null) { child.Stroke = new SolidColorBrush(Colors.White); } } private void TopControls_OnMouseLeave(object sender, MouseEventArgs e) { this._buttonClickable = false; ((Grid)sender).Background = new SolidColorBrush(Colors.Transparent); Path child = VisualTreeHelper.GetChild((Grid)sender, 0) as Path; if (child != null) { child.Stroke = new SolidColorBrush(Colors.White); } } private void TopControls_OnMouseLeftButtonDown(object sender, MouseButtonEventArgs e) { this._buttonClickable = true; ((Grid)sender).Background = (((Grid)sender).Name == "CloseButton" ? new SolidColorBrush(Colors.Red) : new SolidColorBrush(Colors.DimGray)); } private void TopControls_OnMouseLeftButtonUp(object sender, MouseButtonEventArgs e) { if (this._buttonClickable) { MethodInfo method = base.GetType().GetMethod(string.Concat(((Grid)sender).Name, "_Click")); if (method == null) { return; } method.Invoke(this, null); } } private void VoltarFase2_OnClick(object sender, RoutedEventArgs e) { this.ViewModel.Fase1 = true; this.ViewModel.Fase2 = false; } private void VoltarFase3_OnClick(object sender, RoutedEventArgs e) { this.ViewModel.Fase2 = true; this.ViewModel.Fase3 = false; } } }