Ejemplo n.º 1
0
        public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value)
        {
            CustomShape           shape  = value as CustomShape;
            CustomShapeEditorForm editor = new CustomShapeEditorForm();

            if (shape != null)
            {
                editor.EditorControl.Dimension = shape.Dimension;
                editor.EditorControl.Points.AddRange(shape.Points);
            }

            if (editor.ShowDialog() == DialogResult.OK)
            {
                shape = new CustomShape();
                shape.Points.AddRange(editor.EditorControl.Points);
                shape.Dimension = editor.EditorControl.Dimension;

                return(shape);
            }

            return(value);
        }
Ejemplo n.º 2
0
        public override object EditValue(
            ITypeDescriptorContext context,
            System.IServiceProvider provider,
            object value)
        {
            CustomShape           customShape1          = value as CustomShape;
            CustomShapeEditorForm customShapeEditorForm = new CustomShapeEditorForm();

            if (customShape1 != null)
            {
                customShapeEditorForm.EditorControl.Dimension = customShape1.Dimension;
                customShapeEditorForm.EditorControl.Points.AddRange((IEnumerable <ShapePoint>)customShape1.Points);
            }
            if (customShapeEditorForm.ShowDialog() != DialogResult.OK)
            {
                return(value);
            }
            CustomShape customShape2 = new CustomShape();

            customShape2.Points.AddRange((IEnumerable <ShapePoint>)customShapeEditorForm.EditorControl.Points);
            customShape2.Dimension = customShapeEditorForm.EditorControl.Dimension;
            return((object)customShape2);
        }