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

📄 ilcdmatrixcomponenteditor.pas

📁 iocopm3.04源码,一套很好的工控开发工具
💻 PAS
📖 第 1 页 / 共 2 页
字号:
  UpdateFrameRateEdit.AsInteger             := iLCDMatrix.UpdateFrameRate;

  UpLoadOPCProperties(iLCDMatrix, iOPCBrowserPanel);

  for x := 0 to 255 do
    (FCharacterList.Objects[x] as TiLCDCharacter).Assign(TiLCDMatrixAccess(iLCDMatrix).CharacterObject[x]);

  CharactersetNameLabel.Caption := iLCDMatrix.CharactersetName;

  CharactersetCharactorCodeEdit.AsInteger := FLastCharacterCode;
  CharactersetSizeUpdate(Self);
  CharactersetCharactorCodeEditUpdate(Self);
end;
//****************************************************************************************************************************************************
procedure TiLCDMatrixComponentEditorForm.CopyPropertiesToComponent(Component: TWinControl);
var
  x          : Integer;
  iLCDMatrix : TiLCDMatrix;
begin
  iLCDMatrix := Component as TiLCDMatrix;

  iLCDMatrix.Text                 :=  TextEdit.AsString;
  iLCDMatrix.CellsColorOn         :=  CellsColorOnPicker.Color;
  iLCDMatrix.CellsColorOff        :=  CellsColorOffPicker.Color;
  iLCDMatrix.CellsShowOff         :=  CellsShowOffCheckBox.AsBoolean;
  iLCDMatrix.CellsWidth           :=  CellsWidthEdit.AsInteger;
  iLCDMatrix.CellsSpacingHorz     :=  CellsSpacingHorzEdit.AsInteger;
  iLCDMatrix.CellsSpacingVert     :=  CellsSpacingVertEdit.AsInteger;

  iLCDMatrix.CharactersetWidth    :=  CharactersetWidthEdit.AsInteger;
  iLCDMatrix.CharactersetHeight   :=  CharactersetHeightEdit.AsInteger;

  iLCDMatrix.CharacterSpacingHorz :=  CharacterSpacingHorzEdit.AsInteger;
  iLCDMatrix.CharacterSpacingVert :=  CharacterSpacingVertEdit.AsInteger;

  iLCDMatrix.OuterMarginTop       :=  OuterMarginTopEdit.AsInteger;
  iLCDMatrix.OuterMarginBottom    :=  OuterMarginBottomEdit.AsInteger;
  iLCDMatrix.OuterMarginLeft      :=  OuterMarginLeftEdit.AsInteger;
  iLCDMatrix.OuterMarginRight     :=  OuterMarginRightEdit.AsInteger;

  iLCDMatrix.BackGroundColor      :=  BackGroundColorPicker.Color;
  iLCDMatrix.BorderStyle          :=  TiBevelStyle(BorderStyleRadioGroup.AsInteger);
  iLCDMatrix.AutoFrameRate        :=  AutoFrameRateCheckBox.AsBoolean;
  iLCDMatrix.UpdateFrameRate      :=  UpdateFrameRateEdit.AsInteger;

  for x := 0 to 255 do
    TiLCDMatrixAccess(iLCDMatrix).CharacterObject[x].Assign((FCharacterList.Objects[x] as TiLCDCharacter));

  TiLCDMatrixAccess(iLCDMatrix).SetCharactersetName(CharactersetNameLabel.Caption);

  FLastCharacterCode := CharactersetCharactorCodeEdit.AsInteger;

  DownLoadOPCProperties(iLCDMatrix, iOPCBrowserPanel);

  iLCDMatrix.Invalidate;
end;
//****************************************************************************************************************************************************
procedure TiLCDMatrixComponentEditorForm.CharactersetSizeUpdate(Sender: TObject);
var
  x : Integer;
begin
  CharacterMatrixEditor.IndicatorWidth  := (CharacterMatrixEditor.Width  - (CharactersetWidthEdit.AsInteger  - 1)) div CharactersetWidthEdit.AsInteger;
  CharacterMatrixEditor.IndicatorHeight := (CharacterMatrixEditor.Height - (CharactersetHeightEdit.AsInteger - 1)) div CharactersetHeightEdit.AsInteger;

  CharacterMatrixEditor.ColCount := CharactersetWidthEdit.AsInteger;
  CharacterMatrixEditor.RowCount := CharactersetHeightEdit.AsInteger;

  for x := 0 to FCharacterList.Count-1 do
    (FCharacterList.Objects[x] as TiLCDCharacter).RowCount := CharactersetHeightEdit.AsInteger;
end;
//****************************************************************************************************************************************************
procedure TiLCDMatrixComponentEditorForm.LoadDefaultCharactersetButtonClick(Sender: TObject);
var
  x : Integer;
begin
  for x := 0 to FCharacterList.Count-1 do
    (FCharacterList.Objects[x] as TiLCDCharacter).LoadDefault(x);

  CharactersetNameLabel.Caption := '(Default)';

  Modified := True;
end;
//****************************************************************************************************************************************************
procedure TiLCDMatrixComponentEditorForm.CharactersetCharactorCodeEditUpdate(Sender: TObject);
var
  Row     : Integer;
  Col     : Integer;
  RowData : Integer;
begin
  for Row := 0 to CharactersetHeightEdit.AsInteger-1 do
    begin
      RowData := (FCharacterList.Objects[CharactersetCharactorCodeEdit.AsInteger] as TiLCDCharacter).GetRowData(Row);
      for Col := 0 to CharactersetWidthEdit.AsInteger-1 do
        CharacterMatrixEditor.IndicatorActive[Row, Col] := RowData and (1 shl (CharactersetWidthEdit.AsInteger - Col -1)) > 0;
    end;
end;
//****************************************************************************************************************************************************
procedure TiLCDMatrixComponentEditorForm.CharacterMatrixEditorClickIndicator(Row, Col: Integer);
var
  CurrentCol  : Integer;
  NewRowValue : Integer;
begin
  CharacterMatrixEditor.IndicatorActive[Row, Col] := not CharacterMatrixEditor.IndicatorActive[Row, Col];

  NewRowValue := 0;
  for CurrentCol := 0 to CharactersetWidthEdit.AsInteger-1 do                              
    if CharacterMatrixEditor.IndicatorActive[Row, CurrentCol] then
      NewRowValue := NewRowValue + (1 shl (CharactersetWidthEdit.AsInteger - CurrentCol -1));

  (FCharacterList.Objects[CharactersetCharactorCodeEdit.AsInteger] as TiLCDCharacter).SetRowData(Row, NewRowValue);
  Modified := True;
end;
//****************************************************************************************************************************************************
procedure TiLCDMatrixComponentEditorForm.CharacterserLoadPickerChange(Sender: TObject);
var
  x            : Integer;
  Row          : Integer;
  StringList   : TStringList;
  NewWidth     : Integer;
  NewHeight    : Integer;
  CurrentIndex : Integer;
begin
  StringList := TStringList.Create;
  try
    StringList.LoadFromFile(CharacterserLoadPicker.FileName);

    CurrentIndex := 0;

    NewWidth  := StrToInt(StringList.Strings[CurrentIndex]); Inc(CurrentIndex);
    NewHeight := StrToInt(StringList.Strings[CurrentIndex]); Inc(CurrentIndex);

    if (NewHeight*256 + 2) <> StringList.Count then raise Exception.Create('Invalid Characterset File Format');

    CharactersetNameLabel.Caption := ExtractFileName(CharacterserLoadPicker.FileName);

    CharactersetWidthEdit.AsInteger  := NewWidth;
    CharactersetHeightEdit.AsInteger := NewHeight;
    CharactersetSizeUpdate(Self);

    for x := 0 to 255 do
      for Row := 0 to NewHeight-1 do
        begin
          (FCharacterList.Objects[x] as TiLCDCharacter).RowCount := NewHeight;
          (FCharacterList.Objects[x] as TiLCDCharacter).SetRowData(Row, StrToInt(StringList.Strings[CurrentIndex]));
          Inc(CurrentIndex);
        end;

    CharactersetCharactorCodeEditUpdate(Self);

  finally
    StringList.Free;
  end;
end;
//****************************************************************************************************************************************************
procedure TiLCDMatrixComponentEditorForm.CharacterserSavePickerChange(Sender: TObject);
var
  x          : Integer;
  Row        : Integer;
  StringList : TStringList;
begin
  StringList := TStringList.Create;
  try
    StringList.Add(IntToStr(CharactersetWidthEdit.AsInteger));
    StringList.Add(IntToStr(CharactersetHeightEdit.AsInteger));

    for x := 0 to 255 do
      for Row := 0 to CharactersetHeightEdit.AsInteger-1 do
        StringList.Add(IntToStr((FCharacterList.Objects[x] as TiLCDCharacter).GetRowData(Row)));

    StringList.SaveToFile(CharacterserSavePicker.FileName);

    CharactersetNameLabel.Caption := ExtractFileName(CharacterserSavePicker.FileName);
  finally
    StringList.Free;
  end;
end;
//****************************************************************************************************************************************************
end.

⌨️ 快捷键说明

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