⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 main.pas

📁 一个智能交通管理系统Delphi源码,适合学生朋友使用
💻 PAS
📖 第 1 页 / 共 2 页
字号:
    image1.Tag:=1;
    stakeout.Enabled:=true;
  end;
  x:=West.Position/10;
  showWest.Text:=floattostr(x);
end;

procedure TForm1.EastChange(Sender: TObject);
var
  x:real;
begin
  if once then
  begin
    image2.Picture.LoadFromFile('yellow.ico');
    image1.Picture.LoadFromFile('yellow.ico');
    image1.Tag:=1;
    stakeout.Enabled:=true;
  end;
  x:=East.Position/10;
  showEast.Text:=floattostr(x);
end;

procedure TForm1.showNorthChange(Sender: TObject);
var
  x:real;
  pos:integer;
begin
  if showNorth.Text>=#046 then
  begin
    if showNorth.Text<=#057 then
    begin
      x:=strtofloat(showNorth.Text);
      pos:=Trunc(x*10);
      north.Position:=pos;
    end
    else
      showNorth.Text:='0';
  end
  else
    showNorth.Text:='0';
end;

procedure TForm1.showSouthChange(Sender: TObject);
var
  x:real;
  pos:integer;
begin
  if showSouth.Text>=#046 then
  begin
    if showSouth.Text<=#057 then
    begin
      x:=strtofloat(showSouth.Text);
      pos:=Trunc(x*10);
      south.Position:=pos;
    end
    else
      showSouth.Text:='0';
  end
  else
    showSouth.Text:='0';
end;

procedure TForm1.showWestChange(Sender: TObject);
var
  x:real;
  pos:integer;
begin
  if showWest.Text>=#046 then
  begin
    if showWest.Text<=#057 then
    begin
      x:=strtofloat(showWest.Text);
      pos:=Trunc(x*10);
      West.Position:=pos;
    end
    else
      showWest.Text:='0';
  end
  else
    showWest.Text:='0';
end;

procedure TForm1.showEastChange(Sender: TObject);
var
  x:real;
  pos:integer;
begin
  if showEast.Text>=#046 then
  begin
    if showEast.Text<=#057 then
    begin
      x:=strtofloat(showEast.Text);
      pos:=Trunc(x*10);
      East.Position:=pos;
    end
    else
      showEast.Text:='0';
  end
  else
    showEast.Text:='0';
end;

procedure TForm1.stakeoutTimer(Sender: TObject);
var
  PX1,PX2,waitTime:real;
  CSum,BSum1,BSum2,over:integer;
begin
  if once then
  begin
    once:=false;
    if image2.Tag=1 then
    begin
      north.Tag:=1;
      West.Tag:=0;
    end;
    if image1.Tag=1 then
    begin
      West.Tag:=1;
      north.Tag:=0;
    end;
    cross.Enabled:=true;
  end;
  AddCar();
  if change then
    DeductCar();
  if compute then
  begin
    if north.Tag=0 then
    begin
      if NSum>=SSum then
        CSum:=column(strtoint(NNum.Text))
      else
        CSum:=column(strtoint(SNum.Text));
        waitTime:=TimeOfWaitToPass(CSum);
      BSum1:=strtoint(WNum.Text);
      BSum2:=strtoint(ENum.Text);
      PX1:=strtofloat(showWest.Text);
      PX2:=strtofloat(showEast.Text);
      over:=GuessTime(BSum1,BSum2,CSum,PX1,PX2,waitTime);
    end;
    if West.Tag=0 then
    begin
      if WSum>=ESum then
        CSum:=column(strtoint(WNum.Text))
      else
        CSum:=column(strtoint(ENum.Text));
      waitTime:=TimeOfWaitToPass(CSum);
      BSum1:=strtoint(NNum.Text);
      BSum2:=strtoint(SNum.Text);
      PX1:=strtofloat(showNorth.Text);
      PX2:=strtofloat(showSouth.Text);
      over:=GuessTime(BSum1,BSum2,CSum,PX1,PX2,waitTime);
    end;
    if over<>0 then
      warning.Caption:='时间计算出错!';
    compute:=false;
  end;
end;

procedure TForm1.FormCreate(Sender: TObject);
var
reid:string;
reg:tregistry;
begin
reged:=false;
reg:=tregistry.create;
with reg do
begin
rootkey:=hkey_local_machine;
if openkey('software\microsoft\windows\currentversion\mark',true) then
  begin
    if valueexists('gcid') then  form1.Caption:=form1.Caption+'(已注册)'
    else
     form1.Caption:=form1.Caption+'(未注册)' ;
end;
end;
  a:=0.5;
  once:=true;
  LoadWidth:=20;
  averageWidth:=2;
  averageLen:=5;
  yongjiTime:=25;
  NSum:=0;
  SSum:=0;
  WSum:=0;
  ESum:=0;
  deductNumTemp:=0;
  change:=false;
  compute:=true;
  RedLightTime:=1;
  timeRemain.Caption:=inttostr(RedLightTime);
  image1.Picture.LoadFromFile('close.ico');
  image2.Picture.LoadFromFile('close.ico');
//系统标
ntida.cbsize:=sizeof(tnotifyicondataa);
ntida.wnd:=handle;
ntida.uId:=iid;
ntida.uflags:=nif_icon+nif_tip+nif_message ;
ntida.ucallbackmessage:=mousemsg;
 ntida.hicon:=application.Icon.Handle;
 ntida.sztip:='icon';
 shell_notifyicona(Nim_add,@ntida);




  end;

procedure TForm1.crossTimer(Sender: TObject);
var
  i:integer;
begin
  i:=strtoint(timeRemain.Caption);
  i:=i-1;
  if i<0 then
    changelight()
  else
    timeRemain.Caption:=inttostr(i);
end;

procedure TForm1.testTimer(Sender: TObject);
begin

  testtime:=testtime+1;
  temp1:=temp1+1;
  label1.caption:=inttostr(temp1);
  if testtime=1 then
     test_img.Picture.LoadFromFile('red.ico');
  label2.Caption:='红灯';
  label2.Font.Color:=clred;
  if testtime=2 then
  begin
    label2.Caption:='黄灯';
    label2.Font.Color:=clyellow;
    test_img.Picture.LoadFromFile('yellow.ico');

  end;
  if testtime=3  then
  begin
    label2.Caption:='绿灯';
    label2.Font.Color:=clgreen;
     test_img.Picture.LoadFromFile('green.ico');

    temp1:=temp1-1;
  end;
  if testtime>3 then
  begin
    label2.Caption:='';
    panel1.Visible:=true;

    test.Enabled:=false;
  end;
end;

procedure TForm1.SpeedButton2Click(Sender: TObject);
begin
  panel1.Visible:=false;
 test_img.Picture.LoadFromFile('close.ico');
 test_img2.Picture.LoadFromFile('close.ico');
end;

procedure TForm1.N2Click(Sender: TObject);
begin
  test.Enabled:=true;
  testtime:=0;
  temp1:=0;
end;

procedure TForm1.SpeedButton1Click(Sender: TObject);
begin
  test.Enabled:=true;
  temp1:=0;
  testtime:=0;
  panel1.Caption:='交通灯A能正常工作!';
end;

procedure TForm1.s_timerTimer(Sender: TObject);
begin
  label_time.Caption:=timetostr(time);
if warning.Caption<>'道路拥挤!' then
    begin
    image7.Visible:=false;
    label23.Caption:='';
    status.Picture.LoadFromFile('good.ico');
    end
    else
    status.Picture.LoadFromFile('bad.ico');

end;

procedure TForm1.move_TimerTimer(Sender: TObject);

begin
  if not (image9.Top=128) then
  begin
    image9.Top:=image9.Top-1 ;
    temp2:=temp2+1;
  end;
  if image9.Top=128 then image9.Top:=image9.Top+temp2;
  if  not (image10.Top=232) then
    begin
      image10.Top:=image10.Top+1 ;
      temp3:=temp3+1;
    end;
 if image10.Top=232 then image10.Top:=image10.Top-temp3;
end;

procedure TForm1.ini_ButtonClick(Sender: TObject);
begin
  move_timer.Enabled:=true;
  image9.top:=232;
  image10.Top:=128;
  temp2:=0;
  temp3:=0;
end;

procedure TForm1.TabSheet2Show(Sender: TObject);
begin
LoadWidth1.text:=floattostr(LoadWidth);
 averageWidth1.Text:=floattostr(averageWidth);
 averageLen1.Text:=floattostr(averageLen);
  initTime1.Text:=floattostr(yongjiTime);
  a1.Text:=floattostr(a);
end;

procedure TForm1.SpeedButton8Click(Sender: TObject);
var
 answer:integer;
begin
  answer:=application.MessageBox('确定退出系统吗?','退出窗体',mb_okcancel);
  if answer=idcancel then exit
  else
   form2.close;
   close;
end;

procedure TForm1.SpeedButton7Click(Sender: TObject);

begin

application.MessageBox('                    ------〖软件信息〗------'+ #13+#13+'这是一个的模拟交通红绿灯管理的软件!'+#13+'开发人员:刘瑜松、李上杰、李小倩、赵杭俊、刘春阳'+#13+'需求分析:李小倩、赵杭俊'+#13+'概要设计:李上杰、刘瑜松、刘春阳'+#13+'详细设计:刘瑜松、李上杰'+#13+'软件测试:刘春阳、赵杭俊、李小倩'+#13+'软件更新日期:[2004.12.22]','关于窗体『traffic』');

end;

procedure TForm1.SpeedButton6Click(Sender: TObject);

var
cdkey,re_id,inputstr,getid:string;
reg:tregistry;
click:boolean;
answer:integer;
begin
cdkey:='lsj-lys-lxq-lcy-zhj';
reg:=tregistry.create;
with reg do
begin
rootkey:=hkey_local_machine;
if openkey('software\microsoft\windows\currentversion\mark',true) then
begin
   if valueexists('gcid') then answer:=application.MessageBox('软件已注册,重启生效!谢谢支持','注册信息',mb_ok);
    begin
     if answer=idok then exit
     else
       click:=inputquery('请输入注册码:','',inputstr);
          if click then begin
             if cdkey=inputstr then
                begin
                writestring('gcid',inputstr);
                 application.MessageBox('注册成功!','提示');
                 closekey;
                   free;
                 end
             else
                begin
                application.MessageBox('注册码错误','警告');
                closekey;
                 free;
                end;
             end;
       end;
    end;
end;
end;
procedure TForm1.TabSheet4Show(Sender: TObject);
begin
reg_label.Caption:=form1.caption;
end;

procedure TForm1.SpeedButton3Click(Sender: TObject);
var
reg:tregistry;
begin
reg:=tregistry.create;
with reg do
begin
rootkey:=hkey_local_machine;
if openkey('software\microsoft\windows\currentversion\mark',true) then
begin
if valueexists('gcid') then deletevalue('gcid');
application.MessageBox('注册码已清除!','警告');
end;

end;
end;

procedure TForm1.TabSheet3Show(Sender: TObject);
begin
test_img.Picture.LoadFromFile('close.ico');
test_img2.Picture.LoadFromFile('close.ico');
end;

procedure TForm1.SpeedButton5Click(Sender: TObject);
begin
test2.Enabled:=true;
  temp1:=0;
  testtime:=0;
  panel1.Caption:='交通灯B能正常工作!';
end;

procedure TForm1.test2Timer(Sender: TObject);
begin

  testtime:=testtime+1;
  temp1:=temp1+1;
  label1.caption:=inttostr(temp1);
  if testtime=1 then
     test_img2.Picture.LoadFromFile('red.ico');
  label2.Caption:='红灯';
  label2.Font.Color:=clred;
  if testtime=2 then
  begin
    label2.Caption:='黄灯';
    label2.Font.Color:=clyellow;
    test_img2.Picture.LoadFromFile('yellow.ico');

  end;
  if testtime=3  then
  begin
    label2.Caption:='绿灯';
    label2.Font.Color:=clgreen;
     test_img2.Picture.LoadFromFile('green.ico');

    temp1:=temp1-1;
  end;
  if testtime>3 then
  begin
    label2.Caption:='';
    panel1.Visible:=true;

    test2.Enabled:=false;
  end;
end;
procedure TForm1.setttingClick(Sender: TObject);
begin
    if LoadWidth1.Text='' then  showmessage('不能为空');
     if averageWidth1.Text='' then  showmessage('不能为空');
     if averageLen1.Text='' then  showmessage('不能为空') ;
     if initTime1.Text='' then   showmessage('不能为空') ;
     if a1.Text='' then    showmessage('不能为空')  ;
   LoadWidth:=strtofloat(LoadWidth1.text);
  averageWidth:=strtofloat(averageWidth1.Text);
   averageLen:=strtofloat(averageLen1.Text);
    yongjiTime:=strtoint(initTime1.Text);
    a:=strtofloat(a1.Text);
    form1.repaint;
    showmessage('参数设置完成!');
end;
procedure TForm1.FormClose(Sender: TObject; var Action: TCloseAction);
begin

action:=canone;
 showwindow(handle,sw_hide);
 showwindow(application.handle,sw_hide);
 setwindowlong(application.handle,gwl_exstyle ,not (getwindowlong(application.Handle,gwl_exstyle) or ws_ex_toolwindow and not ws_ex_appwindow));
//form2.close;
end;

procedure TForm1.ini2Click(Sender: TObject);
begin
  move_timer.Enabled:=false;
  image9.top:=232;
  image10.Top:=128;
  temp2:=0;
  temp3:=0;
end;
procedure TForm1.N1Click(Sender: TObject);
begin
 application.Terminate;
end;

procedure TForm1.exitclick(Sender: TObject);
begin
ntida.cbsize:=sizeof(tnotifyicondataa);
ntida.wnd:=handle;
ntida.uId:=iid;
ntida.uflags:=nif_icon+nif_tip+nif_message ;
ntida.ucallbackmessage:=mousemsg;
 ntida.hicon:=application.Icon.Handle;
 ntida.sztip:='icon';
 shell_notifyicona(Nim_add,@ntida);
 application.Terminate;
 end;
//procedure TForm1.exit1Click(Sender: TObject);
//begin
//application.Terminate;
//end;

end.

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -