The second pair programming design --UI By Jamie

Original: http://www.cnblogs.com/Tjamie/archive/2013/01/09/2852949.html

 

10,061,189 Tan Zhuanqi

Even 10,061,160 Zhao Peng

 

1, Design

This is the initial design, which in addition Button button, the Label "state floor", "current time" is added other than the manual

All of the following information are added code

It will change with the number of floors and the number of elevator change

For example three elevators, floor 10 will be:

Display rules, the status of the left, which layer is pressed up / down will appear red, N lifts the right side, the word which layer is a layer which is

DETAILED run shot seen below

 

2, the source schema

In the code works on the basis of the original, in the form of two new world

 

3, the number of lines of code

The number of rows does not count the number of rows in the original Program, not counting the two scheduler

Taking into account the need to precondition transmission data, the scheduler does not change under

And have increased passenger elevator for some code, the total number of lines of code (not the comments and blank lines) about 650 lines

 

4, run-time screenshots

 

5, Design experience

My experience from a challenge with three questions Tell me

A challenge

Design UI interface display, from the need to find the code that works from the original engineering data needed, and passed to the UI interface display

This requires us to deeply understand the code of the original project, taking into account the first pair programming we have to understand the basic principles of all project code

The data is still relatively easy to find

But to emphasize the point, can not read data from the scheduler

Otherwise, you can not change a scheduler UI shows

At first I read some data from the scheduler, and later have found a way to read from other projects

Three questions

Resolved a problem

With the original can not run the console display UI, the original program runs quickly, directly show UI if form is definitely "PDB", and not see anything

Sleep Here is invalid, the entire program Sleep is stopped, refreshed UI also be stopped

A problem-solving approaches

Like unified display UI (Finally, is this the way) and then run the program, but also show a while (true) loop, it would be stuck

Therefore, to open a new thread to do, and in part because the definition of UI label is in another thread

会报修改其它线程定义元素的一个错,解决方法之一是在线程开始前,加一句

  Control.CheckForIllegalCrossThreadCalls = false;

但这不是最好的解决方法,这个是告诉程序你不用管这个,我保证肯定没事

一个没有解决的问题

由于上述设计中,必须每次把所有界面上的元素内容清空,再根据当前状态填写新的状态内容

所以肯定有闪烁感

正确的解决办法就是像我们做游戏时一样一帧一帧的做

或者不每次就全刷新,只刷部分改动的数据,这样闪烁感会小一些

但实现有些复杂,加上目前虽有闪烁感,但还可以接受,故不再更改

转载于:https://www.cnblogs.com/buaashine/archive/2013/01/09/2852954.html

Guess you like

Origin blog.csdn.net/weixin_33881140/article/details/94548472