2 // Radegast Metaverse Client
3 // Copyright (c) 2009-2013, Radegast Development Team
4 // All rights reserved.
6 // Redistribution and use in source and binary forms, with or without
7 // modification, are permitted provided that the following conditions are met:
9 // * Redistributions of source code must retain the above copyright notice,
10 // this list of conditions and the following disclaimer.
11 // * Redistributions in binary form must reproduce the above copyright
12 // notice, this list of conditions and the following disclaimer in the
13 // documentation and/or other materials provided with the distribution.
14 // * Neither the name of the application "Radegast", nor the names of its
15 // contributors may be used to endorse or promote products derived from
16 // this software without specific prior written permission.
18 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
19 // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
21 // DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
22 // FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
23 // DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
24 // SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
25 // CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
26 // OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
27 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32 using System.Collections.Generic;
33 using System.Windows.Forms;
37 public interface IContextAction : IDisposable
39 void IContextAction(RadegastInstance instance);
41 /// Generate a list of ToolStripMenuItems that might be be embeded into a ContextMenuStrip host
43 /// <param name="target">the context sensitive item</param>
44 /// <param name="type">the dereferenced type</param>
45 /// <returns>List of ToolStripMenuItem that will be appeneded to the current menu</returns>
46 IEnumerable<ToolStripMenuItem> GetToolItems(object target, Type type);
48 /// Get GUI items that one might include on the form to operate this action
50 /// <param name="target">the context sensitive item</param>
51 /// <param name="type">the dereferenced type</param>
52 /// <returns>List of Buttons and Other hostable Controls that make sense to appear on the form when this item is selected</returns>
53 IEnumerable<Control> GetControls(object target, Type type);
55 /// If the menu item is Enabled
57 /// <param name="target">the context sensiive item</param>
58 /// <returns>false when the menu Item should be greyed</returns>
59 bool IsEnabled(object target);
61 /// The menu Item's text based on target
63 /// <param name="target">the context sensiive item</param>
64 /// <returns>true if the Action is availble - for instance some Avatar might not even be logged in so "follow" would not even show up</returns>
65 string LabelFor(object target);
67 /// If the context menu is usable to the target
69 /// <param name="target">the context sensitive item</param>
70 /// <param name="type">the dereferenced type</param>
71 /// <returns>The name that is displayed in a menu of options</returns>
72 bool Contributes(Object target, Type type);
74 /// The Action code goes here
76 /// <param name="sender">the Control that originates the event</param>
77 /// <param name="e">The EventArgs proprietary to the Controls event.. like MouseEventArgs or KeyEventArgs etc</param>
78 /// <param name="target">The Context Item that is realy targeted</param>
79 void OnInvoke(object sender, EventArgs e, object target);