public DeviceDetails()
 {
     InitializeComponent();
     this.ExportTile.Click += (sender, e) =>
     {
         var dialog = new FolderBrowserDialog();
         DialogResult result = dialog.ShowDialog();
         try
         {
             AdbTools.KillAdb();
             File.WriteAllText(string.Format("{0}\\{1}.txt", dialog.SelectedPath, "build-prop"), buildprop.Text);
             using (Toast toast = new Toast("build.prop exported"))
             {
                 toast.Show();
             }
         }
         catch (Exception ex)
         {
             using (Toast toast = new Toast(string.Format("Error:{0}", ex.Message)))
             {
                 toast.Show();
             }
         }
     };
 }
        private async void AddEvents()
        {
            this.Closed += delegate
            {
                Dispose();
            };

            this.Closing += delegate
            {
                KillAdb.Command.Execute(null);
                Dispose();
            };

            this.Deactivated += delegate
            {
                Dispose();
            };

            this.SideloadTile.IsEnabled = false;
            this.SideloadFile.TextChanged += (sender, args) =>
            {
                this.SideloadTile.IsEnabled = !string.IsNullOrEmpty(this.SideloadFile.Text);
            };

            this.RebootButton.Click += ButtonClickHandler;
            this.RebootRecoveryButton.Click += ButtonClickHandler;
            this.RebootBootloaderButton.Click += ButtonClickHandler;
            this.PushButton.Click += ButtonClickHandler;

            this.PushFile.PreviewDragOver += (sender, args) => args.Handled = true;
            this.PushFile.Drop += TextBoxDropHandler1;

            this.PullFile1.PreviewDragOver += (sender, args) => args.Handled = true;
            this.PullFile1.Drop += TextBoxDropHandler2;
            this.PullFile2.PreviewDragOver += (sender, args) => args.Handled = true;
            this.PullFile2.Drop += TextBoxDropHandler2;
            this.PullFile3.PreviewDragOver += (sender, args) => args.Handled = true;
            this.PullFile3.Drop += TextBoxDropHandler2;
            this.PullFile4.PreviewDragOver += (sender, args) => args.Handled = true;
            this.PullFile4.Drop += TextBoxDropHandler2;
            this.PullButton.Click += ButtonClickHandler;

            this.SideloadFile.PreviewDragOver += (sender, args) => args.Handled = true;
            this.SideloadFile.Drop += TextBoxDropHandler4;


            this.CopyButton.Click += ButtonClickHandler;
            this.MoveButton.Click += ButtonClickHandler;

            this.InstallButton.Click += ButtonClickHandler;
            this.InstallApp.PreviewDragOver += (sender, args) => args.Handled = true;
            this.InstallApp.Drop += TextBoxDropHandler3;

            this.UninstallButton.Click += ButtonClickHandler;

            this.ListApps.Click += async (sender, args) =>
            {
                _FlyoutPresenter.Invoke(this, 2);
                await this.Dispatcher.InvokeAsync(() =>
                {
                    _FlyoutPresenter.Invoke(this, 4);
                    using (Toast toast = new Toast("Working in background...", "Android Toolkit - Notification"))
                    {
                        toast.Show();
                    }
                    var timer = new System.Timers.Timer(2048);
                    timer.Elapsed += async (s, e) =>
                    {
                        await this.Dispatcher.InvokeAsync(() => StatusLabel.Content = "Working in background...");
                        await this.Dispatcher.InvokeAsync(() => _FlyoutPresenter.Invoke(this, 4));
                        timer.Dispose();
                    };
                    timer.Enabled = true;
                });
            };
            this.RefreshApps.Click += ButtonClickHandler;

            this.ListDevices.Click += (sender, args) => _FlyoutPresenter.Invoke(this, 3);

            this.ShowDevices.Click += (sender, args) => _FlyoutPresenter.Invoke(this, 3);

            this.ShowSettings.Click += (sender, args) => _FlyoutPresenter.Invoke(this, 0);

            this.ShowSettings2.Click += (sender, args) => _FlyoutPresenter.Invoke(this, 0);

            this.ShowReboot.Click += (sender, args) => _FlyoutPresenter.Invoke(this, 1);

            this.ShowBackup.Click += (sender, args) => _FlyoutPresenter.Invoke(this, 5);

            this.ShowRemoteAdb.Click += (sender, args) => _FlyoutPresenter.Invoke(this, 6);

            UiSlider.MouseDoubleClick += RestoreScalingFactor;

            bool themeLight = false;

            this.LightTheme.Checked += (sender, args) =>
            {
                themeLight = true;
            };
            this.LightTheme.Unchecked += (sender, args) =>
            {
                themeLight = false;
            };

            this.AccentsComboBox.SelectionChanged += (sender, args) =>
            {
                _newAccent = AccentsComboBox.SelectedItem as Accent;
            };


            this.ApplyThemeChange.Click += async (sender, args) =>
            {
                if (AccentsComboBox.SelectedItem != null)
                {
                    ThemeManager.ChangeAppStyle(this, _newAccent,
                        themeLight
                            ? ThemeManager.AppThemes.First(x => x.Name == "BaseLight")
                            : ThemeManager.AppThemes.First(x => x.Name == "BaseDark"));
                    if (themeLight)
                    {
                        Right.Background = Brushes.White;
                        RightTop.Background = Brushes.GhostWhite;
                    }
                    else
                    {
                        Right.Background = Resources["FlyoutBackgroundBrush"] as SolidColorBrush;
                        RightTop.Background = Resources["FlyoutBackgroundBrush"] as SolidColorBrush;
                    }
                }
                else
                {
                    ThemeManager.ChangeAppStyle(this, ThemeManager.Accents.First(x => x.Name == "Blue"),
                      themeLight
                          ? ThemeManager.AppThemes.First(x => x.Name == "BaseLight")
                          : ThemeManager.AppThemes.First(x => x.Name == "BaseDark"));
                    if (themeLight)
                    {
                        Right.Background = Brushes.White;
                        RightTop.Background = Brushes.GhostWhite;
                    }
                    else
                    {
                        Right.Background = Resources["FlyoutBackgroundBrush"] as SolidColorBrush;
                        RightTop.Background = Resources["FlyoutBackgroundBrush"] as SolidColorBrush;
                    }
                }
                UiSettings.IsExpanded = false;
                UiSettings.IsEnabled = false;
                await this.ShowMessageAsync("UI Changed", "New UI settings have just been applied.");
            };


            this.RestoreFile.PreviewDragOver += (sender, args) => args.Handled = true;
            this.RestoreFile.Drop += TextBoxDropHandler5;

            foreach (var item in await _viewModel.RemoteInfoRepository.Get())
            {
                _viewModel.RemoteInfos.Add(item);
            }

            this.RefreshDevices.Click += (sender, args) =>
            {
                _FlyoutPresenter.Invoke(this, 3);
                _FlyoutPresenter.Invoke(this, 3);
            };

        }
        private async void ButtonClickHandler(object sender, RoutedEventArgs e)
        {
            await this.Dispatcher.InvokeAsync(() =>
            {
                _FlyoutPresenter.Invoke(this, 4);
                using (Toast toast = new Toast("Working in background...", "Android Toolkit - Notification"))
                {
                    toast.Show();
                }
                var timer = new System.Timers.Timer(2048);
                timer.Elapsed += async (s, args) =>
                {
                    await this.Dispatcher.InvokeAsync(() => StatusLabel.Content = "Working in background...");
                    await this.Dispatcher.InvokeAsync(() => _FlyoutPresenter.Invoke(this, 4));
                    timer.Dispose();
                };
                timer.Enabled = true;

            });
        }