質問

I would like to extend the team explorer work item editor with a custom functional button along side export to excel, outlook etc, taking information from the current work item.

I know there is a way to modify the items themselves, as described at witcustomcontrols.codeplex.com, but I'd rather not modify them.

Is the editor extensible in this way, or are there better ways to do this?

Best Regards, Tommy

役に立ちましたか?

解決

Creating a Work Item Custom Control is the way to accomplish what you're trying to do.

The project you already found (witcustomcontrols.codeplex.com) is a good starting point to understand the mechanics of creating work item custom controls, so I'll limit myself to describing the specifics of implementing the basics of a Custom Button.

Create a control that derives from System.Windows.Button and access the WorkItemDatasource property from the OnClick method.

This should get you started:

using System;
using System.Collections.Specialized;
using System.Windows.Forms;
using Microsoft.TeamFoundation.WorkItemTracking.Client;
using Microsoft.TeamFoundation.WorkItemTracking.Controls;

namespace Wicc {
    public class ButtonControl: Button, IWorkItemControl {
        public ButtonControl() {

        }
        protected override void OnClick(EventArgs e) {
            WorkItem workItem = this.WorkItemDatasource as WorkItem;

            // the rest of your code
        }

        #region IWorkItemControl Members

        public event EventHandler AfterUpdateDatasource;

        public event EventHandler BeforeUpdateDatasource;

        public void Clear() {
        }

        public void FlushToDatasource() {
        }

        public void InvalidateDatasource() {
        }

        public StringDictionary Properties {get; set;}

        public bool ReadOnly {get; set;}

        public void SetSite(IServiceProvider serviceProvider) {
        }

        public object WorkItemDatasource { get; set; }

        public string WorkItemFieldName { get; set; }

        #endregion
    }
}

In case you have further questions, let me know.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top