mirror of
http://gitlab.expertsoft.com.ua/git/expertcad
synced 2026-01-11 17:25:39 +02:00
816 lines
28 KiB
ObjectPascal
816 lines
28 KiB
ObjectPascal
unit U_MarkMask;
|
||
|
||
interface
|
||
|
||
uses
|
||
Windows, U_LNG, Messages, SysUtils, Variants, Classes, Contnrs, Graphics, Controls, Forms,
|
||
Dialogs, cxLookAndFeelPainters, cxTextEdit, cxControls, cxContainer,
|
||
U_Common_Classes, cxEdit, cxCheckBox, StdCtrls, cxButtons, ExtCtrls, RzPanel, cxMaskEdit,
|
||
cxSpinEdit,
|
||
|
||
U_BaseCommon, U_BaseConstants, siComp, siLngLnk, RzButton, RzRadChk,
|
||
cxGraphics, cxLookAndFeels, Menus;
|
||
|
||
type
|
||
TMarkControlsGroup = class(TObject)
|
||
protected
|
||
procedure SetCheckBoxVal(ACheckBox: TRzCheckBox; AVal: Boolean);
|
||
public
|
||
FChecked: TRzCheckBox;
|
||
FValue: TcxTextEdit;
|
||
FExampleValue: TControl;
|
||
FMinLen: TcxSpinEdit;
|
||
FLetter: TRzCheckBox;
|
||
FSimpleText: TcxTextEdit;
|
||
FObjectPrefix: Char;
|
||
|
||
procedure SetCheckedValue(AValue: Boolean);
|
||
procedure SetLetterValue(AValue: Boolean);
|
||
procedure SetMinLenValue(AValue: Double);
|
||
end;
|
||
|
||
TF_MarkMask = class(TForm)
|
||
RzPanel1: TRzPanel;
|
||
pnOkCancel: TRzPanel;
|
||
Button_OK: TcxButton;
|
||
Button_Cancel: TcxButton;
|
||
RzGroupBox1: TRzGroupBox;
|
||
RzGroupBox2: TRzGroupBox;
|
||
Label2: TLabel;
|
||
Edit_Example: TcxTextEdit;
|
||
Label3: TLabel;
|
||
Edit_Result: TcxTextEdit;
|
||
lng_Forms: TsiLangLinked;
|
||
CheckBox_Project: TRzCheckBox;
|
||
CheckBox_List: TRzCheckBox;
|
||
CheckBox_Room: TRzCheckBox;
|
||
CheckBox_Object: TRzCheckBox;
|
||
CheckBox_TopComponent: TRzCheckBox;
|
||
CheckBox_Component: TRzCheckBox;
|
||
CheckBox_ComponPort: TRzCheckBox;
|
||
CheckBox_NameShort: TRzCheckBox;
|
||
Label4: TLabel;
|
||
Label5: TLabel;
|
||
Label6: TLabel;
|
||
edSimpleTextBefore: TcxTextEdit;
|
||
Label1: TLabel;
|
||
Edit_ProjValue: TcxTextEdit;
|
||
Edit_ListValue: TcxTextEdit;
|
||
Edit_RoomValue: TcxTextEdit;
|
||
Edit_ObjectValue: TcxTextEdit;
|
||
Edit_ComponValue: TcxTextEdit;
|
||
Edit_NameShortValue: TcxTextEdit;
|
||
Edit_ComponPort: TcxTextEdit;
|
||
Edit_TopComponValue: TcxTextEdit;
|
||
spMinLenProj: TcxSpinEdit;
|
||
spMinLenList: TcxSpinEdit;
|
||
spMinLenRoom: TcxSpinEdit;
|
||
spMinLenObject: TcxSpinEdit;
|
||
spMinLenCompon: TcxSpinEdit;
|
||
spMinLenComponPort: TcxSpinEdit;
|
||
spMinLenTopCompon: TcxSpinEdit;
|
||
edSimpleTextProj: TcxTextEdit;
|
||
edSimpleTextList: TcxTextEdit;
|
||
edSimpleTextRoom: TcxTextEdit;
|
||
edSimpleTextObject: TcxTextEdit;
|
||
edSimpleTextCompon: TcxTextEdit;
|
||
edSimpleTextNameShort: TcxTextEdit;
|
||
edSimpleTextComponPort: TcxTextEdit;
|
||
edSimpleTextTopCompon: TcxTextEdit;
|
||
SpinEdit_ProjExValue: TcxSpinEdit;
|
||
SpinEdit_ListExValue: TcxSpinEdit;
|
||
SpinEdit_RoomExValue: TcxSpinEdit;
|
||
SpinEdit_ObjExValue: TcxSpinEdit;
|
||
SpinEdit_ComponExValue: TcxSpinEdit;
|
||
Edit_NameShortExValue: TcxTextEdit;
|
||
SpinEdit_ComponPortExValue: TcxSpinEdit;
|
||
SpinEdit_TopComponExValue: TcxSpinEdit;
|
||
cbParentComponent: TRzCheckBox;
|
||
edParentComponValue: TcxTextEdit;
|
||
spMinLenParentCompon: TcxSpinEdit;
|
||
edSimpleTextParentCompon: TcxTextEdit;
|
||
seParentComponExValue: TcxSpinEdit;
|
||
Label7: TLabel;
|
||
cbLetterProj: TRzCheckBox;
|
||
cbLetterList: TRzCheckBox;
|
||
cbLetterRoom: TRzCheckBox;
|
||
cbLetterObject: TRzCheckBox;
|
||
cbLetterTopCompon: TRzCheckBox;
|
||
cbLetterParentCompon: TRzCheckBox;
|
||
cbLetterCompon: TRzCheckBox;
|
||
cbLetterComponPort: TRzCheckBox;
|
||
ForAllObjOnList: TRzCheckBox;
|
||
OnlyForSelectedObj: TRzCheckBox;
|
||
RzBitBtn1: TRzBitBtn;
|
||
procedure CheckBox_ElementChange(Sender: TObject);
|
||
procedure Edit_ResultKeyUp(Sender: TObject; var Key: Word;
|
||
Shift: TShiftState);
|
||
procedure Edit_ProjValueKeyUp(Sender: TObject; var Key: Word;
|
||
Shift: TShiftState);
|
||
procedure Edit_NameShortExValueKeyUp(Sender: TObject; var Key: Word;
|
||
Shift: TShiftState);
|
||
procedure FormCreate(Sender: TObject);
|
||
procedure FormDestroy(Sender: TObject);
|
||
procedure pnOkCancelResize(Sender: TObject);
|
||
procedure spMinLenPropertiesChange(Sender: TObject);
|
||
procedure edSimpleTexKeyUp(Sender: TObject; var Key: Word;
|
||
Shift: TShiftState);
|
||
procedure SpinEdit_ProjExValuePropertiesChange(Sender: TObject);
|
||
procedure Edit_ResultPropertiesChange(Sender: TObject);
|
||
procedure cbLetterClick(Sender: TObject);
|
||
procedure FormShow(Sender: TObject);
|
||
procedure ForAllObjOnListClick(Sender: TObject);
|
||
procedure RzBitBtn1Click(Sender: TObject);
|
||
private
|
||
{ Private declarations }
|
||
|
||
FControlGroups: TObjectList;
|
||
|
||
procedure AddControlsToGroup(ACheck, AValue, AExamplValue, AMinLen, ALetter, ASimpleText: TControl; AObjPrefix: Char);
|
||
function GetMarkControlGroupByPrefix(APrefix: Char): TMarkControlsGroup;
|
||
function GetElementBlock(APrefix: Char; AMinLen, ALetter: Integer): String;
|
||
public
|
||
GForm: TForm;
|
||
GFormMode: TFormMode;
|
||
|
||
constructor Create(AOwner: TComponent; AForm: TForm);
|
||
destructor Destroy; override;
|
||
|
||
function MakeEditMarkMask(AFormMode: TFormMode; var AMask: String): Boolean;
|
||
procedure DivideMask(const AMask: String; ASetToResult: Boolean);
|
||
procedure BuildMask;
|
||
procedure BuildExample;
|
||
procedure AfterCheckBoxChange(ACheckBox, AEditValue, AEditBoxWithExValue: TObject);
|
||
procedure OnChangeTemplateParam(AControl: TObject);
|
||
end;
|
||
|
||
//var
|
||
//F_MarkMask: TF_MarkMask;
|
||
|
||
implementation
|
||
|
||
uses U_SCSComponent, U_Main;
|
||
|
||
{$R *.dfm}
|
||
|
||
{ TMarkControlsGroup }
|
||
|
||
procedure TMarkControlsGroup.SetCheckBoxVal(ACheckBox: TRzCheckBox; AVal: Boolean);
|
||
var
|
||
SavedOnClick: TNotifyEvent;
|
||
begin
|
||
SavedOnClick := ACheckBox.OnClick;
|
||
try
|
||
ACheckBox.OnClick := nil;
|
||
ACheckBox.Checked := AVal;
|
||
finally
|
||
ACheckBox.OnClick := SavedOnClick;
|
||
end;
|
||
end;
|
||
|
||
procedure TMarkControlsGroup.SetCheckedValue(AValue: Boolean);
|
||
begin
|
||
SetCheckBoxVal(FChecked, AValue);
|
||
end;
|
||
|
||
procedure TMarkControlsGroup.SetLetterValue(AValue: Boolean);
|
||
begin
|
||
SetCheckBoxVal(FLetter, AValue);
|
||
end;
|
||
|
||
procedure TMarkControlsGroup.SetMinLenValue(AValue: Double);
|
||
var
|
||
SavedOnChange: TNotifyEvent;
|
||
begin
|
||
SavedOnChange := FMinLen.Properties.OnChange;
|
||
try
|
||
FMinLen.Properties.OnChange := nil;
|
||
FMinLen.Value := AValue;
|
||
finally
|
||
FMinLen.Properties.OnChange := SavedOnChange;
|
||
end;
|
||
end;
|
||
|
||
|
||
procedure TF_MarkMask.AddControlsToGroup(ACheck, AValue, AExamplValue, AMinLen, ALetter, ASimpleText: TControl; AObjPrefix: Char);
|
||
var
|
||
MarkControlsGroup: TMarkControlsGroup;
|
||
begin
|
||
MarkControlsGroup := TMarkControlsGroup.Create;
|
||
MarkControlsGroup.FChecked := TRzCheckBox(ACheck);
|
||
MarkControlsGroup.FValue := TcxTextEdit(AValue);
|
||
MarkControlsGroup.FExampleValue := AExamplValue;
|
||
MarkControlsGroup.FMinLen := TcxSpinEdit(AMinLen);
|
||
MarkControlsGroup.FLetter := TRzCheckBox(ALetter);
|
||
MarkControlsGroup.FSimpleText := TcxTextEdit(ASimpleText);
|
||
MarkControlsGroup.FObjectPrefix := AObjPrefix;
|
||
|
||
FControlGroups.Add(MarkControlsGroup);
|
||
|
||
ACheck.Tag := Integer(MarkControlsGroup);
|
||
AValue.Tag := Integer(MarkControlsGroup);
|
||
AExamplValue.Tag := Integer(MarkControlsGroup);
|
||
if AMinLen <> nil then
|
||
AMinLen.Tag := Integer(MarkControlsGroup);
|
||
if ALetter <> nil then
|
||
ALetter.Tag := Integer(MarkControlsGroup);
|
||
ASimpleText.Tag := Integer(MarkControlsGroup);
|
||
end;
|
||
|
||
function TF_MarkMask.GetMarkControlGroupByPrefix(APrefix: Char): TMarkControlsGroup;
|
||
var
|
||
MarkControlsGroup: TMarkControlsGroup;
|
||
i: Integer;
|
||
begin
|
||
Result := nil;
|
||
for i := 0 to FControlGroups.Count - 1 do
|
||
begin
|
||
MarkControlsGroup := TMarkControlsGroup(FControlGroups[i]);
|
||
if MarkControlsGroup.FObjectPrefix = APrefix then
|
||
begin
|
||
Result := MarkControlsGroup;
|
||
Break; //// BREAK ////
|
||
end;
|
||
end;
|
||
end;
|
||
|
||
function TF_MarkMask.GetElementBlock(APrefix: Char; AMinLen, ALetter: Integer): String;
|
||
var
|
||
ParamsStr: String;
|
||
procedure AddToParams(const AParams: String);
|
||
begin
|
||
if ParamsStr <> '' then
|
||
ParamsStr := ParamsStr + ' ';
|
||
ParamsStr := ParamsStr + AParams;
|
||
end;
|
||
begin
|
||
Result := '#'+APrefix;
|
||
if (AMinLen > 0) or (ALetter <> biFalse) then
|
||
begin
|
||
//Result := '<'+Result+' '+mtMinLength+'='+IntToStr(AMinLen)+'>';
|
||
Result := '<'+Result+' ';
|
||
ParamsStr := '';
|
||
if AMinLen > 0 then
|
||
AddToParams(mtMinLength+'='+IntToStr(AMinLen));
|
||
if ALetter <> biFalse then
|
||
AddToParams(mtLetter+'='+IntToStr(ALetter));
|
||
Result := Result +ParamsStr+ '>';
|
||
end;
|
||
end;
|
||
|
||
constructor TF_MarkMask.Create(AOwner: TComponent; AForm: TForm);
|
||
begin
|
||
GForm := AForm;
|
||
inherited Create(AOwner);
|
||
end;
|
||
|
||
destructor TF_MarkMask.Destroy;
|
||
begin
|
||
inherited Destroy;
|
||
end;
|
||
|
||
|
||
function TF_MarkMask.MakeEditMarkMask(AFormMode: TFormMode; var AMask: String): Boolean;
|
||
var
|
||
ModRes: TModalResult;
|
||
ControlExValue: TControl;
|
||
|
||
ExampleNumberIndex: Integer;
|
||
ExampleTextIndex: Integer;
|
||
i: Integer;
|
||
begin
|
||
Result := false;
|
||
try
|
||
GFormMode := AFormMode;
|
||
|
||
//20.09.2010
|
||
//SpinEdit_ProjExValue.Properties.OnChange := nil;
|
||
// SpinEdit_ListExValue.Properties.OnChange := nil;
|
||
// SpinEdit_RoomExValue.Properties.OnChange := nil;
|
||
// SpinEdit_ObjExValue.Properties.OnChange := nil;
|
||
// SpinEdit_TopComponExValue.Properties.OnChange := nil;
|
||
// SpinEdit_ComponExValue.Properties.OnChange := nil;
|
||
// SpinEdit_ComponPortExValue.Properties.OnChange := nil;
|
||
//
|
||
// SpinEdit_ProjExValue.Value := 1;
|
||
// SpinEdit_ListExValue.Value := 2;
|
||
// SpinEdit_RoomExValue.Value := 3;
|
||
// SpinEdit_ObjExValue.Value := 4;
|
||
// SpinEdit_TopComponExValue.Value := 5;
|
||
// SpinEdit_ComponExValue.Value := 6;
|
||
// SpinEdit_ComponPortExValue.Value := 7;
|
||
// Edit_NameShortExValue.Text := 'A';
|
||
//
|
||
// SpinEdit_ProjExValue.Properties.OnChange := SpinEdit_ProjExValuePropertiesChange;
|
||
// SpinEdit_ListExValue.Properties.OnChange := SpinEdit_ProjExValuePropertiesChange;
|
||
// SpinEdit_RoomExValue.Properties.OnChange := SpinEdit_ProjExValuePropertiesChange;
|
||
// SpinEdit_ObjExValue.Properties.OnChange := SpinEdit_ProjExValuePropertiesChange;
|
||
// SpinEdit_TopComponExValue.Properties.OnChange := SpinEdit_ProjExValuePropertiesChange;
|
||
// SpinEdit_ComponExValue.Properties.OnChange := SpinEdit_ProjExValuePropertiesChange;
|
||
// SpinEdit_ComponPortExValue.Properties.OnChange := SpinEdit_ProjExValuePropertiesChange;
|
||
|
||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||
ExampleNumberIndex := 0;
|
||
ExampleTextIndex := 0;
|
||
for i := 0 to FControlGroups.Count - 1 do
|
||
begin
|
||
ControlExValue := TMarkControlsGroup(FControlGroups[i]).FExampleValue;
|
||
if ControlExValue <> nil then
|
||
begin
|
||
if ControlExValue is TcxSpinEdit then
|
||
begin
|
||
ExampleNumberIndex := ExampleNumberIndex + 1;
|
||
TcxSpinEdit(ControlExValue).Properties.OnChange := nil;
|
||
TcxSpinEdit(ControlExValue).Value := ExampleNumberIndex;
|
||
TcxSpinEdit(ControlExValue).Properties.OnChange := SpinEdit_ProjExValuePropertiesChange;
|
||
end
|
||
else if ControlExValue is TcxTextEdit then
|
||
begin
|
||
ExampleTextIndex := ExampleTextIndex + 1;
|
||
TcxTextEdit(ControlExValue).Text := DecToABC(ExampleTextIndex);
|
||
end;
|
||
end;
|
||
end;
|
||
|
||
//Edit_ProjValue.Text := mteProj+'.';
|
||
//Edit_ListValue.Text := mteList+'.';
|
||
//Edit_RoomValue.Text := mteRoom+'.';
|
||
//Edit_ObjectValue.Text := mteObject+'.';
|
||
//Edit_TopComponValue.Text := mteTopCompon;
|
||
//Edit_ComponValue.Text := mteCompon;
|
||
//Edit_ComponPort.Text := mteComponPort;
|
||
//Edit_NameShortValue.Text := mteNameShort;
|
||
case AFormMode of
|
||
fmMake:
|
||
begin
|
||
Caption := cMakeEditMarkMask_Msg1_1;
|
||
|
||
//CheckBox_Project.Checked := false;
|
||
//CheckBox_List.Checked := true;
|
||
//CheckBox_Room.Checked := true;
|
||
//CheckBox_Object.Checked := true;
|
||
//CheckBox_TopComponent.Checked := true;
|
||
//CheckBox_Component.Checked := true;
|
||
//CheckBox_ComponPort.Checked := true;
|
||
//CheckBox_NameShort.Checked := true;
|
||
//BuildMask;
|
||
DivideMask(AMask, true);
|
||
end;
|
||
fmEdit:
|
||
begin
|
||
Caption := cMakeEditMarkMask_Msg1_2;
|
||
DivideMask(AMask, true);
|
||
end;
|
||
end;
|
||
|
||
ModRes := ShowModal;
|
||
if ModRes = mrOk then
|
||
begin
|
||
AMask := Edit_Result.Text;
|
||
Result := true;
|
||
end;
|
||
except
|
||
on E: Exception do AddExceptionToLog('TF_MarkMask.MakeEditMarkMask'+ E.Message);
|
||
end;
|
||
end;
|
||
|
||
|
||
// ##### <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD> <20><> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> #####
|
||
procedure TF_MarkMask.DivideMask(const AMask: String; ASetToResult: Boolean);
|
||
var
|
||
{CurrCheckBox: TRzCheckBox;
|
||
CurrEditValue: TcxTextEdit;
|
||
i: integer;
|
||
PrevChar: Char;
|
||
CurrChar: Char;
|
||
Len: Integer;}
|
||
|
||
i: Integer;
|
||
MarkControlsGroup: TMarkControlsGroup;
|
||
MarkTemplateObjects: TObjectList;
|
||
|
||
MarkTemplateObj: TMarkTemplateObj;
|
||
FindedBlockCount: Integer;
|
||
begin
|
||
try
|
||
{CurrCheckBox := nil;
|
||
CurrEditValue := nil;
|
||
PrevChar := #0;
|
||
CurrChar := #0;
|
||
|
||
CheckBox_Project.Checked := true;
|
||
CheckBox_List.Checked := true;
|
||
CheckBox_Room.Checked := true;
|
||
CheckBox_Object.Checked := true;
|
||
CheckBox_TopComponent.Checked := true;
|
||
CheckBox_Component.Checked := true;
|
||
CheckBox_ComponPort.Checked := true;
|
||
CheckBox_NameShort.Checked := true;
|
||
|
||
CheckBox_Project.Checked := false;
|
||
CheckBox_List.Checked := false;
|
||
CheckBox_Room.Checked := false;
|
||
CheckBox_Object.Checked := false;
|
||
CheckBox_TopComponent.Checked := false;
|
||
CheckBox_Component.Checked := false;
|
||
CheckBox_ComponPort.Checked := false;
|
||
CheckBox_NameShort.Checked := false;
|
||
|
||
Len := Length(AMask);
|
||
for i := 1 to Len do
|
||
begin
|
||
PrevChar := CurrChar;
|
||
CurrChar := AMask[i];
|
||
if PrevChar = '#' then
|
||
begin
|
||
case CurrChar of
|
||
'p': //, 'P': //*** <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||
begin
|
||
CurrCheckBox := CheckBox_Project;
|
||
CurrEditValue := Edit_ProjValue;
|
||
end;
|
||
'l': //, 'L': //*** <20><><EFBFBD><EFBFBD>
|
||
begin
|
||
CurrCheckBox := CheckBox_List;
|
||
CurrEditValue := Edit_ListValue;
|
||
end;
|
||
'r': //, 'R': //*** <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||
begin
|
||
CurrCheckBox := CheckBox_Room;
|
||
CurrEditValue := Edit_RoomValue;
|
||
end;
|
||
'o': //, 'O': //*** <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||
begin
|
||
CurrCheckBox := CheckBox_Object;
|
||
CurrEditValue := Edit_ObjectValue;
|
||
end;
|
||
'C': //*** <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||
begin
|
||
CurrCheckBox := CheckBox_TopComponent;
|
||
CurrEditValue := Edit_TopComponValue;
|
||
end;
|
||
'c': //, 'C': //*** <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||
begin
|
||
CurrCheckBox := CheckBox_Component;
|
||
CurrEditValue := Edit_ComponValue;
|
||
end;
|
||
't': //, 'T': //*** <20><><EFBFBD><EFBFBD>
|
||
begin
|
||
CurrCheckBox := CheckBox_ComponPort;
|
||
CurrEditValue := Edit_ComponPort;
|
||
end;
|
||
's': //, 'S': //*** <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||
begin
|
||
CurrCheckBox := CheckBox_NameShort;
|
||
CurrEditValue := Edit_NameShortValue;
|
||
end;
|
||
end;
|
||
if CurrCheckBox <> nil then
|
||
CurrCheckBox.Checked := true;
|
||
|
||
if CurrEditValue <> nil then
|
||
CurrEditValue.Text := PrevChar + CurrChar;
|
||
end
|
||
else
|
||
if CurrChar <> '#' then
|
||
if CurrEditValue <> nil then
|
||
CurrEditValue.Text := CurrEditValue.Text + CurrChar;
|
||
|
||
end;
|
||
Edit_Result.Text := AMask;
|
||
BuildExample;}
|
||
|
||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD> <20><><EFBFBD>
|
||
edSimpleTextBefore.Text := '';
|
||
for i := 0 to FControlGroups.Count - 1 do
|
||
begin
|
||
MarkControlsGroup := TMarkControlsGroup(FControlGroups[i]);
|
||
|
||
MarkControlsGroup.SetCheckedValue(false);
|
||
|
||
MarkControlsGroup.FValue.Text := GetElementBlock(MarkControlsGroup.FObjectPrefix, 0, biFalse);
|
||
MarkControlsGroup.FValue.Enabled := false;
|
||
//if MarkControlsGroup.FExampleValue is TcxSpinEdit then
|
||
// TcxSpinEdit(MarkControlsGroup.FExampleValue).Value := 0
|
||
//else
|
||
//if MarkControlsGroup.FExampleValue is TcxTextEdit then
|
||
// TcxTextEdit(MarkControlsGroup.FExampleValue).Text := '';
|
||
MarkControlsGroup.FExampleValue.Enabled := false;
|
||
if MarkControlsGroup.FMinLen <> nil then
|
||
begin
|
||
MarkControlsGroup.SetMinLenValue(0);
|
||
MarkControlsGroup.FMinLen.Enabled := false;
|
||
end;
|
||
if MarkControlsGroup.FLetter <> nil then
|
||
begin
|
||
MarkControlsGroup.SetLetterValue(false);
|
||
MarkControlsGroup.FLetter.Enabled := false;
|
||
end;
|
||
MarkControlsGroup.FSimpleText.Text := '.';
|
||
MarkControlsGroup.FSimpleText.Enabled := false;
|
||
end;
|
||
|
||
MarkTemplateObjects := TObjectList.Create(true);
|
||
LoadMarkTemplateObjectsToList(AMask, MarkTemplateObjects);
|
||
FindedBlockCount := 0;
|
||
for i := 0 to MarkTemplateObjects.Count - 1 do
|
||
begin
|
||
MarkTemplateObj := TMarkTemplateObj(MarkTemplateObjects[i]);
|
||
MarkControlsGroup := GetMarkControlGroupByPrefix(MarkTemplateObj.FObjPrefix);
|
||
if MarkControlsGroup <> nil then
|
||
begin
|
||
if FindedBlockCount = 0 then
|
||
edSimpleTextBefore.Text := MarkTemplateObj.FBeforeText;
|
||
|
||
MarkControlsGroup.SetCheckedValue(true);
|
||
|
||
MarkControlsGroup.FValue.Text := GetElementBlock(MarkTemplateObj.FObjPrefix, MarkTemplateObj.FMinIndexLength, MarkTemplateObj.FLetter);
|
||
MarkControlsGroup.FExampleValue.Enabled := true;
|
||
if MarkControlsGroup.FMinLen <> nil then
|
||
begin
|
||
MarkControlsGroup.SetMinLenValue(MarkTemplateObj.FMinIndexLength);
|
||
MarkControlsGroup.FMinLen.Enabled := true;
|
||
end;
|
||
if MarkControlsGroup.FLetter <> nil then
|
||
begin
|
||
MarkControlsGroup.SetLetterValue(IntToBool(MarkTemplateObj.FLetter));
|
||
MarkControlsGroup.FLetter.Enabled := true;
|
||
end;
|
||
MarkControlsGroup.FSimpleText.Text := MarkTemplateObj.FAfterText;
|
||
MarkControlsGroup.FSimpleText.Enabled := true;
|
||
|
||
FindedBlockCount := FindedBlockCount + 1;
|
||
end;
|
||
end;
|
||
FreeAndNil(MarkTemplateObjects);
|
||
|
||
if ASetToResult then
|
||
SetValueToCXTextEditAsNoChange(Edit_Result, AMask);
|
||
|
||
BuildExample;
|
||
except
|
||
on E: Exception do AddExceptionToLog('TF_MarkMask.DivideMask: '+E.Message);
|
||
end;
|
||
end;
|
||
|
||
|
||
// ##### <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD> #####
|
||
procedure TF_MarkMask.BuildMask;
|
||
var
|
||
i: Integer;
|
||
MarkControlsGroup: TMarkControlsGroup;
|
||
MarkTemplate: string;
|
||
begin
|
||
try
|
||
{Edit_Result.Text := '';
|
||
if CheckBox_Project.Checked then
|
||
Edit_Result.Text := Edit_Result.Text + Edit_ProjValue.Text;
|
||
if CheckBox_List.Checked then
|
||
Edit_Result.Text := Edit_Result.Text + Edit_ListValue.Text;
|
||
if CheckBox_Room.Checked then
|
||
Edit_Result.Text := Edit_Result.Text + Edit_RoomValue.Text;
|
||
if CheckBox_Object.Checked then
|
||
Edit_Result.Text := Edit_Result.Text + Edit_ObjectValue.Text;
|
||
if CheckBox_TopComponent.Checked then
|
||
Edit_Result.Text := Edit_Result.Text + Edit_TopComponValue.Text;
|
||
if CheckBox_Component.Checked then
|
||
Edit_Result.Text := Edit_Result.Text + Edit_ComponValue.Text;
|
||
if CheckBox_ComponPort.Checked then
|
||
Edit_Result.Text := Edit_Result.Text + Edit_ComponPort.Text;
|
||
if CheckBox_NameShort.Checked and CheckBox_NameShort.Enabled then
|
||
Edit_Result.Text := Edit_Result.Text + Edit_NameShortValue.Text;
|
||
BuildExample; }
|
||
|
||
MarkTemplate := edSimpleTextBefore.Text;
|
||
for i := 0 to FControlGroups.Count - 1 do
|
||
begin
|
||
MarkControlsGroup := TMarkControlsGroup(FControlGroups[i]);
|
||
if MarkControlsGroup.FChecked.Checked then
|
||
MarkTemplate := MarkTemplate + MarkControlsGroup.FValue.Text + MarkControlsGroup.FSimpleText.Text;
|
||
end;
|
||
SetValueToCXTextEditAsNoChange(Edit_Result, MarkTemplate);
|
||
|
||
BuildExample;
|
||
except
|
||
on E: Exception do AddExceptionToLog('TF_MarkMask.BuildMask: '+E.Message);
|
||
end;
|
||
end;
|
||
|
||
|
||
// ##### <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> #####
|
||
procedure TF_MarkMask.BuildExample;
|
||
var
|
||
MarkTemplateObjects: TObjectList;
|
||
begin
|
||
try
|
||
{
|
||
Edit_Example.Text := MakeMarkMaskForComponent(SpinEdit_ProjExValue.Value,
|
||
SpinEdit_ListExValue.Value,
|
||
SpinEdit_RoomExValue.Value,
|
||
SpinEdit_ObjExValue.Value,
|
||
SpinEdit_TopComponExValue.Value,
|
||
SpinEdit_ComponExValue.Value,
|
||
SpinEdit_ComponPortExValue.Value,
|
||
Edit_NameShortExValue.Text,
|
||
Edit_Result.Text); }
|
||
|
||
MarkTemplateObjects := TObjectList.Create(true);
|
||
LoadMarkTemplateObjectsToList(Edit_Result.Text, MarkTemplateObjects);
|
||
Edit_Example.Text := MakeMarkMaskForComponByBlocks(SpinEdit_ProjExValue.Value,
|
||
SpinEdit_ListExValue.Value,
|
||
SpinEdit_RoomExValue.Value,
|
||
SpinEdit_ObjExValue.Value,
|
||
SpinEdit_TopComponExValue.Value,
|
||
seParentComponExValue.Value,
|
||
SpinEdit_ComponExValue.Value,
|
||
SpinEdit_ComponPortExValue.Value,
|
||
Edit_NameShortExValue.Text,
|
||
'',
|
||
nil,
|
||
MarkTemplateObjects);
|
||
FreeAndNil(MarkTemplateObjects);
|
||
except
|
||
on E: Exception do AddExceptionToLog('TF_MarkMask.BuildExample: '+E.Message);
|
||
end;
|
||
end;
|
||
|
||
|
||
procedure TF_MarkMask.AfterCheckBoxChange(ACheckBox, AEditValue, AEditBoxWithExValue: TObject);
|
||
begin
|
||
TcxCustomEdit(AEditValue).Enabled := TRzCheckBox(ACheckBox).Checked;
|
||
TcxCustomEdit(AEditBoxWithExValue).Enabled := TRzCheckBox(ACheckBox).Checked;
|
||
|
||
//TcxTextEdit(AEditValue).Enabled := TcxCheckBox(ACheckBox).Checked;
|
||
//TcxSpinEdit(ASpinEditExValue).Enabled := TcxCheckBox(ACheckBox).Checked;
|
||
|
||
BuildMask;
|
||
end;
|
||
|
||
procedure TF_MarkMask.OnChangeTemplateParam(AControl: TObject);
|
||
var
|
||
MarkControlsGroup: TMarkControlsGroup;
|
||
MinLen: Integer;
|
||
Letter: Integer;
|
||
begin
|
||
if (AControl <> nil) and (AControl is TControl) then
|
||
if TControl(AControl).Tag <> 0 then
|
||
begin
|
||
MarkControlsGroup := TMarkControlsGroup(TControl(AControl).Tag);
|
||
MinLen := 0;
|
||
Letter := biFalse;
|
||
if MarkControlsGroup.FMinLen <> nil then
|
||
MinLen := Trunc(MarkControlsGroup.FMinLen.Value);
|
||
if MarkControlsGroup.FLetter <> nil then
|
||
Letter := BoolToInt(MarkControlsGroup.FLetter.Checked);
|
||
|
||
MarkControlsGroup.FValue.Text := GetElementBlock(MarkControlsGroup.FObjectPrefix, MinLen, Letter);
|
||
|
||
BuildMask;
|
||
end;
|
||
end;
|
||
|
||
// ##### <20><><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD> <20> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> #####
|
||
procedure TF_MarkMask.Edit_ProjValueKeyUp(Sender: TObject; var Key: Word;
|
||
Shift: TShiftState);
|
||
begin
|
||
BuildMask;
|
||
end;
|
||
|
||
procedure TF_MarkMask.SpinEdit_ProjExValuePropertiesChange(
|
||
Sender: TObject);
|
||
begin
|
||
BuildExample;
|
||
end;
|
||
|
||
// ##### <20><><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> #####
|
||
procedure TF_MarkMask.Edit_NameShortExValueKeyUp(Sender: TObject;
|
||
var Key: Word; Shift: TShiftState);
|
||
begin
|
||
BuildExample;
|
||
end;
|
||
|
||
|
||
// ##### <20><><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> #####
|
||
procedure TF_MarkMask.Edit_ResultKeyUp(Sender: TObject; var Key: Word;
|
||
Shift: TShiftState);
|
||
begin
|
||
//BuildExample;
|
||
end;
|
||
|
||
procedure TF_MarkMask.FormCreate(Sender: TObject);
|
||
begin
|
||
FControlGroups := TObjectList.Create(true);
|
||
|
||
AddControlsToGroup(CheckBox_Project, Edit_ProjValue, SpinEdit_ProjExValue, spMinLenProj, cbLetterProj, edSimpleTextProj, 'p');
|
||
AddControlsToGroup(CheckBox_List, Edit_ListValue, SpinEdit_ListExValue, spMinLenList, cbLetterList, edSimpleTextList, 'l');
|
||
AddControlsToGroup(CheckBox_Room, Edit_RoomValue, SpinEdit_RoomExValue, spMinLenRoom, cbLetterRoom, edSimpleTextRoom, 'r');
|
||
AddControlsToGroup(CheckBox_Object, Edit_ObjectValue, SpinEdit_ObjExValue, spMinLenObject, cbLetterObject, edSimpleTextObject, 'o');
|
||
AddControlsToGroup(CheckBox_TopComponent, Edit_TopComponValue, SpinEdit_TopComponExValue, spMinLenTopCompon, cbLetterTopCompon, edSimpleTextTopCompon, 'C');
|
||
AddControlsToGroup(cbParentComponent, edParentComponValue, seParentComponExValue, spMinLenParentCompon, cbLetterParentCompon, edSimpleTextParentCompon, 'P');
|
||
|
||
AddControlsToGroup(CheckBox_Component, Edit_ComponValue, SpinEdit_ComponExValue, spMinLenCompon, cbLetterCompon, edSimpleTextCompon, 'c');
|
||
AddControlsToGroup(CheckBox_ComponPort, Edit_ComponPort, SpinEdit_ComponPortExValue, spMinLenComponPort, cbLetterComponPort, edSimpleTextComponPort, 't');
|
||
AddControlsToGroup(CheckBox_NameShort, Edit_NameShortValue, Edit_NameShortExValue, nil, nil, edSimpleTextNameShort, 's');
|
||
|
||
pnOkCancelResize(pnOkCancel);
|
||
end;
|
||
|
||
procedure TF_MarkMask.FormDestroy(Sender: TObject);
|
||
begin
|
||
FreeAndNil(FControlGroups);
|
||
end;
|
||
|
||
procedure TF_MarkMask.pnOkCancelResize(Sender: TObject);
|
||
begin
|
||
SetMiddleControlChilds(TControl(Sender), TControl(Self));
|
||
end;
|
||
|
||
procedure TF_MarkMask.CheckBox_ElementChange(Sender: TObject);
|
||
var
|
||
MarkControlsGroup: TMarkControlsGroup;
|
||
begin
|
||
//AfterCheckBoxChange(Sender, Edit_ProjValue, SpinEdit_ProjExValue);
|
||
if Sender <> nil then
|
||
if TControl(Sender).Tag <> 0 then
|
||
begin
|
||
MarkControlsGroup := TMarkControlsGroup(TControl(Sender).Tag);
|
||
|
||
MarkControlsGroup.FExampleValue.Enabled := MarkControlsGroup.FChecked.Checked;
|
||
if MarkControlsGroup.FMinLen <> nil then
|
||
MarkControlsGroup.FMinLen.Enabled := MarkControlsGroup.FChecked.Checked;
|
||
if MarkControlsGroup.FLetter <> nil then
|
||
MarkControlsGroup.FLetter.Enabled := MarkControlsGroup.FChecked.Checked;
|
||
MarkControlsGroup.FSimpleText.Enabled := MarkControlsGroup.FChecked.Checked;
|
||
|
||
BuildMask;
|
||
end;
|
||
end;
|
||
|
||
procedure TF_MarkMask.spMinLenPropertiesChange(Sender: TObject);
|
||
//var
|
||
// MarkControlsGroup: TMarkControlsGroup;
|
||
// MinLen: Integer;
|
||
begin
|
||
// if Sender <> nil then
|
||
// if TControl(Sender).Tag <> 0 then
|
||
// begin
|
||
// MarkControlsGroup := TMarkControlsGroup(TControl(Sender).Tag);
|
||
// MinLen := 0;
|
||
// if MarkControlsGroup.FMinLen <> nil then
|
||
// MinLen := Trunc(MarkControlsGroup.FMinLen.Value);
|
||
//
|
||
// MarkControlsGroup.FValue.Text := GetElementBlock(MarkControlsGroup.FObjectPrefix, MinLen);
|
||
//
|
||
// BuildMask;
|
||
// end;
|
||
OnChangeTemplateParam(Sender);
|
||
end;
|
||
|
||
procedure TF_MarkMask.cbLetterClick(Sender: TObject);
|
||
begin
|
||
OnChangeTemplateParam(Sender);
|
||
end;
|
||
|
||
procedure TF_MarkMask.edSimpleTexKeyUp(Sender: TObject; var Key: Word;
|
||
Shift: TShiftState);
|
||
begin
|
||
BuildMask;
|
||
end;
|
||
|
||
|
||
procedure TF_MarkMask.Edit_ResultPropertiesChange(Sender: TObject);
|
||
begin
|
||
DivideMask(Edit_Result.Text, false);
|
||
end;
|
||
|
||
procedure TF_MarkMask.FormShow(Sender: TObject);
|
||
begin
|
||
ForAllObjOnList.Visible := ShowCheckBoxOnTemplateMarkForm;
|
||
OnlyForSelectedObj.Visible := ShowCheckBoxOnTemplateMarkForm;
|
||
end;
|
||
|
||
procedure TF_MarkMask.ForAllObjOnListClick(Sender: TObject);
|
||
begin
|
||
try
|
||
if ForAllObjOnList.Checked then
|
||
OnlyForSelectedObj.Enabled := True
|
||
else
|
||
OnlyForSelectedObj.Enabled := False;
|
||
except
|
||
on E: Exception do AddExceptionToLogEx('TF_MasterNewList.cbApplyForAllSCSObjectsClick', E.Message);
|
||
end;
|
||
end;
|
||
|
||
procedure TF_MarkMask.RzBitBtn1Click(Sender: TObject);
|
||
begin
|
||
with TF_Main(GForm).F_AnswerToQuast do
|
||
begin
|
||
GCaption := cMarkMask_Msg1;
|
||
GAnswer := cMarkMask_Msg2;
|
||
ShowContextHelp(GCaption, GAnswer);
|
||
end;
|
||
|
||
end;
|
||
|
||
end.
|