Esempio n. 1
0
        public async void DeleteThemeDialog(int id)
        {
            ContentDialog deleteDialog = new ContentDialog
            {
                Title             = "Delete Theme Permanently?",
                Content           = "If you delete this theme you will not be able to recover it. Are you sure you want to PERMANENTLY delete this Theme?",
                PrimaryButtonText = "Delete",
                CloseButtonText   = "Cancel"
            };

            ContentDialogResult result = await deleteDialog.ShowAsync();

            if (result == ContentDialogResult.Primary)
            {
                // Delete the theme
                var theme = ThemeRepository.Find(id);
                if (theme == null)
                {
                    return;
                }
                ThemeRepository.RemoveAndCommit(id);

                // Remove from the Themes List
                for (int i = Themes.Count - 1; i >= 0; i--)
                {
                    if (Themes[i].ID == id)
                    {
                        Themes.RemoveAt(i);
                        break;
                    }
                }
            }
        }
        public async void DeleteThemeDialog()
        {
            ContentDialog deleteDialog = new ContentDialog
            {
                Title             = "Delete Theme Permanently?",
                Content           = "If you delete this theme you will not be able to recover it. Are you sure you want to PERMANENTLY delete this Theme?",
                PrimaryButtonText = "Delete",
                CloseButtonText   = "Cancel"
            };

            ContentDialogResult result = await deleteDialog.ShowAsync();

            if (result == ContentDialogResult.Primary)
            {
                // Check the Active Themes and get rid of them if needed
                ActiveThemeService activeThemeService = new ActiveThemeService();
                if (activeThemeService.GetActiveDesktopThemeID() == Theme.ID)
                {
                    activeThemeService.DeselectActiveDesktopTheme();
                }
                if (activeThemeService.GetActiveLockscreenThemeID() == Theme.ID)
                {
                    activeThemeService.DeselectActiveLockscreenTheme();
                }

                // Delete the theme
                var theme = ThemeRepository.Find(Theme.ID);
                if (theme == null)
                {
                    return;
                }
                ThemeRepository.RemoveAndCommit(Theme.ID);

                // Redirect to the MainPage
                MainViewModel.Instance.NavigateThemesCommand.Execute(null);
            }
        }