Ecere SDK/eC Forums
http://ec-lang.org/community/
Print view

模拟红绿灯(Simulation of traffic lights)
http://ec-lang.org/community/viewtopic.php?f=30&t=36
Page 1 of 1
Author:  liqi98136 [ Wed Mar 10, 2010 7:59 am ]
Post subject:  模拟红绿灯(Simulation of traffic lights)

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 {};
All times are UTC-05:00 Page 1 of 1