本文整理汇总了C#中System.Windows.Forms.Command.GetType方法的典型用法代码示例。如果您正苦于以下问题:C# Command.GetType方法的具体用法?C# Command.GetType怎么用?C# Command.GetType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Windows.Forms.Command
的用法示例。
在下文中一共展示了Command.GetType方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CommandEditorControl
public CommandEditorControl(Type commandType, Command value)
{
InitializeComponent();
foreach (Type type in Assembly.GetCallingAssembly().GetTypes())
{
if (commandType.IsAssignableFrom(type))
{
try
{
Command c = (Command)Activator.CreateInstance(type);
Image image = c.MenuImage ?? c.ToolBarImage;
string text = c.GetType().Name;
ListViewItem item = new ListViewItem(text);
item.Tag = c;
if (image != null)
{
imageList.Images.Add(text, image);
item.ImageKey = text;
}
listView.Items.Add(item);
item.Selected = value != null && value.GetType() == c.GetType();
}
catch (MissingMethodException)
{
}
}
}
foreach (ColumnHeader ch in listView.Columns)
{
ch.Width = -2;
}
listView.ListViewItemSorter = new Sorter();
}
示例2: FillTreeNode
private CommandTreeNode FillTreeNode(CommandTreeNode node, Command command, CommandTreeNode nodeAfter)
{
Type type = command.GetType();
var commandAttr = type.GetCustomAttributes(false).OfType<GinNameAttribute>().FirstOrDefault();
CommandTreeNode commandNode;
if (nodeAfter == null)
{
commandNode = node.AppendChild(command, commandAttr);
}
else
{
commandNode = node.InsertAfter(command, commandAttr, nodeAfter);
}
var properties = type.GetProperties();
foreach (PropertyInfo property in properties)
{
var propertyAttr = (GinArgumentCommandAttribute)property.GetCustomAttributes(typeof(GinArgumentCommandAttribute), false).FirstOrDefault();
if (propertyAttr != null)
{
CommandTreeNode argumentNode = commandNode.AppendChild(command, commandAttr, property, propertyAttr);
object nestedCommand = property.GetValue(command, null);
if (nestedCommand != null)
{
Type nestedType = nestedCommand.GetType();
bool isEnumerable = propertyAttr.IsEnumerable;
if (isEnumerable)
{
IEnumerable iEnum = (IEnumerable)nestedCommand;
foreach (var item in iEnum)
{
FillTreeNode(argumentNode, (Command)item, null);
}
}
else
{
FillTreeNode(argumentNode, (Command)nestedCommand, null);
}
}
}
}
return commandNode;
}
示例3: ClearAllNestedCommands
private void ClearAllNestedCommands(Command command)
{
Type commandType = command.GetType();
var properties = commandType.GetProperties();
foreach (var property in properties)
{
bool isNestedCommand = property.GetCustomAttributes(typeof(GinArgumentCommandAttribute), false).Count() == 1;
if (isNestedCommand)
{
object defaultValue = null;
property.SetValue(command, defaultValue, null);
}
}
}
示例4: AddCommand
private bool AddCommand(Command c)
{
if (c == null)
{
DebugLog("WARNING: Cannot use NULL command");
return false;
}
string cName = c.Name;
if (string.IsNullOrEmpty(cName))
{
DebugLog("WARNING: Cannot use no-name command " + c.GetType());
return false;
}
if (cName.StartsWith("!"))
{
//DebugLog("WARNING: Skipping command " + cName);
return false;
}
if (c.Parameters == null)
{
// DebugLog("WARNING: Skipping non-paramerized command " + cName);
return false;
}
int i = 0;
while (i < c.Parameters.Parameters.Length)
{
Type from = (Type)c.Parameters.Parameters[i].SourceType;
Type use = (Type)c.Parameters.Parameters[i].DestinationType;
AddCommand(c, from, use);
i++;
}
return true;
}
示例5: RegisterConextAction
private void RegisterConextAction(Command t, CommandContextAction cca)
{
String subDir = t.GetType().Namespace;
var ccc = GetCommandContextMenu(subDir);
ccc.AddSubCommand(cca);
var ccc2 = GetCommandContextMenu(t.Category.ToString());
if (ccc2!=ccc) ccc2.AddSubCommand(cca);
//instance.TabConsole.RegisterContextAction(cca);
}
示例6: FillProperties
private void FillProperties(Command cmd)
{
pnlProperties.Controls.Clear();
if (!cmd.AllowUserProperties)
return;
foreach (var prop in cmd.GetType().GetProperties())
{
if (prop.GetCustomAttributes(typeof(UserPropertyAttribute), true).Count() == 0)
continue;
var setterControl = ServiceLocator.GetPropertyUI(prop.PropertyType);
PropertySetterConfiguration setterConfig = new PropertySetterConfiguration();
setterConfig.Property = prop.Name;
setterConfig.Value = null;
setterControl.Initialize(setterConfig);
pnlProperties.Controls.Add((Control)setterControl);
}
}