Dialogs

The Microsoft.Blueprints.Contrib project contains a series of reusable Winform Dialogs for performing various tasks.

ProjectSelector

This form allows you to list projects that exist in the current solution. You can exclude project types, by the use of a filter. This form should be used if you need to obtain a project, in order to execute a command from the guidance.



The ProjectSelector is used in conjunction with the Environment helper classes:

var environmentManager = new EnvironmentManager(context);
  
if (environmentManager.SolutionExplorerNode != SolutionExplorerNode.Project)
{
    using (ProjectSelector projectSelector = new ProjectSelector(context))
    {
        projectSelector.PopulateProjectList();

        if (projectSelector.ShowDialog() == DialogResult.OK)
        {
            environmentManager.SelectProject(projectSelector.SelectedProject);
        }
        else
        {
            throw new OperationCanceledException("User cancelled the Project selection dialog.");
        }
    }
} 

Selector

This form allows you to select a file or directory and return its path. The form can be configured to return an absolute path:





Or alternatively a relative path from the project you are invoking the form from:



The Selector is used in conjuntion with the DynamicUpdate delegate:

DynamicUpdate strategy = template =>
                         {
                             using (Selector selector = new Selector(template))
                             {
                                 selector.InitialDirectory = this.envManager.SelectedProjectDirectory;
                                 selector.SelectorMode = SelectorMode.Directory;
                                 selector.PathMode = SelectorPathMode.Relative;
                                 selector.PathSuffix = @"MyCustomFolderPath";
                                 selector.Filter = "C# Project File|*.csproj|All|*.*";
                                 selector.Title = "Please Select a C# Project File";
  
                                 if (selector.ShowDialog() == DialogResult.OK)
                                 {
                                     template.Properties = selector.Properties;
                                 }
                                 else
                                 {
                                     throw new OperationCanceledException("User selected Cancel. Properties not updated.");
                                 }
                             }
  
                             return template;
                         };

T4 Template Property Editor

This form allows easy editing of T4 Template Properties via a Property Grid. This control should be used with the T4TemplateBuilder and the DynamicUpdate delegate.



The Selector is used in conjuntion with the DynamicUpdate delegate:

DynamicUpdate strategy = template =>
                         {
                             using (T4TemplatePropertyEditor editor = new T4TemplatePropertyEditor(template))
                             {
                                 if (editor.ShowDialog() == DialogResult.OK)
                                 {
                                     template.Properties = editor.Properties;
                                 }
                                 else
                                 {
                                     throw new OperationCanceledException("User selected Cancel. Properties not updated.");
                                 }
                             }
  
                             return template;
                         };

Last edited Feb 28, 2009 at 8:04 AM by HowardvanRooijen, version 7

Comments

No comments yet.