MethodTaskItem Constructors

Definition

Initializes a new instance of the MethodTaskItem class.

Overloads

MethodTaskItem(String, String, String)

Initializes a new instance of the MethodTaskItem class by using the specified method name, text, and category.

MethodTaskItem(String, String, String, String)

Initializes a new instance of the MethodTaskItem class by using the specified method name, text, category, and description.

MethodTaskItem(String, String, String, String, Image)

Initializes a new instance of the MethodTaskItem class by using the specified method name, text, category, description, and menu icon.

MethodTaskItem(String, String, String, String, Image, Object)

Initializes a new instance of the MethodTaskItem class by using the specified method name, text, category, description, menu icon, and user data.

MethodTaskItem(String, String, String)

Initializes a new instance of the MethodTaskItem class by using the specified method name, text, and category.

public:
 MethodTaskItem(System::String ^ methodName, System::String ^ text, System::String ^ category);
public MethodTaskItem (string methodName, string text, string category);
new Microsoft.Web.Management.Client.Win32.MethodTaskItem : string * string * string -> Microsoft.Web.Management.Client.Win32.MethodTaskItem
Public Sub New (methodName As String, text As String, category As String)

Parameters

methodName
String

The name of the method.

text
String

The menu item string for the method.

category
String

The category of the task.

Examples

The following example creates a task list to which it adds a MethodTaskItem object. When the task is invoked, the example writes the current time to the trace listener.

private sealed class HierarchyDemoInfoTaskList : TaskList
{
    private DemoHierarchyInfo _owner;
    private bool _dirtyState = false;
    Person _curPerson = new Person(23, "Albert", "Smith");

    public HierarchyDemoInfoTaskList(DemoHierarchyInfo owner) {
        _owner = owner;
    }

    public void Delete()
    {
        _owner.Delete();
    }
/// GetTaskItems() is called every time the context menu is invoked.
public override System.Collections.ICollection GetTaskItems() {

    ArrayList items = new ArrayList();

    Image imgAsk = rLoadImg.loadImgs(SystemIcons.Asterisk, 16);
    Image imgErr = rLoadImg.loadImgs(SystemIcons.Error, 16);

    items.Add(new MethodTaskItem(
                "DisplayTime",       // Method Name
                "Show Time",        // Menu item Text
                "DemoCategory")    // Category
                );

    Person prs = new Person(66, "Joe", "Smith");
    MethodTaskItem mti_i = new MethodTaskItem(
                                    "InvTst",       // Method Name
                                    "Invoke Test",   // Menu item Text
                                    sDemoCat,       // Category
                                    "Tool Tip:SC",  // ToolTip non-functional
                                    imgAsk,          // Menu Icon
                                    prs);      // user data
    mti_i.CausesNavigation = false;
    traceMTI(mti_i);

    items.Add(mti_i);

public void DisplayTime() {
    _owner.DisplayTime();
}
private void DisplayTime() {
    Trace.WriteLine("DisplayTime = " + DateTime.Now.ToString());
}

Applies to

MethodTaskItem(String, String, String, String)

Initializes a new instance of the MethodTaskItem class by using the specified method name, text, category, and description.

public:
 MethodTaskItem(System::String ^ methodName, System::String ^ text, System::String ^ category, System::String ^ description);
public MethodTaskItem (string methodName, string text, string category, string description);
new Microsoft.Web.Management.Client.Win32.MethodTaskItem : string * string * string * string -> Microsoft.Web.Management.Client.Win32.MethodTaskItem
Public Sub New (methodName As String, text As String, category As String, description As String)

Parameters

methodName
String

The name of the method.

text
String

The menu item string for the method.

category
String

The category of the task.

description
String

The task description.

Remarks

For more information, see the example for the MethodTaskItem(String, String, String, String, Image, Object) overload.

Microsoft.Web.Management classes do not use the description parameter.

Applies to

MethodTaskItem(String, String, String, String, Image)

Initializes a new instance of the MethodTaskItem class by using the specified method name, text, category, description, and menu icon.

public:
 MethodTaskItem(System::String ^ methodName, System::String ^ text, System::String ^ category, System::String ^ description, System::Drawing::Image ^ image);
public MethodTaskItem (string methodName, string text, string category, string description, System.Drawing.Image image);
new Microsoft.Web.Management.Client.Win32.MethodTaskItem : string * string * string * string * System.Drawing.Image -> Microsoft.Web.Management.Client.Win32.MethodTaskItem

Parameters

methodName
String

The name of the method.

text
String

The menu item string for this method.

category
String

The category of the task.

description
String

The task description.

image
Image

The menu icon.

Examples

private sealed class HierarchyDemoInfoTaskList : TaskList
{
    private DemoHierarchyInfo _owner;
    private bool _dirtyState = false;
    Person _curPerson = new Person(23, "Albert", "Smith");

    public HierarchyDemoInfoTaskList(DemoHierarchyInfo owner) {
        _owner = owner;
    }

    public void Delete()
    {
        _owner.Delete();
    }
/// GetTaskItems() is called every time the context menu is invoked.
public override System.Collections.ICollection GetTaskItems() {

    ArrayList items = new ArrayList();

    Image imgAsk = rLoadImg.loadImgs(SystemIcons.Asterisk, 16);
    Image imgErr = rLoadImg.loadImgs(SystemIcons.Error, 16);

    items.Add(new MethodTaskItem(
                "DisplayTime",       // Method Name
                "Show Time",        // Menu item Text
                "DemoCategory")    // Category
                );

    Person prs = new Person(66, "Joe", "Smith");
    MethodTaskItem mti_i = new MethodTaskItem(
                                    "InvTst",       // Method Name
                                    "Invoke Test",   // Menu item Text
                                    sDemoCat,       // Category
                                    "Tool Tip:SC",  // ToolTip non-functional
                                    imgAsk,          // Menu Icon
                                    prs);      // user data
    mti_i.CausesNavigation = false;
    traceMTI(mti_i);

    items.Add(mti_i);

public void DisplayTime() {
    _owner.DisplayTime();
}
private void DisplayTime() {
    Trace.WriteLine("DisplayTime = " + DateTime.Now.ToString());
}

Remarks

Microsoft.Web.Management classes do not use the description parameter.

Applies to

MethodTaskItem(String, String, String, String, Image, Object)

Initializes a new instance of the MethodTaskItem class by using the specified method name, text, category, description, menu icon, and user data.

public:
 MethodTaskItem(System::String ^ methodName, System::String ^ text, System::String ^ category, System::String ^ description, System::Drawing::Image ^ image, System::Object ^ userData);
public MethodTaskItem (string methodName, string text, string category, string description, System.Drawing.Image image, object userData);
new Microsoft.Web.Management.Client.Win32.MethodTaskItem : string * string * string * string * System.Drawing.Image * obj -> Microsoft.Web.Management.Client.Win32.MethodTaskItem

Parameters

methodName
String

The name of the method.

text
String

The menu item string for this method.

category
String

The category of the task.

description
String

The task description.

image
Image

The menu image.

userData
Object

Storage for arbitrary user data.

Examples

The following example creates the custom DemoHierProvidr class, which contains the nested class HierarchyDemoInfoTaskList. The Microsoft.Web.Management.Client.TaskList.GetTaskItems method then creates a MethodTaskItem object for the InvTst method.

internal class DemoHierProvidr : HierarchyProvider
{

    private DemoHierarchyInfo _info;
    public DemoHierProvidr(IServiceProvider serviceProvider)
        : base(serviceProvider)
    {
    }

// DemoHierarchyInfo.InvTst()
//
public int InvTst(Person p)
{
    Trace.WriteLine(" InvTst : person age: " + p._age.ToString()
    + "\n First name \"" + p._fName
    + "\"\n Last name " + p._LstName + "\"");

    return SH._pCnt;
}

private sealed class HierarchyDemoInfoTaskList : TaskList
{
    private DemoHierarchyInfo _owner;
    private bool _dirtyState = false;
    Person _curPerson = new Person(23, "Albert", "Smith");

    public HierarchyDemoInfoTaskList(DemoHierarchyInfo owner) {
        _owner = owner;
    }

    public void Delete()
    {
        _owner.Delete();
    }

    public override bool IsDirty
    {
        get
        {
            return _dirtyState;
        }
    }

    /// GetTaskItems() is called every time the context menu is invoked
    /// For better perf, move ArrayList items = new ArrayList(); to
    /// to the class (as _items) and only initialize once
    /// 

    /// GetTaskItems() is called every time the context menu is invoked.
    public override System.Collections.ICollection GetTaskItems() {

        ArrayList items = new ArrayList();

        Image imgAsk = rLoadImg.loadImgs(SystemIcons.Asterisk, 16);
        Image imgErr = rLoadImg.loadImgs(SystemIcons.Error, 16);

        items.Add(new MethodTaskItem(
                    "DisplayTime",       // Method Name
                    "Show Time",        // Menu item Text
                    "DemoCategory")    // Category
                    );

        Person prs = new Person(66, "Joe", "Smith");
        MethodTaskItem mti_i = new MethodTaskItem(
                                        "InvTst",       // Method Name
                                        "Invoke Test",   // Menu item Text
                                        sDemoCat,       // Category
                                        "Tool Tip:SC",  // ToolTip non-functional
                                        imgAsk,          // Menu Icon
                                        prs);      // user data
        mti_i.CausesNavigation = false;
        traceMTI(mti_i);

        items.Add(mti_i);

// method DemoHierarchyInfo.HierarchyDemoInfoTaskList.InvTst()
public void InvTst(object obj)
{
    // Call parents InvTst (DemoHierarchyInfo.InvTst )
    //
    _owner.InvTst((Person)obj);
    UpdateCurPers();
    _owner.flush();
}

Remarks

Microsoft.Web.Management classes do not use the description parameter.

Applies to