コード例 #1
0
        public CustomShape GetShape()
        {
            CustomShape customShape = new CustomShape();

            customShape.Dimension = this.Dimension;
            foreach (ShapePoint point in this.Points)
            {
                customShape.Points.Add(point);
            }
            return(customShape);
        }
コード例 #2
0
        public override void PaintValue(PaintValueEventArgs e)
        {
            CustomShape customShape = e.Value as CustomShape;

            if (customShape == null)
            {
                return;
            }
            using (GraphicsPath path = customShape.CreatePath(e.Bounds))
                e.Graphics.DrawPath(Pens.Black, path);
        }
コード例 #3
0
        public override void PaintValue(PaintValueEventArgs e)
        {
            //base.PaintValue(e);
            CustomShape shape = e.Value as CustomShape;

            if (shape != null)
            {
                using (GraphicsPath path = shape.CreatePath(e.Bounds))
                    e.Graphics.DrawPath(Pens.Black, path);
            }
        }
コード例 #4
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);
        }
コード例 #5
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);
        }