using System; using System.CodeDom.Compiler; using System.Collections.Generic; using System.ComponentModel; using System.Diagnostics; using System.Linq; using System.Net; using System.Net.Http; using System.Net.Sockets; 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.Threading; using Agger.Registro; using Gestor.Application.Componentes; using Gestor.Application.Helpers; using Gestor.Application.Servicos.Ajuda; using Gestor.Application.Servicos.Generic; using Gestor.Application.ViewModels; using Gestor.Application.Views.Ferramentas; using Gestor.Infrastructure.UnitOfWork.Generic; using Gestor.Infrastructure.UnitOfWork.Logic; using Gestor.Model.API; using Gestor.Model.Common; using Gestor.Model.Domain.Common; using Gestor.Model.Domain.Generic; using Gestor.Model.License; using Newtonsoft.Json.Linq; namespace Gestor.Application.Views; public class LoginWindow : Window, IComponentConnector { internal LoginViewModel ViewModel; private bool _buttonClickable; private DispatcherTimer _carouselTimer; internal Image ProgressRing; internal TextBox UserBox; internal CustomSenhaLoginBox PasswordBox; internal TextBlock TrocaSenha; internal CustomSenhaLoginBox SenhaBox; internal CustomSenhaLoginBox ConfirmacaoBox; internal TextBox ChaveBox; internal Grid MinimizeButton; internal Grid CloseButton; private bool _contentLoaded; public bool Bloquear { get; set; } private JArray LoginSettings { get; set; } public LoginWindow() { //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Expected O, but got Unknown //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Expected O, but got Unknown //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_0072: Expected O, but got Unknown //IL_007f: Unknown result type (might be due to invalid IL or missing references) //IL_0089: Expected O, but got Unknown ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12; ViewModel = new LoginViewModel(); ((FrameworkElement)this).DataContext = ViewModel; InitializeComponent(); ((UIElement)MinimizeButton).MouseEnter += new MouseEventHandler(TopControls_OnMouseEnter); ((UIElement)MinimizeButton).MouseLeave += new MouseEventHandler(TopControls_OnMouseLeave); ((UIElement)CloseButton).MouseEnter += new MouseEventHandler(TopControls_OnMouseEnter); ((UIElement)CloseButton).MouseLeave += new MouseEventHandler(TopControls_OnMouseLeave); ViewModel.Head = "AGGER GESTOR " + ViewModel.Version + " - AGUARDE ESTAMOS INICIALIZANDO"; } protected override void OnRenderSizeChanged(SizeChangedInfo sizeInfo) { //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0025: 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_0053: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_0066: Unknown result type (might be due to invalid IL or missing references) ((FrameworkElement)this).OnRenderSizeChanged(sizeInfo); Size val; if (sizeInfo.HeightChanged) { double top = ((Window)this).Top; val = sizeInfo.PreviousSize; double height = ((Size)(ref val)).Height; val = sizeInfo.NewSize; ((Window)this).Top = top + (height - ((Size)(ref val)).Height) / 2.0; } if (sizeInfo.WidthChanged) { double left = ((Window)this).Left; val = sizeInfo.PreviousSize; double width = ((Size)(ref val)).Width; val = sizeInfo.NewSize; ((Window)this).Left = left + (width - ((Size)(ref val)).Width) / 2.0; } } 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.DarkGoldenrod) : 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_003d: 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_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_004c: Expected O, but got Unknown //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Expected O, but got Unknown //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_0071: Expected O, but got Unknown ((Panel)(Grid)sender).Background = (Brush)((((FrameworkElement)(Grid)sender).Name == "CloseButton") ? new SolidColorBrush((Color)Application.Current.Resources[(object)"AggerYellow100"]) : 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_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0069: Unknown result type (might be due to invalid IL or missing references) //IL_006e: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0078: 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)((((FrameworkElement)(Grid)sender).Name == "CloseButton") ? new SolidColorBrush((Color)Application.Current.Resources[(object)"AggerYellow100"]) : new SolidColorBrush(Colors.DimGray)); } } public void MinimizeButton_Click() { ((Window)this).WindowState = (WindowState)1; } public void CloseButton_Click() { ((Window)this).Close(); } private void Loading(bool isLoading) { ViewModel.EnableFields = !isLoading; ViewModel.LoadingVisibility = isLoading; ViewModel.FieldsVisibility = !isLoading; ((UIElement)this).IsEnabled = !isLoading; } private async void LoginWindow_OnLoaded(object sender, RoutedEventArgs e) { Loading(isLoading: true); await ViewModel.GetCfgJson(); await SearchImage(); ViewModel.EnableButtons = false; LicenseHelper license = new LicenseHelper(); bool registro = await license.VerificarRegistro(); if (!registro) { string key = await license.FindKey(); bool flag = false; if (key != null) { await license.Registrar(key); flag = true; } if (key == null && !string.IsNullOrWhiteSpace(Recursos.Registrar)) { await license.Registrar(Recursos.Registrar); flag = true; } if (flag) { registro = await license.VerificarRegistro(); } } if (registro) { Tuple tuple = await license.VerificarAcesso(); if (!tuple.Item1) { Loading(isLoading: false); ViewModel.AcessoNegado(tuple.Item2); return; } ConnectionHelper connectionHelper = new ConnectionHelper(); Tuple tuple2 = await connectionHelper.PrimeiroAcesso(); if (Connection.ConnectionAddress == null || Connection.ConnectionAddress.Type == 4) { Loading(isLoading: false); ViewModel.AcessoNegado("Erro de conexão com Banco Gestor.\nEntre em contato com Suporte!"); } else if (tuple2.Item1 && tuple2.Item2) { Tuple tuple3 = await license.VerificarVersao(); if (!tuple3.Item1) { Loading(isLoading: false); ViewModel.AcessoNegado(tuple3.Item2); return; } Task.Run(delegate { try { if (!connectionHelper.BDConvertido()) { new BaseServico().BuscarEmpresa(1L); } } catch { } }); Loading(isLoading: false); if (string.IsNullOrWhiteSpace(UserBox.Text)) { ((UIElement)UserBox).Focus(); } else { ((UIElement)PasswordBox.PasswordBox).Focus(); } ViewModel.EnableButtons = true; string result = Connection.Get("Customer/Name/" + ApplicationHelper.NumeroSerial).Result; ViewModel.Head = result; } else { ((Window)new TutorialView(tuple2)).Show(); ((Window)this).Close(); } } else { Loading(isLoading: false); ViewModel.AbrirRegistro(); ViewModel.EnableButtons = true; } } private async Task SearchImage() { try { HttpClient client = new HttpClient(); try { ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12; client.Timeout = TimeSpan.FromSeconds(30.0); LoginSettings = JArray.Parse(await client.GetStringAsync(Address.LoginJsonV2)); DateTime now = DateTime.Now; foreach (JToken item in ((IEnumerable)LoginSettings).Where(delegate(JToken x) { JToken obj2 = x[(object)"Ativo"]; if (obj2 == null || !Extensions.Value((IEnumerable)obj2)) { return false; } JToken obj3 = x[(object)"Produto"]; List list = ((obj3 != null) ? obj3.Values().ToList() : null); if (list == null || !list.Any((int p) => p == 0 || p == 3)) { return false; } DateTime result; bool flag = DateTime.TryParse(((object)x[(object)"Inicio"])?.ToString(), out result); DateTime result2; bool flag2 = DateTime.TryParse(((object)x[(object)"Fim"])?.ToString(), out result2); if (flag && flag2) { if (now >= result) { return now <= result2; } return false; } if (flag) { return now >= result; } return !flag2 || now <= result2; })) { ViewModel.LoginImages.Add(new LoginImageModel { Imagem = ((object)item[(object)"Imagem"])?.ToString(), UrlFixa = ((object)item[(object)"UrlFixa"])?.ToString() }); } ViewModel.SelectedImage = ViewModel.LoginImages.FirstOrDefault(); ((DispatcherObject)this).Dispatcher.Invoke((Action)StartCarousel); } finally { ((IDisposable)client)?.Dispose(); } } catch { } } private void StartCarousel() { //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Expected O, but got Unknown if (ViewModel.LoginImages.Count > 1) { _carouselTimer = new DispatcherTimer { Interval = TimeSpan.FromSeconds(10.0) }; _carouselTimer.Tick += delegate { int index = (ViewModel.LoginImages.IndexOf(ViewModel.SelectedImage) + 1) % ViewModel.LoginImages.Count; ViewModel.SelectedImage = ViewModel.LoginImages[index]; }; _carouselTimer.Start(); } } private async Task VerificarAcesso() { LicenseHelper license = new LicenseHelper(); Tuple tuple = await license.VerificarAcesso(); if (!tuple.Item1) { Loading(isLoading: false); ViewModel.AcessoNegado(tuple.Item2); return true; } if (!ViewModel.Login.Contains("AGGER@")) { bool registrar = false; if (!(await license.VerificarMaquina())) { Loading(isLoading: false); while (!registrar) { List licencas = await license.GetInstalacoes(); if (licencas.Count == 0) { ViewModel.AcessoNegado("ACESSO NEGADO, NÃO EXISTEM LICENÇAS VÁLIDAS."); return true; } Instalacao instalacaoUsuario = ((IEnumerable)licencas.OrderByDescending((Instalacao x) => x.UltimoAcesso)).FirstOrDefault((Func)((Instalacao x) => x.UsuarioId == ((DomainBase)Recursos.Usuario).Id)); bool flag = instalacaoUsuario != null; if (flag) { flag = await ViewModel.ShowMessage("SEU ULTIMO ACESSO FOI NA MAQUINA " + instalacaoUsuario.NomeMaquina + ". DESEJA SUBSTITUIR A LICENÇA PARA ESSA MAQUINA?", "SIM", "NÃO"); } Instalacao val = ((!flag) ? (await ViewModel.ShowInstalacoes(licencas)) : instalacaoUsuario); Instalacao val2 = val; if (val2 == null) { ViewModel.AcessoNegado("MÁQUINA NÃO REGISTRADA"); return true; } Loading(isLoading: true); await new AjudaServico().ExcluirInstalacao(((DomainBase)val2).Id); await Task.Delay(15000); registrar = await license.VerificarMaquina(); Loading(isLoading: false); } } } Tuple tuple2 = await license.VerificarVersao(); if (!tuple2.Item1) { Loading(isLoading: false); ViewModel.AcessoNegado(tuple2.Item2); return true; } string text = await new ConnectionHelper().AtualizarBanco(); if (text != null) { await ViewModel.ShowMessage(text); return false; } if (!(await ViewModel.Load())) { ((Window)this).Close(); } return false; } private async void Acessar_Click(object sender, RoutedEventArgs e) { ((ButtonBase)(RepeatButton)sender).Click -= new RoutedEventHandler(Acessar_Click); await Access(); ((ButtonBase)(RepeatButton)sender).Click += new RoutedEventHandler(Acessar_Click); } private async void PasswordBox_OnKeyDown(object sender, KeyEventArgs e) { if ((int)e.Key == 6) { await Access(); } } private async Task Access(bool error = true) { if (string.IsNullOrEmpty(ViewModel.Login) || string.IsNullOrEmpty(ViewModel.Senha)) { if (error) { ViewModel.ErrorLoginVisibility = (Visibility)0; } ((UIElement)UserBox).Focus(); return; } Loading(isLoading: true); if (!(await ViewModel.Validate(ViewModel.Login, ViewModel.Senha))) { Loading(isLoading: false); ((UIElement)UserBox).Focus(); return; } bool flag = Bloquear; if (!flag) { flag = await VerificarAcesso(); } Bloquear = flag; if (Bloquear) { return; } DateTime networkTime = Funcoes.GetNetworkTime(); if (((DomainBase)Recursos.Usuario).Id > 0) { RegistroLog keyValues = new RegistroLog { Acao = (TipoAcao)0, Usuario = Recursos.Usuario, DataHora = networkTime, Descricao = $"O USUÁRIO {Recursos.Usuario.Nome} LOGOU NO SISTEMA, EM {networkTime}.", EntidadeId = ((DomainBase)Recursos.Usuario).Id, Tela = (TipoTela)49, Versao = LoginViewModel.VersaoAtual, NomeMaquina = Environment.MachineName, UsuarioMaquina = Environment.UserName, Ip = Dns.GetHostEntry(Dns.GetHostName()).AddressList.FirstOrDefault((IPAddress ip) => ip.AddressFamily == AddressFamily.InterNetwork)?.ToString() }; UnitOfWork commited = Instancia.Commited; try { new BaseServico().SaveLog(keyValues, commited); ((GenericUnitOfWork)commited).Commit(); } finally { ((IDisposable)commited)?.Dispose(); } } ((Window)new DownloadWindow(new Parameters { Beta = ApplicationHelper.Beta, Type = 7, Application = "Agger.Gestor.exe", Directory = "", Run = false })).Show(); ((Window)new MainWindow()).Show(); ((Window)this).Close(); } private async void Registrar_OnClick(object sender, RoutedEventArgs e) { Loading(isLoading: true); LicenseHelper license = new LicenseHelper(); string text = await license.Registrar(ViewModel.Chave); if (text == "false") { await ViewModel.ShowMessage("CHAVE INVÁLIDA"); Loading(isLoading: false); ViewModel.AbrirRegistro(); return; } if (text == "root") { await ViewModel.ShowMessage("CHAVE JÁ REGISTRADA ANTERIORMENTE."); } ViewModel.FecharRegistro(); string result = Connection.Get("Customer/Name/" + ApplicationHelper.NumeroSerial).Result; ViewModel.Head = result; Tuple tuple = await license.VerificarAcesso(); if (!tuple.Item1) { Loading(isLoading: false); ViewModel.AcessoNegado(tuple.Item2); return; } Tuple tuple2 = await new ConnectionHelper().PrimeiroAcesso(); if (!tuple2.Item1 || !tuple2.Item2) { ((Window)new TutorialView(tuple2)).Show(); ((Window)this).Close(); } else { Loading(isLoading: false); await Access(error: false); } } private async void TrocarSenha_OnPreviewMouseDown(object sender, MouseButtonEventArgs e) { Loading(isLoading: true); await ViewModel.AbrirTrocaSenha(); Loading(isLoading: false); } private async void TrocarSenha_OnClick(object sender, RoutedEventArgs e) { Loading(isLoading: true); bool num = await ViewModel.TrocaSenha(); Loading(isLoading: false); if (num) { await Access(); } } private void CancelarTrocaSenha_OnClick(object sender, RoutedEventArgs e) { ViewModel.TrocaSenhaVisibility = (Visibility)2; ViewModel.LoginVisibility = (Visibility)0; } private void NovoPerfil_OnPreviewMouseDown(object sender, MouseButtonEventArgs e) { ViewModel.AbrirRegistro(); ViewModel.EnableButtons = true; } private void CancelarRegistro(object sender, RoutedEventArgs e) { ViewModel.FecharRegistro(); } private void LinkImage_MouseDown(object sender, MouseButtonEventArgs e) { Process.Start(new ProcessStartInfo { FileName = ViewModel.ImagemLink, UseShellExecute = true }); } private void CentralAtendimento_OnPreviewMouseDown(object sender, MouseButtonEventArgs e) { Process.Start(new ProcessStartInfo { FileName = ViewModel.CentralAtendimento, UseShellExecute = true }); } [DebuggerNonUserCode] [GeneratedCode("PresentationBuildTasks", "4.0.0.0")] public void InitializeComponent() { if (!_contentLoaded) { _contentLoaded = true; Uri uri = new Uri("/Gestor.Application;component/views/loginwindow.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_005e: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Expected O, but got Unknown //IL_006b: Unknown result type (might be due to invalid IL or missing references) //IL_0075: Expected O, but got Unknown //IL_0078: Unknown result type (might be due to invalid IL or missing references) //IL_0082: Expected O, but got Unknown //IL_0092: Unknown result type (might be due to invalid IL or missing references) //IL_009c: Expected O, but got Unknown //IL_00a9: Unknown result type (might be due to invalid IL or missing references) //IL_00b3: Expected O, but got Unknown //IL_00b5: Unknown result type (might be due to invalid IL or missing references) //IL_00c1: Unknown result type (might be due to invalid IL or missing references) //IL_00cb: Expected O, but got Unknown //IL_00cd: Unknown result type (might be due to invalid IL or missing references) //IL_00d9: Unknown result type (might be due to invalid IL or missing references) //IL_00e3: Expected O, but got Unknown //IL_00ff: Unknown result type (might be due to invalid IL or missing references) //IL_010b: Unknown result type (might be due to invalid IL or missing references) //IL_0115: Expected O, but got Unknown //IL_0117: Unknown result type (might be due to invalid IL or missing references) //IL_0123: Unknown result type (might be due to invalid IL or missing references) //IL_012d: Expected O, but got Unknown //IL_012f: Unknown result type (might be due to invalid IL or missing references) //IL_013b: Unknown result type (might be due to invalid IL or missing references) //IL_0145: 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 //IL_0154: Unknown result type (might be due to invalid IL or missing references) //IL_0160: Unknown result type (might be due to invalid IL or missing references) //IL_016a: Expected O, but got Unknown //IL_016c: Unknown result type (might be due to invalid IL or missing references) //IL_0178: Unknown result type (might be due to invalid IL or missing references) //IL_0182: Expected O, but got Unknown //IL_0185: Unknown result type (might be due to invalid IL or missing references) //IL_018f: Expected O, but got Unknown //IL_019c: Unknown result type (might be due to invalid IL or missing references) //IL_01a6: Expected O, but got Unknown //IL_01b3: Unknown result type (might be due to invalid IL or missing references) //IL_01bd: Expected O, but got Unknown //IL_01c0: Unknown result type (might be due to invalid IL or missing references) //IL_01ca: Expected O, but got Unknown //IL_01d7: Unknown result type (might be due to invalid IL or missing references) //IL_01e1: Expected O, but got Unknown //IL_01ee: Unknown result type (might be due to invalid IL or missing references) //IL_01f8: Expected O, but got Unknown switch (connectionId) { case 1: ((FrameworkElement)(LoginWindow)target).Loaded += new RoutedEventHandler(LoginWindow_OnLoaded); break; case 2: ProgressRing = (Image)target; break; case 3: UserBox = (TextBox)target; break; case 4: PasswordBox = (CustomSenhaLoginBox)target; break; case 5: TrocaSenha = (TextBlock)target; ((UIElement)TrocaSenha).PreviewMouseDown += new MouseButtonEventHandler(TrocarSenha_OnPreviewMouseDown); break; case 6: ((ButtonBase)(RepeatButton)target).Click += new RoutedEventHandler(Acessar_Click); break; case 7: ((UIElement)(TextBlock)target).PreviewMouseDown += new MouseButtonEventHandler(NovoPerfil_OnPreviewMouseDown); break; case 8: SenhaBox = (CustomSenhaLoginBox)target; break; case 9: ConfirmacaoBox = (CustomSenhaLoginBox)target; break; case 10: ((ButtonBase)(RepeatButton)target).Click += new RoutedEventHandler(CancelarTrocaSenha_OnClick); break; case 11: ((ButtonBase)(RepeatButton)target).Click += new RoutedEventHandler(TrocarSenha_OnClick); break; case 12: ((UIElement)(TextBlock)target).PreviewMouseDown += new MouseButtonEventHandler(CentralAtendimento_OnPreviewMouseDown); break; case 13: ChaveBox = (TextBox)target; break; case 14: ((ButtonBase)(RepeatButton)target).Click += new RoutedEventHandler(CancelarRegistro); break; case 15: ((ButtonBase)(RepeatButton)target).Click += new RoutedEventHandler(Registrar_OnClick); break; case 16: MinimizeButton = (Grid)target; ((UIElement)MinimizeButton).MouseLeftButtonDown += new MouseButtonEventHandler(TopControls_OnMouseLeftButtonDown); ((UIElement)MinimizeButton).MouseLeftButtonUp += new MouseButtonEventHandler(TopControls_OnMouseLeftButtonUp); break; case 17: CloseButton = (Grid)target; ((UIElement)CloseButton).MouseLeftButtonDown += new MouseButtonEventHandler(TopControls_OnMouseLeftButtonDown); ((UIElement)CloseButton).MouseLeftButtonUp += new MouseButtonEventHandler(TopControls_OnMouseLeftButtonUp); break; default: _contentLoaded = true; break; } } }