简体   繁体   English

使业务层与演示进行通信

[英]Getting a business layer to communicate with presentation

So I'm working on a small TicTacToe application over the holidays to improve some of my skills. 因此,我会在假期期间开发一个小型TicTacToe应用程序,以提高我的一些技能。 I have a two layered approach right now where there is a project for the presnetation and a project for the business end of the game. 我现在有一个两层的方法,其中有一个用于假装的项目和一个用于游戏业务目的的项目。

My question is what is the best way for the State.cs class to tell the WinUI that we have had nine turns and there is no winner or to tell that yes there is a winner after each move? 我的问题是,State.cs类告诉WinUI我们已经进行了9轮并且没有赢家,或者告诉是的,每一步之后都有赢家的最佳方法是什么?

The easiest thing I can think of would be to raise a custom event and have the WinUI listen for it? 我能想到的最简单的事情是引发一个自定义事件并让WinUI监听它?

My source is on Google Code. 我的来源在Google Code上。 I've just checked it in so you can take a quick browse. 我刚刚检查了一下,以便您快速浏览。

Classes of interest for this question would probably be state.cs and Form1.cs. 此问题感兴趣的类可能是state.cs和Form1.cs。

If you have any other suggestions for my code/design I'm all ears!! 如果您对我的代码/设计还有其他建议,我会很高兴!

CODE IS HERE 代码在这里

Cheers, 干杯,

Mike 麦克风

You are trying to remove the UI logic from the Game logic , Yes? 您正在尝试从游戏逻辑中删除UI 逻辑 ,是吗?

Typically this would either be bound to the game iterface, or you could try using callbacks. 通常,这要么绑定到游戏Iterface,要么尝试使用回调。

I would not recomend this for a single player game. 对于单人游戏,我不建议这样做。 If you wish to create an interactive gaming interface, that would make the feedbacks a little more complex, but you are thinking in th correct direction. 如果您希望创建一个交互式游戏界面,这会使反馈变得更加复杂,但您的想法是正确的。 Let the engine indicate when the UI needs to update events . 让引擎指示UI需要何时更新事件

I would also recomend having a look at some of the old dogs ( As the old saying goes, if you think you are the first to ask the QUESTION, think again ) 我也建议您看一些老狗( 俗话说,如果您认为自己是第一个提出问题的人,请再考虑一遍

c# tic tac toe game C#井字游戏

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

相关问题 业务层或表示层 - business layer or presentation layer 演示文稿,业务和数据层 - Presentation, Business and Data Layer Using business object in presentation layer - Using business object in presentation layer 业务 Object 正在复制表示层的一些属性 - Business Object is duplicating some properties for Presentation Layer 将字符串集放入表示层 - Getting String Sets into Presentation Layer 将依赖于 web 引用的业务逻辑从表示层中分离出来 - Separating business logic dependent on web references out of presentation layer 如何将数据从表示层传递到业​​务逻辑层? (ASP.NET MVC 5) - How do I pass data from presentation layer to business logic layer? (ASP.NET MVC 5) 有哪些方法可以显示源自业务层的验证消息以出现在表示层的上下文区域中? - What approaches are there to show validation messages that originate in the Business Layer to appear in a contextual area in the Presentation Layer? 是否应在演示层或业务层完成将用户特定的“结束日期”转换为DateTime? - Should translation of a user specific 'end date' to a DateTime be done at the Presentation Layer or Business Layer? 使用LINQ-to-Entities将结果从业务层返回到表示层的最佳方法 - Best way to return result from business layer to presentation layer when using LINQ-to-Entities
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM