Ejemplo n.º 1
0
        public CustomShape EditShape(CustomShape shape)
        {
            if (shape == null)
            {
                return(null);
            }

            CustomShape newShape = shape.Clone();

            shapeEditorControl1.Reset();

            if (!newShape.DoFixDimension())
            {
                newShape.CreateRectangleShape(0, 0, 200, 120);
            }

            shapeEditorControl1.Shape     = newShape.Shape;
            shapeEditorControl1.Dimension = newShape.Dimension;

            if ((result = this.ShowDialog()) == DialogResult.OK)
            {
                newShape.Dimension = shapeEditorControl1.Dimension;
                return(newShape);
            }
            else
            {
                return(shape);
            }
        }
Ejemplo n.º 2
0
        private CustomShape CreateNewShape(IDesignerHost designerHost)
        {
            CustomShape customShape = designerHost == null ? new CustomShape() : (CustomShape)designerHost.CreateComponent(typeof(CustomShape));

            customShape.CreateRectangleShape(20f, 20f, 200f, 100f);
            return(customShape);
        }
Ejemplo n.º 3
0
        public CustomShape GetShape()
        {
            CustomShape newShape = new CustomShape();

            newShape.DeserializeProperties(this.SerializeProperties());

            return(newShape);
        }
Ejemplo n.º 4
0
        public CustomShape Clone()
        {
            CustomShape customShape = new CustomShape();

            customShape.shape.CopyFrom(this.shape);
            customShape.dimension = new Rectangle(this.dimension.Location, this.dimension.Size);
            return(customShape);
        }
Ejemplo n.º 5
0
        public CustomShape Clone()
        {
            CustomShape cs = new CustomShape();

            cs.shape.CopyFrom(shape);
            cs.dimension = new Rectangle(dimension.Location, dimension.Size);

            return(cs);
        }
Ejemplo n.º 6
0
        public override object EditValue(
            ITypeDescriptorContext context,
            IServiceProvider provider,
            object value)
        {
            CustomShape customShape = value as CustomShape;

            return((object)new CustomShape());
        }
Ejemplo n.º 7
0
        public void CopyFrom(CustomShape cs)
        {
            if (cs == null || cs.Dimension == null)
            {
                return;
            }

            shape.CopyFrom(cs.shape);
            dimension = new Rectangle(cs.Dimension.Location, cs.Dimension.Size);
        }
Ejemplo n.º 8
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);
            }
        }
Ejemplo n.º 9
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);
        }
Ejemplo n.º 10
0
        private CustomShape EditPoints(ITypeDescriptorContext context, CustomShape shape)
        {
            CustomShapeEditorForm editor = new CustomShapeEditorForm();

            //editor.EditorControl.Dimension = shape.Dimension;

            //foreach (ShapePoint point in shape.Points)
            //{
            //    editor.EditorControl.Points.Add(new ShapePoint(point));
            //}

            shape = editor.EditShape(shape);

            //if (editor.ShowDialog() == DialogResult.OK)
            //{
            //IDesignerHost host = context.Container as IDesignerHost;
            //if (host != null)
            //{
            //    foreach (ShapePoint point in shape.Points)
            //    {
            //        host.DestroyComponent(point);
            //    }
            //}

            //shape.Points.Clear();

            //    foreach (ShapePoint point in editor.EditorControl.Points)
            //    {
            //        ShapePoint p = null;

            //        if (host != null)
            //        {
            //            p = (ShapePoint)host.CreateComponent(typeof(ShapePoint));
            //        }
            //        else
            //        {
            //            p = new ShapePoint();
            //        }

            //        p.X = point.X;
            //        p.Y = point.Y;
            //        p.ControlPoint1 = point.ControlPoint1;
            //        p.ControlPoint2 = point.ControlPoint2;
            //        p.Bezier = point.Bezier;
            //        p.Locked = point.Locked;
            //        shape.Points.Add(p);
            //    }

            //    shape.Dimension = editor.EditorControl.Dimension;
            //}

            return(shape);
        }
Ejemplo n.º 11
0
        private void radButton3_Click(object sender, System.EventArgs e)
        {
            radioButton2.Checked = true;

            Telerik.WinControls.CustomShapeEditorForm form = new Telerik.WinControls.CustomShapeEditorForm();

            if (shape == null)
            {
                shape = new Telerik.WinControls.CustomShape(new Rectangle(0, 0, 320, 180));
            }

            shape = form.EditShape(shape);

            if (form.Result == DialogResult.OK)
            {
                radButton1.ButtonElement.Shape = shape;
            }
        }
Ejemplo n.º 12
0
        public CustomShape CreateShape()
        {
            this.shapeEditorControl1.Reset();
            CustomShape customShape = new CustomShape();

            if (!customShape.DoFixDimension())
            {
                customShape.CreateRectangleShape(0.0f, 0.0f, 200f, 120f);
            }
            this.shapeEditorControl1.Shape     = customShape.Shape;
            this.shapeEditorControl1.Dimension = customShape.Dimension;
            if ((this.result = this.ShowDialog()) != DialogResult.OK)
            {
                return((CustomShape)null);
            }
            customShape.Dimension = this.shapeEditorControl1.Dimension;
            return(customShape);
        }
Ejemplo n.º 13
0
        private void radButton2_Click(object sender, EventArgs e)
        {
            ElementShape shape = null;

            if (radioButton1.Checked)
            {
                RadListDataItem item = radComboBox1.SelectedItem;
                shape = (ElementShape)Activator.CreateInstance((Type)item.Value);
            }
            else
            {
                shape = this.shape;
            }

            MyShapedForm form = new MyShapedForm(shape);

            form.BorderWidth = 2;
            form.ShowDialog();
        }
Ejemplo n.º 14
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.º 15
0
        private CustomShape CreateNewShape(ITypeDescriptorContext context)
        {
            CustomShape shape = null;

            if (context.Container != null)
            {
                shape = (CustomShape)(context.Container as IDesignerHost).CreateComponent(typeof(CustomShape));
            }
            else
            {
                shape = new CustomShape();
            }

            shape.CreateRectangleShape(20, 20, 200, 100);

            //shape.Dimension = new Rectangle(20, 20, 200, 100);

            //shape.Points.Add(new ShapePoint(20, 20));
            //shape.Points.Add(new ShapePoint(220, 20));
            //shape.Points.Add(new ShapePoint(220, 120));
            //shape.Points.Add(new ShapePoint(20, 120));

            return(shape);
        }
Ejemplo n.º 16
0
        public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value)
        {
            shapes        = new ArrayList();
            editorService = (IWindowsFormsEditorService)provider.GetService(typeof(IWindowsFormsEditorService));
            ListBox listBox = CreateListBox(context, value);

            indexChanged = false;

            editorService.DropDownControl(listBox);

            if (!indexChanged)
            {
                return(value);
            }

            if (listBox.SelectedIndex == 0)
            {
                return(null);
            }

            if (listBox.SelectedIndex - 1 > shapes.Count - 1)
            {
                bool newShape = true;

                if (context.Container == null && value is CustomShape)
                {
                    newShape = false;
                }

                if (listBox.SelectedIndex - 1 == shapes.Count && newShape)
                {
                    CustomShape shape = CreateNewShape(context);
                    return(EditPoints(context, shape));
                }
                else
                {
                    return(EditPoints(context, (CustomShape)value));
                }
            }

            object result = shapes[listBox.SelectedIndex - 1];

            if (result is Type)
            {
                if (context.Container != null)
                {
                    foreach (IComponent component in context.Container.Components)
                    {
                        if (component.GetType() == (Type)result)
                        {
                            result = component;
                            break;
                        }
                    }
                    if (result is Type)
                    {
                        IDesignerHost host = (IDesignerHost)context.Container;
                        result = host.CreateComponent((Type)result);
                    }
                }
                else
                {
                    result = Activator.CreateInstance((Type)result);
                }
            }

            shapes.Clear();

            return(result);
        }
Ejemplo n.º 17
0
        public override object EditValue(
            ITypeDescriptorContext context,
            System.IServiceProvider provider,
            object value)
        {
            this.shapes = new ArrayList();
            IDesignerHost designerHost = context.Container as IDesignerHost ?? provider.GetService(typeof(IDesignerHost)) as IDesignerHost;

            this.editorService = (IWindowsFormsEditorService)provider.GetService(typeof(IWindowsFormsEditorService));
            System.Windows.Forms.ListBox listBox = this.CreateListBox(designerHost, value);
            this.indexChanged = false;
            this.editorService.DropDownControl((Control)listBox);
            if (!this.indexChanged)
            {
                return(value);
            }
            if (listBox.SelectedIndex == 0)
            {
                return((object)null);
            }
            if (listBox.SelectedIndex - 1 > this.shapes.Count - 1)
            {
                bool flag = true;
                if (designerHost == null && value is CustomShape)
                {
                    flag = false;
                }
                if (listBox.SelectedIndex - 1 != this.shapes.Count || !flag)
                {
                    return((object)this.EditPoints((CustomShape)value));
                }
                CustomShape newShape    = this.CreateNewShape(designerHost);
                CustomShape customShape = this.EditPoints(newShape);
                newShape.AsString = customShape.AsString;
                return((object)newShape);
            }
            object obj = this.shapes[listBox.SelectedIndex - 1];

            if ((object)(obj as System.Type) != null)
            {
                if (designerHost != null)
                {
                    foreach (IComponent component in (ReadOnlyCollectionBase)designerHost.Container.Components)
                    {
                        if ((object)component.GetType() == (object)(System.Type)obj)
                        {
                            obj = (object)component;
                            break;
                        }
                    }
                    if ((object)(obj as System.Type) != null)
                    {
                        obj = (object)designerHost.CreateComponent((System.Type)obj);
                    }
                }
                else
                {
                    obj = Activator.CreateInstance((System.Type)obj);
                }
            }
            this.shapes.Clear();
            return(obj);
        }
Ejemplo n.º 18
0
 private CustomShape EditPoints(CustomShape shape)
 {
     return(new CustomShapeEditorForm().EditShape(shape));
 }
Ejemplo n.º 19
0
 public CustomShape GetShape()
 {
     CustomShape customShape = new CustomShape();
       customShape.DeserializeProperties(this.SerializeProperties());
       return customShape;
 }