示例#1
0
        /// <summary>
        /// Takes care of displaying the modal window to edit the current value.
        /// For this property it will use an  instance of DataHelperBindingInfo
        /// to exchange the information.
        /// </summary>
        /// <param name="context">ITypeDescriptorContext.</param>
        /// <param name="provider">IServiceProvider.</param>
        /// <param name="value">Object.</param>
        /// <returns></returns>
        public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value)
        {
            DataHelperDesignerModalView selectionControl = null;

            if (provider != null)
            {
                editorService =
                    provider.GetService(
                        typeof(IWindowsFormsEditorService))
                    as IWindowsFormsEditorService;
            }

            if (editorService != null)
            {
                if (value != null)
                {
                    selectionControl = new DataHelperDesignerModalView((DataHelperBindingInfo)value, context);
                }
                else
                {
                    selectionControl = new DataHelperDesignerModalView(DataHelper.getDefaultDataHelperBindingInfo((Control)context.Instance), context);
                }

                if (editorService.ShowDialog(selectionControl) == DialogResult.OK)
                {
                    value = selectionControl.DataHelperBindingInfo;
                }
            }

            return(value);
        }
        /// <summary>
        /// Takes care of displaying the modal window to edit the current value. 
        /// For this property it will use an  instance of DataHelperBindingInfo 
        /// to exchange the information.
        /// </summary>
        /// <param name="context">ITypeDescriptorContext.</param>
        /// <param name="provider">IServiceProvider.</param>
        /// <param name="value">Object.</param>
        /// <returns></returns>
        public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value)
        {
            DataHelperDesignerModalView selectionControl = null;
            if (provider != null)
            {
                editorService =
                    provider.GetService(
                    typeof(IWindowsFormsEditorService))
                    as IWindowsFormsEditorService;
            }

            if (editorService != null)
            {
                if (value != null)
                    selectionControl = new DataHelperDesignerModalView((DataHelperBindingInfo)value, context);
                else
                    selectionControl = new DataHelperDesignerModalView(DataHelper.getDefaultDataHelperBindingInfo((Control)context.Instance), context);

                if (editorService.ShowDialog(selectionControl) == DialogResult.OK)
                    value = selectionControl.DataHelperBindingInfo;
            }

            return value;
        }