Exemplo n.º 1
0
            protected virtual NDrawingDataObject AdaptMyCustomFormat(NMyDataObject myDataObject)
            {
                if (myDataObject == null)
                {
                    throw new ArgumentNullException("myDataObject");
                }

                // create the respective shape with the specified size
                NShape shape;

                if (myDataObject.shapeType == "Rectangle")
                {
                    shape = new NRectangleShape(new NPointF(0, 0), myDataObject.shapeSize);
                }
                else if (myDataObject.shapeType == "Ellipse")
                {
                    shape = new NEllipseShape(new NPointF(0, 0), myDataObject.shapeSize);
                }
                else
                {
                    return(null);
                }

                // create a drawing data object, which encapsulates the shape
                NDrawingDataObject ddo = new NDrawingDataObject(null, new INDiagramElement[] { shape });

                return(ddo);
            }
Exemplo n.º 2
0
            public override object Adapt(IDataObject dataObject)
            {
                if (CanAdapt(dataObject) == false)
                {
                    return(null);
                }

                // adapt bitmap
                if (dataObject.GetDataPresent(DataFormats.Bitmap))
                {
                    Bitmap bmp = (dataObject.GetData(DataFormats.Bitmap) as Bitmap);
                    if (bmp == null)
                    {
                        return(null);
                    }

                    return(AdaptBitmap(bmp));
                }

                // adapt my custom format
                if (dataObject.GetDataPresent("My Custom Format"))
                {
                    NMyDataObject myDataObject = (dataObject.GetData("My Custom Format") as NMyDataObject);
                    if (myDataObject == null)
                    {
                        return(null);
                    }

                    return(AdaptMyCustomFormat(myDataObject));
                }

                return(null);
            }