当前位置: 首页>>代码示例>>C#>>正文


C# Command.GetType方法代码示例

本文整理汇总了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();
        }
开发者ID:huizh,项目名称:xenadmin,代码行数:39,代码来源:CommandEditorControl.cs

示例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;
 }
开发者ID:vgrinin,项目名称:gin,代码行数:42,代码来源:CommandTree.cs

示例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);
         }
     }
 }
开发者ID:vgrinin,项目名称:gin,代码行数:14,代码来源:TreeViewTreeNode.cs

示例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;
 }
开发者ID:drzo,项目名称:opensim4opencog,代码行数:33,代码来源:CommandContextAction.cs

示例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);
 }
开发者ID:drzo,项目名称:opensim4opencog,代码行数:9,代码来源:CommandContextAction.cs

示例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);
            }
        }
开发者ID:PhilipBrockmeyer,项目名称:UxbTransform,代码行数:21,代码来源:CommandDetails.cs


注:本文中的System.Windows.Forms.Command.GetType方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。