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

📄 unit1.pas

📁 铁路道口管理系统 开发源码 大家随便看看 呵呵
💻 PAS
📖 第 1 页 / 共 3 页
字号:
unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, Buttons, jpeg, ExtCtrls, StdCtrls, ComCtrls, Menus, AxCtrls,
  OleCtrls, TabDlg_TLB;

type
  TForm1 = class(TForm)
    Timer1: TTimer;
    PopupMenu1: TPopupMenu;
    N1: TMenuItem;
    PopupMenu2: TPopupMenu;
    N2: TMenuItem;
    N3: TMenuItem;
    N4: TMenuItem;
    SSTab1: TSSTab;
    SpeedButton1: TSpeedButton;
    SpeedButton4: TSpeedButton;
    SpeedButton2: TSpeedButton;
    SpeedButton6: TSpeedButton;
    Label1: TLabel;
    Edit1: TEdit;
    UpDown1: TUpDown;
    SpeedButton5: TSpeedButton;
    Button1: TButton;
    Edit3: TEdit;
    Label3: TLabel;
    Edit2: TEdit;
    Label2: TLabel;
    Label4: TLabel;
    Edit4: TEdit;
    Label5: TLabel;
    Edit5: TEdit;
    SpeedButton3: TSpeedButton;
    N5: TMenuItem;
    N6: TMenuItem;
    N7: TMenuItem;
    N8: TMenuItem;
    N9: TMenuItem;
    N10: TMenuItem;
    procedure SpeedButton1Click(Sender: TObject);
    procedure FormShow(Sender: TObject);
    procedure UpDown1Click(Sender: TObject; Button: TUDBtnType);

    procedure Timer1Timer(Sender: TObject);
    procedure SpeedButton5Click(Sender: TObject);
    procedure SpeedButton3Click(Sender: TObject);
    procedure SpeedButton2Click(Sender: TObject);
    procedure SpeedButton4Click(Sender: TObject);
    procedure SpeedButton6Click(Sender: TObject);
    procedure Button1Click(Sender: TObject);
    procedure N1Click(Sender: TObject);
    procedure SSTab1MouseUp(Sender: TObject; Button: TMouseButton;
      Shift: TShiftState; X, Y: Integer);
    procedure N4Click(Sender: TObject);
    procedure N2Click(Sender: TObject);
    procedure SSTab1MouseMove(Sender: TObject; Shift: TShiftState; X,
      Y: Integer);
    procedure FormCreate(Sender: TObject);
    procedure SpeedButton7Click(Sender: TObject);
    procedure Edit1KeyUp(Sender: TObject; var Key: Word;
      Shift: TShiftState);
    procedure FormClose(Sender: TObject; var Action: TCloseAction);
    procedure N6Click(Sender: TObject);
    procedure N7Click(Sender: TObject);
    procedure N9Click(Sender: TObject);
    procedure N10Click(Sender: TObject);


  private
    { Private declarations }
  public
    MoveStep : Integer;//移动每次大小
    BeforLeft , BeforTop ,FinalLeave: integer;
    JPGHigh , JPGWidth : integer;  //记录导入图片的大小
    SSCDS,DKMoveBegin,IfkeyDown : boolean;
    NewDkX ,NewDKY : integer; //添加新道口和移动道口终止位置坐标
    LocalPath : string;//系统运行路径
    TagNow : integer;  //记录当前道口控件的Tag标志
    MoveBItBtn : TBitBtn; //移动时候记录是哪个BItBtn在操作
    ThisFX : string;//记录道口方向角度
    changFXtag : integer;//改变角度用的记录Tag

    function IfLawInt(Inthis:string):boolean;//判断输入到是否是整数
    procedure MoveOther(Fangxiang:string);  //方向参数中 L:left R:Right U:Up D:Down
    procedure RefrashThis; //刷新屏幕上控件功能
    procedure StationClick(Sender: TObject); //道口单击功能
    procedure StationDown(Sender: TObject; Button: TMouseButton;Shift: TShiftState; X, Y: Integer); //道口移动开始标志
    procedure StationUp(Sender: TObject; Button: TMouseButton;Shift: TShiftState; X, Y: Integer);//道口删除移动结束用
    procedure StationMove(Sender: TObject; Shift: TShiftState; X,Y: Integer);//道口信息移动用

    procedure DeleteDKDB(TagC : integer);//删除道口数据库信息
    procedure ContralXYHF;//恢复操作控件位置
    procedure IfcanseeThis(cansee : boolean);//操作控件是否可见
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation
uses Unit2,Unit3,unit5,Unit6;
{$R *.dfm}



procedure TForm1.FormShow(Sender: TObject);
var
  i : integer;
begin

  With SSTab1 do  //装载地图文件JPG
  begin
    Picture.LoadFromFile(self.LocalPath + 'map\'+ Form5.PathofMap); //维护段地图的路径固定在这里
    Height := 1580;  // Tabhigh := 2270   1500
    Width := 1760;   //tabmaxwidth := 2176   1800
    if form5.NameOfMap = '长春市' then
    begin
      TabHeight := 1550;
      TabMaxWidth := 1700;
      IfcanseeThis(true);
    end
    else if form5.NameOfMap = '长白线' then
    begin
      Height := 700;  // Tabhigh := 2270   1500
      Width := 900;   //tabmaxwidth := 2176   1800
      TabHeight := 680;
      TabMaxWidth := 800;
      IfcanseeThis(false);
    end
    else if form5.NameOfMap = '长吉线' then
    begin
      Height := 720;  // Tabhigh := 2270   1500
      Width := 1050;   //tabmaxwidth := 2176   1800
      TabHeight := 680;
      TabMaxWidth := 800;
      IfcanseeThis(false);
    end
    else if form5.NameOfMap = '哈大线' then
    begin
      Height := 780;  // Tabhigh := 2270   1500
      Width := 1050;   //tabmaxwidth := 2176   1800
      TabHeight := 750;
      TabMaxWidth := 1000;
      IfcanseeThis(false);
    end
    else
    begin
      Height := 780;  // Tabhigh := 2270   1500
      Width := 1050;   //tabmaxwidth := 2176   1800
      TabHeight := 750;
      TabMaxWidth := 1000;
      IfcanseeThis(false);
    end;
  //恢复操作控件位置
    ContralXYHF;
  end;

  SpeedButton1.Parent := SSTab1;
  SpeedButton2.Parent := SSTab1;
  SpeedButton3.Parent := SSTab1;
  SpeedButton4.Parent := SSTab1;
  SpeedButton5.Parent := SSTab1;
  SpeedButton6.Parent := SSTab1;


  edit1.Parent := Form1;
  edit2.Parent := Form1;
  edit3.Parent := Form1;
  edit4.Parent := Form1;
  edit5.Parent := Form1;
  label1.Parent := Form1;
  label2.Parent := Form1;
  label3.Parent := Form1;
  label4.Parent := Form1;
  label5.Parent := Form1;
  Updown1.Parent := Form1;
  BUtton1.Parent := Form1;

  SSCDS := true;
  DKMoveBegin := false;
  IfkeyDown := false;
  Edit1.Text := '100';
  Movestep := 100;

  edit2.Text := '';
  edit3.Text := '';


  //SSTab1.Width := SSTab1.Picture.Width;
  //SSTab1.Height := SSTab1.Picture.Height;
  SSTab1.Top := 0;
  SSTab1.Left := 0;
 { for i := 0 to SStab1.ControlCount -1 do
    begin
      if SStab1.Controls[i].ClassType = Tspeedbutton then
      begin
       // TSpeedButton(SSTab1.Controls[i]).Left := TSpeedButton(SSTab1.Controls[i]).Left - Form5.SonLeftLeave ;
        //TSpeedButton(SSTab1.Controls[i]).Top := TSpeedButton(SSTab1.Controls[i]).Top - Form5.SonTopLeave ;
      end;
    end;   }

  JPGHigh :=  SSTab1.Height-768 ; //高度差
  JPGWidth :=  SSTab1.Width -1024;  //宽度差
  Timer1.Enabled := true;
  RefrashThis; //刷新道口控件
  n6.Enabled:=true;
  n7.Enabled:=true;
end;

procedure TForm1.UpDown1Click(Sender: TObject; Button: TUDBtnType);
begin
  if strtoint(edit1.Text) > 300 then
  begin
    edit1.Text := '300';
  end;
  Movestep := strtoint(edit1.Text);
end;


procedure TForm1.SpeedButton1Click(Sender: TObject);
begin
  //向左移动
    Timer1.Enabled := false;
    BeforLeft:= SSTab1.Left;
    BeforTop := SSTab1.Top;
    SpeedButton1.Enabled := true;
    if SSTab1.Left - MoveStep > -JPGWidth then
    begin
      SSTab1.Left := SSTab1.Left - MoveStep ;
     end
    else
    begin
      SSTab1.Left := -JPGWidth;
      SpeedButton2.Enabled := false;
    end;
    FinalLeave := beforleft-SSTab1.Left  ;
    edit2.Text := inttostr(SSTab1.left);
    MoveOther('L');
    Timer1.Enabled := true;
end;





//其它控件的移动
procedure TForm1.MoveOther(Fangxiang : string);
var
  i : integer;
begin
  try
    for i := 0 to SSTab1.ControlCount -1 do
    begin
      if SSTab1.Controls[i].ClassType = TSpeedButton then  //按钮
      begin
        if fangxiang = 'L' then //向左
          TSpeedButton(SSTab1.Controls[i]).Left := TSpeedButton(SSTab1.Controls[i]).Left + FinalLeave
        else
        if fangxiang = 'R' then //向右
          TSpeedButton(SSTab1.Controls[i]).Left := TSpeedButton(SSTab1.Controls[i]).Left - FinalLeave
        else
        if fangxiang = 'U' then //向上
          TSpeedButton(SSTab1.Controls[i]).Top := TSpeedButton(SSTab1.Controls[i]).Top + FinalLeave
        else
        if fangxiang = 'D' then //向下
          TSpeedButton(SSTab1.Controls[i]).Top := TSpeedButton(SSTab1.Controls[i]).Top - FinalLeave;

        //TSpeedButton(SSTab1.Controls[i]).Refresh;
      end;

      if SSTab1.Controls[i].ClassType = TLabel then  //标签
      begin
        if fangxiang = 'L' then //向左
          TLabel(SSTab1.Controls[i]).Left := TLabel(SSTab1.Controls[i]).Left + FinalLeave
        else
        if fangxiang = 'R' then //向右
          TLabel(SSTab1.Controls[i]).Left := TLabel(SSTab1.Controls[i]).Left - FinalLeave
        else
        if fangxiang = 'U' then //向上
          TLabel(SSTab1.Controls[i]).Top := TLabel(SSTab1.Controls[i]).Top + FinalLeave
        else
        if fangxiang = 'D' then //向下
          TLabel(SSTab1.Controls[i]).Top := TLabel(SSTab1.Controls[i]).Top - FinalLeave ;

        //TLabel(SSTab1.Controls[i]).Refresh;
      end;

      if SSTab1.Controls[i].ClassType = Tedit then  //edit
      begin
        if fangxiang = 'L' then //向左
          Tedit(SSTab1.Controls[i]).Left := Tedit(SSTab1.Controls[i]).Left + FinalLeave
        else
        if fangxiang = 'R' then //向右
          Tedit(SSTab1.Controls[i]).Left := Tedit(SSTab1.Controls[i]).Left - FinalLeave
        else
        if fangxiang = 'U' then //向上
          Tedit(SSTab1.Controls[i]).Top := Tedit(SSTab1.Controls[i]).Top + FinalLeave
        else
        if fangxiang = 'D' then //向下
          Tedit(SSTab1.Controls[i]).Top := Tedit(SSTab1.Controls[i]).Top - FinalLeave  ;

        //Tedit(SSTab1.Controls[i]).Refresh;
      end;

      if SSTab1.Controls[i].ClassType = Tupdown then  //updown
      begin
        if fangxiang = 'L' then //向左
          Tupdown(SSTab1.Controls[i]).Left := Tupdown(SSTab1.Controls[i]).Left + FinalLeave
        else
        if fangxiang = 'R' then //向右
          Tupdown(SSTab1.Controls[i]).Left := Tupdown(SSTab1.Controls[i]).Left - FinalLeave
        else
        if fangxiang = 'U' then //向上
          Tupdown(SSTab1.Controls[i]).Top := Tupdown(SSTab1.Controls[i]).Top + FinalLeave
        else
        if fangxiang = 'D' then //向下
          Tupdown(SSTab1.Controls[i]).Top := Tupdown(SSTab1.Controls[i]).Top - FinalLeave ;
        //Tupdown(SSTab1.Controls[i]).Refresh;
      end;
    end;
    SSTab1.Refresh;
  except

  end;


end;


procedure TForm1.Timer1Timer(Sender: TObject);
var
   i : integer;
begin
  try
    if sscds = false then
      sscds := true
    else
      sscds := false;

    for i := 0 to SSTab1.ControlCount -1 do
    begin
      if SSTab1.Controls[i].ClassType = TShape then
      begin
        if sscds then
          TShape(SStab1.Controls[i]).Pen.Color := ClBlue
        //  TBitBtn(SSTab1.Controls[i]).Glyph.LoadFromFile(LocalPath+'1.bmp')
        else
          TShape(SStab1.Controls[i]).Pen.Color := clYellow;
        //  TBitBtn(SSTab1.Controls[i]).Glyph.LoadFromFile(LocalPath+'2.bmp');
      end;
    end;
  except

  end;
end;

procedure TForm1.SpeedButton5Click(Sender: TObject);
begin

⌨️ 快捷键说明

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