Creating a 'label designer' in C#
I'm trying to create a fairly simple label printer to complement the services offered on our website (processing PayPal payments using IPN and outputting a CSV
file containing customizable transaction information).
I've got the printer module mostly sorted, but I wanted users of the software to be able to adjust the positioning of pieces开发者_开发问答 of information, similar to the P-Touch software provided by Brother.
The process consists of loading in a CSV
file, with various column headers. You should then be able to move the column headers about the layout - whitespace in the middle of the form window, which then, ideally, would snap to an alignment grid.
After that the user can select print preview, and print the labels according to the different label sizes available, where the data source is the CSV file.
My primary issue is the "label designer", and I have no idea where to start. I am using Visual Express 2010 beta and C#.
Basically you need to allow the user to drag labels (objects, controls etc.) around a "form".
dragging picturebox inside winform on runtime
Then you need to be able to snap to a grid while dragging (coppercoder's solution):
Snap to grid mouse locking up
Defining an abstract "object" that encapsulates the "labels" you want your user to "drag around the form" (or panel, or whatever control you use to simulate your paper).
I guess I've done this enough to find it fairly trivial, although if it's your first time implementing something like this it can be a daunting task. Get small portions of functionality working and you'll make it through. Of course you always have stackoverflow for questions.
I would suggest that you start looking at WPF rather that winforms as the graphics in WPF are much more powerful. You would probably need to use the Canvas object, as it child elements need to be explicitly defined, which is the sort of thing you would need for a "label designer".
精彩评论