如何向我的班级添加 GUI

发布于 2024-08-27 17:09:53 字数 160 浏览 4 评论 0原文

我有一个正在运行的类,它执行以下操作,将 sql、zip、加密、ftp 备份到 ftp 服务器。我想做的是添加一个 GUI。 需要为该过程添加 2 个按钮开始和结束以及进度条。 我的课程名为 backup.cs。我尝试过创建一个表单,但似乎不起作用。 任何帮助都会非常完整

Ta 杰拉德

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 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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

世态炎凉 2024-09-03 17:09:53

您的 backup.cs 文件属于什么类型的项目?它在控制台应用程序中吗?

如果是这样,那么您需要重构您的代码,以便完成工作的东西没有用户交互或用户界面(是的,控制台是一个用户界面)。

获得此代码后,您可以创建一个类库来容纳此代码(以便可以从需要的地方调用它)。

然后创建一个新的 Windows 窗体应用程序并引用您的类库。然后,您可以将 UI 元素(按钮等)连接到类库中的方法。

要使进度表正常工作,您需要调用从后台工作线程执行工作的过程。您可能还需要添加事件。应用程序可以订阅这些事件来更新进度表。

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.

忆梦 2024-09-03 17:09:53

我不确定“备份 sql”是什么意思,但如果您使用的是 Microsoft SQLServer 数据库,您可能需要考虑使用 Integration Services - 在 2005/2008 中,它已包含在内并具有您连接在一起的捆绑任务完成你所描述的事情。

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.

绝影如岚 2024-09-03 17:09:53

只需创建一个新的 Windows 窗体应用程序项目,将文件添加到项目中,在窗体代码隐藏文件中指定相应的 using 指令。然后,为它们创建一些按钮和事件处理程序(在可视设计器中双击它们即可完成这些操作)。而且,这几乎就是一切。您甚至可以创建一个类库项目,这样您就可以在不同的项目中使用您的备份类。请注意,这个答案非常基本,所以如果您想了解更多信息,您确实需要阅读一些书籍/文章。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文