Source/Design/GalleryGroupTypeEditor.cs

(开头部分) 3KB

这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。

using System;
using System.ComponentModel;
using System.ComponentModel.Design;
using System.Drawing.Design;
using System.Windows.Forms;
using System.Windows.Forms.Design;


namespace DevComponents.DotNetBar.Design
{
    /// <summary>
    /// Represents GalleryGroup type editor provided for Windows Forms designer support.
    /// </summary>
    public class GalleryGroupTypeEditor : UITypeEditor
    {
        private IWindowsFormsEditorService m_EdSvc = null;
        private const string CREATE_NEW_GROUP = "<Create new group>";

        public override UITypeEditorEditStyle GetEditStyle(ITypeDescriptorContext context)
        {
            if (context != null && context.Instance != null)
            {
                return UITypeEditorEditStyle.DropDown;
            }
            return base.GetEditStyle(context);
        }

        public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value)
        {

            if (context != null && context.Instance != null && provider != null)
            {
                m_EdSvc = (IWindowsFormsEditorService)provider.GetService(typeof(IWindowsFormsEditorService));
                if (m_EdSvc != null)
                {
                    GalleryGroupCollection groups = null;
                    BaseItem itemToAssign = null;
                    GalleryContainer gallery = null;
                    if (context.Instance is BaseItem)
                    {
                        itemToAssign = (BaseItem)context.Instance;
                        gallery = itemToAssign.Parent as GalleryContainer;
                        if (gallery != null)
                            groups = gallery.GalleryGroups;
                        else
                        {
                            System.Windows.Forms.MessageBox.Show("Item does not belong to the Gallery. Cannot edit groups.");
                            return value;
                        }
                    }
                    if (groups == null && context.Instance != null)
                        System.Windows.Forms.MessageBox.Show("Unknow control using GalleryGroupTypeEditor. Cannot edit groups. [" + context.Instance.ToString() + "]");
                    else if (groups == null)
                        System.Windows.Forms.MessageBox.Show("Unknow control using GalleryGroupTypeEditor. Cannot edit groups. [context instance null]");

                    GalleryGroup selectedGroup = gallery.GetGalleryGroup(itemToAssign);
                    ListBox listBox = new ListBox();
                    foreach (GalleryGroup g in groups)
                    {
                        listBox.Items.Add(g);
后面还有 25 行代码,解锁后查看完整代码

24 小时内免费解锁 3 个项目,之后 1 算力/个。 规则说明

AI 解读 AI

登录后可用,每次 10 算力,解读结果公开显示在下面。

还没有人解读过这个文件。