public PropertyValueUIItem[] GetPropertyUIValueItems(ITypeDescriptorContext context, PropertyDescriptor propDesc)
 {
     if (propDesc == null)
     {
         throw new ArgumentNullException("propDesc");
     }
     if (this.handler == null)
     {
         return(new PropertyValueUIItem[0]);
     }
     lock (this)
     {
         if (this.items == null)
         {
             this.items = new ArrayList();
         }
         this.handler(context, propDesc, this.items);
         int count = this.items.Count;
         if (count > 0)
         {
             PropertyValueUIItem[] propertyValueUiItemArray = new PropertyValueUIItem[count];
             this.items.CopyTo((Array)propertyValueUiItemArray, 0);
             this.items.Clear();
             return(propertyValueUiItemArray);
         }
     }
     return(null);
 }
Exemple #2
0
        /// <summary>
        /// Gets all the PropertyValueUIItems that should be displayed on the given property.
        /// For each item returned, a glyph icon will be aded to the property.
        /// </summary>
        /// <param name="context"></param>
        /// <param name="propDesc"></param>
        /// <returns></returns>
        PropertyValueUIItem[] IPropertyValueUIService.GetPropertyUIValueItems(ITypeDescriptorContext context, PropertyDescriptor propDesc)
        {
            if (propDesc == null)
            {
                throw new ArgumentNullException("propDesc");
            }

            if (_handler == null)
            {
                return(new PropertyValueUIItem[0]);
            }

            lock (this)
            {
                if (_itemList == null)
                {
                    _itemList = new ArrayList();
                }

                _handler(context, propDesc, _itemList);

                int nItems = _itemList.Count;

                if (nItems > 0)
                {
                    PropertyValueUIItem[] items = new PropertyValueUIItem[nItems];
                    _itemList.CopyTo(items, 0);
                    _itemList.Clear();
                    return(items);
                }
            }

            return(null);
        }
        public void PropertyValueUIItem_Ctor_Image_PropertyValueUIItemInvokeHandler_String(Image uiItemImage, PropertyValueUIItemInvokeHandler handler, string tooltip)
        {
            var item = new PropertyValueUIItem(uiItemImage, handler, tooltip);

            Assert.Same(uiItemImage, item.Image);
            Assert.Same(handler, item.InvokeHandler);
            Assert.Same(tooltip, item.ToolTip);
        }
        public void Ctor_PropertiesAssignedCorrectly()
        {
            string toolTip = "Custom toolTip";

            using (Image img = Image.FromFile(Path.Combine("bitmaps", "nature24bits.jpg")))
            {
                var propertyValue = new PropertyValueUIItem(img, Dummy_PropertyValueUIItemInvokeHandler, toolTip);
                Assert.Equal(img, propertyValue.Image);
                Assert.Equal(Dummy_PropertyValueUIItemInvokeHandler, propertyValue.InvokeHandler);
                Assert.Equal(toolTip, propertyValue.ToolTip);
            }
        }
        public PropertyValueUIItem[] GetPropertyUIValueItems(ITypeDescriptorContext context, PropertyDescriptor propDesc)
        {
            ArrayList valueUIItemList = new ArrayList();

            if (this.propertyValueUIHandler != null)
            {
                this.propertyValueUIHandler(context, propDesc, valueUIItemList);
            }
            PropertyValueUIItem[] array = new PropertyValueUIItem[valueUIItemList.Count];
            if (valueUIItemList.Count > 0)
            {
                valueUIItemList.CopyTo(array);
            }
            return(array);
        }
        public PropertyValueUIItem[] GetPropertyUIValueItems(ITypeDescriptorContext context, PropertyDescriptor propDesc)
        {
            // Let registered handlers have a chance to add their UIItems
            ArrayList propUIValues = new ArrayList();

            if (propertyValueUIHandler != null)
            {
                propertyValueUIHandler(context, propDesc, propUIValues);
            }
            PropertyValueUIItem[] values = new PropertyValueUIItem[propUIValues.Count];
            if (propUIValues.Count > 0)
            {
                propUIValues.CopyTo(values);
            }
            return(values);
        }
Exemple #7
0
        public PropertyValueUIItem[] GetPropertyUIValueItems(ITypeDescriptorContext context, PropertyDescriptor propDesc)
        {
            ArrayList list = null;

            if (QueryPropertyUIValueItems != null)
            {
                list = new ArrayList( );
                QueryPropertyUIValueItems(context, propDesc, list);
            }

            if (list == null || list.Count == 0)
            {
                return(new PropertyValueUIItem[0]);
            }

            var result = new PropertyValueUIItem[list.Count];

            list.CopyTo(result);

            return(result);
        }
        /// <include file='doc\PropertyValueUIService.uex' path='docs/doc[@for="PropertyValueUIService.GetPropertyUIValueItems"]/*' />
        /// <devdoc>
        /// Gets all the PropertyValueUIItems that should be displayed on the given property.
        /// For each item returned, a glyph icon will be aded to the property.
        /// </devdoc>
        public PropertyValueUIItem[] GetPropertyUIValueItems(ITypeDescriptorContext context, PropertyDescriptor propDesc)
        {
            if (handler == null)
            {
                return(new PropertyValueUIItem[0]);
            }

            lock (itemList) {
                itemList.Clear();
                handler.Invoke(context, propDesc, itemList);

                int nItems = itemList.Count;

                if (nItems > 0)
                {
                    PropertyValueUIItem[] items = new PropertyValueUIItem[nItems];
                    itemList.CopyTo(items, 0);
                    return(items);
                }
            }
            return(null);
        }
Exemple #9
0
        /// <summary>
        /// Get a list of UI items for a property
        /// </summary>
        /// <param name="context"></param>
        /// <param name="propDesc"></param>
        /// <returns></returns>
        public PropertyValueUIItem[] GetPropertyUIValueItems(
            ITypeDescriptorContext context, PropertyDescriptor propDesc)
        {
            PropertyValueUIItem[] result = new PropertyValueUIItem[0];
            if (propDesc == null || _UIHandler == null)
            {
                return(result);
            }

            //call any subscribed handlers allowing them
            //to provide a list of UI items. the UI items
            //provide images and tooltips for the properties
            //grid.
            ArrayList propertyItems = new ArrayList();

            _UIHandler(context, propDesc, propertyItems);
            if (propertyItems.Count > 0)
            {
                result = new PropertyValueUIItem[propertyItems.Count];
                propertyItems.CopyTo(result);
            }
            return(result);
        }
Exemple #10
0
        /// <summary>
        /// Extends BeginInvoke so that when a state object is not needed, null does not need to be passed.
        /// <example>
        /// propertyvalueuiiteminvokehandler.BeginInvoke(context, descriptor, invokedItem, callback);
        /// </example>
        /// </summary>
        public static IAsyncResult BeginInvoke(this PropertyValueUIItemInvokeHandler propertyvalueuiiteminvokehandler, System.ComponentModel.ITypeDescriptorContext context, System.ComponentModel.PropertyDescriptor descriptor, PropertyValueUIItem invokedItem, AsyncCallback callback)
        {
            if (propertyvalueuiiteminvokehandler == null)
            {
                throw new ArgumentNullException("propertyvalueuiiteminvokehandler");
            }

            return(propertyvalueuiiteminvokehandler.BeginInvoke(context, descriptor, invokedItem, callback, null));
        }
 private void OnBindProperty(ITypeDescriptorContext context, PropertyDescriptor descriptor, PropertyValueUIItem invokedItem)
 {
     BindUITypeEditor.EditValue(context);
 }
 internal void OnFixPropertyError(ITypeDescriptorContext context, PropertyDescriptor descriptor, PropertyValueUIItem invokedItem)
 {
     this.action.Invoke();
 }
        private void OnPropertyValueUIItemInvoke(ITypeDescriptorContext context, PropertyDescriptor descriptor, PropertyValueUIItem invokedItem)
        {
            // TODO: design a way for consumers to register own AdvancedBindingEditor
#if DESIGNER_DATABINDING
            LocalUIItem      localItem = (LocalUIItem)invokedItem;
            IServiceProvider sop       = null;
            Control          control   = localItem.Binding.Control;
            if (control.Site != null)
            {
                sop = (IServiceProvider)control.Site.GetService(typeof(IServiceProvider));
            }

            if (sop != null)
            {
                AdvancedBindingPropertyDescriptor.advancedBindingEditor.EditValue(context, sop, control.DataBindings);
            }
#endif
        }
 private void OnPropertyValueUIItemInvoke(ITypeDescriptorContext context, PropertyDescriptor descriptor, PropertyValueUIItem invokedItem)
 {
     Debug.Fail("propertyuivalue '" + invokedItem.ToolTip + "' invoked");
 }
Exemple #15
0
 private void PropertyValueUIItemInvoke(ITypeDescriptorContext context, PropertyDescriptor descriptor, PropertyValueUIItem invokedItem)
 {
 }
        private void UIItemClicked(ITypeDescriptorContext context, PropertyDescriptor propDesc, PropertyValueUIItem item)
        {
            StringBuilder            sb  = new StringBuilder( );
            CustomPropertyDescriptor cpd = propDesc as CustomPropertyDescriptor;

            sb.AppendLine("Prop state icon clicked for property '" + cpd.DisplayName + "'.");
            sb.AppendLine("Tool tip:");
            sb.AppendLine(item.ToolTip);
            MessageBox.Show(sb.ToString( ));
        }
Exemple #17
0
        private void OnPropertyValueUIItemInvoke(ITypeDescriptorContext context, PropertyDescriptor descriptor, PropertyValueUIItem invokedItem)
        {
            LocalUIItem      localItem = (LocalUIItem)invokedItem;
            IServiceProvider sop       = null;
            Control          control   = localItem.Binding.Control;

            if (control.Site != null)
            {
                sop = ( IServiceProvider )control.Site.GetService(typeof(IServiceProvider));
            }
            if (sop != null)
            {
                AdvancedBindingPropertyDescriptor advancedPropDesc = new AdvancedBindingPropertyDescriptor();
                AdvancedBindingObject             advancedObject   = (AdvancedBindingObject)advancedPropDesc.GetValue(control.DataBindings);
                AdvancedBindingPropertyDescriptor.advancedBindingEditor.EditValue(context, sop, advancedObject);
            }
        }
 private static void OnValueUIItemInvoke(ITypeDescriptorContext context, PropertyDescriptor propDesc, PropertyValueUIItem invokedItem)
 {
 }
//</Snippet2>

        // Invoke handler associated with the PropertyValueUIItem objects
        // provided by the marginPropertyValueUIHandler.
        private void marginInvoke(System.ComponentModel.ITypeDescriptorContext context, System.ComponentModel.PropertyDescriptor propDesc, PropertyValueUIItem item)
        {
            MessageBox.Show("Test invoke message box");
        }
 private void OnValueUIItemInvoke(ITypeDescriptorContext context, PropertyDescriptor propDesc, PropertyValueUIItem invokedItem)
 {
     // REVIEW: Any invoke action?
 }
 private static void Dummy_PropertyValueUIItemInvokeHandler(ITypeDescriptorContext context, PropertyDescriptor propDesc, PropertyValueUIItem invokedItem)
 {
 }
        private void OnPropertyValueUIItemInvoke(ITypeDescriptorContext context, PropertyDescriptor descriptor, PropertyValueUIItem invokedItem)
        {
            LocalUIItem      item    = (LocalUIItem)invokedItem;
            IServiceProvider service = null;
            Control          control = item.Binding.Control;

            if (control.Site != null)
            {
                service = (IServiceProvider)control.Site.GetService(typeof(IServiceProvider));
            }
            if (service != null)
            {
                AdvancedBindingPropertyDescriptor.advancedBindingEditor.EditValue(context, service, control.DataBindings);
            }
        }