Source/Design/ShapeTypeEditor.cs

(开头部分) 3KB

这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。

using System;
using System.Text;
using System.Drawing.Design;
using System.Windows.Forms.Design;
using System.ComponentModel.Design;
using System.ComponentModel;
using System.Globalization;

namespace DevComponents.DotNetBar.Design
{
    public class ShapeTypeEditor : System.Drawing.Design.UITypeEditor
    {
        /// <summary>
        /// Gets the editor style used by the EditValue method.
        /// </summary>
        /// <param name="context">An ITypeDescriptorContext that can be used to gain additional context information.</param>
        /// <returns>A UITypeEditorEditStyle value that indicates the style of editor used by EditValue. If the UITypeEditor does not support this method, then GetEditStyle will return None</returns>
        public override UITypeEditorEditStyle GetEditStyle(ITypeDescriptorContext context)
        {
            return UITypeEditorEditStyle.Modal;
        }

        public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value)
        {
            if ((context != null) && (provider != null))
            {
                IUIService service = (IUIService)provider.GetService(typeof(IUIService));
                IHelpService helpService = (IHelpService)provider.GetService(typeof(IHelpService));
                IShapeDescriptor shape = EditShape(service, context.Instance, helpService, value);
                return shape;
            }
            return value;
        }

        internal static IShapeDescriptor EditShape(IUIService uiService, object instance, IHelpService helpService, object currentValue)
        {
#if FRAMEWORK20
            ShapeEditorForm editor = new ShapeEditorForm();
            editor.Value = currentValue as IShapeDescriptor;
            if (uiService != null)
                uiService.ShowDialog(editor);
            else
                editor.ShowDialog();

            if (editor.DialogResult == System.Windows.Forms.DialogResult.OK)
            {
                currentValue = editor.Value;
            }

            editor.Dispose();

#endif
			return currentValue as IShapeDescriptor;
        }
    }

    public class ShapeStringConverter : TypeConverter
    {
        public override bool CanConvertTo(ITypeDescriptorContext context, Type destinationType)
        {
后面还有 28 行代码,解锁后查看完整代码

24 小时内免费解锁 3 个项目,之后 1 算力/个。 规则说明

AI 解读 AI

登录后可用,每次 10 算力,解读结果公开显示在下面。

还没有人解读过这个文件。