unit U_ArchBalconyParams; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls, U_BaseCommon, U_BaseConstants, U_ArchCommon, RzButton, Mask, RzEdit, RzPanel, ExtCtrls, siComp, siLngLnk, RzRadChk; type TF_ArchBalconyParams = class(TForm) pnMain: TRzPanel; pnOkCancel: TRzPanel; btOk: TRzBitBtn; btCancel: TRzBitBtn; lng_Forms: TsiLangLinked; pnGeneral: TRzPanel; RzGroupBox1: TRzGroupBox; fisLbWidth: TLabel; fisLbHeight: TLabel; fisLbDepth: TLabel; fisWidth: TRzNumericEdit; fisHeight: TRzNumericEdit; fisDepth: TRzNumericEdit; RzGroupBox2: TRzGroupBox; fwndLbWidth: TLabel; fwndLbHeight: TLabel; fwndWidth: TRzNumericEdit; fwndHeight: TRzNumericEdit; RzGroupBox3: TRzGroupBox; fdrLbWidth: TLabel; fdrLbHeight: TLabel; fdrWidth: TRzNumericEdit; fdrHeight: TRzNumericEdit; procedure FormCreate(Sender: TObject); procedure FormDestroy(Sender: TObject); procedure pnOkCancelResize(Sender: TObject); procedure fwndWidthChange(Sender: TObject); procedure fdrWidthChange(Sender: TObject); procedure fdrHeightChange(Sender: TObject); private GForm: TForm; FPropsUOM: TStringList; FType: Integer; FIsEditing: Boolean; function GetSlopeParams(AArchWndInfo: TArchInfoBasic; AClass: TArchInfoBasicClass; const APropPrefix: string): TArchInfoBasic; procedure AutoCalcSlopeWidth; procedure SetCaptions; procedure SetControls; procedure SetSlopeParams(ASlopeInfo: TArchInfoBasic; const APropPrefix: string); public Constructor Create(AOwner: TComponent; AForm: TForm); Destructor Destroy; override; function Execute(AType: Integer; AArchInfo: TComponent): TArchInfoBasic; published property PropMainForm: TForm read GForm; property PropsUOM: TStringList read FPropsUOM; end; function ShowArchBalconyParams(AType: Integer; AArchInfo: TComponent): TArchInfoBasic; var F_ArchBalconyParams: TF_ArchBalconyParams; implementation Uses U_Main; {$R *.dfm} constructor TF_ArchBalconyParams.Create(AOwner: TComponent; AForm: TForm); begin GForm := AForm; inherited Create(AOwner); end; destructor TF_ArchBalconyParams.Destroy; begin inherited; end; function TF_ArchBalconyParams.Execute(AType: Integer; AArchInfo: TComponent): TArchInfoBasic; var Info: TArchBalconyInfo; begin Result := nil; try FType := AType; FIsEditing := AArchInfo <> nil; SetCaptions; SetControls; Info := TArchBalconyInfo.Create(nil); if AArchInfo <> nil then begin Info.Assign(AArchInfo); end else begin LoadArchObjDefaultParams(TComponent(Info), AType); // Параметры по умолчанию Info.CreateChilds; if LoadArchObjDefaultParams(Info.WndInfo, ctArhBalconyWnd) = nil then //if LoadArchObjDefaultParams(TComponent(Pointer(@Info.WndInfo)^), ctArhBalconyWnd) = nil then begin Info.WndInfo.Height := 1.4; Info.WndInfo.Width := 1.4; end; if LoadArchObjDefaultParams(Info.DoorInfo, ctArhBalconyDoor) = nil then //if LoadArchObjDefaultParams(TComponent(Pointer(@Info.DoorInfo)^), ctArhBalconyDoor) = nil then begin Info.DoorInfo.Height := 2; Info.DoorInfo.Width := 0.7; end; if LoadArchObjDefaultParams(Info.InnerSlope, ctArhBalconyInnerSlope) = nil then //if LoadArchObjDefaultParams(TComponent(Pointer(@Info.InnerSlope)^), ctArhBalconyInnerSlope) = nil then begin Info.InnerSlope.Height := 2; Info.InnerSlope.Width := 2.1; Info.InnerSlope.Depth := 0.1; end; end; //ObjectPropsToForm(Info, Self); SetSlopeParams(Info.WndInfo, 'fwnd'); SetSlopeParams(Info.DoorInfo, 'fdr'); SetSlopeParams(Info.InnerSlope, 'fis'); Info.Free; if ShowModal = mrOk then begin Result := TArchBalconyInfo.Create(nil); //ObjectPropsFromForm(Result, Self); TArchBalconyInfo(Result).WndInfo := TArchWndInfo(GetSlopeParams(Result, TArchWndInfo, 'fwnd')); TArchBalconyInfo(Result).DoorInfo := TArchWndInfo(GetSlopeParams(Result, TArchWndInfo, 'fdr')); TArchBalconyInfo(Result).InnerSlope := TArchSlopeInfo(GetSlopeParams(Result, TArchSlopeInfo, 'fis')); TArchBalconyInfo(Result).Width := TArchBalconyInfo(Result).WndInfo.Width + TArchBalconyInfo(Result).DoorInfo.Width; // Сохраняем параметры как по-умолчанию SetArchObjToDefaultParams(TArchBalconyInfo(Result), AType); SetArchObjToDefaultParams(TArchBalconyInfo(Result).WndInfo, ctArhBalconyWnd); SetArchObjToDefaultParams(TArchBalconyInfo(Result).DoorInfo, ctArhBalconyDoor); SetArchObjToDefaultParams(TArchBalconyInfo(Result).InnerSlope, ctArhBalconyInnerSlope); end; except on E: Exception do AddExceptionToLogExt(ClassName, 'Execute', E.Message); end; end; function TF_ArchBalconyParams.GetSlopeParams(AArchWndInfo: TArchInfoBasic; AClass: TArchInfoBasicClass; const APropPrefix: string): TArchInfoBasic; begin Result := AClass.Create(AArchWndInfo); ObjectPropsFromForm(Result, Self, APropPrefix); end; procedure TF_ArchBalconyParams.AutoCalcSlopeWidth; begin fisWidth.Value := fwndWidth.Value + fdrWidth.Value; end; procedure TF_ArchBalconyParams.SetCaptions; //var // i: integer; // Labl: TLabel; // lbCaptionLen: String; begin //for i := 0 to ComponentCount - 1 do // begin // if Components[i] is TLabel then // begin // Labl := TLabel(Components[i]); // lbCaptionLen := ''; // if Pos('Coordz', Labl.Name) <> 0 then // lbCaptionLen := cArchParams_Msg05 // else if Pos('Width', Labl.Name) <> 0 then // lbCaptionLen := cArchParams_Msg02 // else if Pos('Height', Labl.Name) <> 0 then // lbCaptionLen := cArchParams_Msg06 // else if Pos('Depth', Labl.Name) <> 0 then // lbCaptionLen := cArchParams_Msg07; // // if lbCaptionLen <> '' then // Labl.Caption := lbCaptionLen +', '+ GetNameUOM(TF_Main(GForm).FUOM, true); // end; // end; SetLableCaptions(Self, TF_Main(GForm).FUOM); end; procedure TF_ArchBalconyParams.SetControls; begin //Self.AutoSize := false; //pnMain.AutoSize := false; //pnMain.AutoSize := true; //Self.AutoSize := true; end; procedure TF_ArchBalconyParams.SetSlopeParams(ASlopeInfo: TArchInfoBasic; const APropPrefix: string); begin if Assigned(ASlopeInfo) then ObjectPropsToForm(ASlopeInfo, Self, APropPrefix); end; procedure TF_ArchBalconyParams.FormCreate(Sender: TObject); begin pnOkCancelResize(pnOkCancel); FPropsUOM := TStringList.Create; SetFormControlDisplayFormat(Self); end; procedure TF_ArchBalconyParams.FormDestroy(Sender: TObject); begin FreeAndNil(FPropsUOM); end; function ShowArchBalconyParams(AType: Integer; AArchInfo: TComponent): TArchInfoBasic; begin Result := nil; try if F_ArchBalconyParams = nil then F_ArchBalconyParams := TF_ArchBalconyParams.Create(F_ProjMan, F_ProjMan); Result := F_ArchBalconyParams.Execute(AType, AArchInfo); except on E: Exception do AddExceptionToLogEx('ShowArchBalconyParams', E.Message); end; end; procedure TF_ArchBalconyParams.pnOkCancelResize(Sender: TObject); begin SetMiddleControlChilds(TControl(Sender), TControl(Self)); end; procedure TF_ArchBalconyParams.fwndWidthChange(Sender: TObject); begin AutoCalcSlopeWidth; end; procedure TF_ArchBalconyParams.fdrWidthChange(Sender: TObject); begin AutoCalcSlopeWidth; end; procedure TF_ArchBalconyParams.fdrHeightChange(Sender: TObject); begin fisHeight.Value := fdrHeight.Value; end; end.