internal static ModelItem Convert(ModelPropertyEntry modelPropertyEntry, bool returnParentActivity)
        {
            ModelItem convertedValue = null;
            if (modelPropertyEntry != null)
            {
                ModelProperty property = modelPropertyEntry.FirstModelProperty;
                if (property != null)
                {
                    convertedValue = property.Parent;
                    if (returnParentActivity)
                    {
                        while (convertedValue != null)
                        {
                            Type itemType = convertedValue.ItemType;
                            if (typeof(Activity).IsAssignableFrom(itemType) || typeof(WorkflowService).IsAssignableFrom(itemType))
                            {
                                break;
                            }

                            convertedValue = convertedValue.Parent;
                        }
                    }
                }
            }

            return convertedValue;
        }
コード例 #2
0
 public CachedValues(ModelPropertyEntry parent) 
 {
     _parent = parent;
 }
コード例 #3
0
        // <summary>
        // Removes and re-adds the specified property from this category, if it existed
        // there to begin with.  Noop otherwise.
        //
        // Use this method to refresh the cate----zation of a property if it suddenly
        // becomes Advanced if it was Basic before, or if its IsBrowsable status changes.
        // </summary>
        // <param name="property">Property to refresh</param>
        // <param name="bucket">Property bucket to repopulate</param>
        // <param name="sortComparer">Comparer to use to reinsert the given property in its new place</param>
        internal void Refresh(ModelPropertyEntry property, ObservableCollection<PropertyEntry> bucket, IComparer<PropertyEntry> sortComparer) 
        {
            if (property == null) 
            {
                throw FxTrace.Exception.ArgumentNull("property");
            }
            if (bucket != _basicProperties && bucket != _advancedProperties) 
            {
                Debug.Fail("Invalid bucket specified.  Property was not refreshed.");
                return;
            }

            // Let's see if we know about this property
            ObservableCollectionWorkaround<PropertyEntry> collection;
            collection = _advancedProperties;

            int index = collection.BinarySearch(property, null);
            if (index < 0) 
            {
                collection = _basicProperties;
                index = collection.BinarySearch(property, null);
            }

            // If not, noop
            if (index < 0)
            {
                return;
            }

            // We know about this property, so refresh it.  It may have changed
            // somehow (eg. switched from basic to advanced, become hidden, etc.)
            // so make sure it's thrown into the right bucket.
            collection.RemoveAt(index);
            Add(property, bucket, sortComparer, false);
        }
コード例 #4
0
        // IPropertyViewManager Members

        // <summary>
        // Add a property into the correct category within the specified CategoryList.
        // </summary>
        // <param name="propertySet">Specified property (passed in as a set for multi-select scenarios)</param>
        // <param name="propertyName">Name of the current property (perf optimization)</param>
        // <param name="categoryList">CategoryList instance to populate</param>
        // <returns>Wrapped ModelPropertyEntry for the specified propertySet</returns>
        public ModelPropertyEntry AddProperty(IEnumerable<ModelProperty> propertySet, string propertyName, CategoryList categoryList) 
        {
            string categoryName = System.Activities.Presentation.Internal.Properties.Resources.PropertyCategoryAllProperties;
            ModelCategoryEntry category = categoryList.FindCategory(categoryName) as ModelCategoryEntry;

            bool reuseEntries = ExtensibilityAccessor.IsEditorReusable(propertySet);
            if (reuseEntries && category != null) 
            {
                ModelPropertyEntry foundProperty;
                if ((foundProperty = (ModelPropertyEntry)category[propertyName]) != null) {
                    if (foundProperty.PropertyType != null && foundProperty.PropertyType.Equals(System.Activities.Presentation.Internal.PropertyEditing.Model.ModelUtilities.GetPropertyType(propertySet)))
                    {
                        // Found a match for the property, so reuse it

                        bool oldIsBrowsable = foundProperty.IsBrowsable;

                        foundProperty.SetUnderlyingModelProperty(propertySet);

                        // If the IsBrowsable or IsAdvanced value of the property changed,
                        // refresh the property within the category, because how and whether
                        // this property should be rendered may have changed.
                        // Note that refreshing a selected property also nullifies its stickiness
                        // (ie. it resets CategoryList.PropertySelectionMode)
                        if (oldIsBrowsable != foundProperty.IsBrowsable) 
                        {
                            category.Refresh(foundProperty, category.BasicProperties, this.PropertyComparer);
                        }

                        return foundProperty;
                    }
                }
            }

            if (category == null) 
            {
                category = new ModelCategoryEntry(categoryName);
                categoryList.InsertAlphabetically(category);
            }

            ModelPropertyEntry property = new ModelPropertyEntry(propertySet, null);
            category.Add(property, category.BasicProperties, this.PropertyComparer);
            return property;
        }
コード例 #5
0
        // <summary>
        // Basic ctor
        // </summary>
        // <param name="parentProperty">Parent property</param>
        public ModelPropertyEntryCollection(ModelPropertyEntry parentProperty)
            : base(parentProperty.PropertyValue) 
        {

            CreateCollection(parentProperty);
        }
コード例 #6
0
        private void CreateCollection(ModelPropertyEntry parentProperty) 
        {

            // Assert some assumptions that should be true at this point
            Fx.Assert(parentProperty != null, "parentProperty should not be null");
            Fx.Assert(parentProperty.ModelPropertySet != null, "parentProperty.ModelPropertySet should not be null");
            Fx.Assert(parentProperty.ModelPropertySet.Count > 0, "parentProperty.ModelPropertySet.Count should be > 0");

            // Ignore sub-properties of MarkupExtensions for v1
            if (parentProperty.IsMarkupExtension)
            {
                return;
            }

            IEnumerable<IList<ModelProperty>> mergedSubProperties = ModelPropertyMerger.GetMergedSubProperties(parentProperty.ModelPropertySet);

            int index = 0;
            bool multiSelect = parentProperty.ModelPropertySet.Count > 1;
            foreach (IList<ModelProperty> subPropertySet in mergedSubProperties) 
            {

                if (index == 0)
                {
                    _properties = new List<ModelPropertyEntry>();
                }

                ModelPropertyEntry entry;

                if (multiSelect)
                {
                    entry = new ModelPropertyEntry(subPropertySet, (ModelPropertyValue)parentProperty.PropertyValue);
                }
                else
                {
                    entry = new ModelPropertyEntry(subPropertySet[0], (ModelPropertyValue)parentProperty.PropertyValue);
                }

                _properties.Add(entry);
                index++;
            }

            // Sort the sub-properties by their OrderToken as well as their name
            if (_properties != null)
            {
                _properties.Sort();
            }
        }