Beispiel #1
0
        /// <summary>
        /// Edits the specified object's value using the editor style
        /// indicated by <see cref="M:System.Drawing.Design.UITypeEditor.GetEditStyle"/>.
        /// </summary>
        /// <param name="context">An <see cref="T:System.ComponentModel.ITypeDescriptorContext"/> that can be used to gain additional context information.</param>
        /// <param name="provider">An <see cref="T:System.IServiceProvider"/> that this editor can use to obtain services.</param>
        /// <param name="value">The object to edit.</param>
        /// <returns>The new value of the object.</returns>
        /// <exception cref="ArgumentNullException">
        /// <para><paramref name="provider"/> is <see langword="null"/>.</para>
        /// -or-
        /// <para><paramref name="value"/> is <see langword="null"/>.</para>
        /// </exception>
        public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value)
        {
            if (provider == null)
            {
                throw new ArgumentNullException("provider");
            }

            if (value == null)
            {
                throw new ArgumentNullException("value");
            }

            if (value.GetType() != typeof(int))
            {
                return(value);
            }

            IWindowsFormsEditorService editorService = (IWindowsFormsEditorService)provider.GetService(typeof(IWindowsFormsEditorService));

            if (editorService != null)
            {
                NuGenTransparencyEditorUI transparencyEditor = new NuGenTransparencyEditorUI((int)value);
                editorService.DropDownControl(transparencyEditor);

                return(transparencyEditor.GetValue);
            }

            return(value);
        }
		/// <summary>
		/// Edits the specified object's value using the editor style
		/// indicated by <see cref="M:System.Drawing.Design.UITypeEditor.GetEditStyle"/>.
		/// </summary>
		/// <param name="context">An <see cref="T:System.ComponentModel.ITypeDescriptorContext"/> that can be used to gain additional context information.</param>
		/// <param name="provider">An <see cref="T:System.IServiceProvider"/> that this editor can use to obtain services.</param>
		/// <param name="value">The object to edit.</param>
		/// <returns>The new value of the object.</returns>
		/// <exception cref="ArgumentNullException">
		/// <para><paramref name="provider"/> is <see langword="null"/>.</para>
		/// -or-
		/// <para><paramref name="value"/> is <see langword="null"/>.</para>
		/// </exception>
		public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value)
		{
			if (provider == null)
			{
				throw new ArgumentNullException("provider");
			}

			if (value == null)
			{
				throw new ArgumentNullException("value");
			}

			if (value.GetType() != typeof(int)) 
			{
				return value;
			}

			IWindowsFormsEditorService editorService = (IWindowsFormsEditorService)provider.GetService(typeof(IWindowsFormsEditorService));
			
			if (editorService != null) 
			{
				NuGenTransparencyEditorUI transparencyEditor = new NuGenTransparencyEditorUI((int)value);
				editorService.DropDownControl(transparencyEditor);

				return transparencyEditor.GetValue;
			}

			return value;
		}