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


C# CustomClass.Add方法代码示例

本文整理汇总了C#中CustomClass.Add方法的典型用法代码示例。如果您正苦于以下问题:C# CustomClass.Add方法的具体用法?C# CustomClass.Add怎么用?C# CustomClass.Add使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CustomClass的用法示例。


在下文中一共展示了CustomClass.Add方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: CustomClass

        /// <summary>
        /// Called after the dialog has been created.
        /// </summary>
        /// <param name="DTEObject">The DTE object.</param>
        void IDTToolsOptionsPage.OnAfterCreated(DTE DTEObject)
        {
            // Enumerate plug-ins and create a dynamic properties
            // Must also check for unique features
            CustomClass featuresHost = new CustomClass();
            foreach (BIDSHelperPluginBase plugin in Connect.Plugins.Values)
            {
                CustomProperty parent = featuresHost.Find(plugin.FeatureName);
                if (parent == null)
                {
                    // New feature
                    featuresHost.Add(new CustomProperty(plugin));
                }
                else
                {
                    parent.Children.Add(new CustomProperty(plugin));
                }
            }

            // Assign our dynamic properties collection to the property grid
            this.propertyGridFeatures.SelectedObject = featuresHost;

            // Hide property grid when we have nothing to show, and display
            // "add-in is not currently enabled" message instead
            propertyGridFeatures.Visible = (featuresHost.Count > 0);
            lblCurrentlyDisabled.Visible = !propertyGridFeatures.Visible;

            // Skip the rest if the add-in is disabled
            if (lblCurrentlyDisabled.Visible)
            {
                return;
            }

            // Set width of property grid columns, make the description larger than default 50%
            FieldInfo fieldInfo = typeof(PropertyGrid).GetField("gridView", BindingFlags.NonPublic | BindingFlags.Instance);
            object gridViewRef = fieldInfo.GetValue(this.propertyGridFeatures);
            Type gridViewType = gridViewRef.GetType();
            MethodInfo methodInfo = gridViewType.GetMethod("MoveSplitterTo", BindingFlags.NonPublic | BindingFlags.Instance);
            int width = (int)(this.propertyGridFeatures.Width * 0.7);
            methodInfo.Invoke(gridViewRef, new object[]{width});

            // Description area size is tool small for 3 lines of text, but fine for 2.
            // The DocComment Lines or Height approach is too unreliable, need to get
            // accurate border sizes, DrawString etc. Only a few descriptions that are
            // too long. Most are only 1 line, so live with it as is.

            // Set default focus to General category, the top of the grid
            // Walk up to the top of the grid tree first
            GridItem item = this.propertyGridFeatures.SelectedGridItem;
            if (item == null)
            {
                return;
            }

            while (item.Parent != null)
            {
                item = item.Parent;
            }

            foreach (GridItem category in item.GridItems)
            {
                if (category.Label == CustomProperty.GetFeatureCategoryLabel(BIDSFeatureCategories.General))
                {
                    if (category.GridItems.Count > 0)
                    {
                        category.GridItems[0].Select();
                    }
                    else
                    {
                        category.Select();
                    }
                }
            }
        }
开发者ID:sgtgold,项目名称:bids-helper-extension,代码行数:78,代码来源:BIDSHelperOptionsPage.cs

示例2: InitializeSelectedObject

 // Initialize value with selected object
 private void InitializeSelectedObject()
 {
     mp = new CustomClass();
     pg1.SelectedObject = mp;
     mp.Add(new CustomProperty("","x", m_selectedObject.xOffset, typeof(float), false, true));
     mp.Add(new CustomProperty("","y", m_selectedObject.yOffset, typeof(float), false, true));
     GetVariable();
     pg1.Refresh();
 }
开发者ID:sanyaade-g2g-repos,项目名称:quickdiagram,代码行数:10,代码来源:InfoForm.cs


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