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

📄 mainunit.~pas

📁 发射台 控制台 dephi编写 大家可以随便可看看, 可以做dephi入门实例学习
💻 ~PAS
📖 第 1 页 / 共 5 页
字号:
var
  sList : TStrings;
begin
//    self.Timer1.Enabled := false;
  sList := TStringList.Create;
  sList.Add(self.BoxA1.Text);
  sList.Add(self.BoxA3.Text);
  sList.Add(self.BoxA4.Text);
  sList.Add(self.BoxA5.Text);
  sList.Add(self.BoxA6.Text);
  self.RefreshAInUseList;
  self.RefreshComBoxList(1);
  if sList.Strings[0] = self.BoxA2.Text then
    begin
      self.BoxA1.ItemIndex := 0;
    end else
    begin
      self.BoxA1.ItemIndex := FindSInSlist(sList.Strings[0], self.BoxA1.Items);
    end;
  if sList.Strings[1] = self.BoxA2.Text then
    begin
      self.BoxA3.ItemIndex := 0;
    end else
    begin
      self.BoxA3.ItemIndex := FindSInSlist(sList.Strings[1], self.BoxA3.Items);
    end;
  if sList.Strings[2] = self.BoxA2.Text then
    begin
      self.BoxA4.ItemIndex := 0;
    end else
    begin
      self.BoxA4.ItemIndex := FindSInSlist(sList.Strings[2], self.BoxA4.Items);
    end;
  if sList.Strings[3] = self.BoxA2.Text then
    begin
      self.BoxA5.ItemIndex := 0;
    end else
    begin
      self.BoxA5.ItemIndex := FindSInSlist(sList.Strings[3], self.BoxA5.Items);
    end;
  if sList.Strings[4] = self.BoxA2.Text then
    begin
      self.BoxA6.ItemIndex := 0;
    end else
    begin
      self.BoxA6.ItemIndex := FindSInSlist(sList.Strings[4], self.BoxA6.Items);
    end;
    sList.Free;
//    self.Timer1.Enabled := true;
end;

procedure TFrmMain.BoxA3Click(Sender: TObject);
var
  sList : TStrings;
begin
//     self.Timer1.Enabled := false;
 sList := TStringList.Create;
  sList.Add(self.BoxA1.Text);
  sList.Add(self.BoxA2.Text);
  sList.Add(self.BoxA4.Text);
  sList.Add(self.BoxA5.Text);
  sList.Add(self.BoxA6.Text);
  self.RefreshAInUseList;
  self.RefreshComBoxList(2);
  if sList.Strings[0] = self.BoxA3.Text then
    begin
      self.BoxA1.ItemIndex := 0;
    end else
    begin
      self.BoxA1.ItemIndex := FindSInSlist(sList.Strings[0], self.BoxA1.Items);
    end;
  if sList.Strings[1] = self.BoxA3.Text then
    begin
      self.BoxA2.ItemIndex := 0;
    end else
    begin
      self.BoxA2.ItemIndex := FindSInSlist(sList.Strings[1], self.BoxA2.Items);
    end;
  if sList.Strings[2] = self.BoxA3.Text then
    begin
      self.BoxA4.ItemIndex := 0;
    end else
    begin
      self.BoxA4.ItemIndex := FindSInSlist(sList.Strings[2], self.BoxA4.Items);
    end;
  if sList.Strings[3] = self.BoxA3.Text then
    begin
      self.BoxA5.ItemIndex := 0;
    end else
    begin
      self.BoxA5.ItemIndex := FindSInSlist(sList.Strings[3], self.BoxA5.Items);
    end;
  if sList.Strings[4] = self.BoxA3.Text then
    begin
      self.BoxA6.ItemIndex := 0;
    end else
    begin
      self.BoxA6.ItemIndex := FindSInSlist(sList.Strings[4], self.BoxA6.Items);
    end;
    sList.Free;
//    self.Timer1.Enabled := true;
end;

procedure TFrmMain.BoxA4Click(Sender: TObject);
var
  sList : TStrings;
begin
//    self.Timer1.Enabled := false;
  sList := TStringList.Create;
  sList.Add(self.BoxA1.Text);
  sList.Add(self.BoxA2.Text);
  sList.Add(self.BoxA3.Text);
  sList.Add(self.BoxA5.Text);
  sList.Add(self.BoxA6.Text);
  self.RefreshAInUseList;
  self.RefreshComBoxList(3);
  if sList.Strings[0] = self.BoxA4.Text then
    begin
      self.BoxA1.ItemIndex := 0;
    end else
    begin
      self.BoxA1.ItemIndex := FindSInSlist(sList.Strings[0], self.BoxA1.Items);
    end;
  if sList.Strings[1] = self.BoxA4.Text then
    begin
      self.BoxA2.ItemIndex := 0;
    end else
    begin
      self.BoxA2.ItemIndex := FindSInSlist(sList.Strings[1], self.BoxA2.Items);
    end;
  if sList.Strings[2] = self.BoxA4.Text then
    begin
      self.BoxA3.ItemIndex := 0;
    end else
    begin
      self.BoxA3.ItemIndex := FindSInSlist(sList.Strings[2], self.BoxA3.Items);
    end;
  if sList.Strings[3] = self.BoxA4.Text then
    begin
      self.BoxA5.ItemIndex := 0;
    end else
    begin
      self.BoxA5.ItemIndex := FindSInSlist(sList.Strings[3], self.BoxA5.Items);
    end;
  if sList.Strings[4] = self.BoxA4.Text then
    begin
      self.BoxA6.ItemIndex := 0;
    end else
    begin
      self.BoxA6.ItemIndex := FindSInSlist(sList.Strings[4], self.BoxA6.Items);
    end;
    sList.Free;
//    self.Timer1.Enabled := true;
end;


procedure TFrmMain.BoxA5Click(Sender: TObject);
var
  sList : TStrings;
begin
//    self.Timer1.Enabled := false;
  sList := TStringList.Create;
  sList.Add(self.BoxA1.Text);
  sList.Add(self.BoxA2.Text);
  sList.Add(self.BoxA3.Text);
  sList.Add(self.BoxA4.Text);
  sList.Add(self.BoxA6.Text);
  self.RefreshAInUseList;
  self.RefreshComBoxList(4);
  if sList.Strings[0] = self.BoxA5.Text then
    begin
      self.BoxA1.ItemIndex := 0;
    end else
    begin
      self.BoxA1.ItemIndex := FindSInSlist(sList.Strings[0], self.BoxA1.Items);
    end;
  if sList.Strings[1] = self.BoxA5.Text then
    begin
      self.BoxA2.ItemIndex := 0;
    end else
    begin
      self.BoxA2.ItemIndex := FindSInSlist(sList.Strings[1], self.BoxA2.Items);
    end;
  if sList.Strings[2] = self.BoxA5.Text then
    begin
      self.BoxA3.ItemIndex := 0;
    end else
    begin
      self.BoxA3.ItemIndex := FindSInSlist(sList.Strings[2], self.BoxA3.Items);
    end;
  if sList.Strings[3] = self.BoxA5.Text then
    begin
      self.BoxA4.ItemIndex := 0;
    end else
    begin
      self.BoxA4.ItemIndex := FindSInSlist(sList.Strings[3], self.BoxA4.Items);
    end;
  if sList.Strings[4] = self.BoxA5.Text then
    begin
      self.BoxA6.ItemIndex := 0;
    end else
    begin
      self.BoxA6.ItemIndex := FindSInSlist(sList.Strings[4], self.BoxA6.Items);
    end;
    sList.Free;
//    self.Timer1.Enabled := true;
end;

procedure TFrmMain.BoxA6Click(Sender: TObject);
var
  sList : TStrings;
begin
//    self.Timer1.Enabled := false;
  sList := TStringList.Create;
  sList.Add(self.BoxA1.Text);
  sList.Add(self.BoxA2.Text);
  sList.Add(self.BoxA3.Text);
  sList.Add(self.BoxA4.Text);
  sList.Add(self.BoxA5.Text);
  self.RefreshAInUseList;
  self.RefreshComBoxList(5);
  if sList.Strings[0] = self.BoxA6.Text then
    begin
      self.BoxA1.ItemIndex := 0;
    end else
    begin
      self.BoxA1.ItemIndex := FindSInSlist(sList.Strings[0], self.BoxA1.Items);
    end;
  if sList.Strings[1] = self.BoxA6.Text then
    begin
      self.BoxA2.ItemIndex := 0;
    end else
    begin
      self.BoxA2.ItemIndex := FindSInSlist(sList.Strings[1], self.BoxA2.Items);
    end;
  if sList.Strings[2] = self.BoxA6.Text then
    begin
      self.BoxA3.ItemIndex := 0;
    end else
    begin
      self.BoxA3.ItemIndex := FindSInSlist(sList.Strings[2], self.BoxA3.Items);
    end;
  if sList.Strings[3] = self.BoxA6.Text then
    begin
      self.BoxA4.ItemIndex := 0;
    end else
    begin
      self.BoxA4.ItemIndex := FindSInSlist(sList.Strings[3], self.BoxA4.Items);
    end;
  if sList.Strings[4] = self.BoxA6.Text then
    begin
      self.BoxA5.ItemIndex := 0;
    end else
    begin
      self.BoxA5.ItemIndex := FindSInSlist(sList.Strings[4], self.BoxA5.Items);
    end;
    sList.Free;
//    self.Timer1.Enabled := true;
end;


procedure TFrmMain.BtnModifyClick(Sender: TObject);
var
  cRow, cCol, index, i, j : integer;
  RootNode, CurNode : IXMLNode;
begin
//  self.Timer1.Enabled := false;
  cCol := self.StringGrid1.Selection.Left;
  cRow := self.StringGrid1.Selection.Top;
  if self.StringGrid1.ColCount -1 - cCol < 2 then
    begin
      ShowMessage('您选择的是无效区域!');
//      self.Timer1.Enabled := true;
      exit;
    end;
  if self.StringGrid1.RowCount -1 - cRow < 2 then
    begin
      ShowMessage('您选择的是无效区域!');
//      self.Timer1.Enabled := true;
      exit;
    end;

  j := 0;
  for i := 0 to 5 do
    begin
      if self.StringGrid1.Cells[cCol, i+1] <> '' then
        begin
          j := 1;
          break;
        end;
    end;
  if j = 0 then  //如果选中的区域整列都为空,自动切换为新增
    begin
      self.BtnAddClick(sender);
      self.DTSwitch.Time := StrToTime(self.StringGrid1.Cells[cCol, 0]);
 //     self.Timer1.Enabled := true;
     exit;
    end;

  try
    self.DTSwitch.Time := StrToTime(self.StringGrid1.Cells[cCol, 0]);
    self.ClearComBox;

    if self.XMLDocument1.Active = true then
    begin
      self.XMLDocument1.Active := false;
    end;
    self.XMLDocument1.FileName := RunMapFileName;
    self.XMLDocument1.Active := true;
    RootNode := self.XMLDocument1.DocumentElement;

    index := IndexInFile[0][cCol-1];
    if index >0 then
      begin
        CurNode := RootNode.ChildNodes.Get(index-1);
        self.BoxA1.ItemIndex := self.FindSInSList(CurNode.Attributes['AName'], self.BoxA1.Items);
        self.BoxA1Click(nil);
      end;

    index := IndexInFile[1][cCol-1];
    if index >0 then
      begin
        CurNode := RootNode.ChildNodes.Get(index-1);
        self.BoxA2.ItemIndex := self.FindSInSList(CurNode.Attributes['AName'], self.BoxA2.Items);
        self.BoxA2Click(nil);
      end;

    index := IndexInFile[2][cCol-1];
    if index >0 then
      begin
        CurNode := RootNode.ChildNodes.Get(index-1);
        self.BoxA3.ItemIndex := self.FindSInSList(CurNode.Attributes['AName'], self.BoxA3.Items);
        self.BoxA3Click(nil);
      end;

    index := IndexInFile[3][cCol-1];
    if index >0 then
      begin
        CurNode := RootNode.ChildNodes.Get(index-1);
        self.BoxA4.ItemIndex := self.FindSInSList(CurNode.Attributes['AName'], self.BoxA4.Items);
        self.BoxA4Click(nil);
      end;
 
    index := IndexInFile[4][cCol-1];
    if index >0 then
      begin
        CurNode := RootNode.ChildNodes.Get(index-1);
        self.BoxA5.ItemIndex := self.FindSInSList(CurNode.Attributes['AName'], self.BoxA5.Items);
        self.BoxA5Click(nil);
      end;

    index := IndexInFile[5][cCol-1];
    if index >0 then
      begin
        CurNode := RootNode.ChildNodes.Get(index-1);
        self.BoxA6.ItemIndex := self.FindSInSList(CurNode.Attributes['AName'], self.BoxA6.Items);
        self.BoxA6Click(nil);
      end;
    self.OperateType := 1;
    self.BtnStateSwitch(false);
//    self.DTSwitch.Enabled := true;
//    self.Timer1.Enabled := true;
  except
    ShowMessage('修改初始化信息失败!');
//    self.Timer1.Enabled := true;
    self.DTSwitch.Enabled := true;
    self.BtnStateSwitch(true);
    exit;
  end;


end;

procedure TFrmMain.BtnDeleteClick(Sender: TObject);
var
  cRow, cCol, i : integer;
  RootNode : IXMLNode;
  myRect: TGridRect;
begin
//    self.Timer1.Enabled := false;
  cCol := self.StringGrid1.Selection.Left;
  cRow := self.StringGrid1.Selection.Top;
  if self.StringGrid1.ColCount -1 - cCol < 2 then
    begin
      ShowMessage('您选择的是无效区域!');
//    self.Timer1.Enabled := true;
      exit;
    end;
  if self.StringGrid1.RowCount -1 - cRow < 2 then
    begin
      ShowMessage('您选择的是无效区域!');
//     self.Timer1.Enabled := true;
     exit;
    end;

  if self.StringGrid1.Cells[cCol, cRow] = '' then
    begin
//     self.Timer1.Enabled := true;
      myRect.Left := cCol;
      myRect.Top := cRow+1;
      myRect.Right := cCol;
      myRect.Bottom := cRow+1;
      self.StringGrid1.Selection := myRect;
      exit;
    end;
  i := IndexInFile[cRow-1][cCol-1];
  try
    if self.XMLDocument1.Active = true then
    begin
      self.XMLDocument1.Active := false;
    end;
    self.XMLDocument1.FileName := RunMapFileName;
    self.XMLDocument1.Active := true;
    RootNode := self.XMLDocument1.DocumentElement;
    RootNode.ChildNodes.Delete(i-1);
    self.XMLDocument1.SaveToFile();
    self.XMLDocument1.Active := false;
    self.RefreshDBGrid;

⌨️ 快捷键说明

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