Groups | Blog | Home
all groups > dotnet drawing api > january 2005 >

dotnet drawing api : Restricted "Paint" Program


c downey
1/22/2005 1:18:53 PM
Does anybody know how I would go about building a program where the user
could drag and drop clipart onto a form (I know this can be done) but once
they are finished, they can save the entire as an image.

E.G. The form is going to represent a backyard, and I want to build it so
that the user can drag and drop pre-determined image items into the backyard
i.e. Sandbox, Swimming Pool, Dog house, whatever, and position it where they
want. When they are finished they click save and the entire image gets
saved so I can embed it in another program.

Any userfull starting points would be greatly appreciated, and better yet,
if there is something out there that already does this I would love to have
a look.

TIA

jeff NO[at]SPAM bennet-tec.com
1/28/2005 8:23:30 PM

[quoted text, click to view]

Yes, there is something already available for you

Our MetaDraw control is designed for crating images.
With MetaDraw your project is EASY

A) You can allow user to drag and drop images
( eg: clipart from Windows Explorer
or images from another application
or even other images from picture boxes
in your applications )
into a MetaDraw window in your project

B) You can allow user to select and drag ( reposition )
graphics within the image

C) You can allow user to Resize images with the mouse

D) Entire layout can be Zoomed and/or Scrolled

E) Entire layout can be saved to a variety of standard
image formats. If you save to a vector format
you can even reload and allow user to continue to
drag independant elements around

F) Entire layout can be printed


Take a look at MetaDraw at www.Bennet-Tec.com


Download the Installation kit and try it out


Here is some sample code


A) TO ALLOW DRAGGING INTO METADRAW
FROM EITHER WINDOWS EXPLORER OR ANOTHER APPLICATION

MetaDraw1.AllowDrop =3D True ' BTIS

Private Sub MetaDraw1_DragEnter(
ByVal sender As Object,
ByVal e As System.Windows.Forms.DragEventArgs
) Handles MetaDraw1.DragEnter

' If the data is a file or a bitmap,
' Display the copy cursor.
If e.Data.GetDataPresent(DataFormats.Bitmap) _
Or e.Data.GetDataPresent(DataFormats.FileDrop) Then
e=2EEffect =3D DragDropEffects.Copy
Else
e=2EEffect =3D DragDropEffects.None
End If

End Sub

Private Sub MetaDraw1_DragDrop( _
ByVal sender As Object, _
ByVal e As System.Windows.Forms.DragEventArgs _
) Handles MetaDraw1.DragDrop

If e.Data.GetDataPresent(DataFormats.FileDrop) Then
' Assign the file names to a string array, in
' case the user has selected multiple files.
Dim files As String() =3D _
CType(e.Data.GetData(DataFormats.FileDrop), _
String())

' Merge the first image into the layout
MetaDraw1.LoadPicture(files(0),
PictureSource.PictureClip)

End If

' Handle Bitmap data.
If e.Data.GetDataPresent(DataFormats.Bitmap) Then

' Create an Image and Merge into the layout
MetaDraw1.LoadPicture( _
CType(e.Data.GetData(DataFormats.Bitmap), _
Image), PictureSource.PictureClip)

End If

End Sub


B) TO ALLOW USER TO DRAG AND RESIZE IMAGES
ALREADY IN METADRAW

MetaDraw1.EditMode =3D EditMode.Select
' EditFlags can also be set if you only
' want to allow moving or only resizing

C) SCROLLING IS AUTOMATICALLY SUPPORTED
- NO CODE NECESSARY

D) ZOOMING

Either set ZoomFactor to desired Zoom
or allow user to zoom with mouse by setting EditMode

MetaDraw1.EditMode =3D EditMode.Zoo

E) SAVE AND RELOAD

MetaDraw1.SavePicture("C:\SomePath\SomeFile.BMP", _
PictureSource.Picture, PictureType.Bitmap)
MetaDraw1.SavePicture("C:\SomePath\someFile.BMP", _
PictureSource.Picture, PictureType.Default


F) PRINT
MetaDraw1.Current =3D ObjHandle.MainContainer
MetaDraw1.ExportDC =3D -2



That's it.
Application done.

Note you can use the same Drag/Drop to drop into
an ordinary picturebox without MetaDraw but then
you won't be able to move the elements around or
resize them after they are dropped.

I hope this is helpful to you

Write back - if you have any questions.


* * Please include a copy of this message with your reply

Jeff Bennett
Jeff @ Bennet-Tec.Com

* Bennet-Tec Information Systems, Inc
* 50 Jericho Tpk, Jericho, NY 11753
* Phone 516 997 5596, Fax - 5597
* RELIABLE Components Make You Look Sharp!
* TList/Pro * ALLText HT/Pro * MetaDraw *
* Custom Software Development Services Too.
* WWW.Bennet-Tec.Com

=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D =3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
Newsgroups: microsoft.public.dotnet.framework.drawing
From: "c downey" <captain65{at}Hotmail{dot}com> -
Date: Sat, 22 Jan 2005 13:18:53 -0700
Local: Sat, Jan 22 2005 12:18 pm
Subject: Restricted "Paint" Program

Does anybody know how I would go about building a program wh=ADere the
user
could drag and drop clipart onto a form (I know this can be =ADdone) but
once
they are finished, they can save the entire as an image.


E=2EG. The form is going to represent a backyard, and I want =ADto build
it so
that the user can drag and drop pre-determined image items i=ADnto the
backyard
i=2Ee. Sandbox, Swimming Pool, Dog house, whatever, and positi=ADon it
where they
want. When they are finished they click save and the entire=AD image
gets
saved so I can embed it in another program.

Any userfull starting points would be greatly appreciated, a=ADnd better
yet,
if there is something out there that already does this I wou=ADld love
to have=20
a look.=20


TIA=20

=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D =3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
AddThis Social Bookmark Button