简体   繁体   English

C#Rich GUI应用程序

[英]C# Rich GUI Application

I want to create an app to declare microprocessor's pin as input/output with mouse clicks. 我想创建一个应用程序,通过单击鼠标将微处理器的引脚声明为输入/输出。 I created a mockup - http://i.stack.imgur.com/GOHQ5.png . 我创建了一个模型-http: //i.stack.imgur.com/GOHQ5.png I think it would be best to declare each pin as an separate class so I can change its state easily, but I dont know how to achieve that along with graphical representation of it. 我认为最好将每个引脚声明为一个单独的类,这样我就可以轻松更改其状态,但是我不知道如何实现它的图形表示。 Each square should be clickable and changin its color. 每个正方形都应可单击并更改其颜色。 Then foreach loop to iterate throu them and get state information of each.Should I go with WPF or Silverlight or just simple click events? 然后foreach循环遍历它们并获取每个对象的状态信息。我应该使用WPF还是Silverlight还是仅使用简单的单击事件? What is the best approach to implement that in .NET? 在.NET中实施该方法的最佳方法是什么?

If you want a website, do Silverlight. 如果您想要一个网站,请执行Silverlight。 Otherwise do WPF because it will be easier. 否则,请执行WPF,因为这样会更容易。

I'd just do an image for the center piece, unless it's going to change size, in which case you could just draw it out of lines and an ellipse. 我只是为中心部分做一个图像,除非它会改变大小,在这种情况下,您可以将其画成线条和椭圆形。 Use a Canvas in your main window, not a grid. 在主窗口而不是网格中使用画布。 Make a Pin class that handles the state/color/positioning information. 制作一个Pin类来处理状态/颜色/位置信息。 You can draw the square with a Rectangle. 您可以使用矩形绘制正方形。

Don't worry about MVVM, that's going to be more trouble than it's worth for your case. 不必担心MVVM,这将比您的情况所造成的麻烦还要大。

Silverlight or WPF doesn't make much of a difference in this case. 在这种情况下,Silverlight或WPF并没有多大区别。 Deployment of the application (web or not) might help you chose. 部署应用程序(是否通过Web)可能会帮助您选择。

Implement the state machine/processor as a class (ViewModel) and implement the UI as a View. 将状态机/处理器实现为类(ViewModel),并将UI实现为View。 That will help to keep the code clean. 这将有助于保持代码干净。 Look up MVVM Model-View-ViewModel. 查找MVVM Model-View-ViewModel。

You could do this in WPF, Silverlight or Winforms. 您可以在WPF,Silverlight或Winforms中执行此操作。

From a graphical perspective, it might be easier to reproduce your mockup in WPF or Silverlight. 从图形角度来看,在WPF或Silverlight中重现您的模型可能更容易。 Choosing between WPF and Silverlight really comes down to how you want to deploy the app (eg for SL you need a web server). 在WPF和Silverlight之间进行选择实际上取决于您要如何部署应用程序(例如,对于SL,您需要Web服务器)。

Make your choice, start writing code and then come back here with specific issues as you encounter them. 做出选择,开始编写代码,然后在遇到特定问题时返回此处。

Good Luck. 祝好运。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM