模拟红绿灯(Simulation of traffic lights)

来自中国的朋友,欢迎您在本版面使用中文讨论问题。请注意,如果您想得到不懂中文的人的帮助,请同时提供英文译文。
Help and discussions in Chinese.
Post Reply
liqi98136
Posts: 53
Joined: Sun Jan 17, 2010 11:37 pm

模拟红绿灯(Simulation of traffic lights)

Post by liqi98136 »

Code: Select all

import "ecere"

class Form1 : Window
{
   text = "红绿灯traffic lights";
   background = activeBorder;
   borderStyle = sizable;
   hasMaximize = true;
   hasMinimize = true;
   hasClose = true;
   size = { 344, 224 };
   anchor = { horz = -127, vert = -68 };

   BitmapResource red{"red.png"};
   BitmapResource blue{"blue.png"};
   Timer timer
   {
      userData = this, started = false, delay = 1;

      bool DelayExpired()
      {
         if (button1.checked)
            {
            button2.checked=true;
            button2.Activate();
            }
         else
            {
            button1.checked=true;
            button1.Activate(); 
            }
         Update(null);
         return true;
      }
   };
   Button button3
   {
      this, text = "开始start", position = { 256, 56 };

      bool NotifyClicked(Button button, int x, int y, Modifiers mods)
      {
         if(timer.started)
             {
             button3.text = "开始start";
             timer.started = false; 
             }
         else 
             {
             button3.text = "停止stop";
             timer.started = true; 
             }
         return true;
      }
   };
   Picture picture1 { this, text = "picture1", background = white, position = { 48, 56 } };
   Button button1
   {
      this, text = "红灯red light", background = white, position = { 176, 56 }, isRadio = true;

      
      bool NotifyClicked(Button button, int x, int y, Modifiers mods)
      {
         picture1.image= red;
         return true;
      }
      

      bool NotifyActivate(Window window, bool active, Window previous)
      {
         picture1.image= red; 
         return true;
      }


   };
   Button button2 
   {
      this, text = "绿灯blue light", position = { 176, 96 }, isRadio = true;

      
      bool NotifyClicked(Button button, int x, int y, Modifiers mods)
      {
         picture1.image = blue; 
         return true;
      } 

      bool NotifyActivate(Window window, bool active, Window previous)
      {
         picture1.image = blue; 
         return true;
      }
   };
}

Form1 form1 {};
Post Reply