等待用户输入 [英] waiting for user input

查看:117
本文介绍了等待用户输入的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在做一个小型的Windows Forms项目。我有一种情况,我有一些用户控件。

假设控件是:

UC_a,UC_b,UC_d,UC_e ....等



现在,我的主应用程序窗口中有一个splitContainer和一些radiobuttons。

我想将用户控件加载到spliContainer的panel1中。 />


我不想一次性添加它们。相反,它是这样的:

首先,用户必须选择一个单选按钮。

根据这个选择,用户控件加载。

假设用户选择了radiobutton1。

现在我想要的是先加载UC_a。

假设UC_a包含一个组合框和一个复选框。用户现在必须从组合框中选择一个值,然后选中复选框。只有在用户完成这两个操作后,主应用程序才必须加载下一个用户控件。假设UC_b是必须添加到splitcontainer.panel1的下一个用户控件。

UC_b可能需要用户在UC_a中选择的值,因此,如果UC_b在用户之前加载选择UC_a中的值,它会抛出错误。

现在,其中一些控件可能会加载多次,即加载UC_a后,用户已提供必要的输入,5或可以创建10个单独的UC_b实例并添加到面板中。

说,每个UC_b都有一个复选框,用户需要通过选中它们各自的复选框来选择这些UC_b控件中的任何一个。一旦选择了3个UC_b,加载UC_c等等......



我的问题是:如何使主应用等待这些用户的用户输入继续之前的控件?

I am doing a small ''Windows Forms'' project. I have a situation where I have a few user controls.
Suppose the controls are:
UC_a, UC_b, UC_d, UC_e.... etc.

Now, I have a splitContainer and some radiobuttons in my main app window.
I want to load the user controls into the panel1 of spliContainer.

I do not want to add them all at once. Rather, it goes like this:
First, the user has to select one of the radio buttons.
Depending on this selection, the user controls get loaded.
Suppose the user has selected radiobutton1.
Now what i want is to first load UC_a.
Suppose UC_a contains a combobox and a checkbox. The user now has to select one value from the combobox and then check the checkbox. Only once the user has done these 2 actions must the main app load the next user control. Suppose UC_b is the next user control that has to be added to the splitcontainer.panel1.
UC_b may need the value that was selected by the user in UC_a and so, if UC_b is loaded prior to the user selecting the values in UC_a, it will throw error.
Now, some of these controls maybe loaded multiple times, ie, say, after UC_a is loaded, and the user has provided the necessary inputs, 5 or 10 separate instances of UC_b maybe created and added to the panel.
say, each UC_b has a checkbox and The user needs to select any 3 of these UC_b controls by checking their respective checkboxes. Once 3 UC_b has been selected, load UC_c and so on...

My question is: How do I make the main app wait for the user input in these user controls before continuing?

推荐答案

你可以使用有限状态机 - 浏览状态设计模式

并看看这里具有子状态的有限状态机 [ ^ ]
You could use a finite state machine - have a look around for the State Design Pattern
and have a look here Finite State Machine with Sub-state[^]


这篇关于等待用户输入的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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