Exemplo n.º 1
0
        /// <summary>
        /// 如果当前属性面板窗体有效(可见状态)
        /// 将实体对象提取出来,然后设置到属性网格中
        /// </summary>
        private void UpdateSelectedObjectIfActive()
        {
            //如果窗体不可见,不更新属性网格
            if (!this.Visible)
            {
                return;
            }

            //加载当前可用的设计器谓词
            //先加载设计器谓词,避免先显示了属性行再显示谓词面板造成属性行部分滚动条闪动
            if (this.Host != null)
            {
                IMenuCommandService menuCommandService =
                    this.Host.GetService(typeof(IMenuCommandService)) as IMenuCommandService;
                Debug.Assert(menuCommandService != null, "menuCommandService 为 null");
                if (menuCommandService != null)
                {
                    this.PropertyGrid.Verbs = menuCommandService.Verbs;
                }
            }

            if (SelectedObjects != null)
            {
                EntityBase[] entity   = new EntityBase[SelectedObjects.Length];
                object[]     selArray = new object[SelectedObjects.Length];
                SelectedObjects.CopyTo(selArray, 0);

                for (int i = 0; i < SelectedObjects.Length; i++)
                {
                    IShellControlDev shellControlDev = selArray[i] as IShellControlDev;
                    //entity[i] = shellControlDev.GetEntity();
                    entity[i] = shellControlDev.Entity;
                }

                SetDesignableObjects(entity);
            }
            else
            {
                IShellControlDev shellControlDev = SelectedObject as IShellControlDev;

                if (shellControlDev != null)
                {
                    //SetDesignableObject(shellControlDev.GetEntity());
                    SetDesignableObjects(new object[] { shellControlDev.Entity });
                }
                else
                {
                    SetDesignableObjects(null);
                }
            }
        }