控制器/静态状态类的WinForms应用程序 - 在哪里放? [英] Controller/Static State Class in WinForms Application - Where to put?

查看:135
本文介绍了控制器/静态状态类的WinForms应用程序 - 在哪里放?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在写一个WinForms应用程序,并希望有一个MVC式设计。其实它更MVP或MVVM。

I'm writing a WinForms application and want to have an "MVC-Type" Design. Actually it's more MVP or MVVM,.

该计划是有一个中央控制器,做所有的实际工作,使窗体只呈现出来的ViewModels和处理用户输入,但一切真正做什么事情的经过控制器。

The plan is to have a Central Controller which does all the actual work, so that the Forms just render out ViewModels and handle user input, but everything that actually does something goes through the Controller.

我不知道这是否是一个好主意,并在把控制器?目前的想法是,这是在Program.cs中(在一些依赖像IMyDatabaseRepository发送)初始化静态类,以便它只是停留一个控制器,它代表用户界面和模型之间的工作。

I just wonder if this is a good idea, and where to put the Controller? The current idea is to have a static class which is initialized in Program.cs (Sending in some Dependencies like IMyDatabaseRepository) so that it just stays a controller that delegates work between User Interface and Model.

您可能已经猜到,我来自一个网络的背景,并与WinForms的建筑没有什么经验。 previously,我的MainForm是Controller类,拿着所有的状态变量,这显然意味着,我的MainForm就是我的应用程序,而不是用户界面只是一部分。

As you might guess, I come from a Web Background and have little experience with WinForms architecture. Previously, my MainForm was the Controller class, holding all the State Variables, which obviously means that my MainForm is my application rather than just a part of the User Interface.

推荐答案

有趣的问题迈克尔!

下面是一些链接:

  • Sacha Barber's WPF MVVM VS Project Template
  • Sacha's Article Series on CodeProject.com
  • Nice article on this Wordpress blog

希望这些帮助你正确地组织您的项目!

Hope these help you to structure your project properly!

这篇关于控制器/静态状态类的WinForms应用程序 - 在哪里放?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆