コード例 #1
0
        PropertyDescriptorCollection ICustomTypeDescriptor.GetProperties()
        {
            // get model properties
            List <PropertyDescriptor> properties = new List <PropertyDescriptor>();


            foreach (PropertyDescriptor modelPropertyDescriptor in ModelUtilities.WrapProperties(this))
            {
                properties.Add(modelPropertyDescriptor);
            }

            // try to see if there are pseudo builtin properties for this type.
            AttachedPropertiesService AttachedPropertiesService = this.modelTreeManager.Context.Services.GetService <AttachedPropertiesService>();

            if (AttachedPropertiesService != null)
            {
                var nonBrowsableAttachedProperties = from attachedProperty in AttachedPropertiesService.GetAttachedProperties(this.itemType)
                                                     where (!attachedProperty.IsBrowsable && !attachedProperty.IsVisibleToModelItem)
                                                     select attachedProperty;

                foreach (AttachedProperty AttachedProperty in nonBrowsableAttachedProperties)
                {
                    properties.Add(new AttachedPropertyDescriptor(AttachedProperty, this));
                }
            }
            return(new PropertyDescriptorCollection(properties.ToArray(), true));
        }
コード例 #2
0
        private ModelItem FindModelItemToFocus(ModelItem itemToFocus)
        {
            WorkflowViewService viewService = this.WorkflowViewService;

            if (viewService == null || itemToFocus == null)
            {
                return(itemToFocus);
            }

            ModelUtilities.ReverseTraverse(itemToFocus, (ModelItem modelItem) =>
            {
                if (modelItem == null)
                {
                    // continue;
                    return(true);
                }

                // if the item has Designer, we assume it can get focus.
                if (CanFocusOnModelItem(modelItem, viewService))
                {
                    itemToFocus = modelItem;
                    // break;
                    return(false);
                }

                // continue
                return(true);
            });

            return(itemToFocus);
        }
コード例 #3
0
        private static SearchableEntry CreateSearchableEntryForArgumentOrVariable(ModelItem itemToFocus)
        {
            SearchableEntry entry = null;

            ModelUtilities.ReverseTraverse(itemToFocus, (ModelItem modelItem) =>
            {
                entry = CreateSearchableEntryNoRecursive(modelItem);
                return(entry == null);
            });
            return(entry);
        }
コード例 #4
0
ファイル: ModelUtilities.cs プロジェクト: dox0/DotNet471RS3
        internal static ModelItem ReverseFindFirst(ModelItem start, Predicate <ModelItem> matcher)
        {
            Fx.Assert(start != null, "start should not be null");
            Fx.Assert(matcher != null, "matcher should not be null");

            ModelItem result = null;

            ModelUtilities.ReverseTraverse(start, (ModelItem current) =>
            {
                if (matcher(current))
                {
                    result = current;
                    return(false);
                }

                return(true);
            });
            return(result);
        }
コード例 #5
0
        internal IEnumerable <ModelItem> GetItemsOnDesigner(bool preOrder, bool excludeRoot, bool excludeErrorActivity, bool excludeExpression, bool includeOtherObjects)
        {
            WorkflowViewService viewService = this.WorkflowViewService;
            IList <ModelItem>   items       =
                ModelTreeManager.DepthFirstSearch(modelService.Root,
                                                  delegate(Type type)
            {
                // Only find items on the designer surface.
                return(includeOtherObjects || (typeof(WorkflowViewElement).IsAssignableFrom(viewService.GetDesignerType(type))));
            },
                                                  delegate(ModelItem modelItem)
            {
                return(!(excludeExpression && modelItem != null && typeof(ITextExpression).IsAssignableFrom(modelItem.ItemType)));
            },
                                                  preOrder);

            // ModelItemKeyValuePair is associated with CaseDesigner.
            // So ModelItemKeyValuePair will be returned even if they are not really Cases.
            // Those ModelItemKeyValuePairs need to be excluded.
            IEnumerable <ModelItem> itemsToSearch = null;

            if (!excludeErrorActivity)
            {
                itemsToSearch = items.Where <ModelItem>(item => !ModelUtilities.IsModelItemKeyValuePair(item.ItemType) ||
                                                        ModelUtilities.IsSwitchCase(item));
            }
            else
            {
                itemsToSearch = items.Where <ModelItem>(item =>
                                                        (!ModelUtilities.IsModelItemKeyValuePair(item.ItemType) || ModelUtilities.IsSwitchCase(item)) &&
                                                        !IsErrorActivity(item));
            }
            if (excludeRoot)
            {
                itemsToSearch = itemsToSearch.Except <ModelItem>(new ModelItem[] { modelService.Root });
            }
            return(itemsToSearch);
        }
コード例 #6
0
 PropertyDescriptorCollection ICustomTypeDescriptor.GetProperties(Attribute[] attributes)
 {
     return(ModelUtilities.WrapProperties(this));
 }
コード例 #7
0
 PropertyDescriptor ICustomTypeDescriptor.GetDefaultProperty()
 {
     return(ModelUtilities.GetDefaultProperty(this));
 }
コード例 #8
0
 TypeConverter ICustomTypeDescriptor.GetConverter()
 {
     return(ModelUtilities.GetConverter(this));
 }