コード例 #1
0
        private CategoryBase CreateCategory(string name, Type selectedType)
        {
            CategoryLocalizationHelper.CategoryName canonicalCategoryName = CategoryLocalizationHelper.GetCanonicalCategoryName(name);
            CategoryBase      categoryBase        = (CategoryBase)CategoryFactory.GetCustomCategorySelector(canonicalCategoryName).CreateSceneNodeCategory(canonicalCategoryName, name, this.SceneNodeObjectSet.DesignerContext.MessageLoggingService);
            ITypeResolver     typeResolver        = (ITypeResolver)this.SceneNodeObjectSet.ProjectContext;
            CategoryEditorSet categoryEditorsList = new CategoryEditorSet();
            IType             type = typeResolver.GetType(selectedType);

            PropertyInspectorModel.GetCategoryEditors(type, categoryEditorsList, this.MessageLoggingService);
            foreach (CategoryEditor categoryEditor in categoryEditorsList.Union(CategoryEditorInstanceFactory.GetEditors((ITypeId)type, categoryBase as SceneNodeCategory)))
            {
                if (categoryEditor.TargetCategory == categoryBase.CategoryName)
                {
                    categoryBase.CategoryEditors.Add(categoryEditor);
                }
            }
            return(categoryBase);
        }
コード例 #2
0
        private CategoryBase CreateCategory(string name, Type selectedType)
        {
            CategoryLocalizationHelper.CategoryName canonicalCategoryName = CategoryLocalizationHelper.GetCanonicalCategoryName(name);
            CategoryBase      categoryBase        = (CategoryBase)CategoryFactory.GetCustomCategorySelector(canonicalCategoryName).CreateSceneNodeCategory(canonicalCategoryName, name, this.SceneNodeObjectSet.DesignerContext.MessageLoggingService);
            ITypeResolver     typeResolver        = (ITypeResolver)this.SceneNodeObjectSet.ProjectContext;
            CategoryEditorSet categoryEditorsList = new CategoryEditorSet();
            IType             type = typeResolver.GetType(selectedType);

            PropertyInspectorModel.GetCategoryEditors(type, categoryEditorsList, this.MessageLoggingService);
            using (IEnumerator <CategoryEditor> enumerator = categoryEditorsList.Union(CategoryEditorInstanceFactory.GetEditors((ITypeId)type, categoryBase as SceneNodeCategory)).GetEnumerator())
            {
                while (((IEnumerator)enumerator).MoveNext())
                {
                    CategoryEditor current = enumerator.Current;
                    if (current.get_TargetCategory() == categoryBase.get_CategoryName())
                    {
                        categoryBase.CategoryEditors.Add(current);
                    }
                }
            }
            return(categoryBase);
        }
コード例 #3
0
        public override CategoryBase FindOrCreateCategory(string categoryName, Type selectedType)
        {
            CategoryLocalizationHelper.CategoryName canonicalCategoryName = CategoryLocalizationHelper.GetCanonicalCategoryName(categoryName);
            if (canonicalCategoryName != CategoryLocalizationHelper.CategoryName.Unknown)
            {
                categoryName = CategoryLocalizationHelper.GetLocalizedCategoryName(canonicalCategoryName);
            }
            int index = OrderedListExtensions.GenericBinarySearch <CategoryBase, CategoryLocalizationHelper.CategoryName>(this.Categories, canonicalCategoryName, (Func <CategoryLocalizationHelper.CategoryName, CategoryBase, int>)((canonicalName, category) =>
            {
                SceneNodeCategory sceneNodeCategory = (SceneNodeCategory)category;
                return(canonicalName.CompareTo((object)sceneNodeCategory.CanonicalName));
            }));

            if (index >= 0)
            {
                return(this.Categories[index]);
            }
            CategoryBase category1 = this.CreateCategory(categoryName, selectedType);

            this.Categories.Insert(~index, category1);
            return(category1);
        }
コード例 #4
0
 public override void OnSelectionChanged(SceneNode[] selectedObjects)
 {
     base.OnSelectionChanged(selectedObjects);
     if (this.objectSet != null)
     {
         this.objectSet.Dispose();
         this.objectSet = (TriggerObjectSet)null;
     }
     this.selectedObjects = selectedObjects;
     if (selectedObjects.Length > 0)
     {
         SceneNode sceneNode = selectedObjects[0];
         if (sceneNode != null && ProjectNeutralTypes.BehaviorTriggerAction.IsAssignableFrom((ITypeId)sceneNode.Type))
         {
             BehaviorTriggerBaseNode behaviorTriggerBaseNode = sceneNode.Parent as BehaviorTriggerBaseNode;
             if (behaviorTriggerBaseNode != null)
             {
                 this.objectSet   = new TriggerObjectSet((BehaviorTriggerActionNode)sceneNode);
                 this.TriggerType = behaviorTriggerBaseNode.Type;
                 List <TargetedReferenceStep> list = new List <TargetedReferenceStep>();
                 foreach (IProperty property in ITypeExtensions.GetProperties(behaviorTriggerBaseNode.Type, MemberAccessTypes.Public, true))
                 {
                     ReferenceStep referenceStep = property as ReferenceStep;
                     if (referenceStep != null)
                     {
                         list.Add(new TargetedReferenceStep(referenceStep, behaviorTriggerBaseNode.Type));
                     }
                 }
                 foreach (TargetedReferenceStep targetedReferenceStep in list)
                 {
                     if (PropertyInspectorModel.IsPropertyBrowsable(this.selectedObjects, targetedReferenceStep))
                     {
                         AttributeCollection attributes     = targetedReferenceStep.Attributes;
                         Attribute[]         attributeArray = new Attribute[attributes.Count + 1];
                         int index;
                         for (index = 0; index < attributes.Count; ++index)
                         {
                             attributeArray[index] = attributes[index];
                         }
                         attributeArray[index] = (Attribute) new CategoryAttribute(CategoryLocalizationHelper.GetLocalizedCategoryName(CategoryLocalizationHelper.CategoryName.Triggers));
                         SceneNodeProperty property = (SceneNodeProperty)this.objectSet.CreateProperty(new PropertyReference(targetedReferenceStep.ReferenceStep), new AttributeCollection(attributeArray));
                         if (!PlatformTypes.IList.IsAssignableFrom((ITypeId)property.PropertyTypeId))
                         {
                             this.AddProperty(property);
                         }
                     }
                 }
             }
         }
     }
     this.OnPropertyChanged("IsEmpty");
 }
コード例 #5
0
ファイル: CategoryFactory.cs プロジェクト: radtek/Shopdrawing
        public static CustomCategorySelector GetCustomCategorySelector(PropertyReferenceProperty property)
        {
            CustomCategorySelector selectorByCategoryName;

            if ((selectorByCategoryName = CategoryFactory.GetCategorySelectorByCategoryName(CategoryLocalizationHelper.GetCanonicalCategoryName(property.CategoryName))) != null)
            {
                return(selectorByCategoryName);
            }
            if (BehaviorHelper.IsPropertyBehaviorCommand(property))
            {
                return((CustomCategorySelector) new CategoryFactory.BehaviorCommandCategorySelector());
            }
            return(new CustomCategorySelector());
        }