本文整理汇总了C#中MenuCommand类的典型用法代码示例。如果您正苦于以下问题:C# MenuCommand类的具体用法?C# MenuCommand怎么用?C# MenuCommand使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
MenuCommand类属于命名空间,在下文中一共展示了MenuCommand类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: AddRenameCommand
void AddRenameCommand(IClass c, List<ToolStripItem> resultItems)
{
var cmd = new MenuCommand("${res:SharpDevelop.Refactoring.RenameCommand}", Rename);
cmd.ShortcutKeys = MenuCommand.ParseShortcut("Control|R");
cmd.Tag = c;
resultItems.Add(cmd);
}
示例2: SaveMeshInPlace
public static void SaveMeshInPlace(MenuCommand menuCommand)
{
VoxelMesh vm = menuCommand.context as VoxelMesh;
SaveVoxelStruct(vm);
}
示例3: AddAccordionElement
public static void AddAccordionElement(MenuCommand menuCommand)
{
GameObject go = CreateUIElementRoot("Accordion Element", menuCommand, s_ThickGUIElementSize);
go.AddComponent<LayoutElement>();
go.AddComponent<AccordionElement>();
Selection.activeGameObject = go;
}
示例4: PopupMenu
/// <summary>
/// Display the popup menu for this row
/// </summary>
/// <param name="parent">The parent control</param>
/// <param name="x">X coordinate of menu</param>
/// <param name="y">Y coordinate of menu</param>
public void PopupMenu( System.Windows.Forms.Control parent , int x , int y )
{
// Use reflection to get the list of popup menu commands
MemberInfo[] members = this.GetType().FindMembers ( MemberTypes.Method ,
BindingFlags.Public | BindingFlags.Instance ,
new System.Reflection.MemberFilter ( Filter ) ,
null ) ;
if ( members.Length > 0 )
{
// Create a context menu
ContextMenu menu = new ContextMenu ( ) ;
// Now loop through those members and generate the popup menu
// Note the cast to MethodInfo in the foreach
foreach ( MethodInfo meth in members )
{
// Get the caption for the operation from the ContextMenuAttribute
ContextMenuAttribute[] ctx = (ContextMenuAttribute[]) meth.GetCustomAttributes ( typeof ( ContextMenuAttribute ) , true ) ;
MenuCommand callback = new MenuCommand ( this , meth ) ;
MenuItem item = new MenuItem ( ctx[0].Caption , new EventHandler ( callback.Execute ) ) ;
item.DefaultItem = ctx[0].Default ;
menu.MenuItems.Add ( item ) ;
}
System.Drawing.Point pt = new System.Drawing.Point ( x , y ) ;
menu.Show ( parent , pt ) ;
}
}
示例5: ValidateSliceUsingXML
public static bool ValidateSliceUsingXML(MenuCommand command) {
var textureImporter = command.context as TextureImporter;
//valid only if the texture type is 'sprite' or 'advanced'.
return textureImporter && textureImporter.textureType == TextureImporterType.Sprite ||
textureImporter.textureType == TextureImporterType.Advanced;
}
示例6: ExtractCubemap
public static void ExtractCubemap(MenuCommand mc)
{
var path = AssetDatabase.GetAssetPath(mc.context);
if (string.IsNullOrEmpty(path) == false)
{
var assets = AssetDatabase.LoadAllAssetsAtPath(path);
if (RemoveExtension(ref path) == true)
{
foreach (var asset in assets)
{
var cubemap = asset as Cubemap;
if (cubemap != null)
{
SaveCubemapFace(cubemap, CubemapFace.NegativeX, path);
SaveCubemapFace(cubemap, CubemapFace.NegativeY, path);
SaveCubemapFace(cubemap, CubemapFace.NegativeZ, path);
SaveCubemapFace(cubemap, CubemapFace.PositiveX, path);
SaveCubemapFace(cubemap, CubemapFace.PositiveY, path);
SaveCubemapFace(cubemap, CubemapFace.PositiveZ, path);
}
}
}
}
}
示例7: ValidateSliceUsingXML
public static bool ValidateSliceUsingXML(MenuCommand cmd)
{
TextureImporter importer = cmd.context as TextureImporter;
return importer != null &&
(importer.textureType == TextureImporterType.Sprite || importer.textureType == TextureImporterType.Advanced);
}
示例8: AddGNStringText
private static void AddGNStringText(MenuCommand menuCommand)
{
GameObject go = new GameObject("Text");
GameObjectUtility.SetParentAndAlign(go, menuCommand.context as GameObject);
if(go.GetComponentInParent<Canvas>()== null)
{
var canvas = Object.FindObjectOfType<Canvas>();
if(canvas == null)
{
var goCanvas = new GameObject("Canvas");
canvas = goCanvas.AddComponent<Canvas>();
canvas.renderMode = RenderMode.ScreenSpaceOverlay;
goCanvas.AddComponent<UnityEngine.UI.CanvasScaler>();
goCanvas.AddComponent<UnityEngine.UI.GraphicRaycaster>();
}
go.transform.SetParent(canvas.transform);
go.transform.localPosition = Vector3.zero;
}
go.AddComponent<GNText>();
Undo.RegisterCreatedObjectUndo(go, "Create " + go.name);
Selection.activeObject = go;
if(GNStringManager.instance == null)
{
var sm = new GameObject("StringManager");
sm.AddComponent<GNStringManager>();
}
}
示例9: AddButton
public static void AddButton(MenuCommand menuCommand)
{
GameObject buttonRoot = CreateUIElementRoot("Button", menuCommand, s_ThickGUIElementSize);
GameObject childText = new GameObject("Text");
GameObjectUtility.SetParentAndAlign(childText, buttonRoot);
Image image = buttonRoot.AddComponent<Image>();
image.sprite = AssetDatabase.GetBuiltinExtraResource<Sprite>(kStandardSpritePath);
image.type = Image.Type.Sliced;
image.color = s_DefaultSelectableColor;
Button bt = buttonRoot.AddComponent<Button>();
SetDefaultColorTransitionValues(bt);
Text text = childText.AddComponent<Text>();
text.text = "Button";
text.alignment = TextAnchor.MiddleCenter;
SetDefaultTextValues(text);
RectTransform textRectTransform = childText.GetComponent<RectTransform>();
textRectTransform.anchorMin = Vector2.zero;
textRectTransform.anchorMax = Vector2.one;
textRectTransform.sizeDelta = Vector2.zero;
}
示例10: DoSomethingAll
static void DoSomethingAll(MenuCommand theCommand)
{
List<Object> aList = new List<Object>();
aList.Add(((Component)theCommand.context).gameObject);
aList.AddRange(((Component)theCommand.context).GetComponents<Component>());
Search(aList.ToArray());
}
示例11: SliceUsingXML
public static void SliceUsingXML(MenuCommand cmd)
{
TextureImporter importer = cmd.context as TextureImporter;
XMLSpriteSlicer window = ScriptableObject.CreateInstance<XMLSpriteSlicer>();
window._textureImporter = importer;
window.ShowUtility();
}
示例12: Create_DialogueCanvas
private static void Create_DialogueCanvas(MenuCommand menuCommand)
{
GameObject go = Instantiate(Resources.Load("VN Engine/DialogueCanvas", typeof(GameObject))) as GameObject; // Create new object
go.name = "DialogueCanvas";
GameObjectUtility.SetParentAndAlign(go, menuCommand.context as GameObject); // Parent the new object
Undo.RegisterCreatedObjectUndo(go, "Create " + go.name); // Register the creation in the undo system
Selection.activeObject = go;
}
示例13: CreatePipLight
static void CreatePipLight(MenuCommand menuCommand)
{
GameObject go = new GameObject ("Pip Light");
go.AddComponent<PipLight> ();
GameObjectUtility.SetParentAndAlign (go, menuCommand.context as GameObject);
Undo.RegisterCreatedObjectUndo (go, "Create " + go.name);
Selection.activeObject = go;
}
示例14: BuildMenuByFile
ToolStripItem[] BuildMenuByFile(ICollection<INavigationPoint> points, int additionalItems)
{
Dictionary<string, List<INavigationPoint>> files =
new Dictionary<string, List<INavigationPoint>>();
List<string> fileNames = new List<string>();
foreach (INavigationPoint p in points) {
if (p.FileName==null) {
throw new ApplicationException("should not get here!");
}
if (!fileNames.Contains(p.FileName)) {
fileNames.Add(p.FileName);
files.Add(p.FileName, new List<INavigationPoint>());
}
if (!files[p.FileName].Contains(p)) {
files[p.FileName].Add(p);
}
}
fileNames.Sort();
ToolStripItem[] items =
new ToolStripItem[fileNames.Count + additionalItems];
ToolStripMenuItem containerItem = null;
MenuCommand cmd = null;
int i = 0;
foreach (string fname in fileNames) {
// create a menu bucket
containerItem = new ToolStripMenuItem();
containerItem.Text = System.IO.Path.GetFileName(fname);
containerItem.ToolTipText = fname;
// sort and populate the bucket's contents
// files[fname].Sort();
foreach(INavigationPoint p in files[fname]) {
cmd = new MenuCommand(p.Description, new EventHandler(NavigateTo));
cmd.Tag = p;
containerItem.DropDownItems.Add(cmd);
}
// if there's only one nested item, add it
// to the result directly, ignoring the bucket
// if (containerItem.DropDownItems.Count==1) {
// items[i] = containerItem.DropDownItems[0];
// items[i].Text = ((INavigationPoint)items[i].Tag).FullDescription;
// i++;
// } else {
// // add the bucket to the result
// items[i++] = containerItem;
// }
// add the bucket to the result
items[i++] = containerItem;
}
return items;
}
示例15: SliceUsingXML
public static void SliceUsingXML(MenuCommand command) {
var textureImporter = command.context as TextureImporter;
var window = CreateInstance<TextureAtlasSlicer>();
window.importer = textureImporter;
window.ShowUtility();
}