how to added a GUI to my class
i have a class that runs, it does the following backups a sql, zip, encrypts, ftp to an ftp server. what i want to do is add a GUI. Need to add开发者_StackOverflow社区 a 2 buttons start and finish and progress bar for the procedure. my class is called backup.cs. i have tried creating a form but doesn't seam to work. any help would be great full
Ta Gerard
What sort of project is your backup.cs
file in? Is it in a console application?
If so then you'll need to refactor your code so that the stuff that does the work has no user interaction or user interface (and yes a console is a user interface).
Once you have this code you can create a class library to house this code (so that it can be called from where ever you need it).
Then create a new Windows Forms Application and reference your class library. You can then hook up your UI elements (buttons etc.) to the methods in the class library.
To get a progress meter working you'll need call your procedure that does the work from a background worker thread. You may need to add events as well. These events can be subscribed to by the application to update the progress meter.
I'm not sure what you mean by "backups a sql" but if you're using a Microsoft SQLServer database, you might want to look into using Integration Services - with 2005/2008, it's included and has bundled tasks that you wire together to accomplish what you describe.
Just create a new windows forms application project, add your file to a project, specify a corresponding using directive in a form code-behind file. Then, create some buttons and event handlers for them (doubleclicking on them in visual designer will do the stuff). And, that is pretty much everything. You can even create a class library project, so you can use your backup class with different projects. Please note, that this answer is really basic, so please, if you want to know more, you really need to read some books/articles.
精彩评论