unit U_Settings;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, ExtCtrls, RzPanel, RzRadGrp, cxControls, cxContainer, cxEdit,
  cxCheckBox, cxLookAndFeelPainters, StdCtrls, cxButtons,
  // POWERCAD
  PCPanel, PCDrawBox, PCDrawing, PowerCad, pcMsbar, XP_Panel, PCTypesUtils,
  DrawObjects, DlgBase,  ExtDlgs, PCLayerDlg, OleCtnrs, PCgui, GuiStrings,
  DrawEngine, U_ESCadClasess;


type
  TF_Settings = class(TForm)
    RzGroupBox1: TRzGroupBox;
    cbShowLinesLength: TcxCheckBox;
    cbShowLinesCaptions: TcxCheckBox;
    cbShowConnectorsCaptions: TcxCheckBox;
    bOK: TcxButton;
    bCancel: TcxButton;
    bDefault: TcxButton;
    RzGroupBox2: TRzGroupBox;
    cbAutoSelectTrace: TcxCheckBox;
    procedure bCancelClick(Sender: TObject);
    procedure bOKClick(Sender: TObject);
    procedure FormShow(Sender: TObject);
    procedure bDefaultClick(Sender: TObject);
    procedure FormCreate(Sender: TObject);
    procedure FormKeyPress(Sender: TObject; var Key: Char);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  F_Settings: TF_Settings;

implementation
uses USCS_Main, U_CAD, U_Common, U_Layers;

{$R *.dfm}

procedure TF_Settings.bCancelClick(Sender: TObject);
begin
  Close;
end;

procedure TF_Settings.bOKClick(Sender: TObject);
begin
  try
    GCadForm.FShowLinesLength := cbShowLinesLength.Checked;
    GCadForm.FShowLinesCaptions := cbShowLinesCaptions.Checked;
    GCadForm.FShowConnectorsCaptions := cbShowConnectorsCaptions.Checked;
    GCadForm.FAutoSelectTrace := cbAutoSelectTrace.Checked;
  except
    ShowMessage('EXCEPTION: TF_Settings.bOKClick');
  end;
end;

procedure TF_Settings.FormShow(Sender: TObject);
begin
  try
    cbShowLinesLength.Checked := GCadForm.FShowLinesLength;
    cbShowLinesCaptions.Checked := GCadForm.FShowLinesCaptions;
    cbShowConnectorsCaptions.Checked := GCadForm.FShowConnectorsCaptions;
    cbAutoSelectTrace.Checked := GCadForm.FAutoSelectTrace;
    bOK.SetFocus;
  except
    ShowMessage('EXCEPTION: TF_Settings.FormShow');
  end;
end;

procedure TF_Settings.bDefaultClick(Sender: TObject);
begin
  GCadForm.FShowLinesLength := True;
  GCadForm.FShowLinesCaptions := True;
  GCadForm.FShowConnectorsCaptions := True;
  GCadForm.FAutoSelectTrace := False;
  cbShowLinesLength.Checked := GCadForm.FShowLinesLength;
  cbShowLinesCaptions.Checked := GCadForm.FShowLinesCaptions;
  cbShowConnectorsCaptions.Checked := GCadForm.FShowConnectorsCaptions;
  cbAutoSelectTrace.Checked := GCadForm.FAutoSelectTrace;
end;

procedure TF_Settings.FormCreate(Sender: TObject);
begin
  cbShowLinesLength.Checked := GCadForm.FShowLinesLength;
  cbShowLinesCaptions.Checked := GCadForm.FShowLinesCaptions;
  cbShowConnectorsCaptions.Checked := GCadForm.FShowConnectorsCaptions;
  cbAutoSelectTrace.Checked := GCadForm.FAutoSelectTrace;
end;

procedure TF_Settings.FormKeyPress(Sender: TObject; var Key: Char);
begin
  if Key = #27 then
    Close;
end;

end.
