Example #1
0
        /// <summary>
        /// Delayed loading of the property inspector to avoid creating the entire list of property
        /// editors immediately after selection. Keeps that app running smooth.
        /// </summary>
        /// <returns></returns>
        private async void ProcessIncrementalPropertyAddAsync()
        {
            const int batchAmount = 10;

            var propertiesToAdd = PropertyInformation.GetProperties(_target);

            await Dispatcher.Yield(DispatcherPriority.Background);

            int visiblePropertyCount = 0;

            foreach (var property in propertiesToAdd)
            {
                // iterate over the PropertyInfo objects,
                // setting the property grid's filter on each object,
                // and adding those properties to the observable collection of propertiesToSort (this.properties)
                property.Filter = Filter;

                if (property.IsVisible)
                {
                    _properties.Add(property);
                }
                _allProperties.Add(property);

                // checking whether a property is visible ... actually runs the property filtering code
                if (property.IsVisible)
                {
                    property.Index = visiblePropertyCount++;
                }

                if ((visiblePropertyCount % batchAmount) == 0)
                {
                    await Dispatcher.Yield(DispatcherPriority.Background);
                }
            }
        }
Example #2
0
        /// <summary>
        /// Delayed loading of the property inspector to avoid creating the entire list of property
        /// editors immediately after selection. Keeps that app running smooth.
        /// </summary>
        /// <param name="performInitialization"></param>
        /// <returns></returns>
        private void ProcessIncrementalPropertyAdd()
        {
            var numberToAdd = 10;

            if (this.propertiesToAdd == null)
            {
                this.propertiesToAdd = PropertyInformation.GetProperties(this.target).GetEnumerator();

                numberToAdd = 0;
            }

            var i = 0;

            for (; i < numberToAdd && this.propertiesToAdd.MoveNext(); ++i)
            {
                // iterate over the PropertyInfo objects,
                // setting the property grid's filter on each object,
                // and adding those properties to the observable collection of propertiesToSort (this.properties)
                var property = this.propertiesToAdd.Current;
                property.Filter = this.Filter;

                if (property.IsVisible)
                {
                    this.Properties.Add(property);
                }

                this.allProperties.Add(property);

                // checking whether a property is visible ... actually runs the property filtering code
                if (property.IsVisible)
                {
                    property.Index = this.visiblePropertyCount++;
                }
            }

            if (i == numberToAdd)
            {
                this.processIncrementalCall.Enqueue(this.Dispatcher);
            }
            else
            {
                this.propertiesToAdd = null;
            }
        }