毕业论文论文范文课程设计实践报告法律论文英语论文教学论文医学论文农学论文艺术论文行政论文管理论文计算机安全
您现在的位置: 毕业论文 >> 课程设计 >> 正文

城市路灯智能监控管理系统源码 第2页

更新时间:2010-7-6:  来源:毕业论文
城市路灯智能监控管理系统源码 第2页
unit UnitMain;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, RzPanel, RzSplit, ExtCtrls,
  ComCtrls, RzListVw, RzTreeVw, RzTabs, Menus, RzCommon, jpeg, RzButton, StdActns,  ActnList,
  ActnMan, ToolWin, ActnCtrls, ActnMenus, ImgList, XPStyleActnCtrls, Grids, RzStatus, DB, ADODB;

type
  PSiteNodeData = ^TSiteNodeData;
  TSiteNodeData = record                //终端列表树附加数据
    SiteID: integer;                    //
    SiteAddress: integer;               //
    SiteName: string;                   //
    SitePos: TPoint;                    //
  end;

  TChartSiteItem = class                //回路状态图数据单位
    SiteName: string;                   //终端名称
    SiteAddress: integer;               //终端地址
    PanelChart: TPanel;                 //容器
    ShapeDo, ShapeDi: array [0..15] of TShape;
    ShapeKa, ShapeKm: array [0..3]  of TShape;
    constructor Create;
    dest毕业论文http://www.youerw.comructor Destroy; override;
  end;

  TChartSiteList = class                //终端回路状态图数据表
    Count: integer;
    //ImageChartBranch, ImageChartMode: TImage;
    Items: array of TChartSiteItem;
    constructor Create;

    procedure RefreshBar;               //刷行间隔颜色

    function GetIndex(Site: integer): integer;

    //刷新运行状态图  FLAG: 1-新建  2-删除  3-移动  4-重置
    procedure Refresh(Flag: integer; Site1: integer=0; Site2: integer=0);
    procedure SiteNew(Site: integer);
    procedure SiteDel(Site: integer);
    procedure SiteMov(Site1, Site2: integer);
    procedure SiteReset;
    procedure RefreshSiteName(SiteCode: integer; SiteName: string);   //终端名称改变了,只刷名称
  end;

  TFormMain = class(TForm)
    rzstsbr1: TRzStatusBar;
    rztlbr1: TRzToolbar;
    pm1: TPopupMenu;
    N1111: TMenuItem;
    N2221: TMenuItem;
    N3331: TMenuItem;
    actmmb1: TActionMainMenuBar;
    actmgr1: TActionManager;
    actAbout: TAction;
    flxt1: TFileExit;
    Action5: TAction;
    Action6: TAction;
    btn1: TRzToolButton;
    btn2: TRzToolButton;
    PageControl1: TRzPageControl;
    TabSheet1: TRzTabSheet;
    TabSheet2: TRzTabSheet;
    TabSheet3: TRzTabSheet;
    GroupBox1: TRzGroupBox;
    ListView1: TRzListView;
    ImageNav: TImage;
    GroupBox2: TRzGroupBox;
    GroupBox3: TRzGroupBox;
    ScrollBox1: TScrollBox;
    ListViewSiteValue: TRzListView;
    ListViewSiteData: TRzListView;
    ShapeNav: TShape;
    rzstspn1: TRzStatusPane;
    rzglyphsts1: TRzGlyphStatus;
    rzglyphsts2: TRzGlyphStatus;
    rzstspn2: TRzStatusPane;
    rzstspn3: TRzStatusPane;
    rzstspn4: TRzStatusPane;
    ImageList1: TImageList;
    Action1: TAction;
    Action2: TAction;
    Action3: TAction;
    Action4: TAction;
    btn3: TRzToolButton;
    btn4: TRzToolButton;
    rzspcr1: TRzSpacer;
    btn5: TRzToolButton;
    btn6: TRzToolButton;
    qry1: TADOQuery;
    qry2: TADOQuery;
    ImageList2: TImageList;
    PanelBottom: TRzPanel;
    PanelLeft: TRzPanel;
    PanelRight: TRzPanel;
    PanelMap: TRzPanel;
    PanelMain: TRzPanel;
    ImageMap: TImage;
    Splitter1: TSplitter;
    Splitte毕业论文http://www.youerw.comr2: TSplitter;
    TreeViewSiteList: TRzTreeView;
    Action7: TAction;
    ScrollBoxChart: TScrollBox;
    rzspcr2: TRzSpacer;
    Action8: TAction;
    btn7: TRzToolButton;
    PanelCmd: TRzPanel;
    Action9: TAction;
    Action10: TAction;
    procedure Action5Execute(Sender: TObject);
    procedure Action6Execute(Sender: TObject);
    procedure Action1Execute(Sender: TObject);
    procedure Action2Execute(Sender: TObject);
    procedure Action3Execute(Sender: TObject);
    procedure Action4Execute(Sender: TObject);
    procedure FormCreate(Sender: TObject);
    procedure TreeViewSiteListDblClick(Sender: TObject);
    procedure ImageMapMouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
    procedure ImageMapMouseMove(Sender: TObject; Shift: TShiftState; X, Y: Integer);
    procedure ImageMapMouseUp(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
    procedure Action7Execute(Sender: TObject);
    procedure PanelMapResize(Sender: TObject);
    procedure Action8Execute(Sender: TObject);
    procedure ImageNavMouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
  private
    { Private declarations }


    MapOper: integer;                   //0-允许平移地图,1-地图平移中, 1-新建终端,2-允许平移地图,4-新建中心
    MapXSave, MapYSave: integer;        //点击鼠标,保存坐标

    MapConstWidth, MapConstHeight: integer;     //
    NavConstWidth, NavConstHeight: integer;     //

    procedure InitMap;                  //初始化本文来自优文论文网原文请找QQ752018766地图
    procedure InitTreeSiteList;         //初始化终端列表树
    procedure InitListSite;             //初始化终端表(终端运行状态,终端运行数据,终端数据返回)

    procedure MapReposition;            //地图重定位
    procedure RefreshShapeNav;          //刷新地图游标
  public
    { Public declarations }
    ZoomRate: integer;                          //地图缩放比例
  end;

const
  MapRate: array [0..6] of double=(1.0, 1/1.414, 1/2, 1/1.414/2, 1/4, 1/1.414/4, 1/8);

var
  FormMain: TFormMain;
  ChartSiteList: TChartSiteList;

implementation

uses UnitData, UnitSuperUser;

{$R *.dfm}

procedure TFormMain.Action1Execute(Sender: TObject);
begin
  Action1.Checked := not Action1.Checked;
  btn1.Down := Action1.Checked;
  PanelLeft.Visible := Action1.Checked;
end;

procedure TFormMain.Action2Execute(Sender: TObject);
begin
  Action2.Checked := not Action2.Checked;
  btn2.Down := Action2.Checked;
  GroupBox3.Visible := Action2.Checked;
end;

procedure TFormMain.Action3Execute(Sender: TObject);
begin
  Action3.Checked := not Action3.Checked;
  btn3.Down := Action3.Checked;
  PanelBottom.Visible := Action3.Checked;
  Splitter1.Visible := Action3.Checked;
end;

procedure TFormMain.Action4Execute(Sender: TObject);
begin
  Action4.Checked := not Action4.Checked;
  btn4.Down := Action4.Checked;
  PanelRigh毕业论文http://www.youerw.comt.Visible := Action4.Checked;
  Splitter2.Visible := Action4.Checked;
end;

procedure TFormMain.Action5Execute(Sender: TObject);
var
  p: TPoint;
begin
  p.X := trunc((PanelMap.Width  div 2 - ImageMap.Left) / MapRate[ZoomRate]);
  p.Y := trunc((PanelMap.Height div 2 - ImageMap.Top)  / MapRate[ZoomRate]);

  if ZoomRate=0 then exit;
  ZoomRate := ZoomRate - 1;

  ImageMap.Width  := trunc(MapConstWidth  * MapRate[ZoomRate]);
  ImageMap.Height := trunc(MapConstHeight * MapRate[ZoomRate]);

  ImageMap.Left := PanelMap.Width  div 2 - trunc(p.X * MapRate[ZoomRate]);
  ImageMap.Top  := PanelMap.Height div 2 - trunc(p.Y * MapRate[ZoomRate]);

  MapReposition;
  RefreshShapeNav;
  //RefreshControlCenter;
end;

procedure TFormMain.Action6Execute(Sender: TObject);
var
  p: TPoint;
begin
  p.X := trunc((PanelMap.Width  div 2 - ImageMap.Left) / MapRate[ZoomRate]);
  p.Y := trunc((PanelMap.Height div 2 - ImageMap.Top)  / MapRate[ZoomRate]);

  if ZoomRate=6 then exit;
  ZoomRate := ZoomRate + 1;

  ImageMap.Width  := trunc(MapConstWidth  * MapRate[ZoomRate]);
  ImageMap.Height := trunc(MapConstHeight * MapRate[ZoomRate]);

  ImageMap.Left := PanelMap.Width  div 2 - trunc(p.X * MapRate[ZoomRate]);
  ImageMap.Top  := PanelMap.Height div 2 - trunc(p.Y * MapRate[ZoomRate]);

  MapReposition;
  RefreshShapeNav;
  //RefreshControlCenter;
end;

procedure TFormMain.Action7Execute(Sender: TObject);
var
  p: TPoint;
begin
  p.X := MapConstWidth  div 2;
  p.Y := MapConstHeight div 2;

  ZoomRate := 0;
  ImageMap.Left := PanelMap.Width  div 2 - p.X;
  ImageMap.Top  := PanelMap.Height div 2 - p.Y;
  ImageMap.Width  := MapConstWidth;
  ImageMap.Height := MapConstHeight;

  RefreshShapeNav;
  //SiteMap.RefreshSitePos;
  //RefreshControlCenter;
end;

procedure TFormMain.Action8Execute(Sender: TObject);
begin
  FormSuperUser.Show;
end;

procedure TFormMain.FormCreate(Sender: TObject);
begin
  //Caption := Setting.ProjectName;

  //LoadFormMain;

  InitMap;

  //InitLux;
  //InitImageGprs;
  //InitImageComm;

  //InitAlarm;

  InitTreeSiteList;
  InitListSite;

  //InitSiteTable;
  //InitSiteChart;
  //InitSiteReturn;

  //ActionSiteList.Checked := true;
  //ActionNav.毕业论文http://www.youerw.comChecked := true;
  //ActionSiteStatus.Checked := true;

  //if FormMainSave.FormMaximized then
  //  WindowState := wsMaximized
  //else
  //  WindowState := wsNormal;

  //ActionPan.Execute;

  ImageMap.AutoSize := false;
  ImageMap.Stretch := true;
end;

procedure TFormMain.ImageMapMouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
begin
  case MapOper of
  0:    //平移地图
    begin
      MapOper := 1;
      MapXSave := X;
      MapYSave := Y;
    end;
  1:    //
      ;
  2:    //创建监控中心
    begin
      //ShowMessage(Format('监控中心(%d, %d)',[X,Y]));
      //BuildControlCenter(x, y);
      //ImageMap.Cursor := crDefault;
      //ToolButton26.Down := false;
      MapOper := 0;
    end;
  3:    //新建终端
    begin
      {FormNewSite.Pos.X := trunc(X / MapRate[ZoomRate]);
      FormNewSite.Pos.Y := trunc(Y / MapRate[ZoomRate]);
      if FormNewSite.ShowModal=mrOK then
      begin
        RefreshSiteList;
        FormSiteDetail.SiteID := FormNewSite.SiteID;
        FormSiteDetail.Oper := 1;
        FormSiteDetail.ShowModal;
        SiteChart.SiteNew(FormNewSite.SiteCode);
      end;
      ImageMap.Cursor := crDefault;
      ToolButton11.Down := false;}
      MapOper := 0;
    end;
  end;
end;

procedure TFormMain.ImageMapMouseMove(Sender: TObject; Shift: TShiftState; X, Y: Integer);
begin
  case MapOper of
  1:  //地图移动中
    begin
      ImageMap.Left := ImageMap.Left + x - MapXSave;
      ImageMap.Top  := ImageMap.Top  + y - MapYSave;

      MapReposition;
      RefreshShapeNav;
      //RefreshControlCenter;
    end;
  end;
end;

procedure TFormMain.ImageMapMouseUp(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
begin
  MapOper := 0;
  //case MapOper of
  //1:    //
  //  MapOper := 0;
  //end;
end;

毕业论文http://www.youerw.com
var
  l, t: integer;
//  i: integer;
begin
  l := x + (Sender as TControl).Left;
  t := y + (Sender as TControl).Top - ImageNav.Top;
  ImageMap.Left := -l * ImageMap.Width  div NavConstWidth  + PanelMap.Width  div 2;
  ImageMap.Top  := -t * ImageMap.Height div NavConstHeight + PanelMap.Height div 2;
  {for i:=0 to SiteMap.Count-1 do
  begin
    SiteMap.Items[i].ShapeSite.Left := trunc(SiteMap.Items[i].Pos.X * MapRate[ZoomRate]) + ImageMap.Left;
    SiteMap.Items[i].ShapeSite.Top  := trunc(SiteMap.Items[i].Pos.Y * MapRate[ZoomRate]) + ImageMap.Top;
    SiteMap.Items[i].LabelSite.Left := SiteMap.Items[i].ShapeSite.Left + 18;
    SiteMap.Items[i].LabelSite.Top  := SiteMap.Items[i].ShapeSite.Top  + 2;
  end;}

  MapReposition;
  RefreshShapeNav;
  //RefreshControlCenter;
end;
procedure TFormMain.InitListSite;
begin
  ChartSiteList := TChartSiteList.Create;
end;

procedure TFormMain.InitMap;
begin
  ImageMap.Picture.LoadFromFile('.\picture\MAP.JPG');
  ImageNav.Picture.LoadFromFile('.\picture\NAV.JPG');

  MapConstWidth  := ImageMap.Width;
  MapConstHeight := ImageMap.Height;
  NavConstWidth  := ImageNav.Width;
  NavConstHeight := ImageNav.Height;

  ImageMap.AutoSize := false;
  ImageMap.Stretch  := true;

  //SiteMap := TSiteMap.Create;
  //ShapeMapSiteClick := false;

  //ActionResetMap.Execute;
  //p := FormMainSave.MapCenter;
  //ZoomRate := FormMainSave.MapZoomRate;

  //ImageMap.Width  := trunc(MapConstWidth  * MapRate[ZoomRate]);
  //ImageMap.Height := trunc(MapConstHeight * MapRate[ZoomRate]);
  //ImageMap.Left   := PanelMap.Width  div 2 - p.X;
  //ImageMap.Top    := PanelMap.Height div 2 - p.Y;

  //SiteMap.RefreshSitePos;
  //MapChanged;

  //tbl1.Active := true;
  //ControlCenter.Flag := tbl1.RecordCount>0;
  //if ControlCenter.Flag then
  //begin
  //  ControlCenter.Pos.X := tbl1.Fields[0].AsInteger;
  //  ControlCenter.Pos.Y := tbl1.Fields[1].AsInteger;
  //  CreateControlCenter;
  //end;
end;

procedure TFormMain.InitTreeSiteList;
var
  NodeStreet: TTreeNode;
  CountSite: int毕业论文http://www.youerw.comeger;
  s: string;
  procedure SiteTreeAddChild(NodeParent: TTreeNode; strWhere: string);
  var
    NodeSite: TTreeNode;
    //Data: PSiteObjectItem;
    SiteIndex: Integer;
  begin
    with qry2 do
    begin
      Active := false;
      SQL.Clear;
      SQL.Add('select SiteID, SiteAddress, SiteName, Xpos, Ypos from site where StreetID' + strWhere);
      SQL.Add('order by SiteName');
      Active := true;
    end;

    while not qry2.Eof do
    begin
      NodeSite := TreeViewSiteList.Items.AddChild(NodeParent, qry2.FieldByName('sitename').AsString);
      NodeSite.ImageIndex := 2;
      NodeSite.SelectedIndex := 2;
      SiteIndex := soList.GetIndexBySiteID(qry2.FieldByName('SiteID').AsInteger);
      //Data := @(soList.Items[SiteIndex]);
      soList.Items[SiteIndex].NodeAbsoluteIndex := NodeSite.AbsoluteIndex;
      NodeSite.Data := @(soList.Items[SiteIndex]);
      Dec(CountSite);
      qry2.Next;
    end;
  end;
begin
  TreeViewSiteList.Items.Clear;
  TreeViewSiteList.Items.AddChild(nil, '监控中心');

  with qry2 do
  begin
    Active := false;
    SQL.Clear;
    SQL.Add('select count(SiteID) from site');
    Active := True;
  end;
  CountSite := qry2.Fields[0].AsInteger;

  s := '';
  with qry1 do
  begin
    Active := False;
    SQL.Clear;
    SQL.Add('select StreetID, StreetName from street where StreetID>1 order by StreetName');
    Active := true;
  end;
  while not qry1.Eof do
  begin
    NodeStreet := TreeViewSiteList.Items.AddChild(TreeViewSiteList.Items[0], qry1.FieldByName('StreetName').AsString);
    NodeStreet.ImageIndex := 1;
    NodeStreet.SelectedIndex := 1;
    SiteTreeAddChild(NodeStreet, '=' + qry1.FieldByName('StreetID').AsString);
    if s='' then
      s := qry1.FieldByName('StreetID').AsString
    else
      s := s + ', ' + qry1.FieldByName('StreetID').AsString;
    qry1.Next;
  end;

  with qry2 do
  begin
    Active := False;
    SQL.Clear;
    SQL.Add('select count(SiteID) from site where StreetID not in (' + s + ')');
    Active := true;
毕业论文http://www.youerw.com  end;
  if qry2.Fields[0].AsInteger > 0 then
  begin
    //if MessageBox(Handle, '终端站点丢失,请检查数据库。' + #13#10 +
    //  '是否自动修复?', '数据库不匹配', MB_YESNO + MB_ICONSTOP +
    //  MB_DEFBUTTON2 + MB_TOPMOST) = mrYes then
    //    MessageBox(Handle, '功能尚未添加,敬请期待。', '程序员快累死了', MB_OK +
    //      MB_ICONINFORMATION + MB_DEFBUTTON2 + MB_TOPMOST);
    SiteTreeAddChild(TreeViewSiteList.Items[0], ' not in (' + s +')');
  end;

  TreeViewSiteList.Items[0].Expand(True);
  TreeViewSiteList.Selected := TreeViewSiteList.Items[0];
end;

procedure TFormMain.MapReposition;
//var
//  i: integer;
begin
  if ImageMap.Width > PanelMap.Width then
  begin
    if ImageMap.Left > 0 then ImageMap.Left := 0;
    if PanelMap.Width - ImageMap.Left > ImageMap.Width then ImageMap.Left := PanelMap.Width - ImageMap.Width;
  end
  else
  begin
    if ImageMap.Left < 0 then ImageMap.Left := 0;
    if PanelMap.Width - ImageMap.Left < ImageMap.Width then ImageMap.Left := PanelMap.Width - ImageMap.Width;
  end;

  if ImageMap.Height > PanelMap.Height then
  begin
    if ImageMap.Top > 0 then ImageMap.Top := 0;
    if PanelMap.Height - ImageMap.Top > ImageMap.Height then ImageMap.Top := PanelMap.Height - ImageMap.Height;
  end
  else
  begin
    if ImageMap.Top < 0 then ImageMap.Top := 0;
    if PanelMap.Height - ImageMap.Top < ImageMap.Height then ImageMap.Top := PanelMap.Height - ImageMap.Height;
  end;

  {for i:=0 to SiteMap.Count-1 do
  begin
    SiteMap.Items[i].ShapeSite.Left := trunc(SiteMap.Items[i].Pos.X * MapRate[FormMain.ZoomRate]) + ImageMap.Left;
    SiteMap.Items[i].ShapeSite.Top  := trunc(SiteMap.Items[i].Pos.Y * MapRate[FormMain.ZoomRate]) + ImageMap.Top;
    SiteMap.Items[i].LabelSite.Left := SiteMap.Items[i].ShapeSite.Left + 18;
    SiteMap.Items[i].LabelSite.Top  := SiteMap.Items[i].ShapeSite.Top  + 2;
  end;}
end;

procedure TFormMain.PanelMapResize(Sender: TObject);
begin
  MapReposition;
  RefreshShapeNav;
  //RefreshControlCenter;
end;

procedure TFormMain.RefreshShapeNav;
begin
  ShapeNav.Width  := PanelMap.Width  * 240 div ImageMap.Width;
  ShapeNav.Height := PanelMap.Height * 181 div ImageMap.Height;
  ShapeNav.Left   := -ImageMap.Left  * 240 div ImageMap.Width;
  ShapeNav.Top    := -ImageMap.Top   * 181 div ImageMap.Height + ImageNav.Top;
end;

procedure TFormMain.TreeViewSiteListDblClick(Sender: TObject);
begin
  //TreeViewSiteList.Selected.AbsoluteIndex
  //TreeViewSiteList.Items.Insert(TreeViewSiteList.Selected, '这里插入了一个');
毕业论文http://www.youerw.comconstructor TChartSiteList.Create;
var
  i: integer;
  //j: Integer;
begin
  FormMain.ScrollBoxChart.HorzScrollBar.Position := 0;
  FormMain.ScrollBoxChart.VertScrollBar.Position := 0;

  Count := soList.Count;
  SetLength(Items, Count);

  for I := 0 to Count - 1 do
  begin
    Items[i] := TChartSiteItem.Create;
    Items[i].SiteName    := soList.Items[i].SiteName;
    Items[i].SiteAddress := soList.Items[i].SiteAddress;
  end;
  //j := 0;
  {for i:=1 to SiteMaxCount do
  begin
    if SiteList.Items[i]<>nil then
    begin
      if Items[j]=nil then Items[j] := TSiteChartItem.Create;
      Items[j].SiteCode := i;
      Items[j].SiteName := SiteList.Items[i].SiteName;
      Items[j].PanelChart.Top := j*20;
      Items[j].PanelChart.Caption := Format(' %03d  '+Items[j].SiteName, [Items[j].SiteCode]);
      j := j + 1;
    end;

上一页  [1] [2] 

城市路灯智能监控管理系统源码 第2页下载如图片无法显示或论文不完整,请联系qq752018766
设为首页 | 联系站长 | 友情链接 | 网站地图 |

copyright©youerw.com 优文论文网 严禁转载
如果本毕业论文网损害了您的利益或者侵犯了您的权利,请及时联系,我们一定会及时改正。