Partager via


Extend the Built-In Tabs

 

Applies To: Windows Server 2012 Essentials, Windows Home Server 2011, Windows Storage Server 2008 R2 Essentials, Windows Small Business Server 2011 Essentials

To add a new column to the list pane, add tasks to the task pane, or add details to the details pane in the pages of the Users, Server Folders, or Computers and Backup tabs you must create a class that inherits the PageContentAdorner class.

Important

The class that you create should not perform actions that are resource intensive. Intensive operations in the CreateColumns, CreateTasks, GetDetails, or RemoveItem methods can cause the Dashboard to cease functioning while waiting for the operations to finish. It is recommended that you create a separate service that collects and caches the data so that your object reads and displays cached values.

To extend an existing page with additional column, task, and detail information

  1. Create a new solution by using the procedure in Set Up the Development Environment, and ensure that you used the HSBSTabExtender template to create the solution.

  2. Open PageAdorner.cs. In the constructor of PageAdorner class, provide the name that is used to identify the add-in. The following code sample shows how to define the constructor:

    Open PageAdorner.cs. In the constructor of PageAdorner class, provide the identifier (GUID), the display name, and the description for the add-in. For more information about creating a GUID, see Create Guid (guidgen.exe) (https://go.microsoft.com/fwlink/?LinkId=116098). The following code sample shows how to define the constructor:

    public class PageAdorner : PageContentAdorner  
    {  
        public PageAdorner()  
           : base(new Guid("bf47cf96-4c65-4382-ab53-87d03a7d18a6"), "Display name for add-in", "Description of add-in")  
       {  
       }  
    }   
    
  3. In CreateColumns method, return the columns that you want to add to the list pane of the tab. The following code example shows how to add an “Antivirus” column:

    public override ListColumnCollection<ListObject> CreateColumns()  
    {  
       ListColumnCollection<ListObject> columns =   
          new ListColumnCollection<ListObject>();  
       ListColumn<ListObject> column =   
          new ListColumn<ListObject>("Antivirus",   
             new Converter<ListObject, string>(  
                delegate(ListObject businessObj)  
                {  
                   return GetDataFromYourCache(businessObj.Id.ToString());  
                }));  
    
       columns.Add(column);  
    
       return columns;  
    }  
    
  4. Override the CreateRefreshContext method which is used to refresh the list of ListObject objects. The following code example shows how to override the CreateRefreshContext method.

    public override ListProviderAdorner CreateRefreshContext()  
    {  
       return (new ListAdorner());  
    }  
    
  5. Add the GetDataFromYourCache method:

    private string GetDataFromYourCache(string ComputerId)  
    {  
       // This is where you use the id to perform a quick lookup   
       // in your cached data.  
       // Do not perform network based lookups here because of the  
       // negative impact on the performance of the Dashboard.  
       // Instead, use a proxy service or other mechanism for   
       // collecting data and caching it locally, and then collect  
       // that info from there. For this example, we'll just return  
       // the string "yes" if the name contains the letter 'a'.  
    
       return ComputerId.Contains("a") ? "yes" : "no";  
    }  
    
  6. In the CreateTasks method, return the tasks that you want to add to the task pane of the tab. The following code example shows how to add a global task and an object-specific task to the task pane.

    public override TaskCollection CreateTasks()  
    {  
       TaskCollection tasks = new TaskCollection();  
    
       // Global Tasks  
       tasks.Add(new SyncUiTask("Demo Global Task",  
          delegate()  
          {  
             MessageBox.Show("Not yet implemented");  
             return null;  
          }));  
    
       // Object Specific  
       SyncUiTask<ListObject> taskObjectSpecific =   
          new SyncUiTask<ListObject>("Demo Object Specific Task",  
             delegate(ListObject computer)  
             {  
                MessageBox.Show(computer.Id);  
                return null;  
             });  
       tasks.Add(taskObjectSpecific);  
    
       return tasks;  
    }  
    
  7. In the GetDetails method, return one or more custom details you want to add to the details pane of the tab. The custom detail is displayed along with the existing details of the business object. The following code example shows how to add the “Computer Id” detail item:

    public override DetailGroup GetDetails(ListObject computer)  
    {  
       DetailGroup group = new DetailGroup("Computer detailed information");  
       group.Add("Computer Id: ", computer.Id);  
    
       return group;  
    }  
    
  8. To refresh the data in the tab, call the Refresh method of the base class.

    base.Refresh
    ()  
    
  9. Open ListAdorner.cs. To perform a custom action when an object is removed, you must add the code to the RemoveItem method.

    private void RemoveItem(object obj)  
    {  
       Debug.WriteLine("Request to remove item {0}", obj.ToString());  
    }  
    

    Note

    You should not use this method to perform resource or time intensive operations or cleanup. This method should only be used to clean up or dispose of the events or objects that were used specifically to extend the tab. All other cleanup that is associated with the removal of the business object should be completed by subscribing to the remove notifications that correspond to the tab.

  10. Save and build the solution.

To install the add-in

  1. In the project, open the AddinConfig.addin file.

    The file contains the following code:

    <addin name="Test Add-in" basedir="PROVIDE_FULL_PATH_TO_BINARIES_HERE" type="MyNamespace.PageAdorner, TopLevelTab" />  
    

    Note

    The value of the baseDir attribute is the path to the folder where the .dll files are placed. The .dll file contains the class that defines the operations for your add-in. The type attribute defines the namespace followed by the class name and the .dll file name without the .dll extension.

  2. Change the name, type, and basedir attributes to values that are specific for your add-in.

  3. Save the .addin file.

  4. Rename the AddinConfig.Addin file to a unique name that does not conflict with other installed add-ins.

  5. Copy the .addin file to the following folder:

    %ProgramFiles%\Windows Server\Bin\Addins\<TargetTab>

    Note

    <TargetTab> is the name of the folder that matches the name of a built-in top-level tab.

  6. Copy the binary files for the add-in to the folder that was specified in the basedir attribute.

Note

You must restart the Dashboard for the add-in to be displayed.