當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。