Ejemplo n.º 1
0
        public void TestDelete()
        {
            // copy test theme
            var copyPath = Path.GetTempFileName();
            File.Copy(_themePath, copyPath, true);

            // load the copy
            var theme = new Theme();
            theme.LoadFromPath(copyPath);

            // delete
            theme.Delete();

            // assert the file does not exist
            Assert.That(File.Exists(copyPath), Is.False);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Show a yes/no dialog that offers deletion of <paramref name="theme" />
        /// </summary>
        /// <param name="theme">The theme.</param>
        public void DeleteTheme(Theme theme)
        {
            if (!theme.Editable) {
                return;
            }
            var result = _dialogService.Messagebox("Remove currently selected theme?", "Delete Theme",
                MessageBoxButton.YesNo);

            if (result == MessageBoxResult.Yes) {
                var idx = Items.IndexOf(SelectedItem);
                // delete the theme
                theme.Delete();

                // unregister the theme
                ThemeManager.UnregisterTheme(theme);

                // select another theme
                if (Items.Any()) {
                    SelectedItem = Items[--idx];
                }
                else {
                    SelectedItem = null;
                }
                FocusSelectedItem();
            }
        }