Ejemplo n.º 1
0
 public void RefreshForm()
 {
     if (Form == null)
     {
         Form = new ColorEditorForm();
     }
 }
		// ------------------------------------------------------------------

		/// <summary>
		/// Edits the specified object's value using the editor style indicated 
		/// by the <see cref="M:System.Drawing.Design.UITypeEditor.GetEditStyle"></see> 
		/// method.
		/// </summary>
		/// <param name="context">An <see cref="T:System.ComponentModel.ITypeDescriptorContext"></see> 
		/// that can be used to gain additional context information.</param>
		/// <param name="provider">An <see cref="T:System.IServiceProvider"></see> 
		/// that this editor can use to obtain services.</param>
		/// <param name="value">The object to edit.</param>
		/// <returns>
		/// The new value of the object. If the value of the object has not 
		/// changed, this should return the same object it was passed.
		/// </returns>
		public override object EditValue(
			ITypeDescriptorContext context,
			IServiceProvider provider,
			object value )
		{
			Color color;

			if ( value == null )
			{
				color = Color.Empty;
			}else 
			{
				color = (Color)value;
			}

			using ( var form = new ColorEditorForm() )
			{
				form.SelectedColor = color;

				if ( form.ShowDialog() == DialogResult.OK )
				{
						value = form.SelectedColor;
				}
			}

			return value;
		}
Ejemplo n.º 3
0
        // ------------------------------------------------------------------

        /// <summary>
        /// Edits the specified object's value using the editor style indicated
        /// by the <see cref="M:System.Drawing.Design.UITypeEditor.GetEditStyle"></see>
        /// method.
        /// </summary>
        /// <param name="context">An <see cref="T:System.ComponentModel.ITypeDescriptorContext"></see>
        /// that can be used to gain additional context information.</param>
        /// <param name="provider">An <see cref="T:System.IServiceProvider"></see>
        /// that this editor can use to obtain services.</param>
        /// <param name="value">The object to edit.</param>
        /// <returns>
        /// The new value of the object. If the value of the object has not
        /// changed, this should return the same object it was passed.
        /// </returns>
        public override object EditValue(
            ITypeDescriptorContext context,
            IServiceProvider provider,
            object value)
        {
            Color color;

            if (value == null)
            {
                color = Color.Empty;
            }
            else
            {
                color = (Color)value;
            }

            using (var form = new ColorEditorForm())
            {
                form.SelectedColor = color;

                if (form.ShowDialog() == DialogResult.OK)
                {
                    value = form.SelectedColor;
                }
            }

            return(value);
        }
Ejemplo n.º 4
0
        public MainForm()
        {
            InitializeComponent();

#if DEBUG
            ColorEditorForm.Test();
#endif
        }
Ejemplo n.º 5
0
        private void launchColorEditorButton_Click(object sender, EventArgs e)
        {
            using (var form = new ColorEditorForm())
            {
                // Must set the extender _first_, since it helps in lookup
                // of the selected color.
                form.ExternalColorEditorInformationProvider = new ExternalTestProvider();
                form.SelectedColor = colorPanel.BackColor;

                if (form.ShowDialog(this) == DialogResult.OK)
                {
                    colorPanel.BackColor = form.SelectedColor;
                }
            }
        }