using System; using System.Collections.Generic; using System.Collections.ObjectModel; using System.Linq; using System.Text; using Apex.MVVM; using SharpShell.ServerRegistration; namespace ShellExtensionManager.ShellExtensions { [ViewModel] public class ShellExtensionsViewModel : ViewModel { public ShellExtensionsViewModel() { // Create the RefreshExtensions Asynchronous Command. RefreshExtensionsCommand = new AsynchronousCommand(DoRefreshExtensionsCommand); RefreshExtensionsCommand.DoExecute(); } /// <summary> /// Performs the command. /// </summary> /// <param name="parameter">The RefreshExtensions command parameter.</param> private void DoRefreshExtensionsCommand(object parameter) { // Get all servers. var servers = ServerRegistrationManager.EnumerateExtensions(RegistrationType.OS64Bit, ShellExtensionType.IconHandler); foreach (var server in servers) { var extensionViewModel = new ExtensionViewModel(); extensionViewModel.DisplayName = server.DisplayName; extensionViewModel.ShellExtensionType = server.ShellExtensionType; foreach (var classReg in server.ClassRegistrations) extensionViewModel.ClassRegistrations.Add(classReg); RefreshExtensionsCommand.ReportProgress(() => Extensions.Add(extensionViewModel)); } } /// <summary> /// Gets the RefreshExtensions command. /// </summary> /// <value>The value of .</value> public AsynchronousCommand RefreshExtensionsCommand { get; private set; } /// <summary> /// The Extensions observable collection. /// </summary> private readonly ObservableCollection<ExtensionViewModel> ExtensionsProperty = new ObservableCollection<ExtensionViewModel>(); /// <summary> /// Gets the Extensions observable collection. /// </summary> /// <value>The Extensions observable collection.</value> public ObservableCollection<ExtensionViewModel> Extensions { get { return ExtensionsProperty; } } /// <summary> /// The NotifyingProperty for the SelectedExtension property. /// </summary> private readonly NotifyingProperty SelectedExtensionProperty = new NotifyingProperty("SelectedExtension", typeof(ExtensionViewModel), default(ExtensionViewModel)); /// <summary> /// Gets or sets SelectedExtension. /// </summary> /// <value>The value of SelectedExtension.</value> public ExtensionViewModel SelectedExtension { get { return (ExtensionViewModel)GetValue(SelectedExtensionProperty); } set { SetValue(SelectedExtensionProperty, value); } } } }
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.
This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)