Exemplo n.º 1
0
        /// <summary>
        /// Edits the specified object's value using the editor style indicated by the <see cref="M:System.Drawing.Design.UITypeEditor.GetEditStyle"/> method.
        /// </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. 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)
        {
            FormCharacterPicker picker = null;
            var descriptor             = context.Instance as ContentTypeDescriptor;

            Debug.Assert(descriptor != null, "Descriptor is null!");

            var content = descriptor.Content as GorgonFontContent;

            Debug.Assert(content != null, "Content is null!");

            Font currentFont = null;

            try
            {
                currentFont = new Font(content.FontFamily, 16.0f, content.FontStyle, GraphicsUnit.Pixel);
                picker      = new FormCharacterPicker
                {
                    CurrentFont = currentFont,
                    Characters  = content.Characters
                };

                if (picker.ShowDialog() == DialogResult.OK)
                {
                    return(picker.Characters);
                }
            }
            finally
            {
                if (currentFont != null)
                {
                    currentFont.Dispose();
                }
                if (picker != null)
                {
                    picker.Dispose();
                }
            }
            return(base.EditValue(context, provider, value));
        }
Exemplo n.º 2
0
        /// <summary>
        /// Handles the Click event of the buttonCharacterList control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
        private void buttonCharacterList_Click(object sender, EventArgs e)
        {
            Font currentFont           = null;
            FormCharacterPicker picker = null;

            try
            {
                currentFont = new Font(FontFamilyName, 16.0f, GraphicsUnit.Pixel);

                picker = new FormCharacterPicker
                {
                    Characters  = FontCharacters,
                    CurrentFont = currentFont
                };

                if (picker.ShowDialog(this) == DialogResult.OK)
                {
                    FontCharacters = picker.Characters;
                }
            }
            catch (Exception ex)
            {
                GorgonDialogs.ErrorBox(this, ex);
            }
            finally
            {
                if (currentFont != null)
                {
                    currentFont.Dispose();
                }

                if (picker != null)
                {
                    picker.Dispose();
                }
            }
        }