expertcad/SRC/Main/U_Scale.pas
2025-05-12 10:07:51 +03:00

119 lines
2.9 KiB
ObjectPascal

unit U_Scale;
interface
uses
Windows, U_LNG, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, cxLookAndFeelPainters, cxControls, cxContainer,
cxEdit, cxTextEdit, cxButtons, cxMaskEdit, siComp, siLngLnk, cxGraphics,
cxLookAndFeels, Menus;
type
TF_Scale = class(TForm)
bOK: TcxButton;
bCancel: TcxButton;
edScale: TcxMaskEdit;
lng_Forms: TsiLangLinked;
procedure bOKClick(Sender: TObject);
procedure bCancelClick(Sender: TObject);
procedure edScaleKeyPress(Sender: TObject; var Key: Char);
procedure FormShow(Sender: TObject);
procedure FormKeyPress(Sender: TObject; var Key: Char);
procedure edScaleExit(Sender: TObject);
private
{ Private declarations }
public
CurrentMapScale: string;
{ Public declarations }
end;
var
F_Scale: TF_Scale;
implementation
uses USCS_Main, U_CAD, U_Common, U_BaseCommon;
{$R *.dfm}
procedure TF_Scale.bOKClick(Sender: TObject);
var
Val: Integer;
begin
try
Val := StrToInt(edScale.Text);
if Val < 50 then
Val := 50;
//16.12.2011 if Val > 3000 then
//16.12.2011 Val := 3000;
if Val > GCadForm.PCad.MaxScale then //16.12.2011
Val := GCadForm.PCad.MaxScale;
GCadForm.PCad.MapScale := Val;
if not GProjectChanged then // Tolik 28/08/2019 --
SetProjectChanged(True);
except
on E: Exception do AddExceptionToLogEx('TF_Scale.bOKClick', E.Message);
end;
end;
procedure TF_Scale.bCancelClick(Sender: TObject);
begin
try
Close;
except
on E: Exception do AddExceptionToLogEx('TF_Scale.bCancelClick', E.Message);
end;
end;
procedure TF_Scale.edScaleKeyPress(Sender: TObject; var Key: Char);
begin
try
// if (Key = '.') or (Key = ',') then
// if Key <> DecimalSeparator then
// Key := #0;
if Key = #13 then
begin
bOK.SetFocus;
bOK.Click;
end;
except
on E: Exception do AddExceptionToLogEx('TF_Scale.edScaleKeyPress', E.Message);
end;
end;
procedure TF_Scale.FormShow(Sender: TObject);
begin
try
// MaskEdit
edScale.Properties.EditMask := '\d?\d?\d?\d?';
edScale.Text := FloatToStr(GCadForm.PCad.MapScale);
CurrentMapScale := edScale.Text;
edScale.SetFocus;
edScale.SelStart := 0;
edScale.SelLength := Length(edScale.Text) + 1;
except
on E: Exception do AddExceptionToLogEx('TF_Scale.FormShow', E.Message);
end;
end;
procedure TF_Scale.FormKeyPress(Sender: TObject; var Key: Char);
begin
try
if Key = #27 then
Close;
except
on E: Exception do AddExceptionToLogEx('TF_Scale.FormKeyPress', E.Message);
end;
end;
procedure TF_Scale.edScaleExit(Sender: TObject);
begin
try
if edScale.Text = '' then
edScale.Text := CurrentMapScale;
except
on E: Exception do AddExceptionToLogEx('TF_Scale.edScaleExit', E.Message);
end;
end;
end.