unit U_MasterNewListLite;

interface

uses
  Windows, U_LNG, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, cxLookAndFeelPainters, StdCtrls, cxButtons, ExtCtrls, RzPanel,
  cxControls, cxContainer, cxEdit, cxTextEdit, cxMaskEdit, cxSpinEdit,
  cxDropDownEdit, cxRadioGroup, Mask, cxCheckBox, RzBorder, RzTabs,
  cxColorComboBox, PCTypesUtils, cxImageComboBox, cxImage,

  U_ComponTypesMarkMask, U_CaseForm, U_BaseCommon, U_BaseConstants, U_SCSLists, RzEdit, RzSpnEdt, ComCtrls, RzButton,
  RzRadChk, U_ESCadClasess, cxFontNameComboBox, RzCmboBx, U_Common, Buttons,
  siComp, siLngLnk, cxLabel, AppEvnts, RzLabel, Menus, XPMenu, PCPanel,
  PCDrawBox, PCDrawing, PowerCad, Math, cxGraphics, cxLookAndFeels;
  
type
  TF_MasterNewListLite = class(TForm)
    PageControl: TRzPageControl;
    TabProject: TRzTabSheet;
    RzGroupBox10: TRzGroupBox;
    Label49: TLabel;
    edProjectName: TRzEdit;
    seProjectIndex: TRzSpinEdit;
    cbProjectIsIndexWithName: TRzCheckBox;
    RzGroupBox11: TRzGroupBox;
    lbCustomer: TLabel;
    lbContractor: TLabel;
    Label65: TLabel;
    edCustomer: TRzEdit;
    edContractor: TRzEdit;
    edOrganization: TRzEdit;
    RzGroupBox8: TRzGroupBox;
    lbAutoSaveProjectMinutes: TLabel;
    cbIsAutoSaveProject: TRzCheckBox;
    seAutoSaveProjectMinutes: TRzSpinEdit;
    RzGroupBox24: TRzGroupBox;
    cbListsInreversOrder: TRzCheckBox;
    RzGroupBox19: TRzGroupBox;
    lbCurrencyAccordance: TLabel;
    RzGroupBox17: TRzGroupBox;
    Label51: TLabel;
    Label52: TLabel;
    Label54: TLabel;
    btChoiceCurrency: TRzRapidFireButton;
    edCurrencyName: TRzEdit;
    edCurrencyNameBrief: TRzEdit;
    neNDS: TRzNumericEdit;
    RzGroupBox31: TRzGroupBox;
    Label63: TLabel;
    Label64: TLabel;
    seHeightThroughFloor: TRzSpinEdit;
    RzGroupBox42: TRzGroupBox;
    Label56: TLabel;
    Label71: TLabel;
    rbMetric_sm: TRzRadioButton;
    rbMetric_m: TRzRadioButton;
    rbWhitworth_in: TRzRadioButton;
    rbWhitworth_ft: TRzRadioButton;
    RzPanel1: TRzPanel;
    bCancel: TRzBitBtn;
    bPrev: TRzBitBtn;
    bNext: TRzBitBtn;
    cbCreateList: TRzCheckBox;
    TabList1: TRzTabSheet;
    TabList2: TRzTabSheet;
    RzGroupBox18: TRzGroupBox;
    Label32: TLabel;
    Label50: TLabel;
    edDefListName: TRzMaskEdit;
    edDefRoomName: TRzEdit;
    RzGroupBox3: TRzGroupBox;
    Label7: TLabel;
    Label8: TLabel;
    Label1: TLabel;
    Label2: TLabel;
    edRoomHeight: TcxMaskEdit;
    edFalseFloorHeight: TcxMaskEdit;
    RzGroupBox12: TRzGroupBox;
    Label18: TLabel;
    Label25: TLabel;
    Label20: TLabel;
    Label21: TLabel;
    Label19: TLabel;
    Label26: TLabel;
    Label22: TLabel;
    Label23: TLabel;
    Label24: TLabel;
    Label27: TLabel;
    edLengthKoef: TcxMaskEdit;
    edCableChannelFullnessKoef: TcxMaskEdit;
    edPortReserv: TcxMaskEdit;
    edMultiportReserv: TcxMaskEdit;
    edTwistedPairMaxLength: TcxMaskEdit;
    RzGroupBox5: TRzGroupBox;
    Label10: TLabel;
    Label11: TLabel;
    Label12: TLabel;
    Label13: TLabel;
    rbLineCeiling: TcxRadioButton;
    rbLineFalseFloor: TcxRadioButton;
    rbLineFloor: TcxRadioButton;
    rbLineConnObjects: TcxRadioButton;
    edLineCeiling: TcxMaskEdit;
    edLineFalseFloor: TcxMaskEdit;
    edLineFloor: TcxMaskEdit;
    edLineConnObjects: TcxMaskEdit;
    RzGroupBox4: TRzGroupBox;
    Label3: TLabel;
    Label4: TLabel;
    Label9: TLabel;
    rbConnCeiling: TcxRadioButton;
    rbConnFalseFloor: TcxRadioButton;
    rbConnFloor: TcxRadioButton;
    edConnCeiling: TcxMaskEdit;
    edConnFalseFloor: TcxMaskEdit;
    edConnFloor: TcxMaskEdit;
    edConnTotal: TcxMaskEdit;
    edLineTotal: TcxMaskEdit;
    gbRulerModeWhitworth: TRzGroupBox;
    Label72: TLabel;
    Label73: TLabel;
    Label74: TLabel;
    Label75: TLabel;
    Bevel2: TBevel;
    edSizeAsWhitworth: TcxMaskEdit;
    edSizeAllWhitworth: TcxMaskEdit;
    rbin1: TcxRadioButton;
    rbft1: TcxRadioButton;
    rbin2: TcxRadioButton;
    rbft2: TcxRadioButton;
    RzGroupBox22: TRzGroupBox;
    cbFontName: TRzFontComboBox;
    RzGroupBox1: TRzGroupBox;
    gbPageSize: TRzGroupBox;
    Label5: TLabel;
    Label6: TLabel;
    Label68: TLabel;
    Label69: TLabel;
    cbPageSize: TcxComboBox;
    edWidth: TcxSpinEdit;
    edHeight: TcxSpinEdit;
    edListCountX: TcxSpinEdit;
    edListCountY: TcxSpinEdit;
    RzGroupBox2: TRzGroupBox;
    rbPortrait: TcxRadioButton;
    rbLandscape: TcxRadioButton;
    RzGroupBox37: TRzGroupBox;
    RzGroupBox16: TRzGroupBox;
    rbSimple: TcxRadioButton;
    rbDetailed: TcxRadioButton;
    rbExtended: TcxRadioButton;
    RzGroupBox13: TRzGroupBox;
    rbUkr: TcxRadioButton;
    rbRus: TcxRadioButton;
    RzGroupBox38: TRzGroupBox;
    cbShowMainStamp: TRzCheckBox;
    cbShowUpperStamp: TRzCheckBox;
    cbShowSideStamp: TRzCheckBox;
    TabList3: TRzTabSheet;
    RzGroupBox6: TRzGroupBox;
    edSubPath: TRzEdit;
    bLoadSub: TRzButton;
    bAdvanced: TRzBitBtn;
    lng_Forms: TsiLangLinked;
    gbRulerModeMetric: TRzGroupBox;
    Label14: TLabel;
    Label16: TLabel;
    Label15: TLabel;
    Label17: TLabel;
    Bevel1: TBevel;
    edSizeAsMetric: TcxMaskEdit;
    edSizeAllMetric: TcxMaskEdit;
    rbmm1: TcxRadioButton;
    rbsm1: TcxRadioButton;
    rbm1: TcxRadioButton;
    rbmm2: TcxRadioButton;
    rbsm2: TcxRadioButton;
    rbm2: TcxRadioButton;
    cadMaket: TPowerCad;
    cbCurrency: TRzComboBox;
    cbRecalcPricesByNDSChange: TRzCheckBox;
    gbStampMargins: TRzGroupBox;
    Label76: TLabel;
    Label77: TLabel;
    Label78: TLabel;
    Label79: TLabel;
    seStampMarginLeft: TcxSpinEdit;
    seStampMarginRight: TcxSpinEdit;
    seStampMarginTop: TcxSpinEdit;
    seStampMarginBottom: TcxSpinEdit;
    lbStampDeveloper: TLabel;
    edStampDeveloper: TcxTextEdit;
    lbStampChecker: TLabel;
    edStampChecker: TcxTextEdit;
    btSetStampMarginsByPrinter: TSpeedButton;
    btSetDefStampMargins: TSpeedButton;
    rbUkrDSTU: TcxRadioButton;
    gbNewTracesLengthType: TRzGroupBox;
    rbNewTracesLengthAuto: TRzRadioButton;
    rbNewTracesLengthUser: TRzRadioButton;
    procedure bAdvancedClick(Sender: TObject);

    procedure rbPortraitClick(Sender: TObject);
    procedure rbLandscapeClick(Sender: TObject);
    procedure cbPageSizePropertiesCloseUp(Sender: TObject);

    procedure FormShow(Sender: TObject);

    procedure bListCancelClick(Sender: TObject);
    procedure rbConnCeilingClick(Sender: TObject);
    procedure rbConnFalseFloorClick(Sender: TObject);
    procedure rbConnFloorClick(Sender: TObject);
    procedure rbLineCeilingClick(Sender: TObject);
    procedure rbLineFalseFloorClick(Sender: TObject);
    procedure rbLineFloorClick(Sender: TObject);
    procedure rbLineConnObjectsClick(Sender: TObject);
    procedure edConnFloorPropertiesChange(Sender: TObject);
    procedure edConnRoomPropertiesChange(Sender: TObject);
    procedure edConnFalseFloorPropertiesChange(Sender: TObject);
    procedure edLineRoomPropertiesChange(Sender: TObject);
    procedure edLineFalseFloorPropertiesChange(Sender: TObject);
    procedure edLineFloorPropertiesChange(Sender: TObject);
    procedure edLineConnObjectsPropertiesChange(Sender: TObject);
    procedure bMasksCoponTypesClick(Sender: TObject);
    procedure cbAllNetworksClick(Sender: TObject);
    procedure cbShowLinesCaptionsClick(Sender: TObject);
    procedure bProjectOKClick(Sender: TObject);
    procedure bProjectCancelClick(Sender: TObject);
    procedure FormCreate(Sender: TObject);
    procedure FormDestroy(Sender: TObject);
    procedure bOKClick(Sender: TObject);
    procedure bCancleClick(Sender: TObject);
    procedure btChoiceCurrencyClick(Sender: TObject);
    procedure GlobalPageControlTabClick(Sender: TObject);
    procedure cbIsAutoSaveProjectClick(Sender: TObject);
    procedure edConnFloorExit(Sender: TObject);
    procedure edLineCeilingExit(Sender: TObject);
    procedure edLineFalseFloorExit(Sender: TObject);
    procedure edLineFloorExit(Sender: TObject);
    procedure edListNameExit(Sender: TObject);
    procedure edRoomHeightExit(Sender: TObject);
    procedure edFalseFloorHeightExit(Sender: TObject);
    procedure edLengthKoefExit(Sender: TObject);
    procedure edCableChannelFullnessKoefExit(Sender: TObject);
    procedure edPortReservExit(Sender: TObject);
    procedure edMultiportReservExit(Sender: TObject);
    procedure edTwistedPairMaxLengthExit(Sender: TObject);
    procedure edLineConnObjectsExit(Sender: TObject);
    procedure edStepGridExit(Sender: TObject);
    procedure edTraceWidthExit(Sender: TObject);
    procedure edBlockStepExit(Sender: TObject);
    procedure seCurrIndexKeyPress(Sender: TObject; var Key: Char);
    procedure seProjectIndexKeyPress(Sender: TObject; var Key: Char);
    procedure cbTraceStylePropertiesCloseUp(Sender: TObject);
    procedure edTraceWidthPropertiesEditValueChanged(Sender: TObject);
    procedure ListPageControlChange(Sender: TObject);
    procedure GlobalPageControlChange(Sender: TObject);
    procedure seIndexPointObjKeyPress(Sender: TObject; var Key: Char);
    procedure seIndexConnectorKeyPress(Sender: TObject; var Key: Char);
    procedure seIndexLineKeyPress(Sender: TObject; var Key: Char);
    procedure seIndexPointObjExit(Sender: TObject);
    procedure seIndexConnectorExit(Sender: TObject);
    procedure seIndexLineExit(Sender: TObject);
    procedure edWidthExit(Sender: TObject);
    procedure edHeightExit(Sender: TObject);
    procedure cbFontNameCloseUp(Sender: TObject);
    procedure rbSimpleClick(Sender: TObject);
    procedure rbExtendedClick(Sender: TObject);
    procedure rbDetailedClick(Sender: TObject);
    procedure rbUkrClick(Sender: TObject);
    procedure rbRusClick(Sender: TObject);
    procedure rbmm1Click(Sender: TObject);
    procedure rbsm1Click(Sender: TObject);
    procedure rbm1Click(Sender: TObject);
    procedure rbmm2Click(Sender: TObject);
    procedure rbsm2Click(Sender: TObject);
    procedure rbm2Click(Sender: TObject);
    procedure cbTraceColorPropertiesCloseUp(Sender: TObject);
    procedure edSizeAsMetricExit(Sender: TObject);
    procedure edSizeAllMetricExit(Sender: TObject);
    procedure cbCADCaptions_ShortClick(Sender: TObject);
    procedure cbCADCaptions_FullClick(Sender: TObject);
    procedure cbCADCaptionsDetailClick(Sender: TObject);
    procedure cbCADCaptionsSimpleClick(Sender: TObject);
    procedure cbCADNotes_ShortClick(Sender: TObject);
    procedure cbCADNotes_FullClick(Sender: TObject);
    procedure cbCADNotesDetailClick(Sender: TObject);
    procedure cbCADNotesSimpleClick(Sender: TObject);
    procedure edNotePrefixExit(Sender: TObject);
    procedure cbShowLinesLengthClick(Sender: TObject);
    procedure cbShowLinesNotesClick(Sender: TObject);
    procedure cbShowConnectorsCaptionsClick(Sender: TObject);
    procedure cbShowConnectorsNotesClick(Sender: TObject);
    procedure cbShowRaiseClick(Sender: TObject);
    procedure cbPutCableOnTraceClick(Sender: TObject);
    procedure cbApplyForAllSCSObjectsClick(Sender: TObject);
    procedure cbGroupObjectsByTypePropertiesChange(Sender: TObject);
    procedure cbReindexComponentsClick(Sender: TObject);
    procedure cbCADCaptionsExternalSCSClick(Sender: TObject);
    procedure cbLinesCaptionsColorPropertiesCloseUp(Sender: TObject);
    procedure cbConnectorsCaptionsColorPropertiesCloseUp(Sender: TObject);
    procedure cbLinesNotesColorPropertiesCloseUp(Sender: TObject);
    procedure cbConnectorsNotesColorPropertiesCloseUp(Sender: TObject);
    procedure cbLinesNotesFontSizeCloseUp(Sender: TObject);
    procedure cbConnectorsNotesFontSizeCloseUp(Sender: TObject);
    procedure cbLinesCaptionsFontSizeCloseUp(Sender: TObject);
    procedure cbConnectorsCaptionsFontSizeCloseUp(Sender: TObject);
    procedure cbLinesCaptionsFontSizeKeyPress(Sender: TObject;
      var Key: Char);
    procedure cbConnectorsCaptionsFontSizeKeyPress(Sender: TObject;
      var Key: Char);
    procedure cbLinesNotesFontSizeKeyPress(Sender: TObject; var Key: Char);
    procedure cbConnectorsNotesFontSizeKeyPress(Sender: TObject;
      var Key: Char);
    procedure cbLinesNotesFontSizeExit(Sender: TObject);
    procedure cbConnectorsNotesFontSizeExit(Sender: TObject);
    procedure cbLinesCaptionsFontSizeExit(Sender: TObject);
    procedure cbConnectorsCaptionsFontSizeExit(Sender: TObject);
    procedure cbLinesCaptionsFontBoldClick(Sender: TObject);
    procedure cbCrossATSFontBoldClick(Sender: TObject);
    procedure cbDistribCabFontBoldClick(Sender: TObject);
    procedure cbCrossATSFontSizeKeyPress(Sender: TObject; var Key: Char);
    procedure cbDistribCabFontSizeKeyPress(Sender: TObject; var Key: Char);
    procedure cbCrossATSFontSizeExit(Sender: TObject);
    procedure cbDistribCabFontSizeExit(Sender: TObject);
    procedure cbCrossATSFontSizeCloseUp(Sender: TObject);
    procedure cbDistribCabFontSizeCloseUp(Sender: TObject);
    procedure cbBlackPrintClick(Sender: TObject);
    procedure cbColorPrintClick(Sender: TObject);
    procedure rbInternalSCSClick(Sender: TObject);
    procedure rbExternalSCSClick(Sender: TObject);
    procedure rbInternalSCSPClick(Sender: TObject);
    procedure rbExternalSCSPClick(Sender: TObject);
    procedure lbSaveDefSettingsClick(Sender: TObject);
    procedure lbLoadDefSettingsClick(Sender: TObject);
    procedure lbOtherComponIndexingParamsClick(Sender: TObject);
    procedure edTraceStepRotateExit(Sender: TObject);
    procedure edTraceStepRotatePropertiesChange(Sender: TObject);
    procedure cbAutoCadMouseClick(Sender: TObject);
    procedure cbScaleByCursorClick(Sender: TObject);
    procedure cbAutoPosTraceBetweenRMClick(Sender: TObject);
    procedure edListCountXPropertiesChange(Sender: TObject);
    procedure edListCountYPropertiesChange(Sender: TObject);
    procedure cbShowMainStampClick(Sender: TObject);
    procedure cbShowUpperStampClick(Sender: TObject);
    procedure cbShowSideStampClick(Sender: TObject);
    procedure lbTracingParamsClick(Sender: TObject);
    procedure lbSaveLoadSettingsClick(Sender: TObject);
    procedure pmiSaveSettingsToFileClick(Sender: TObject);
    procedure pmiLoadSettingsFromFileClick(Sender: TObject);
    procedure pmiSaveNewProjSettingsToFileClick(Sender: TObject);
    procedure pmSaveLoadSettingsPopup(Sender: TObject);
    procedure edSaveUndoCountExit(Sender: TObject);
    procedure cbAllowSuppliesKindClick(Sender: TObject);
    procedure rbIndexPointComponInRoomClick(Sender: TObject);
    procedure rbIndexPointComponInListClick(Sender: TObject);
    procedure rbIndexPointComponInProjectClick(Sender: TObject);
    procedure rbMarkByTemplateClick(Sender: TObject);
    procedure rbMarkByTIAEIA606AClick(Sender: TObject);
    procedure rbRoomNameShortFromNameClick(Sender: TObject);
    procedure rbRoomNameShortFromDefStrClick(Sender: TObject);
    procedure edRoomHeightKeyPress(Sender: TObject; var Key: Char);

    procedure rbMetric_smClick(Sender: TObject);
    procedure rbMetric_mClick(Sender: TObject);
    procedure rbWhitworth_inClick(Sender: TObject);
    procedure rbWhitworth_ftClick(Sender: TObject);

    procedure edSizeAsWhitworthExit(Sender: TObject);
    procedure edSizeAllWhitworthExit(Sender: TObject);
    procedure rbin1Click(Sender: TObject);
    procedure rbft1Click(Sender: TObject);
    procedure rbin2Click(Sender: TObject);
    procedure rbft2Click(Sender: TObject);
    procedure cbCreateListClick(Sender: TObject);
    procedure bNextClick(Sender: TObject);
    procedure bPrevClick(Sender: TObject);
    procedure bLoadSubClick(Sender: TObject);
    procedure edWidthPropertiesChange(Sender: TObject);
    procedure edHeightPropertiesChange(Sender: TObject);
    procedure cbCurrencyChange(Sender: TObject);
    procedure seStampMarginLeftPropertiesChange(Sender: TObject);
    procedure seStampMarginRightPropertiesChange(Sender: TObject);
    procedure seStampMarginTopPropertiesChange(Sender: TObject);
    procedure seStampMarginBottomPropertiesChange(Sender: TObject);
    procedure btSetStampMarginsByPrinterClick(Sender: TObject);
    procedure btSetDefStampMarginsClick(Sender: TObject);
    procedure rbUkrDSTUClick(Sender: TObject);
    procedure rbNewTracesLengthTypeClick(Sender: TObject);

  private
    FComponTypesMarkMask: TF_ComponTypesMarkMask;
    FProjectSpravochnikForm: TF_CaseForm;
    FListSpravochnikForm: TF_CaseForm;

    FItemID: Integer;
    FItemType: TItemType;
    FListID: Integer;
    FListParams: TListParams;
    FMakeEditMode: TMakeEdit;
    FProjectCurrencyID: Integer;
    FProjectID: Integer;
    FProjectParams: TProjectParams;

    FProjectCurrency: TCurrency;
    FNBCurrency: TCurrency;

    FReindexPointCompons: Boolean;
    FIsFromMaster: Boolean;

    FCADStampForPrinter: Boolean;

    FNewTracesLengthTypeChanged: Boolean;
    FArrNewTracesLengthRB: TObjectArray; //array of TObject;
    FArrNewTracesLengthVal: TIntegerArray; // array of Integer;

    function CanShowlbSettings: Boolean;
    procedure DefineStyleRBNewTracesLengthType(Sender: TObject);
    function EnableLoadDefSettings: Boolean;
    procedure SetControlsByComponMarkMode;
    procedure SetControlsByPointComponIndexingMode;
    procedure SetControlsByProjType;
    procedure SetControlsByRoomNameShortSrcType;
    procedure SetEditsToZero;

    { Private declarations }
  public
    FMasterAsList: Boolean;
    FCurrProjUnitOfMeasure: Integer; 
    FCADParams: TCADParams;
    FParentCADParams: PCADParams;

    property F_ComponTypesMarkMask: TF_ComponTypesMarkMask read FComponTypesMarkMask write FComponTypesMarkMask;
    property F_ProjectSpravochnikForm: TF_CaseForm read FProjectSpravochnikForm write FProjectSpravochnikForm;
    property F_ListSpravochnikForm: TF_CaseForm read FListSpravochnikForm write FListSpravochnikForm;

    procedure SetPageParamsOnChange;
    //<From Oleg>
    procedure BeforeShowForm;
    procedure CreateSpravochniki;
    procedure FormAsList(AAsList: Boolean);
    procedure FormModeAsProject(AAsProject: Boolean);

    function GetPointComonIndexingModeFromForm: TPointComonIndexingMode;
    function GetMarkModeFrom: TMarkMode;

    procedure SetProjCurrencyMToForm(AShowCurrencyM: Boolean);
    procedure SetProjCurrencyToForm(ACurrency: TCurrency; AReloadCombo: Boolean=true);
    procedure SetProjCurrencyToFormByID(AIDCurrency: Integer);
    procedure SetNBCurrencyToForm;
    
    procedure ShowListSpravochnik(ASpravochnikKind: TViewKind; AGUIDToLocate: String);
    procedure ShowProjectSpravochnik(ASpravochnikKind: TViewKind; AGUIDToLocate: String);
    //</From Oleg>
    procedure SetParamsOnLineTracingType(aLineTracingType: TLineTracingType; aRoomHeight, aFalseFloorHeight, aLineHeight, aConnHeight: Double);
    procedure ClearAllChangedColor;
    function CheckMapScaleResult: Double;
    function GetRuleStep(AOnlyifChecked: Boolean): Double;
    function GetRuleAllSize(AOnlyifChecked: Boolean): Double;

    // установить СИ и MaskEdits
    procedure SetUOM(aUOM: Integer; AIsChanging: Boolean=false);
    procedure SetMaskEdits;
    procedure SetMaket;

    // MAIN
    function  MakeEditProject(AMakeEdit: TMakeEdit; AIDProject: Integer;  var AProjectParams: TProjectParams;
                ASpravochnikKind: TViewKind = vkNone; AGUIDToLocate: String = '';
                AIsFromMaster: Boolean=false; AParentCADParams: PCADParams=nil): Boolean;
    function  ChangeListParams(AMakeEdit: TMakeEdit; var AListParams: TListParams; AShowForm: Boolean; {aCADParams: TCADParams}
                  ASpravochnikKind: TViewKind = vkNone; AGUIDToLocate: String = '';
                  AIsFromMaster: Boolean=false; AParentCADParams: PCADParams=nil): Boolean;

    function GetListParamsFromForm(ALoadSpravochnik: Boolean = true): TListParams;
    procedure SetListParamsToForm(AListParams: TListParams; AFirstLoading: Boolean = true{; aCADParams: TCADParams});
    function  GetProjectParamsFromForm(ALoadSpravochnik: Boolean = true): TProjectParams;
    procedure SetProjectParamsToForm(AProjectParams: TProjectParams; AFirstLoading: Boolean = true);

    { Public declarations }
  end;

var
  F_MasterNewListLite: TF_MasterNewListLite;

implementation
uses USCS_Main, U_CAD, U_Main, U_SCSObjectsProp, U_Constants, DB, U_MasterNewList, {Tolik 01/08/2019 -- } U_BaseSettings;
{$R *.dfm}

procedure TF_MasterNewListLite.bAdvancedClick(Sender: TObject);
begin
  try

  except
    on E: Exception do AddExceptionToLogEx('TF_MasterNewListLite.bAdvancedClick', E.Message);
  end;
end;

procedure TF_MasterNewListLite.SetPageParamsOnChange;
begin
  try
    // A0
    if cbPageSize.ItemIndex = 0 then
    begin
      if rbLandscape.Checked then
      begin
        edWidth.Value := cA0x * edListCountX.Value;
        edHeight.Value := cA0y * edListCountY.Value;
      end;
      if rbPortrait.Checked then
      begin
        edWidth.Value := cA0y * edListCountX.Value;
        edHeight.Value := cA0x * edListCountY.Value;
      end;
    end;
    // A1
    if cbPageSize.ItemIndex = 1 then
    begin
      if rbLandscape.Checked then
      begin
        edWidth.Value := cA1x * edListCountX.Value;
        edHeight.Value := cA1y * edListCountY.Value;
      end;
      if rbPortrait.Checked then
      begin
        edWidth.Value := cA1y * edListCountX.Value;
        edHeight.Value := cA1x * edListCountY.Value;
      end;
    end;
    // A2
    if cbPageSize.ItemIndex = 2 then
    begin
      if rbLandscape.Checked then
      begin
        edWidth.Value := cA2x * edListCountX.Value;
        edHeight.Value := cA2y * edListCountY.Value;
      end;
      if rbPortrait.Checked then
      begin
        edWidth.Value := cA2y * edListCountX.Value;
        edHeight.Value := cA2x * edListCountY.Value;
      end;
    end;
    // A3
    if cbPageSize.ItemIndex = 3 then
    begin
      if rbLandscape.Checked then
      begin
        edWidth.Value := cA3x * edListCountX.Value;
        edHeight.Value := cA3y * edListCountY.Value;
      end;
      if rbPortrait.Checked then
      begin
        edWidth.Value := cA3y * edListCountX.Value;
        edHeight.Value := cA3x * edListCountY.Value;
      end;
    end;
    // A4
    if cbPageSize.ItemIndex = 4 then
    begin
      if rbLandscape.Checked then
      begin
        edWidth.Value := cA4x * edListCountX.Value;
        edHeight.Value := cA4y * edListCountY.Value;
      end;
      if rbPortrait.Checked then
      begin
        edWidth.Value := cA4y * edListCountX.Value;
        edHeight.Value := cA4x * edListCountY.Value;
      end;
    end;
    // A5
    if cbPageSize.ItemIndex = 5 then
    begin
      if rbLandscape.Checked then
      begin
        edWidth.Value := cA5x * edListCountX.Value;
        edHeight.Value := cA5y * edListCountY.Value;
      end;
      if rbPortrait.Checked then
      begin
        edWidth.Value := cA5y * edListCountX.Value;
        edHeight.Value := cA5x * edListCountY.Value;
      end;
    end;
    // A6
    if cbPageSize.ItemIndex = 6 then
    begin
      if rbLandscape.Checked then
      begin
        edWidth.Value := cA6x * edListCountX.Value;
        edHeight.Value := cA6y * edListCountY.Value;
      end;
      if rbPortrait.Checked then
      begin
        edWidth.Value := cA6y * edListCountX.Value;
        edHeight.Value := cA6x * edListCountY.Value;
      end;
    end;
    // B4
    if cbPageSize.ItemIndex = 7 then
    begin
      if rbLandscape.Checked then
      begin
        edWidth.Value := cB4x * edListCountX.Value;
        edHeight.Value := cB4y * edListCountY.Value;
      end;
      if rbPortrait.Checked then
      begin
        edWidth.Value := cB4y * edListCountX.Value;
        edHeight.Value := cB4x * edListCountY.Value;
      end;
    end;
    // B5
    if cbPageSize.ItemIndex = 8 then
    begin
      if rbLandscape.Checked then
      begin
        edWidth.Value := cB5x * edListCountX.Value;
        edHeight.Value := cB5y * edListCountY.Value;
      end;
      if rbPortrait.Checked then
      begin
        edWidth.Value := cB5y * edListCountX.Value;
        edHeight.Value := cB5x * edListCountY.Value;
      end;
    end;
    // Письменный
    if cbPageSize.ItemIndex = 9 then
    begin
      if rbLandscape.Checked then
      begin
        edWidth.Value := cLetterx * edListCountX.Value;
        edHeight.Value := cLettery * edListCountY.Value;
      end;
      if rbPortrait.Checked then
      begin
        edWidth.Value := cLettery * edListCountX.Value;
        edHeight.Value := cLetterx * edListCountY.Value;
      end;
    end;
    // Газетный
    if cbPageSize.ItemIndex = 10 then
    begin
      if rbLandscape.Checked then
      begin
        edWidth.Value := cTabloidx * edListCountX.Value;
        edHeight.Value := cTabloidy * edListCountY.Value;
      end;
      if rbPortrait.Checked then
      begin
        edWidth.Value := cTabloidy * edListCountX.Value;
        edHeight.Value := cTabloidx * edListCountY.Value;
      end;
    end;
    //
    if cbPageSize.ItemIndex <= 10 then
    begin
     edWidth.Properties.ReadOnly := True;
     edHeight.Properties.ReadOnly := True;
    end
    else
    if cbPageSize.ItemIndex = 11 then
    begin
     edWidth.Properties.ReadOnly := False;
     edHeight.Properties.ReadOnly := False;
    end;
  except
    on E: Exception do AddExceptionToLogEx('TF_MasterNewListLite.SetPageParamsOnChange', E.Message);
  end;
end;

procedure TF_MasterNewListLite.rbPortraitClick(Sender: TObject);
var
  CheckPageSizeIndex: Integer;
  CheckListCountX: Integer;
  CheckListCountY: Integer;
  CheckPageOrient: TPageOrient; 
begin
  try
    SetPageParamsOnChange;
    if FCADParams.CADPageOrient = poPortrait then
    begin
      rbPortrait.Font.Color := clBlack;
      rbLandscape.Font.Color := clBlack;
    end
    else
    begin
      rbPortrait.Font.Color := clBlue;
      rbLandscape.Font.Color := clBlack;
    end;
    SetMaket;
  except
    on E: Exception do AddExceptionToLogEx('TF_MasterNewListLite.rbPortraitClick', E.Message);
  end;
end;

procedure TF_MasterNewListLite.rbLandscapeClick(Sender: TObject);
var
  CheckPageSizeIndex: Integer;
  CheckListCountX: Integer;
  CheckListCountY: Integer;
  CheckPageOrient: TPageOrient; 
begin
  try
    SetPageParamsOnChange;
    if FCADParams.CADPageOrient = poLandscape then
    begin
      rbPortrait.Font.Color := clBlack;
      rbLandscape.Font.Color := clBlack;
    end
    else
    begin
      rbPortrait.Font.Color := clBlack;
      rbLandscape.Font.Color := clBlue;
    end;
    SetMaket;
  except
    on E: Exception do AddExceptionToLogEx('TF_MasterNewListLite.rbLandscapeClick', E.Message);
  end;
end;

procedure TF_MasterNewListLite.cbPageSizePropertiesCloseUp(Sender: TObject);
var
  CheckValue: Integer;
  CheckPageSizeIndex: Integer;
  CheckListCountX: Integer;
  CheckListCountY: Integer;
  CheckPageOrient: TPageOrient; 
begin
  try
    SetPageParamsOnChange;
    CheckValue := cbPageSize.ItemIndex;
    if CheckValue = FCADParams.CADPageSizeIndex then
      cbPageSize.Style.Font.Color := clBlack
    else
      cbPageSize.Style.Font.Color := clBlue;
    SetMaket;      
  except
    on E: Exception do AddExceptionToLogEx('TF_MasterNewListLite.cbPageSizePropertiesCloseUp', E.Message);
  end;
end;

procedure TF_MasterNewListLite.FormShow(Sender: TObject);
var
  ListParams: TListParams;
  ListSettings: TListSettingRecord;
  CurMapScale: Double;
begin
  try
    ClearAllChangedColor;
    // СИ
    SetUOM(FProjectParams.Setting.UnitOfMeasure, false);
    if (FProjectParams.Setting.UnitOfMeasure = umSm) or (FProjectParams.Setting.UnitOfMeasure = umM) then
    begin
      gbRulerModeMetric.Visible := True;
      gbRulerModeWhitworth.Visible := False;
    end
    else
    if (FProjectParams.Setting.UnitOfMeasure = umIn) or (FProjectParams.Setting.UnitOfMeasure = umFt) then
    begin
      gbRulerModeMetric.Visible := False;
      gbRulerModeWhitworth.Visible := True;
    end;

    // !!!
    if F_MasterNewListLite.Tag <> 1 then
    begin
      rbm1.Checked := True;
      //21.09.2010 edSizeAsMetric.Text := FormatFloat(ffMask, 1);
      if edSizeAsMetric.Text = '' then
        edSizeAsMetric.Text := FormatFloat(ffMask, 1);
      rbft1.Checked := True;
      //21.09.2010 edSizeAsWhitworth.Text := FormatFloat(ffMask, 1);;
      if edSizeAsWhitworth.Text = '' then
        edSizeAsWhitworth.Text := FormatFloat(ffMask, 1);
    end;
    // !!!

    if F_MasterNewListLite.Tag = 0 then
    begin
      //cbShowLinesCaptions.AllowGrayed := False;
      //cbShowLinesCaptions.State := cbChecked;
      //cbShowLinesNotes.AllowGrayed := False;
      //cbShowLinesNotes.State := cbUnchecked;
      //cbShowConnectorsCaptions.AllowGrayed := False;
      //cbShowConnectorsCaptions.State := cbChecked;
      //cbShowConnectorsNotes.AllowGrayed := False;
      //cbShowConnectorsNotes.State := cbUnchecked;
      // типы сетей
      //cbAllNetworks.Checked := True;
      //cbComputerNetwork.Checked := false;
      //cbComputerNetwork.Enabled := false;
      //cbTelephonNetwork.Checked := false;
      //cbTelephonNetwork.Enabled := false;
      //cbElectricNetwork.Checked := false;
      //cbElectricNetwork.Enabled := false;
      //cbTelevisionNetwork.Checked := false;
      //cbTelevisionNetwork.Enabled := false;
      //cbGasNetwork.Checked := false;
      //cbGasNetwork.Enabled := false;
    end;

    SetPageParamsOnChange;
    //cbApplyForAllSCSObjects.Checked := True;
    //cbApplyForSelectedOnly.Checked := False;

    //cbRescaleDrawing.Enabled := False;
    //cbRescaleDrawing.Checked := False;

    //lbLoadDefSettings.Enabled := EnableLoadDefSettings and CanShowlbSettings;
    //lbSaveDefSettings.Enabled := CanShowlbSettings;
    //lbSaveLoadSettings.Enabled := CanShowlbSettings;

    cbCreateList.Checked := True;
  except
    on E: Exception do AddExceptionToLogEx('TF_MasterNewListLite.FormShow', E.Message);
  end;
end;

procedure TF_MasterNewListLite.bListCancelClick(Sender: TObject);
begin
  Close;
end;

procedure TF_MasterNewListLite.rbConnCeilingClick(Sender: TObject);
begin
  try
    edConnCeiling.Enabled := True;
    edConnFalseFloor.Enabled := False;
    edConnFloor.Enabled := False;
    try
      edConnTotal.Text := FormatFloat(ffMask, StrToFloat_My(edRoomHeight.Text) - StrToFloat_My(edConnCeiling.Text));
    except
      edConnTotal.Text := '0';
    end;
    if F_MasterNewListLite.Visible and edConnCeiling.Visible then
    begin
      try
        edConnCeiling.SetFocus;
        edConnCeiling.SelStart := 0;
        edConnCeiling.SelLength := Length(edConnCeiling.Text) + 1;
      except
      end;
    end;
  except
    on E: Exception do AddExceptionToLogEx('TF_MasterNewListLite.rbConnCeilingClick', E.Message);
  end;
end;

procedure TF_MasterNewListLite.rbConnFalseFloorClick(Sender: TObject);
begin
  try
    edConnCeiling.Enabled := False;
    edConnFalseFloor.Enabled := True;
    edConnFloor.Enabled := False;
    try
      edConnTotal.Text := FormatFloat(ffMask, StrToFloat_My(edRoomHeight.Text) - StrToFloat_My(edFalseFloorHeight.Text) - StrToFloat_My(edConnFalseFloor.Text));
    except
      edConnTotal.Text := '0';
    end;
    if F_MasterNewListLite.Visible and edConnFalseFloor.Visible then
    begin
      try
        edConnFalseFloor.SetFocus;
        edConnFalseFloor.SelStart := 0;
        edConnFalseFloor.SelLength := Length(edConnFalseFloor.Text) + 1;
      except
      end;
    end;
  except
    on E: Exception do AddExceptionToLogEx('TF_MasterNewListLite.rbConnFalseFloorClick', E.Message);
  end;
end;

procedure TF_MasterNewListLite.rbConnFloorClick(Sender: TObject);
begin
  try
    edConnCeiling.Enabled := False;
    edConnFalseFloor.Enabled := False;
    edConnFloor.Enabled := True;
    try
      edConnTotal.Text := edConnFloor.Text;
    except
      edConnTotal.Text := '0';
    end;
    if F_MasterNewListLite.Visible and edConnFloor.Visible then
    begin
      try
        edConnFloor.SetFocus;
        edConnFloor.SelStart := 0;
        edConnFloor.SelLength := Length(edConnFloor.Text) + 1;
      except
      end;
    end;
  except
    on E: Exception do AddExceptionToLogEx('TF_MasterNewListLite.rbConnFloorClick', E.Message);
  end;
end;

procedure TF_MasterNewListLite.rbLineCeilingClick(Sender: TObject);
var
  CheckValue: Double;
begin
  try
    edLineCeiling.Enabled := True;
    edLineFalseFloor.Enabled := False;
    edLineFloor.Enabled := False;
    edLineConnObjects.Enabled := False;
    try
      edLineTotal.Text := FormatFloat(ffMask, StrToFloat_My(edRoomHeight.Text) - StrToFloat_My(edLineCeiling.Text));
    except
      edLineTotal.Text := '0';
    end;
    if (GCadForm <> nil) and (GCadForm.PCad <> nil) then
      GCadForm.FLineTracingType := ltt_FromCeiling;
    CheckValue := StrToFloat_My(edLineTotal.Text);
    if CheckValue = MetreToUOM(FCADParams.CADHeightLines) then
      edLineTotal.Style.Font.Color := clBlack
    else
      edLineTotal.Style.Font.Color := clBlue;
    if F_MasterNewListLite.Visible and edLineCeiling.Visible then
    begin
      try
        edLineCeiling.SetFocus;
        edLineCeiling.SelStart := 0;
        edLineCeiling.SelLength := Length(edLineCeiling.Text) + 1;
      except
      end;
    end;
  except
    on E: Exception do AddExceptionToLogEx('TF_MasterNewListLite.rbLineCeilingClick', E.Message);
  end;
end;

procedure TF_MasterNewListLite.rbLineFalseFloorClick(Sender: TObject);
var
  CheckValue: Double;
begin
  try
    edLineCeiling.Enabled := False;
    edLineFalseFloor.Enabled := True;
    edLineFloor.Enabled := False;
    edLineConnObjects.Enabled := False;
    try
      edLineTotal.Text := FormatFloat(ffMask, StrToFloat_My(edRoomHeight.Text) - StrToFloat_My(edFalseFloorHeight.Text) - StrToFloat_My(edLineFalseFloor.Text));
    except
      edConnTotal.Text := '0';
    end;
    if (GCadForm <> nil) and (GCadForm.PCad <> nil) then
      GCadForm.FLineTracingType := ltt_FromFalseFloor;
    CheckValue := StrToFloat_My(edLineTotal.Text);
    if CheckValue = MetreToUOM(FCADParams.CADHeightLines) then
      edLineTotal.Style.Font.Color := clBlack
    else
      edLineTotal.Style.Font.Color := clBlue;
    if F_MasterNewListLite.Visible and edLineFalseFloor.Visible then
    begin
      try
        edLineFalseFloor.SetFocus;
        edLineFalseFloor.SelStart := 0;
        edLineFalseFloor.SelLength := Length(edLineFalseFloor.Text) + 1;
      except
      end;
    end;
  except
    on E: Exception do AddExceptionToLogEx('TF_MasterNewListLite.rbLineFalseFloorClick', E.Message);
  end;
end;

procedure TF_MasterNewListLite.rbLineFloorClick(Sender: TObject);
var
  CheckValue: Double;
begin
  try
    edLineCeiling.Enabled := False;
    edLineFalseFloor.Enabled := False;
    edLineFloor.Enabled := True;
    edLineConnObjects.Enabled := False;
    try
      edLineTotal.Text := edLineFloor.Text;
    except
      edLineTotal.Text := '0';
    end;
    if (GCadForm <> nil) and (GCadForm.PCad <> nil) then
      GCadForm.FLineTracingType := ltt_FromFloor;
    CheckValue := StrToFloat_My(edLineTotal.Text);
    if CheckValue = MetreToUOM(FCADParams.CADHeightLines) then
      edLineTotal.Style.Font.Color := clBlack
    else
      edLineTotal.Style.Font.Color := clBlue;

    if F_MasterNewListLite.Visible and edLineFloor.Visible then
    begin
      try
        edLineFloor.SetFocus;
        edLineFloor.SelStart := 0;
        edLineFloor.SelLength := Length(edLineFloor.Text) + 1;
      except
      end;
    end;
  except
    on E: Exception do AddExceptionToLogEx('TF_MasterNewListLite.rbLineFloorClick', E.Message);
  end;
end;

procedure TF_MasterNewListLite.rbLineConnObjectsClick(Sender: TObject);
var
  CheckValue: Double;
begin
  try
    edLineCeiling.Enabled := False;
    edLineFalseFloor.Enabled := False;
    edLineFloor.Enabled := False;
    edLineConnObjects.Enabled := True;
    try
      edLineTotal.Text := FormatFloat(ffMask, StrToFloat_My(edConnTotal.Text) + StrToFloat_My(edLineConnObjects.Text));
    except
      edLineTotal.Text := '0';
    end;
    if (GCadForm <> nil) and (GCadForm.PCad <> nil) then
      GCadForm.FLineTracingType := ltt_FromConnObjects;
    CheckValue := StrToFloat_My(edLineTotal.Text);
    if CheckValue = MetreToUOM(FCADParams.CADHeightLines) then
      edLineTotal.Style.Font.Color := clBlack
    else
      edLineTotal.Style.Font.Color := clBlue;
    if F_MasterNewListLite.Visible and edLineConnObjects.Visible then
    begin
      try
        edLineConnObjects.SetFocus;
        edLineConnObjects.SelStart := 0;
        edLineConnObjects.SelLength := Length(edLineConnObjects.Text) + 1;
      except
      end;
    end;
  except
    on E: Exception do AddExceptionToLogEx('TF_MasterNewListLite.rbLineConnObjectsClick', E.Message);
  end;
end;

procedure TF_MasterNewListLite.FormAsList(AAsList: Boolean);
begin
  try
      // При старте
    PageControl.ActivePageIndex := 1;
    bPrev.Enabled := False;
    bNext.Caption := cMasterNewListLite_Mes1;
    bNext.ModalResult := mrNone;

//    pnComponentType.Visible := Not AAsList;
//    F_ListSpravochnikForm.GT_ComponentTypesComponentIndex.Visible := Not AAsList;
{    F_ProjMan.F_MakeEditComponentType.lbNewComponentIndex.Visible := Not AAsList;
    F_ProjMan.F_MakeEditComponentType.lbNewComponentIndexProjArea.Visible := Not AAsList;
    F_ProjMan.F_MakeEditComponentType.seNewComponentIndex.Visible := Not AAsList;}
    F_ProjMan.F_MakeEditComponentType.RzRadiogroup1.Visible := Not AAsList;
    //*** Загрузить свойства для типов компонент
    if AAsList and Not FIsFromMaster then
    begin
//      lbSaveDefSettings.Caption := cMasterNewList_Mes7_2;
//      lbLoadDefSettings.Caption := cMasterNewList_Mes8_2;
//      pmiSaveSettingsToFile.Caption := cMasterNewList_Mes9_3;
//      pmiLoadSettingsFromFile.Caption := cMasterNewList_Mes9_4;
      LoadFromItemSpravochnikToForm(F_MasterNewList.F_ProjectSpravochnikForm, F_ProjMan.GSCSBase.CurrProject.CurrID, itProject, false, [vkProperty]);
    end;
  except
    on E: Exception do AddExceptionToLogEx('TF_MasterNewListLite.FormAsList', E.Message);
  end;
end;

procedure TF_MasterNewListLite.FormModeAsProject(AAsProject: Boolean);
begin
  try
    // При старте
    PageControl.ActivePageIndex := 0;
    bPrev.Enabled := False;
    bNext.Caption := cMasterNewListLite_Mes1;
    bNext.ModalResult := mrNone;
    if AAsProject then
      cbRecalcPricesByNDSChange.Visible := FMakeEditMode <> meMake;
  
//    TabProjectProperties.TabVisible := AAsProject;
//    TabListProperties.TabVisible := AAsProject;
//    tsProjectSpravochniki.TabVisible := AAsProject;
//    gbListName.Enabled := Not AAsProject;
//    cbApplyForAllSCSObjects.Visible := Not AAsProject;
//    cbApplyForSelectedOnly.Visible := Not AAsProject;
    //bListOK.Visible := Not AAsProject;
    //bListCancel.Visible := Not AAsProject;
//    lbCurrIndex.Enabled := Not AAsProject;
//    seCurrIndex.Enabled := Not AAsProject;
//    gbIndexesForNewObjects.Visible := Not AAsProject;

//    pnComponentType.Visible := AAsProject and (FMakeEditMode <> meMake);

//    if AAsProject then
//    begin
//      cbReindexAllPointComponents.Checked := false;
//      cbReindexComponents.Checked := false;
//      cbReindexInChangedTypes.Checked := true;
//      cbRemarkAllCompons.Checked := false;
//      lbSaveDefSettings.Caption := cMasterNewList_Mes7_1;
//      lbLoadDefSettings.Caption := cMasterNewList_Mes8_1;
//      pmiSaveSettingsToFile.Caption := cMasterNewList_Mes9_1;
//      pmiLoadSettingsFromFile.Caption := cMasterNewList_Mes9_2;
//    end;

//    if AAsProject then
//    begin
//      GlobalPageControl.ActivePage := TabProjectProperties;
//      pcProjectOptions.ActivePage := tsProjOptionsGeneral;
//    end
//    else
//      GlobalPageControl.ActivePage := TabListProperties;
  except
    on E: Exception do AddExceptionToLogEx('TF_MasterNewListLite.FormModeAsProject', E.Message);
  end;
end;

procedure TF_MasterNewListLite.BeforeShowForm;
begin
  FNewTracesLengthTypeChanged := false;
end;

procedure TF_MasterNewListLite.CreateSpravochniki;

  procedure SetFormToTabSheet(AForm: TForm; ATabSheet: TWinControl);
  begin
    try
//      AForm.Parent := ATabSheet;
//      AForm.BorderStyle := bsNone;
//      AForm.Align := alClient;
//      TF_CaseForm(AForm).Panel_OkCancel.Visible := false;
//      AForm.Visible := true;
    except
      on E: Exception do AddExceptionToLogEx('SetFormToTabSheet', E.Message);
    end;
  end;
begin
  try
//    FProjectSpravochnikForm := TF_CaseForm.Create(F_ProjMan, F_ProjMan, Self, itProject);
//    FListSpravochnikForm := TF_CaseForm.Create(F_ProjMan, F_ProjMan, Self, itList);

//    SetFormToTabSheet(FProjectSpravochnikForm, tsProjectSpravochniki);
//    SetFormToTabSheet(FListSpravochnikForm, tsListSpravochniki);

//    FProjectSpravochnikForm.pcDirectories.ActivePage := FProjectSpravochnikForm.tsCurrency;
//    FListSpravochnikForm.pcDirectories.ActivePage := FListSpravochnikForm.tsComponentTypes;

//    FProjectSpravochnikForm.PrepareForm(vkCurrency, fmView);
//    FListSpravochnikForm.PrepareForm(vkComponentType, fmView);

//    FProjectSpravochnikForm.MemTableComponTypes := FListSpravochnikForm.mtComponentType;
//    FProjectSpravochnikForm.MemTableProperties := FProjectSpravochnikForm.mtProperties;
//    FListSpravochnikForm.MemTableProperties := FProjectSpravochnikForm.mtProperties;

  except
    on E: Exception do AddExceptionToLogEx('TF_MasterNewListLite.CreateSpravochniki: ', E.Message);
  end;
end;

function TF_MasterNewListLite.GetListParamsFromForm(ALoadSpravochnik: Boolean = true): TListParams;
begin
  try
    ZeroMemory(@Result, SizeOf(TListParams));
    Result := FListParams;

//    Result.Name := edListName.Text;
//    Result.IsIndexWithName := BoolToInt(cbListIsIndexWithName.Checked);

    // ListIndex
//    Result.MarkID := Round(seCurrIndex.Value);
//    Result.IndexConnector := Round(seIndexConnector.Value - 1);
//    Result.IndexLine := Round(seIndexLine.Value - 1);
//    Result.IndexPointObj := Round(seIndexPointObj.Value - 1);
//    Result.Caption := Result.Name + ' ' + IntTostr(Result.MarkID);

    Result.Settings.CADPageSizeIndex := cbPageSize.ItemIndex;
    Result.Settings.CADListCountX := edListCountX.Value;
    Result.Settings.CADListCountY := edListCountY.Value;
    Result.Settings.CADWidth := edWidth.Value / edListCountX.Value;
    Result.Settings.CADHeight := edHeight.Value / edListCountY.Value;

    if rbLandscape.Checked then
      Result.Settings.CADPageOrient := poLandscape;
    if rbPortrait.Checked then
      Result.Settings.CADPageOrient := poPortrait;

//    Result.Settings.CADGridStep := StrToFloat_My(edStepGrid.Text);

    // Штамп стандартный/подробный
    if rbSimple.Checked then
      Result.Settings.CADStampType := stt_simple;
    if rbExtended.Checked then
      Result.Settings.CADStampType := stt_extended;
    if rbDetailed.Checked then
      Result.Settings.CADStampType := stt_detailed;

    // язык украинский/русский/английский
    {$IF Defined(SCS_PE) or Defined(SCS_SPA)}
      Result.Settings.CADStampLang := stl_eng;
    {$ELSE}
      {$IF Defined(SCS_RF)}
        Result.Settings.CADStampLang := stl_rus;
      {$ELSE}
        if rbUkr.Checked then
          Result.Settings.CADStampLang := stl_ukr
        else if rbRus.Checked then
          Result.Settings.CADStampLang := stl_rus
        else if rbUkrDSTU.Checked then
          Result.Settings.CADStampLang := stl_ukr_dstu;
      {$IFEND}
    {$IFEND}

    //11.11.2011 отступы рамки листа
    //Result.Settings.CADStampMargins.Left := FloatInUOM(seStampMarginLeft.Value, ConvertUOMToMin(GCurrProjUnitOfMeasure), umMM);
    //Result.Settings.CADStampMargins.Right := FloatInUOM(seStampMarginRight.Value, ConvertUOMToMin(GCurrProjUnitOfMeasure), umMM);
    //Result.Settings.CADStampMargins.Top := FloatInUOM(seStampMarginTop.Value, ConvertUOMToMin(GCurrProjUnitOfMeasure), umMM);
    //Result.Settings.CADStampMargins.Bottom := FloatInUOM(seStampMarginBottom.Value, ConvertUOMToMin(GCurrProjUnitOfMeasure), umMM);
    Result.Settings.CADStampMargins := GetStampMarginsFromForm(Self, GCurrProjUnitOfMeasure); //28.11.2011
    Result.Settings.CADStampForPrinter := FCADStampForPrinter; //29.11.2011

    //15.11.2011 - Разработал проверил
    Result.Settings.CADStampDeveloper := edStampDeveloper.Text;
    Result.Settings.CADStampChecker := edStampChecker.Text;


    // ObjType in CAD
//    if cbCADCaptions_Short.Checked then
//      Result.Settings.ShowObjectTypeCAD := st_Short;
//    if cbCADCaptions_Full.Checked then
//      Result.Settings.ShowObjectTypeCAD := st_Full;
    // ObjCaptionsKind in CAD
//    if cbCADCaptionsDetail.Checked then
//      Result.Settings.CADCaptionsKind := skDetail
//    else
//    if cbCADCaptionsSimple.Checked then
//      Result.Settings.CADCaptionsKind := skSimple
//    else
//    if cbCADCaptionsExternalSCS.Checked then
//      Result.Settings.CADCaptionsKind := skExternalSCS;

    // ObjNotesType
//    if cbCADNotes_Short.Checked then
//      Result.Settings.CADShowObjectNotesType := st_Short;
//    if cbCADNotes_Full.Checked then
//      Result.Settings.CADShowObjectNotesType := st_Full;
    // ObjNotesKind
//    if cbCADNotesDetail.Checked then
//      Result.Settings.CADNotesKind := skDetail
//    else
//    if cbCADNotesSimple.Checked then
//      Result.Settings.CADNotesKind := skSimple;

    // TraceColor
//    Result.Settings.CADTraceColor := cbTraceColor.ColorValue;
    // TraceStyle
//    Result.Settings.CADTraceStyle := TPenStyle(cbTraceStyle.ItemIndex);
    // TraceWidth
//    Result.Settings.CADTraceWidth := StrToInt(edTraceWidth.Text);
    // NotePrefix
//    Result.Settings.NoteCountPrefix := edNotePrefix.Text;

    // ObjType in PM
//    if cbPM_Short.Checked then
//      Result.Settings.ShowObjectTypePM := st_Short;
//    if cbPM_Full.Checked then
//      Result.Settings.ShowObjectTypePM := st_Full;
    // Grouping Objects in Tree
//    Result.Settings.GroupListObjectsByType := cbGroupObjectsByType.Checked;

    // Control Join/Complect Components
//    Result.Settings.ControlJoinByNetType := cbControlJoinByNetType.Checked;
//    Result.Settings.ControlComplectByProducer := cbControlComplectByProducer.Checked;
//    Result.Settings.ControlJoinByProperties := cbControlJoinByProperties.Checked;
//    Result.Settings.ControlComplectByProperties := cbControlComplectByProperties.Checked;

    // Установка эл-в каб. каналов
//    Result.Settings.CanSetCorkBetweenTraces := cbCanSetCorkBetweenTraces.Checked;

    // Put Cable in Trace
//    Result.Settings.PutCableInTrace := cbPutCableOnTrace.Checked;

//    if TCheckBoxState(cbShowLinesCaptions.State) <> cbGrayed then
//    begin
      // ShowLinesCaptions
//      Result.Settings.ShowLineObjectCaption := cbShowLinesCaptions.Checked;
//    end;
//    if cbShowLinesLength.Enabled and (TCheckBoxState(cbShowLinesLength.State) <> cbGrayed) then
//    begin
      // ShowLineLngth
//      Result.Settings.ShowLineObjectLength := cbShowLinesLength.Checked;
//    end;
//    if TCheckBoxState(cbShowLinesNotes.State) <> cbGrayed then
//    begin
      // ShowLinesNotes
//      Result.Settings.ShowLineObjectNote := cbShowLinesNotes.Checked;
//    end;
//    if TCheckBoxState(cbShowConnectorsCaptions.State) <> cbGrayed then
//    begin
      // ShowConnCaptions
//      Result.Settings.ShowConnObjectCaption := cbShowConnectorsCaptions.Checked;
//    end;
//    if TCheckBoxState(cbShowConnectorsNotes.State) <> cbGrayed then
//    begin
      // ShowConnNotes
//      Result.Settings.ShowConnObjectNote := cbShowConnectorsNotes.Checked;
//    end;
    // ShowRaise
//    Result.Settings.CADShowRaise := cbShowRaise.Checked;

    // Шаг трассы по умолчанию
//    Result.Settings.CADBlockStep := StrToFloat_My(edBlockStep.Text);

    Result.Settings.HeightRoom := UOMToMetre(StrToFloat_My(F_MasterNewListLite.edRoomHeight.Text));
    Result.Settings.HeightCeiling := UOMToMetre(StrToFloat_My(F_MasterNewListLite.edFalseFloorHeight.Text));
    Result.Settings.HeightSocket := UOMToMetre(StrToFloat_My(F_MasterNewListLite.edConnTotal.Text));
    Result.Settings.HeightCorob := UOMToMetre(StrToFloat_My(F_MasterNewListLite.edLineTotal.Text));

    Result.Settings.LengthKoef := StrToFloat_My(F_MasterNewListLite.edLengthKoef.Text);
    Result.Settings.CableCanalFullnessKoef := StrToFloat_My(F_MasterNewListLite.edCableChannelFullnessKoef.Text);
    Result.Settings.PortReserv := UOMToMetre(StrToFloat_My(F_MasterNewListLite.edPortReserv.Text));
    Result.Settings.MultiportReserv := UOMToMetre(StrToFloat_My(F_MasterNewListLite.edMultiportReserv.Text));
    Result.Settings.TwistedPairMaxLength := UOMToMetre(StrToFloat_My(F_MasterNewListLite.edTwistedPairMaxLength.Text));

    Result.Settings.CADFontName := F_MasterNewListLite.cbFontName.FontName;

    // тип уголка по дефолту
//    if rbCornerNone.Checked then
//      Result.Settings.CornerType := crn_None;
//    if rbCornerOut.Checked then
//      Result.Settings.CornerType := crn_Out;
//    if rbCornerIn.Checked then
//      Result.Settings.CornerType := crn_In;
//    if rbCornerVertical.Checked then
//      Result.Settings.CornerType := crn_Vertical;
//    if rbCornerAdapter.Checked then
//      Result.Settings.CornerType := crn_Adapter;

    // Тип префикса для количества компонент
//    if rbBeforePrefix.Checked then
//       Result.Settings.PrefixCountType := pctBefore
//    else
//    if rbAfterPrefix.Checked then
//      Result.Settings.PrefixCountType := pctAfter;

    // соблюдать условия типов линий
//    Result.Settings.KeepLineTypesRules := cbKeepLineTypesRules.Checked;

//    Result.Settings.CADLinesCaptionsColor := cbLinesCaptionsColor.ColorValue;
//    Result.Settings.CADConnectorsCaptionsColor := cbConnectorsCaptionsColor.ColorValue;
//    Result.Settings.CADLinesNotesColor := cbLinesNotesColor.ColorValue;
//    Result.Settings.CADConnectorsNotesColor := cbConnectorsNotesColor.ColorValue;

//    Result.Settings.CADLinesCaptionsFontSize := StrToInt(cbLinesCaptionsFontSize.Text);
//    Result.Settings.CADConnectorsCaptionsFontSize := StrToInt(cbConnectorsCaptionsFontSize.Text);
//    Result.Settings.CADLinesNotesFontSize := StrToInt(cbLinesNotesFontSize.Text);
//    Result.Settings.CADConnectorsNotesFontSize := StrToInt(cbConnectorsNotesFontSize.Text);

//    Result.Settings.CADLinesCaptionsFontBold := cbLinesCaptionsFontBold.Checked;
//    Result.Settings.CADCrossATSFontSize := StrToInt(cbCrossATSFontSize.Text);
//    Result.Settings.CADCrossATSFontBold := cbCrossATSFontBold.Checked;
//    Result.Settings.CADDistribCabFontSize := StrToInt(cbDistribCabFontSize.Text);
//    Result.Settings.CADDistribCabFontBold := cbDistribCabFontBold.Checked;

//    if cbBlackPrint.Checked then
//      Result.Settings.CADPrintType := pt_Black;
//    if cbColorPrint.Checked then
//      Result.Settings.CADPrintType := pt_Color;

//    if rbInternalSCS.Checked then
//      Result.Settings.SCSType := st_Internal;
//    if rbExternalSCS.Checked then
//      Result.Settings.SCSType := st_External;
//    if not rbInternalSCS.Checked and not rbExternalSCS.Checked then
//      Result.Settings.SCSType := st_NoChoose;

    try
      if (GCadForm <> nil) and (GCadForm.PCad <> nil) then
      begin
        Result.Settings.CADShowRuler := GCadForm.PCad.RulerVisible;
        Result.Settings.CADShowGrid := GCadForm.PCad.Grids;
        Result.Settings.CADShowGuides := GCadForm.PCad.GuidesVisible;
        Result.Settings.CADSnapGrid := GCadForm.PCad.SnapToGrids;
        Result.Settings.CADSnapGuides := GCadForm.PCad.SnapToGuides;
        Result.Settings.CADSnapNearObject := GCadForm.PCad.SnapToNearPoint;
      end;
    except
      Result.Settings.CADShowRuler := True;
      Result.Settings.CADShowGrid := True;
      Result.Settings.CADShowGuides := True;
      Result.Settings.CADSnapGrid := True;
      Result.Settings.CADSnapGuides := True;
      Result.Settings.CADSnapNearObject := False;
    end;

//    if cbAutoApplyHeights.Enabled then
//      Result.Settings.UseComponTypeHeights := cbAutoApplyHeights.Checked
//    else
      Result.Settings.UseComponTypeHeights := False;

//    Result.Settings.CADShowCabinetsNumbers := cbShowCabinetsNumbers.Checked;
//    Result.Settings.CADShowCabinetsBounds := cbShowCabinetsBounds.Checked;

    // тип отображения измерительных линий
//    if rbNone.Checked then
//      Result.Settings.CADDimLinesType := dlt_None;
//    if rbRow.Checked then
//      Result.Settings.CADDimLinesType := dlt_Row;
//    if rbStroke.Checked then
//      Result.Settings.CADDimLinesType := dlt_Stroke;

    // шаг угла поворота трассы
//    Result.Settings.CADTraceStepRotate := StrToInt(edTraceStepRotate.Text);

    // autocad
//    Result.Settings.AutoCadMouse := cbAutoCadMouse.Checked;
//    Result.Settings.ScaleByCursor := cbScaleByCursor.Checked;
//    Result.Settings.CADAutoPosTraceBetweenRM := cbAutoPosTraceBetweenRM.Checked;

    // показывать штапмы на рамке листа
    Result.Settings.CADShowMainStamp := cbShowMainStamp.Checked;
    Result.Settings.CADShowSideStamp := cbShowSideStamp.Checked;
    Result.Settings.CADShowUpperStamp := cbShowUpperStamp.Checked;

    Result.Settings.CADRuleStep := GetRuleStep(false);
    Result.Settings.CADRuleAllSize := GetRuleAllSize(false);

    Result.Settings.CADNewTraceLengthType := GetRadioGrpBoxIntVal(FArrNewTracesLengthRB, FArrNewTracesLengthVal, Ord(tltNone));

//    Result.Settings.CADSaveUndoCount := StrToInt(edSaveUndoCount.Text);
//    Result.Settings.CADAllowSuppliesKind := cbAllowSuppliesKind.Checked;

    if ALoadSpravochnik then
      LoadFromFormToItemSpravochnik(F_MasterNewList.F_ListSpravochnikForm, FItemID, FItemType, itList,
          false, false,
          false, false, false, FMakeEditMode = meMake, [vkComponentType], @Result);
  except
    on E: Exception do AddExceptionToLogEx('TF_MasterNewListLite.GetListParamsFromForm', E.Message);
  end;
end;

function TF_MasterNewListLite.GetPointComonIndexingModeFromForm: TPointComonIndexingMode;
begin
  Result := cimInProject;
//  if rbIndexPointComponInProject.Checked then
//    Result := cimInProject
//  else
//  if rbIndexPointComponInList.Checked then
//    Result := cimInList
//  else
//  if rbIndexPointComponInRoom.Checked then
//    Result := cimInRoom;
end;

function TF_MasterNewListLite.GetMarkModeFrom: TMarkMode;
begin
  Result := mmTemplate;
//  if rbMarkByTemplate.Checked then
//    Result := mmTemplate
//  else
//  if rbMarkByTIAEIA606A.Checked then
//    Result := mmTIAEIA606A;
end;

function TF_MasterNewListLite.GetProjectParamsFromForm(ALoadSpravochnik: Boolean = true): TProjectParams;
var
  ListParams: TListParams;
  OldUOMValue: Integer;
begin
  try
    Result := FProjectParams;

    Result.Name := edProjectName.Text;
    Result.MarkID := Round(seProjectIndex.Value);
    Result.IsIndexWithName := BoolToInt(cbProjectIsIndexWithName.Checked);
    Result.Caption := Result.Name;
    if Result.IsIndexWithName = biTrue then
      Result.Caption := Result.Caption + ' ' + IntTostr(Result.MarkID);
    Result.ServCreateList := cbCreateList.Checked;      

    //*** Валюты
    Result.Setting.IDCurrency := FProjectCurrencyID;
    Result.Setting.CurrencyKolvo := FProjectCurrency.Kolvo; //Round(seCurrencyKolvo.Value);
    Result.Setting.CurrencyRatio := FProjectCurrency.Ratio; //neCurrencyRatio.Value;
    Result.Setting.NDS := neNDS.Value;
    Result.ServCanRecalcPricesByNDSChange := cbRecalcPricesByNDSChange.Checked;

    Result.Setting.DefListName := edDefListName.Text;
    Result.Setting.DefRoomName := edDefRoomName.Text;

    //*** Организация
    Result.Setting.OrganizationName := edOrganization.Text;
    //*** Заказчик
    Result.Setting.CustomerName := edCustomer.Text;
    //*** Подрядчик
    Result.Setting.ContractorName := edContractor.Text;

    //*** Автоохранение
    Result.Setting.IsAutoSaveProject := cbIsAutoSaveProject.Checked;
    Result.Setting.AutoSaveProjectMinutes := Trunc(seAutoSaveProjectMinutes.Value);

    Result.Setting.ListsInReverseOrder := cbListsInreversOrder.Checked;

    //*** Способ индексации комплектующих
//    if rbIndexingModeProject.Checked then
//      Result.Setting.PointComplIndexingMode := pcimInProject
//    else
//    if rbIndexingModeCompon.Checked then
//      Result.Setting.PointComplIndexingMode := pcimInCompon;
    //Способ индексации точечных компонент
    Result.Setting.PointComonIndexingMode := GetPointComonIndexingModeFromForm;

    //*** Порядок переиндексации компонент
//    if rbReindexOrderTypeCreate.Checked then
//      Result.Setting.ReindexOrderType := rotCreated
//    else
//    if rbReindexOrderTypePosPM.Checked then
//      Result.Setting.ReindexOrderType := rotPositionPM;

    // Маркировка компонентов
//    if rbMarkByTemplate.Checked then
//      Result.Setting.MarkMode := mmTemplate
//    else
//    if rbMarkByTIAEIA606A.Checked then
//      Result.Setting.MarkMode := mmTIAEIA606A;
    // При отсутствии обозначения кабинета:
//    if rbRoomNameShortFromName.Checked then
//      Result.Setting.RoomNameShortSrcType := rnssRoomName
//    else
//    if rbRoomNameShortFromDefStr.Checked then
//      Result.Setting.RoomNameShortSrcType := rnssRoomDefStr;
//    Result.Setting.RoomNameShortDefault := edRoomNameShortDefault.Text;
//    Result.Setting.RoomNameShortIfNoRoom := edRoomNameShortIfNoRoom.Text;
//    Result.Setting.IsMarkByTemplateIfNoAtOtherMode := cbIsMarkByTemplateIfNoAtOtherMode.Checked;


    //*** Добавлять нормы на компонент из интерфейсов
//    Result.Setting.UseNormsFromInterfaces := cbUseNormsFromInterfaces.Checked;

    //*** Система измерений
    OldUOMValue := Result.Setting.UnitOfMeasure;
    if rbMetric_sm.Checked then
      Result.Setting.UnitOfMeasure := umSM
    else
    if rbMetric_m.Checked then
      Result.Setting.UnitOfMeasure := umM
    else
    if rbWhitworth_in.Checked then
      Result.Setting.UnitOfMeasure := umIn
    else
    if rbWhitworth_ft.Checked then
      Result.Setting.UnitOfMeasure := umFt;
    // применить новую систему измерений
    // если в режиме редактирования
    if OldUOMValue <> Result.Setting.UnitOfMeasure then
    begin
      GCurrProjUnitOfMeasure := Result.Setting.UnitOfMeasure;
      ApplyUOMForProject(OldUOMValue, GCurrProjUnitOfMeasure);
      // если открыта форма Св-в обьектов - закрыть
      if F_SCSObjectsProp.Showing then
        F_SCSObjectsProp.Close;
      // обновить длины трасс
      UpdateAllTracesLengthOnAllLists;
    end;

    //*** Высота межэтажных перекрытий
    Result.Setting.HeightThroughFloor := UOMToMetre(RoundCP(seHeightThroughFloor.Value));

    //*** Параметры листа
    ListParams := GetListParamsFromForm(ALoadSpravochnik);
    Result.DefListSetting := ListParams.Settings;

    // Служебные поля
//    Result.ServRemarkAllCompons := cbRemarkAllCompons.Checked or ((FMakeEditMode = meEdit) and (GetMarkModeFrom <> FProjectParams.Setting.MarkMode));

    if ALoadSpravochnik then
      LoadFromFormToItemSpravochnik(F_MasterNewList.F_ProjectSpravochnikForm, FItemID, FItemType, itProject,
        false, false, false, false, false,
        FMakeEditMode = meMake, [vkAll], @Result);

//    if rbInternalSCSP.Checked then
//      FSCS_Main.aMarkingPages.Enabled := True
//    else
//    if rbExternalSCSP.Checked then
//      FSCS_Main.aMarkingPages.Enabled := False;
  except
    on E: Exception do AddExceptionToLogEx('TF_MasterNewListLite.GetProjectParamsFromForm', E.Message);
  end;
end;

procedure TF_MasterNewListLite.SetProjCurrencyMToForm(AShowCurrencyM: Boolean);
var
  CurrencyM: TCurrency;
  BookmarkStr: String;
  Bookmark: TBookmark;
begin
  try
    ZeroMemory(@CurrencyM, SizeOf(TCurrency));
    //BookmarkStr := F_MasterNewList.F_ProjectSpravochnikForm.mtCurrency.GetBookmarkStr;
    Bookmark := F_MasterNewList.F_ProjectSpravochnikForm.mtCurrency.GetBookmark;
    try
      if F_MasterNewList.F_ProjectSpravochnikForm.mtCurrency.Active then
        if F_MasterNewList.F_ProjectSpravochnikForm.mtCurrency.Locate(fnMain, ctMain, []) then
          CurrencyM := GetCurrencyFromMemTable(F_MasterNewList.F_ProjectSpravochnikForm.mtCurrency);
    finally
      if Not AShowCurrencyM then
      //  F_MasterNewList.F_ProjectSpravochnikForm.mtCurrency.Bookmark := BookmarkStr
      if BookMark <> nil then
      begin
        //F_MasterNewList.F_ProjectSpravochnikForm.mtCurrency.Bookmark := Bookmark;
        F_MasterNewList.F_ProjectSpravochnikForm.mtCurrency.GotoBookMark(BookMark);
        F_MasterNewList.F_ProjectSpravochnikForm.mtCurrency.FreeBookMark(Bookmark);
      end;

    end;
    if CurrencyM.ID > 0 then
    begin
      SetProjCurrencyToForm(CurrencyM);
      FProjectCurrency := CurrencyM;
      if AShowCurrencyM then
      begin
        //GlobalPageControl.ActivePage := tsProjectSpravochniki;
        //F_MasterNewList.F_ProjectSpravochnikForm.pcDirectories.ActivePage := FProjectSpravochnikForm.tsCurrency;
        if MessageQuastYN(cMasterNewListLite_Mes7) = IDYES then
          bAdvanced.Click;
      end;
    end;
  except
    on E: Exception do AddExceptionToLogEx('TF_MasterNewListLite.SetProjCurrencyMToForm', E.Message);
  end;
end;

procedure TF_MasterNewListLite.SetProjCurrencyToForm(ACurrency: TCurrency; AReloadCombo: Boolean=true);
var
  CurrIdx: Integer;
begin
  try
    edCurrencyName.Text := ACurrency.Name;
    edCurrencyNameBrief.Text := ACurrency.NameBrief;

    lbCurrencyAccordance.Visible := (FNBCurrency.GUID <> ACurrency.GUID);
    lbCurrencyAccordance.Caption := IntToStr(FNBCurrency.Kolvo)+FNBCurrency.NameBrief +' = '+
                                      FloatToStr(GetPriceAfterChangeCurrency(FNBCurrency.Kolvo, FNBCurrency, ACurrency))+ACurrency.NameBrief;

    if AReloadCombo then
    begin
      cbCurrency.Sorted := true;
      AddGUIDIDToStringsFromMT(cbCurrency.Items, F_MasterNewList.F_ProjectSpravochnikForm.mtCurrency, fnName, fnGuid, true);
      //cbCurrency.Sorted := false;
    end;

    CurrIdx := IndexOfGUIDInStrings(ACurrency.GUID, cbCurrency.Items);
    if CurrIdx <> -1 then
      cbCurrency.ItemIndex := CurrIdx;
  except
    on E: Exception do AddExceptionToLogEx('TF_MasterNewListLite.SetProjCurrencyToForm', E.Message);
  end;
end;

procedure TF_MasterNewListLite.SetProjCurrencyToFormByID(AIDCurrency: Integer);
var
  ProjectCurrency: TCurrency;
begin
  try
    FProjectCurrencyID := AIDCurrency;
    ProjectCurrency := F_NormBase.DM.GetCurrencyByID(AIDCurrency);
    FProjectCurrency := ProjectCurrency;
    SetProjCurrencyToForm(ProjectCurrency);
  except
    on E: Exception do AddExceptionToLogEx('TF_MasterNewListLite.SetProjCurrencyToFormByID', E.Message);
  end;
end;


procedure TF_MasterNewListLite.SetListParamsToForm(AListParams: TListParams; AFirstLoading: Boolean = true{; aCADParams: TCADParams});
begin
  try
    SetMaskEdits;
    if FParentCADParams = nil then
      FCADParams := SetCADParamsStruct(AListParams) //aCADParams;
    else
      FCADParams := FParentCADParams^;

//    if AFirstLoading then
//      ListPageControl.ActivePageIndex := 0;

//    edListName.Text := AListParams.Name;
//    cbListIsIndexWithName.Checked := IntToBool(AListParams.IsIndexWithName);

    // ListIndex
//    seCurrIndex.Value := AListParams.MarkID;
//    seIndexConnector.Value := AListParams.IndexConnector + 1;
//    seIndexLine.Value := AListParams.IndexLine + 1;
//    seIndexPointObj.Value := AListParams.IndexPointObj + 1;

    cbPageSize.ItemIndex := AListParams.Settings.CADPageSizeIndex;     // A4
    edListCountX.Value := AListParams.Settings.CADListCountX;
    edListCountY.Value := AListParams.Settings.CADListCountY;
    edWidth.Value := AListParams.Settings.CADWidth * edListCountX.Value;
    edHeight.Value := AListParams.Settings.CADHeight * edListCountY.Value;

    if AListParams.Settings.CADPageOrient = poLandscape then
      rbLandscape.Checked := True;
    if AListParams.Settings.CADPageOrient = poPortrait then
      rbPortrait.Checked := True;

//    edStepGrid.Text := FormatFloat(ffMask, AListParams.Settings.CADGridStep);

    // Штамп стандартный/подробный
    if AListParams.Settings.CADStampType = stt_simple then
      rbSimple.Checked := True
    else
    if AListParams.Settings.CADStampType = stt_extended then
      rbExtended.Checked := True
    else
    if AListParams.Settings.CADStampType = stt_detailed then
      rbDetailed.Checked := True;

    // язык украинский/русский/английский
    if AListParams.Settings.CADStampLang = stl_ukr then
      rbUkr.Checked := True
    else if AListParams.Settings.CADStampLang = stl_rus then
      rbRus.Checked := True
    else if AListParams.Settings.CADStampLang = stl_ukr_dstu then
      rbUkrDSTU.Checked := True;

    {$IF Defined(SCS_RF)}
      RzGroupBox13.Visible := False;
      rbRus.Checked := True;
    {$IFEND}


    //11.11.2011 - отступы рамки листа
    //seStampMarginLeft.Value := FloatInUOM(AListParams.Settings.CADStampMargins.Left, umMM, ConvertUOMToMin(GCurrProjUnitOfMeasure));
    //seStampMarginRight.Value := FloatInUOM(AListParams.Settings.CADStampMargins.Right, umMM, ConvertUOMToMin(GCurrProjUnitOfMeasure));
    //seStampMarginTop.Value := FloatInUOM(AListParams.Settings.CADStampMargins.Top, umMM, ConvertUOMToMin(GCurrProjUnitOfMeasure));
    //seStampMarginBottom.Value := FloatInUOM(AListParams.Settings.CADStampMargins.Bottom, umMM, ConvertUOMToMin(GCurrProjUnitOfMeasure));
    SetStampMarginsToForm(AListParams.Settings.CADStampMargins, Self, GCurrProjUnitOfMeasure); //28.11.2011
    FCADStampForPrinter := AListParams.Settings.CADStampForPrinter; //29.11.2011

    //15.11.2011 - Разработал проверил
    edStampDeveloper.Text := AListParams.Settings.CADStampDeveloper;
    edStampChecker.Text := AListParams.Settings.CADStampChecker;

    // ObjType in CAD
//    if AListParams.Settings.ShowObjectTypeCAD = st_Short then
//      cbCADCaptions_Short.Checked := True;
//    if AListParams.Settings.ShowObjectTypeCAD = st_Full then
//      cbCADCaptions_Full.Checked := True;
//    cbCADCaptionsDetail.Checked := AListParams.Settings.CADCaptionsKind = skDetail;
//    cbCADCaptionsSimple.Checked := AListParams.Settings.CADCaptionsKind = skSimple;
//    cbCADCaptionsExternalSCS.Checked := AListParams.Settings.CADCaptionsKind = skExternalSCS;

    // ObjNotesType
//    if AListParams.Settings.CADShowObjectNotesType = st_Short then
//      cbCADNotes_Short.Checked := True;
//    if AListParams.Settings.CADShowObjectNotesType = st_Full then
//      cbCADNotes_Full.Checked := True;
//    cbCADNotesDetail.Checked := AListParams.Settings.CADNotesKind = skDetail;
//    cbCADNotesSimple.Checked := AListParams.Settings.CADNotesKind = skSimple;

    // TraceColor
//    cbTraceColor.ColorValue := AListParams.Settings.CADTraceColor;
    // TraceStyle
//    cbTraceStyle.ItemIndex := ord(AListParams.Settings.CADTraceStyle);
    // TraceWidth
//    edTraceWidth.Text := IntToStr(AListParams.Settings.CADTraceWidth);
    // NotePrefix
//    edNotePrefix.Text := AListParams.Settings.NoteCountPrefix;

    // ObjType in PM
//    if AListParams.Settings.ShowObjectTypePM = st_Short then
//      cbPM_Short.Checked := True;
//    if AListParams.Settings.ShowObjectTypePM = st_Full then
//      cbPM_Full.Checked := True;
    // Grouping Objects in Tree
//    cbGroupObjectsByType.Checked := AListParams.Settings.GroupListObjectsByType;

    // Control Join/Complect Components
//    cbControlJoinByNetType.Checked := AListParams.Settings.ControlJoinByNetType;
//    cbControlComplectByProducer.Checked := AListParams.Settings.ControlComplectByProducer;
//    cbControlJoinByProperties.Checked := AListParams.Settings.ControlJoinByProperties;
//    cbControlComplectByProperties.Checked := AListParams.Settings.ControlComplectByProperties;

    // Установка эл-в каб. каналов
//    cbCanSetCorkBetweenTraces.Checked := AListParams.Settings.CanSetCorkBetweenTraces;

    // Put Cable in Trace
//    cbPutCableOnTrace.Checked := AListParams.Settings.PutCableInTrace;

    // ShowLinesCaptions
//    cbShowLinesCaptions.Checked := AListParams.Settings.ShowLineObjectCaption;
    // ShowLineLength
//    cbShowLinesLength.Checked := AListParams.Settings.ShowLineObjectLength;
    // ShowLinesNotes
//    cbShowLinesNotes.Checked := AListParams.Settings.ShowLineObjectNote;
    // ShowConnCaptions
//    cbShowConnectorsCaptions.Checked := AListParams.Settings.ShowConnObjectCaption;
    // ShowConnNotes
//    cbShowConnectorsNotes.Checked := AListParams.Settings.ShowConnObjectNote;

    // ShowRaise
//    cbShowRaise.Checked := AListParams.Settings.CADShowRaise;

    // Шаг трассы по умолчанию
//    edBlockStep.Text := FormatFloat(ffMask, AListParams.Settings.CADBlockStep);

    // Тип уголка по умолчанию
//    if AListParams.Settings.CornerType = crn_None then
//      rbCornerNone.Checked := True;
//    if AListParams.Settings.CornerType = crn_Out then
//      rbCornerOut.Checked := True;
//    if AListParams.Settings.CornerType = crn_In then
//      rbCornerIn.Checked := True;
//    if AListParams.Settings.CornerType = crn_Vertical then
//      rbCornerVertical.Checked := True;
//    if AListParams.Settings.CornerType = crn_Adapter then
//      rbCornerAdapter.Checked := True;

    // Тип префикса для количества компонент
//    if AListParams.Settings.PrefixCountType = pctBefore then
//      rbBeforePrefix.Checked := true
//    else
//    if AListParams.Settings.PrefixCountType = pctAfter then
//      rbAfterPrefix.Checked := true;

//    cbKeepLineTypesRules.Checked := AListParams.Settings.KeepLineTypesRules;

    edRoomHeight.Text := FormatFloat(ffMask, MetreToUOM(AListParams.Settings.HeightRoom));
    edFalseFloorHeight.Text := FormatFloat(ffMask, MetreToUOM(AListParams.Settings.HeightCeiling));
    rbConnFloor.Checked := True;
    edConnFloor.Text := FormatFloat(ffMask, MetreToUOM(AListParams.Settings.HeightSocket));
    edLineFloor.Text := FormatFloat(ffMask, MetreToUOM(AListParams.Settings.HeightCorob));
    edConnTotal.Text := FormatFloat(ffMask, MetreToUOM(AListParams.Settings.HeightSocket));
    edLineTotal.Text := FormatFloat(ffMask, MetreToUOM(AListParams.Settings.HeightCorob));
    if (GCadForm <> nil) and (GCadForm.PCad <> nil) then
      SetParamsOnLineTracingType(GCadForm.FLineTracingType, AListParams.Settings.HeightRoom, AListParams.Settings.HeightCeiling, AListParams.Settings.HeightCorob, AListParams.Settings.HeightSocket);

    edLengthKoef.Text := FormatFloat(ffMask, AListParams.Settings.LengthKoef);
    edCableChannelFullnessKoef.Text := FormatFloat(ffMask, AListParams.Settings.CableCanalFullnessKoef);
    edPortReserv.Text := FormatFloat(ffMask, MetreToUOM(AListParams.Settings.PortReserv));
    edMultiportReserv.Text := FormatFloat(ffMask, MetreToUOM(AListParams.Settings.MultiportReserv));
    edTwistedPairMaxLength.Text := FormatFloat(ffMask, MetreToUOM(AListParams.Settings.TwistedPairMaxLength));
    cbFontName.FontName := AListParams.Settings.CADFontName;

//    cbAutoApplyHeights.Checked := AListParams.Settings.UseComponTypeHeights;
//    cbShowCabinetsNumbers.Checked := AListParams.Settings.CADShowCabinetsNumbers;
//    cbShowCabinetsBounds.Checked := AListParams.Settings.CADShowCabinetsBounds;

//    cbLinesCaptionsColor.ColorValue := AListParams.Settings.CADLinesCaptionsColor;
//    cbConnectorsCaptionsColor.ColorValue := AListParams.Settings.CADConnectorsCaptionsColor;
//    cbLinesNotesColor.ColorValue := AListParams.Settings.CADLinesNotesColor;
//    cbConnectorsNotesColor.ColorValue := AListParams.Settings.CADConnectorsNotesColor;

//    cbLinesCaptionsFontSize.Text := IntToStr(AListParams.Settings.CADLinesCaptionsFontSize);
//    cbConnectorsCaptionsFontSize.Text := IntToStr(AListParams.Settings.CADConnectorsCaptionsFontSize);
//    cbLinesNotesFontSize.Text := IntToStr(AListParams.Settings.CADLinesNotesFontSize);
//    cbConnectorsNotesFontSize.Text := IntToStr(AListParams.Settings.CADConnectorsNotesFontSize);

//    cbLinesCaptionsFontBold.Checked := AListParams.Settings.CADLinesCaptionsFontBold;
//    cbCrossATSFontSize.Text := IntToStr(AListParams.Settings.CADCrossATSFontSize);
//    cbCrossATSFontBold.Checked := AListParams.Settings.CADCrossATSFontBold;
//    cbDistribCabFontSize.Text := IntToStr(AListParams.Settings.CADDistribCabFontSize);
//    cbDistribCabFontBold.Checked := AListParams.Settings.CADDistribCabFontBold;

//    if AListParams.Settings.CADPrintType = pt_Black then
//      cbBlackPrint.Checked := True;
//    if AListParams.Settings.CADPrintType = pt_Color then
//      cbColorPrint.Checked := True;

    // тип отображения измерительных линий
//    if AListParams.Settings.CADDimLinesType = dlt_None then
//      rbNone.Checked := True;
//    if AListParams.Settings.CADDimLinesType = dlt_Row then
//      rbRow.Checked := True;
//    if AListParams.Settings.CADDimLinesType = dlt_Stroke then
//      rbStroke.Checked := True;

//    edTraceStepRotate.Text := IntToStr(AListParams.Settings.CADTraceStepRotate);

    // тип СКС
//    rbInternalSCS.Checked := False;
//    rbExternalSCS.Checked := False;
//    rbInternalSCSP.Checked := False;
//    rbExternalSCSP.Checked := False;
//    if AListParams.Settings.SCSType = st_NoChoose then
//    begin
//      cbCADCaptionsDetail.Enabled := False;
//      cbCADCaptionsSimple.Enabled := False;
//      cbCADCaptionsExternalSCS.Enabled := False;
//    end;
//    if AListParams.Settings.SCSType  = st_Internal then
//    begin
//      rbInternalSCS.Checked := True;
//      rbInternalSCSClick(Self);
//    end;
//    if AListParams.Settings.SCSType = st_External then
//    begin
//      rbExternalSCS.Checked := True;
//      rbExternalSCSClick(Self);
//    end;

    // autocad
//    cbAutoCadMouse.Checked := AListParams.Settings.AutoCadMouse;
//    cbScaleByCursor.Checked := AListParams.Settings.ScaleByCursor;
//    cbAutoPosTraceBetweenRM.Checked := AListParams.Settings.CADAutoPosTraceBetweenRM;

    // показывать штапмы на рамке листа
    cbShowMainStamp.Checked := AListParams.Settings.CADShowMainStamp;
    cbShowSideStamp.Checked := AListParams.Settings.CADShowSideStamp;
    cbShowUpperStamp.Checked := AListParams.Settings.CADShowUpperStamp;

//    edSaveUndoCount.Text := IntToStr(AListParams.Settings.CADSaveUndoCount);
//    cbAllowSuppliesKind.Checked := AListParams.Settings.CADAllowSuppliesKind;

    SetRadioGrpBoxIntVal(FArrNewTracesLengthRB, FArrNewTracesLengthVal, AListParams.Settings.CADNewTraceLengthType, true);

    if gbRulerModeMetric.Visible then
    begin
      edSizeAsMetric.Text := FormatFloat(ffMask, AListParams.Settings.CADRuleStep);
      edSizeAllMetric.Text := FormatFloat(ffMask, AListParams.Settings.CADRuleAllSize);
    end
    else
    begin
      edSizeAsWhitworth.Text := FormatFloat(ffMask, AListParams.Settings.CADRuleStep);
      edSizeAllWhitworth.Text := FormatFloat(ffMask, AListParams.Settings.CADRuleAllSize);
    end;

    if FParentCADParams = nil then //23.10.2012
      FCADParams.CADMapScale := CheckMapScaleResult;

    if AFirstLoading and Not FIsFromMaster then
    begin
      if FMakeEditMode = meMake then
        LoadFromItemSpravochnikToForm(F_MasterNewList.F_ListSpravochnikForm, FItemID, FItemType, true, [vkComponentType]);
      if FMakeEditMode = meEdit then
        LoadFromItemSpravochnikToForm(F_MasterNewList.F_ListSpravochnikForm, FItemID, FItemType, false, [vkComponentType]);
    end;

    SetMaket;
  except
    on E: Exception do AddExceptionToLogEx('TF_MasterNewListLite.SetListParamsToForm', E.Message);
  end;
end;

procedure TF_MasterNewListLite.SetNBCurrencyToForm;
var
  BookmarkStr: String;
  Bookmark: TBookmark;
begin
  try
    FNBCurrency := F_NormBase.DM.GetCurrencyByType(ctMain);
    if FNBCurrency.GUID <> '' then
    begin
     //BookmarkStr := F_MasterNewList.F_ProjectSpravochnikForm.mtCurrency.Bookmark;
     //BookmarkStr := F_MasterNewList.F_ProjectSpravochnikForm.mtCurrency.GetBookmarkStr;
     BookMark := F_MasterNewList.F_ProjectSpravochnikForm.mtCurrency.GetBookmark;

      if F_MasterNewList.F_ProjectSpravochnikForm.mtCurrency.Active then
        if F_MasterNewList.F_ProjectSpravochnikForm.mtCurrency.Locate(fnGUID, FNBCurrency.GUID, []) then
          FNBCurrency := GetCurrencyFromMemTable(F_MasterNewList.F_ProjectSpravochnikForm.mtCurrency);
     // F_MasterNewList.F_ProjectSpravochnikForm.mtCurrency.Bookmark := BookmarkStr;
     if Bookmark <> nil then
     begin
       F_MasterNewList.F_ProjectSpravochnikForm.mtCurrency.GotoBookmark(BookMark);
       F_MasterNewList.F_ProjectSpravochnikForm.mtCurrency.FreeBookMark(BookMark);
     end;

    end;

    //edNBCurrencyName.Text := FNBCurrency.Name;
    //edNBCurrencyNameBrief.Text := FNBCurrency.NameBrief;
    //seNBCurrencyKolvo.Value := FNBCurrency.Kolvo;
    //neNBCurrencyRatio.Value := FNBCurrency.Ratio;
  except
    on E: Exception do AddExceptionToLogEx('TF_MasterNewListLite.SetNBCurrencyToForm', E.Message);
  end;
end;

procedure TF_MasterNewListLite.SetProjectParamsToForm(AProjectParams: TProjectParams; AFirstLoading: Boolean = true);
var
  ListParams: TListParams;
  rbUOM: TRzRadioButton;
begin
  try
    edProjectName.Text := AProjectParams.Name;
    seProjectIndex.Value := AProjectParams.MarkID;
    cbProjectIsIndexWithName.Checked := IntToBool(AProjectParams.IsIndexWithName);
    //neProjectIndex.Text := IntTostr(AProjectParams.MarkID);
    //udProjectIndex.Position

    //*** Валюты
    //SetNBCurrencyToForm;
    //SetCurrencyToFormByID(AProjectParams.Setting.IDCurrency);
    //seCurrencyKolvo.Value := AProjectParams.Setting.CurrencyKolvo;
    //neCurrencyRatio.Value := AProjectParams.Setting.CurrencyRatio;
    neNDS.Value := AProjectParams.Setting.NDS;
    cbRecalcPricesByNDSChange.Checked := AProjectParams.ServCanRecalcPricesByNDSChange;

    edDefListName.Text := AProjectParams.Setting.DefListName;
    edDefRoomName.Text := AProjectParams.Setting.DefRoomName;

    //*** Организация
    edOrganization.Text := AProjectParams.Setting.OrganizationName;
    //*** Заказчик
    edCustomer.Text := AProjectParams.Setting.CustomerName;
    //*** Подрядчик
    edContractor.Text := AProjectParams.Setting.ContractorName;

    //*** Автоохранение
    cbIsAutoSaveProject.Checked := AProjectParams.Setting.IsAutoSaveProject;
    cbIsAutoSaveProjectClick(cbIsAutoSaveProject);
    seAutoSaveProjectMinutes.Value := AProjectParams.Setting.AutoSaveProjectMinutes;

    cbListsInreversOrder.Checked := AProjectParams.Setting.ListsInReverseOrder;

    //Способ индексации точечных компонент
//    if AProjectParams.Setting.PointComonIndexingMode = cimInProject then
//      rbIndexPointComponInProject.Checked := true
//    else
//    if AProjectParams.Setting.PointComonIndexingMode = cimInList then
//      rbIndexPointComponInList.Checked := true
//    else
//    if AProjectParams.Setting.PointComonIndexingMode = cimInRoom then
//      rbIndexPointComponInRoom.Checked := true;

    //*** Способ индексации комплектующих
//    if AProjectParams.Setting.PointComplIndexingMode = pcimInProject then
//      rbIndexingModeProject.Checked := true
//    else
//    if AProjectParams.Setting.PointComplIndexingMode = pcimInCompon then
//      rbIndexingModeCompon.Checked := true;
    //*** Порядок переиндексации компонент
//    if AProjectParams.Setting.ReindexOrderType = rotCreated then
//      rbReindexOrderTypeCreate.Checked := true
//    else
//    if AProjectParams.Setting.ReindexOrderType = rotPositionPM then
//      rbReindexOrderTypePosPM.Checked := true;

    // Маркировка компонентов
//    if AProjectParams.Setting.MarkMode = mmTemplate then
//      rbMarkByTemplate.Checked := true
//    else
//    if AProjectParams.Setting.MarkMode = mmTIAEIA606A then
//      rbMarkByTIAEIA606A.Checked := true;
    // При отсутствии обозначения кабинета:
//    if AProjectParams.Setting.RoomNameShortSrcType = rnssRoomName then
//      rbRoomNameShortFromName.Checked := true
//    else
//    if AProjectParams.Setting.RoomNameShortSrcType = rnssRoomDefStr then
//      rbRoomNameShortFromDefStr.Checked := true;
//    edRoomNameShortDefault.Text := AProjectParams.Setting.RoomNameShortDefault;
//    edRoomNameShortIfNoRoom.Text := AProjectParams.Setting.RoomNameShortIfNoRoom;
//    cbIsMarkByTemplateIfNoAtOtherMode.Checked := AProjectParams.Setting.IsMarkByTemplateIfNoAtOtherMode;

    //*** Высота межэтажных перекрытий
    seHeightThroughFloor.Value := MetreToUOM(AProjectParams.Setting.HeightThroughFloor);
    //*** Добавлять нормы на компонент из интерфейсов
//    cbUseNormsFromInterfaces.Checked := AProjectParams.Setting.UseNormsFromInterfaces;

    //*** Система измерений
    // сантиметры
    rbUOM := nil;
    if AProjectParams.Setting.UnitOfMeasure = umSM then
    begin
      rbUOM := rbMetric_sm; //rbMetric_sm.Checked := True;
      GCurrProjUnitOfMeasure := umSM;
    end
    else
    // метры
    if AProjectParams.Setting.UnitOfMeasure = umM then
    begin
      rbUOM := rbMetric_m; //rbMetric_m.Checked := True;
      GCurrProjUnitOfMeasure := umM;
    end
    else
    // дюймы
    if AProjectParams.Setting.UnitOfMeasure = umIn then
    begin
      rbUOM := rbWhitworth_in; //rbWhitworth_in.Checked := True;
      GCurrProjUnitOfMeasure := umIn;
    end
    // футы
    else
    if AProjectParams.Setting.UnitOfMeasure = umFt then
    begin
      rbUOM := rbWhitworth_ft; //rbWhitworth_ft.Checked := True;
      GCurrProjUnitOfMeasure := umFt;
    end
    // другое
    else
    begin
      rbUOM := rbMetric_m; //rbMetric_m.Checked := True;
      GCurrProjUnitOfMeasure := umM;
    end;
    SetValueToRzRadioButtonAsNoChange(rbUOM, true);


    //*** Параметры листа
    ListParams.MarkID := 0;
    ListParams.Name := '';
    ListParams.Settings := AProjectParams.DefListSetting;

    SetListParamsToForm(ListParams, AFirstLoading {, SetCADParamsStruct(ListParams)});

    if AFirstLoading and Not FIsFromMaster then
    begin
      if FMakeEditMode = meMake then
        LoadFromItemSpravochnikToForm(F_MasterNewList.F_ProjectSpravochnikForm, FItemID, FItemType, true, [vkAll]);
      if FMakeEditMode = meEdit then
        LoadFromItemSpravochnikToForm(F_MasterNewList.F_ProjectSpravochnikForm, FItemID, FItemType, false, [vkAll]);
    end;

    //if Not FIsFromMaster then
    begin
      SetNBCurrencyToForm;
      SetProjCurrencyMToForm(false);
    end;
    SetControlsByPointComponIndexingMode;
    SetControlsByProjType;

    cbCreateList.Visible := FMakeEditMode = meMake;
  except
    on E: Exception do AddExceptionToLogEx('TF_MasterNewListLite.SetProjectParamsToForm', E.Message);
  end;
end;

procedure TF_MasterNewListLite.ShowListSpravochnik(ASpravochnikKind: TViewKind; AGUIDToLocate: String);
begin
  try
    if (ASpravochnikKind <> vkNone) and (AGUIDToLocate <> '') then
    begin
//      ListPageControl.ActivePage := tsListSpravochniki;
      FListSpravochnikForm.SetPageByViewKind(ASpravochnikKind);
      FListSpravochnikForm.PrepareForm(ASpravochnikKind, fmView);
      FListSpravochnikForm.LocateItemByGUID(AGUIDToLocate);
    end;
  except
    on E: Exception do AddExceptionToLogEx('TF_MasterNewListLite.ShowListSpravochnik', E.Message);
  end;
end;

procedure TF_MasterNewListLite.ShowProjectSpravochnik(ASpravochnikKind: TViewKind; AGUIDToLocate: String);
begin
  try
    if (ASpravochnikKind <> vkNone) then
    begin
      if ASpravochnikKind = vkComponentType then
      begin
//        GlobalPageControl.ActivePage := TabListProperties;
        ShowListSpravochnik(ASpravochnikKind, AGUIDToLocate);
      end
      else
      begin
//        GlobalPageControl.ActivePage := tsProjectSpravochniki;
        FProjectSpravochnikForm.SetPageByViewKind(ASpravochnikKind);
        FProjectSpravochnikForm.PrepareForm(ASpravochnikKind, fmView);
        FProjectSpravochnikForm.LocateItemByGUID(AGUIDToLocate);
      end;
    end;
  except
    on E: Exception do AddExceptionToLogEx('TF_MasterNewListLite.ShowProjectSpravochnik', E.Message);
  end;
end;

procedure TF_MasterNewListLite.edConnRoomPropertiesChange(Sender: TObject);
var
  data: double;
begin
  try
    if edConnCeiling.Text <> '' then
    begin
      data := StrToFloat_My(edConnCeiling.Text);
      edConnTotal.Text := FormatFloat(ffMask, StrToFloat_My(edRoomHeight.Text) - data);
    end
    else
      edConnTotal.Text := '0';
  except
    on E: Exception do AddExceptionToLogEx('TF_MasterNewListLite.edConnRoomPropertiesChange', E.Message);
  end;
end;

procedure TF_MasterNewListLite.edConnFalseFloorPropertiesChange(Sender: TObject);
var
  data: double;
begin
  try
    if edConnFalseFloor.Text <> '' then
    begin
      data := StrToFloat_My(edConnFalseFloor.Text);
      edConnTotal.Text := FormatFloat(ffMask, StrToFloat_My(edRoomHeight.Text) - StrToFloat_My(edFalseFloorHeight.Text) - data);
    end
    else
      edConnTotal.Text := '0';
  except
    on E: Exception do AddExceptionToLogEx('TF_MasterNewListLite.edConnFalseFloorPropertiesChange', E.Message);
  end;
end;

procedure TF_MasterNewListLite.edConnFloorPropertiesChange(Sender: TObject);
var
  data: double;
begin
  try
    if edConnFloor.Text <> '' then
    begin
      data := StrToFloat_My(edConnFloor.Text);
      edConnTotal.Text := FormatFloat(ffMask, data);
    end
    else
      edConnTotal.Text := '0';
  except
    on E: Exception do AddExceptionToLogEx('TF_MasterNewListLite.edConnFloorPropertiesChange', E.Message);
  end;
end;


procedure TF_MasterNewListLite.edLineRoomPropertiesChange(Sender: TObject);
var
  data: double;
begin
  try
    if edLineCeiling.Text <> '' then
    begin
      data := StrToFloat_My(edLineCeiling.Text);
      edLineTotal.Text := FormatFloat(ffMask, StrToFloat_My(edRoomHeight.Text) - data);
    end
    else
      edLineTotal.Text := '0';
  except
    on E: Exception do AddExceptionToLogEx('TF_MasterNewListLite.edLineRoomPropertiesChange', E.Message);
  end;
end;

procedure TF_MasterNewListLite.edLineFalseFloorPropertiesChange(Sender: TObject);
var
  data: double;
begin
  try
    if edLineFalseFloor.Text <> '' then
    begin
      data := StrToFloat_My(edLineFalseFloor.Text);
      edLineTotal.Text := FormatFloat(ffMask, StrToFloat_My(edRoomHeight.Text) - StrToFloat_My(edFalseFloorHeight.Text) - data);
    end
    else
      edLineTotal.Text := '0';
  except
    on E: Exception do AddExceptionToLogEx('TF_MasterNewListLite.edLineFalseFloorPropertiesChange', E.Message);
  end;
end;

procedure TF_MasterNewListLite.edLineFloorPropertiesChange(Sender: TObject);
var
  data: double;
begin
  try
    if edLineFloor.Text <> '' then
    begin
      data := StrToFloat_My(edLineFloor.Text);
      edLineTotal.Text := FormatFloat(ffMask, data);
    end
    else
      edLineTotal.Text := '0';
  except
    on E: Exception do AddExceptionToLogEx('TF_MasterNewListLite.edLineFloorPropertiesChange', E.Message);
  end;
end;

procedure TF_MasterNewListLite.edLineConnObjectsPropertiesChange(Sender: TObject);
var
  data: double;
begin
  try
    if edLineConnObjects.Text <> '' then
    begin
      data := StrToFloat_My(edLineConnObjects.Text);
      edLineTotal.Text := FormatFloat(ffMask, StrToFloat_My(edConnTotal.Text) + data);
    end
    else
      edLineTotal.Text := '0';
  except
    on E: Exception do AddExceptionToLogEx('TF_MasterNewListLite.edLineConnObjectsPropertiesChange', E.Message);
  end;
end;

procedure TF_MasterNewListLite.bMasksCoponTypesClick(Sender: TObject);
begin
  try
    //EditCatalogMarkMasksExecute(GCadForm.FCADListID, itList);
  except
    on E: Exception do AddExceptionToLogEx('TF_MasterNewListLite.bMasksCoponTypesClick', E.Message);
  end;
end;

procedure TF_MasterNewListLite.cbAllNetworksClick(Sender: TObject);
begin
  try
//    if cbAllNetworks.Checked then
//    begin
//      cbComputerNetwork.Checked := False;
//      cbTelephonNetwork.Checked := False;
//      cbElectricNetwork.Checked := False;
//      cbTelevisionNetwork.Checked := False;
//      cbGasNetwork.Checked := False;
//      cbComputerNetwork.Enabled := False;
//      cbTelephonNetwork.Enabled := False;
//      cbElectricNetwork.Enabled := False;
//      cbTelevisionNetwork.Enabled := False;
//      cbGasNetwork.Enabled := False;
//    end
//    else
//    begin
//      cbComputerNetwork.Enabled := True;
//      cbTelephonNetwork.Enabled := True;
//      cbElectricNetwork.Enabled := True;
//      cbTelevisionNetwork.Enabled := True;
//      cbGasNetwork.Enabled := True;
//    end;
  except
    on E: Exception do AddExceptionToLogEx('TF_MasterNewListLite.cbAllNetworksClick', E.Message);
  end;
end;

procedure TF_MasterNewListLite.cbShowLinesCaptionsClick(Sender: TObject);
begin
  try
//    if cbShowLinesCaptions.Checked then
//    begin
//      cbShowLinesLength.Enabled := True;
//      cbShowLinesLength.Checked := True;
//    end
//    else
//    begin
//      cbShowLinesLength.Checked := False;
//      cbShowLinesLength.Enabled := False;
//    end;
//    if cbShowLinesCaptions.State <> cbGrayed then
//    begin
//      if cbShowLinesCaptions.Checked = FCADParams.CADShowLineObjectCaption then
//        cbShowLinesCaptions.Font.Color := clBlack
//      else
//        cbShowLinesCaptions.Font.Color := clBlue;
//    end
//    else
//    begin
//      cbShowLinesCaptions.Font.Color := clBlack
//    end;
  except
    on E: Exception do AddExceptionToLogEx('TF_MasterNewListLite.cbShowLinesCaptionsClick', E.Message);
  end;
end;

procedure TF_MasterNewListLite.bProjectOKClick(Sender: TObject);
begin
  Exit;
end;

procedure TF_MasterNewListLite.bProjectCancelClick(Sender: TObject);
begin
  Close;
end;

procedure TF_MasterNewListLite.FormCreate(Sender: TObject);
begin
  try
    // Tolik 01/11/2019 --
    seProjectIndex.Min := 0;
    seProjectIndex.Max := 0;
    seAutoSaveProjectMinutes.Min := 0;
    seAutoSaveProjectMinutes.Max := 0;
    seHeightThroughFloor.Min := 0;
    seHeightThroughFloor.Max := 0;
    //
    seHeightThroughFloor.Decimals := 2;

    {FComponTypesMarkMask := nil;
    FComponTypesMarkMask := TF_ComponTypesMarkMask.Create(Self, TForm(F_ProjMan));
    FComponTypesMarkMask.Parent := TabTemplate;
    FComponTypesMarkMask.BorderStyle := bsNone;
    FComponTypesMarkMask.Align := alClient;
    FComponTypesMarkMask.Panel_OkCancel.Visible := false;
    FComponTypesMarkMask.Visible := true;}

    FProjectSpravochnikForm := nil;
    FListSpravochnikForm := nil;
    FParentCADParams := nil; //23.10.2012
    //cbReindexComponentsClick(cbReindexComponents);
    {$IF DEfined(SCS_PE) or Defined(SCS_SPA)}
      RzGroupBox13.Visible := False;
      //gbSCSTypePrj.Visible := False;
      //gbSCSType.Visible := False;
      //cbCADCaptionsExternalSCS.Visible := False;
      //TabSheet3.TabVisible := False;
      //TabSheet4.TabVisible := False;
    {$IFEND}

    SetEditsToZero;

    // Динамические массивы соответствий RadioButton к згначениям
    InitDynArrayOfObject(FArrNewTracesLengthRB, [rbNewTracesLengthAuto, rbNewTracesLengthUser]);
    InitDynArrayOfInt(FArrNewTracesLengthVal, [Ord(tltAuto), Ord(tltUser)]);
  except
    on E: Exception do AddExceptionToLogEx('TF_MasterNewListLite.FormCreate', E.Message);
  end;
end;

procedure TF_MasterNewListLite.FormDestroy(Sender: TObject);
begin
  //if FProjectSpravochnikForm <> nil then
  //  FreeAndNil(FProjectSpravochnikForm);
  //if FListSpravochnikForm <> nil then
  //  FreeAndNil(FListSpravochnikForm);

  //FreeAndNil(FComponTypesMarkMask);
end;

procedure TF_MasterNewListLite.bOKClick(Sender: TObject);
var
  fControl: TWinControl;
  StrMessage: String;

  procedure AddStrToMessage(AStr: String);
  begin
    if StrMessage <> '' then
      StrMessage := StrMessage + #10+#13;
    StrMessage := StrMessage + AStr + '.';
  end;

begin
  try
    if FItemType = itProject then
      if FMakeEditMode = meEdit then
      begin
        StrMessage := '';
        if GetPointComonIndexingModeFromForm <> FProjectParams.Setting.PointComonIndexingMode then
          AddStrToMessage(cMasterNewList_Mes15);
        if GetMarkModeFrom <> FProjectParams.Setting.MarkMode then
          AddStrToMessage(cMasterNewList_Mes16);
        if StrMessage <> '' then
        begin
          StrMessage := cMasterNewList_Mes14 + '!'+#10+#13 + StrMessage + #10+#13+#10+#13 +cMasterNewList_Mes17 + '?';
          if MessageModal(StrMessage, ApplicationName, MB_ICONQUESTION or MB_YESNO) <> IDYES then
          begin
            ModalResult := mrNone;
            Exit; ///// EXIT /////
          end;
        end;
      end;

    fControl := ActiveControl;
    if fControl <> nil then
    begin
      //bOK.SetFocus;
    end;
    //if (Not rbExternalSCSP.Checked) And (Not rbInternalSCSP.Checked) then
    //begin
      //ShowMessage(cMasterNewList_Mes11);
      //ModalResult := mrNone;
    //end
    //else
    if not GProjectChanged then // Tolik 28/08/2019 --
      SetProjectChanged(True);
  except
    on E: Exception do AddExceptionToLogEx('TF_MasterNewListLite.bOKClick', E.Message);
  end;
end;

procedure TF_MasterNewListLite.bCancleClick(Sender: TObject);
begin
  Close;
end;

procedure TF_MasterNewListLite.btChoiceCurrencyClick(Sender: TObject);
begin
  try
    SetProjCurrencyMToForm(true);
  except
    on E: Exception do AddExceptionToLogEx('TF_MasterNewListLite.btChoiceCurrencyClick', E.Message);
  end;
end;

function TF_MasterNewListLite.MakeEditProject(AMakeEdit: TMakeEdit; AIDProject: Integer;
  var AProjectParams: TProjectParams; ASpravochnikKind: TViewKind = vkNone; AGUIDToLocate: String = '';
  AIsFromMaster: Boolean=false; AParentCADParams: PCADParams=nil): Boolean;
var
  //ProjectParams: TProjectParams;
  //ListParams: TListParams;
  SavedFOnShow: TNotifyEvent;
  CADParams: TCADParams;
  AListParams: TListParams;

  SavedUOMPM: Integer;
begin
  try
    Result := false;

    //03.03.2011  Подгружаем справочники и валюты
    if F_MasterNewList.CreateSpravochniki then
      F_MasterNewList.SetProjectParamsToForm(AProjectParams, true);

    FMakeEditMode := AMakeEdit;
    FIsFromMaster := AIsFromMaster;
    FParentCADParams := AParentCADParams;

    FormModeAsProject(true);
    SavedFOnShow := OnShow;
    SavedUOMPM := GetUOMFromPM; //#From Oleg#

    try
      FProjectParams.ID := 0;
      FProjectParams.MarkID := 0;
      FProjectParams.Name := '';

      Caption := '';
      Tag := -1;
      FItemType := itProject;
      FListID := -1;
      FMasterAsList := False; //24.10.2012
      case AMakeEdit of
        meMake:
        begin
          Caption := cMasterNewListLite_Mes5;
//          FProjectParams := GetProjectParamsForNew(true);
          //24.10.2012 FMasterAsList := False;
        end;
        meEdit:
        begin
          Caption := cMasterNewList_Mes3;
//          FProjectParams := GetCurrProjectParams;
        end;
      end;
      FProjectParams := AProjectParams;
      
      FProjectID := FProjectParams.ID;
      FItemID := FProjectID;

      FListParams.Settings := FProjectParams.DefListSetting;

      SetProjectParamsToForm(FProjectParams);

      //*** Если нужно сразу показать справочник (он должен быть уже загружен в SetProjectParamsToForm)
      ShowProjectSpravochnik(ASpravochnikKind, AGUIDToLocate);

      BeforeShowForm;

      if ShowModal = mrOk then
      begin
        AProjectParams := GetProjectParamsFromForm;
        AProjectParams.DefListSetting.ListType := FProjectParams.DefListSetting.ListType;
        AProjectParams.DefListSetting.IDFigureForDesignList := FProjectParams.DefListSetting.IDFigureForDesignList;
        AProjectParams.DefListSetting.IDListForDesignList := FProjectParams.DefListSetting.IDListForDesignList;
        Result := true;
      end
      else
      if ModalResult = 200 then
      begin
        AProjectParams := GetProjectParamsFromForm(false);
        AProjectParams.DefListSetting.ListType := FProjectParams.DefListSetting.ListType;
        AProjectParams.DefListSetting.IDFigureForDesignList := FProjectParams.DefListSetting.IDFigureForDesignList;
        AProjectParams.DefListSetting.IDListForDesignList := FProjectParams.DefListSetting.IDListForDesignList;

        Result := F_MasterNewList.MakeEditProject(AMakeEdit, AIDProject, AProjectParams, ASpravochnikKind, AGUIDToLocate, true, @FCADParams);
      end;
    finally
      if ModalResult <> mrOk then //#From Oleg#
        SetUOMToPM(SavedUOMPM);   //#From Oleg#

      //OnShow := SavedFOnShow;
      FormModeAsProject(false);
    end;
  except
    on E: Exception do AddExceptionToLogEx('TF_MasterNewListLite.MakeEditProject', E.Message);
  end;
end;

function TF_MasterNewListLite.ChangeListParams(AMakeEdit: TMakeEdit; var AListParams: TListParams; AShowForm: Boolean; {aCADParams: TCADParams}
  ASpravochnikKind: TViewKind = vkNone; AGUIDToLocate: String = '';
  AIsFromMaster: Boolean=false; AParentCADParams: PCADParams=nil): Boolean;
begin
  Result := false;
  try
    try
      FMakeEditMode := AMakeEdit;
      FIsFromMaster := AIsFromMaster;
      FParentCADParams := AParentCADParams;

      FListParams.MarkID := 0;
      FListParams.Name := '';

      FMasterAsList := True;
      case AMakeEdit of
        meMake:
        begin
          Caption := cMasterNewListLite_Mes6;
          //24.10.2012 FMasterAsList := True;
        end;
        meEdit:
        begin
          Caption := cMasterNewList_Mes5;
          //ListParams := GetListParamsFromForm;
        end;
      end;
      FItemType := itList;
      FListID := AListParams.ID;
      FItemID := AListParams.ID;
      FListParams := AListParams;
      FProjectParams := GetCurrProjectParams;

      FormAsList(true);
      SetListParamsToForm(FListParams);

      //*** Справочник для листа
      ShowListSpravochnik(ASpravochnikKind, AGUIDToLocate);

      if AShowForm then
      begin
        // !!!
//        if AListParams.Settings.ListType = lt_Normal then
//        begin
//          ListPageControl.Pages[0].TabVisible := True;
//          ListPageControl.Pages[2].TabVisible := True;
//          ListPageControl.Pages[3].TabVisible := True;
//          ListPageControl.Pages[4].TabVisible := True;
//          ListPageControl.Pages[5].TabVisible := True;
//          gbViewTracesOptions.Enabled := True;
//          gbShowCaptionsTypeInCAD.Enabled := True;
//          gbShowNotesTypeInCAD.Enabled := True;
//          gbPrefixInCAD.Enabled := True;
//          gbShowNetTypes.Enabled := True;
//          gbViewOptions.Enabled := True;
//          cbPutCableOnTrace.Enabled := True;
//          cbApplyForAllSCSObjects.Enabled := True;
//          cbShowCabinetsNumbers.Enabled := True;
//          if cbCADCaptionsExternalSCS.Checked then
//          begin
//            cbAutoApplyHeights.Enabled := False;
//            rbConnFloor.Enabled := False;
//            edConnFloor.Enabled := False;
//            rbLineCeiling.Enabled := False;
//            edLineCeiling.Enabled := False;
//            rbLineConnObjects.Enabled := False;
//            edLineConnObjects.Enabled := False;
//            rbLineFalseFloor.Enabled := False;
//            edLineFalseFloor.Enabled := False;
//            rbLineFloor.Enabled := False;
//            edLineFloor.Enabled := False;
//          end
//          else
//          begin
//            cbAutoApplyHeights.Enabled := True;
//            rbConnFloor.Enabled := True;
//            edConnFloor.Enabled := True;
//            rbLineCeiling.Enabled := True;
//            rbLineConnObjects.Enabled := True;
//            rbLineFalseFloor.Enabled := True;
//            rbLineFloor.Enabled := True;
//            if rbLineCeiling.Checked then
//            begin
//              edLineCeiling.Enabled := True;
//              edLineConnObjects.Enabled := False;
//              edLineFalseFloor.Enabled := False;
//              edLineFloor.Enabled := False;
//            end;
//            if rbLineConnObjects.Checked then
//            begin
//              edLineConnObjects.Enabled := True;
//              edLineCeiling.Enabled := False;
//              edLineFalseFloor.Enabled := False;
//              edLineFloor.Enabled := False;
//            end;
//            if rbLineFalseFloor.Checked then
//            begin
//              edLineFalseFloor.Enabled := True;
//              edLineCeiling.Enabled := False;
//              edLineConnObjects.Enabled := False;
//              edLineFloor.Enabled := False;
//            end;
//            if rbLineFloor.Checked then
//            begin
//              edLineFloor.Enabled := True;
//              edLineCeiling.Enabled := False;
//              edLineConnObjects.Enabled := False;
//              edLineFalseFloor.Enabled := False;
//            end;
//          end;
//        end;
//        if AListParams.Settings.ListType = lt_ProjectPlan then
//        begin
//          ListPageControl.ActivePageIndex := 1;
//          ListPageControl.Pages[0].TabVisible := False;
//          ListPageControl.Pages[2].TabVisible := False;
//          ListPageControl.Pages[3].TabVisible := False;
//          ListPageControl.Pages[4].TabVisible := False;
//          ListPageControl.Pages[5].TabVisible := False;
//          gbViewTracesOptions.Enabled := False;
//          gbShowCaptionsTypeInCAD.Enabled := False;
//          gbShowNotesTypeInCAD.Enabled := False;
//          gbPrefixInCAD.Enabled := False;
//          gbShowNetTypes.Enabled := False;
//          gbViewOptions.Enabled := False;
//          cbPutCableOnTrace.Enabled := False;
//          cbApplyForAllSCSObjects.Enabled := False;
//          cbShowCabinetsNumbers.Enabled := False;
//        end;
//        if AListParams.Settings.ListType = lt_DesignBox then
//        begin
//          ListPageControl.ActivePageIndex := 1;
//          ListPageControl.Pages[0].TabVisible := False;
//          ListPageControl.Pages[2].TabVisible := False;
//          ListPageControl.Pages[3].TabVisible := False;
//          ListPageControl.Pages[4].TabVisible := False;
//          ListPageControl.Pages[5].TabVisible := False;
//          gbViewTracesOptions.Enabled := False;
//          gbShowCaptionsTypeInCAD.Enabled := False;
//          gbShowNotesTypeInCAD.Enabled := False;
//          gbPrefixInCAD.Enabled := False;
//          gbShowNetTypes.Enabled := False;
//          gbViewOptions.Enabled := False;
//          cbPutCableOnTrace.Enabled := False;
//          cbApplyForAllSCSObjects.Enabled := False;
//          cbShowCabinetsNumbers.Enabled := False;
//        end;

        BeforeShowForm;

        if ShowModal = mrOK then
        begin
          // *UNDO*
          if AMakeEdit = meEdit then
          begin
            if GCadForm <> nil then
              if GCadForm.FCanSaveForUndo then
              begin
                GCadForm.SaveForUndo(uat_None, True, False);
                GCadForm.FCanSaveForUndo := False;
              end;
          end;

          AListParams := GetListParamsFromForm;
          AListParams.Settings.ListType := FListParams.Settings.ListType;
          AListParams.Settings.IDFigureForDesignList := FListParams.Settings.IDFigureForDesignList;
          AListParams.Settings.IDListForDesignList := FListParams.Settings.IDListForDesignList;
          Result := true;
        end
        else
        if ModalResult = 200 then
        begin
          AListParams := GetListParamsFromForm(false);
          AListParams.Settings.ListType := FListParams.Settings.ListType;
          AListParams.Settings.IDFigureForDesignList := FListParams.Settings.IDFigureForDesignList;
          AListParams.Settings.IDListForDesignList := FListParams.Settings.IDListForDesignList;
          Result := F_MasterNewList.ChangeListParams(AMakeEdit, AListParams, AShowForm{, CADParams}, ASpravochnikKind, AGUIDToLocate, true, @FCADParams);
        end;
        
      end;
      if Not AShowForm then
        Result := true;
    except
      on E: Exception do AddExceptionToLogEx('TF_MasterNewListLite.ChangeListParams', E.Message);
    end;
  finally
    FormAsList(false);
  end;
end;

procedure TF_MasterNewListLite.GlobalPageControlTabClick(Sender: TObject);
begin
  try
//    if (GCadForm <> nil) and (GCadForm.PCad <> nil) then
//    begin
//      if GlobalPageControl.ActivePageIndex = 1 then
//      begin
//        // настройки в зависимости от типа листа
//        if GCadForm.FListType = lt_DesignBox then
//        begin
//          ListPageControl.ActivePageIndex := 1;
//          ListPageControl.Pages[0].TabVisible := False;
//          ListPageControl.Pages[2].TabVisible := False;
//          ListPageControl.Pages[3].TabVisible := False;
//          ListPageControl.Pages[4].TabVisible := False;
//          gbViewTracesOptions.Enabled := False;
//          gbShowCaptionsTypeInCAD.Enabled := False;
//          gbShowNotesTypeInCAD.Enabled := False;
//          gbPrefixInCAD.Enabled := False;
//          gbShowNetTypes.Enabled := False;
//          gbViewOptions.Enabled := False;
//          cbPutCableOnTrace.Enabled := False;
//          cbApplyForAllSCSObjects.Enabled := False;
//          cbShowCabinetsNumbers.Enabled := False;
//        end;
//        if GCadForm.FListType = lt_Normal then
//        begin
//          ListPageControl.Pages[0].TabVisible := True;
//          ListPageControl.Pages[2].TabVisible := True;
//          ListPageControl.Pages[3].TabVisible := True;
//          ListPageControl.Pages[4].TabVisible := True;
//          gbViewTracesOptions.Enabled := True;
//          gbShowCaptionsTypeInCAD.Enabled := True;
//          gbShowNotesTypeInCAD.Enabled := True;
//          gbPrefixInCAD.Enabled := True;
//          gbShowNetTypes.Enabled := True;
//          gbViewOptions.Enabled := True;
//          cbPutCableOnTrace.Enabled := True;
//          cbApplyForAllSCSObjects.Enabled := True;
//          cbShowCabinetsNumbers.Enabled := True;
//        end;
//      end;
//    end;
  except
    on E: Exception do AddExceptionToLogEx('TF_MasterNewListLite.GlobalPageControlTabClick', E.Message);
  end;
end;

procedure TF_MasterNewListLite.cbIsAutoSaveProjectClick(Sender: TObject);
begin
  try
    seAutoSaveProjectMinutes.Enabled := cbIsAutoSaveProject.Checked;
    lbAutoSaveProjectMinutes.Enabled := cbIsAutoSaveProject.Checked;
  except
    on E: Exception do AddExceptionToLogEx('TF_MasterNewListLite.cbIsAutoSaveProjectClick', E.Message);
  end;
end;

procedure TF_MasterNewListLite.SetParamsOnLineTracingType(aLineTracingType: TLineTracingType; aRoomHeight, aFalseFloorHeight, aLineHeight, aConnHeight: Double);
var
  CalcData: Double;
begin
  try
    if aLineTracingType = ltt_FromCeiling then
    begin
      CalcData := aRoomHeight - aLineHeight;
      if (GCurrProjUnitOfMeasure = umSM) or (GCurrProjUnitOfMeasure = umM) then
        CalcData := BriefFormat(CalcData);
      rbLineCeiling.Checked := True;
      edLineCeiling.Text := FormatFloat(ffMask, MetreToUOM(CalcData));
      edLineFalseFloor.Text := '0';
      edLineFloor.Text := '0';
      edLineConnObjects.Text := '0';
      edLineCeiling.Enabled := True;
      edLineFalseFloor.Enabled := False;
      edLineFloor.Enabled := False;
      edLineConnObjects.Enabled := False;
    end;
    if aLineTracingType = ltt_FromFalseFloor then
    begin
      CalcData := aRoomHeight - aFalseFloorHeight - aLineHeight;
      if (GCurrProjUnitOfMeasure = umSM) or (GCurrProjUnitOfMeasure = umM) then
        CalcData := BriefFormat(CalcData);
      rbLineFalseFloor.Checked := True;
      edLineCeiling.Text := '0';
      edLineFalseFloor.Text := FormatFloat(ffMask, MetreToUOM(CalcData));
      edLineFloor.Text := '0';
      edLineConnObjects.Text := '0';
      edLineCeiling.Enabled := False;
      edLineFalseFloor.Enabled := True;
      edLineFloor.Enabled := False;
      edLineConnObjects.Enabled := False;
    end;
    if aLineTracingType = ltt_FromFloor then
    begin
      CalcData := aLineHeight;
      if (GCurrProjUnitOfMeasure = umSM) or (GCurrProjUnitOfMeasure = umM) then
        CalcData := BriefFormat(CalcData);
      rbLineFloor.Checked := True;
      edLineCeiling.Text := '0';
      edLineFalseFloor.Text := '0';
      edLineFloor.Text := FormatFloat(ffMask, MetreToUOM(CalcData));
      edLineConnObjects.Text := '0';
      edLineCeiling.Enabled := False;
      edLineFalseFloor.Enabled := False;
      edLineFloor.Enabled := True;
      edLineConnObjects.Enabled := False;
    end;
    if aLineTracingType = ltt_FromConnObjects then
    begin
      CalcData := aLineHeight - aConnHeight;
      if (GCurrProjUnitOfMeasure = umSM) or (GCurrProjUnitOfMeasure = umM) then
        CalcData := BriefFormat(CalcData);
      rbLineConnObjects.Checked := True;
      edLineCeiling.Text := '0';
      edLineFalseFloor.Text := '0';
      edLineFloor.Text := '0';
      edLineConnObjects.Text := FormatFloat(ffMask, MetreToUOM(CalcData));
      edLineCeiling.Enabled := False;
      edLineFalseFloor.Enabled := False;
      edLineFloor.Enabled := False;
      edLineConnObjects.Enabled := True;
    end;
    //edLineTotal.Text := FormatFloat(ffMask, aLineHeight);
    edLineTotal.Text := FormatFloat(ffMask, MetreToUOM(aLineHeight));
  except
    on E: Exception do AddExceptionToLogEx('TF_MasterNewListLite.SetParamsOnLineTracingType', E.Message);
  end;
end;

procedure TF_MasterNewListLite.edConnFloorExit(Sender: TObject);
var
  val: double;
  ValRoom: Double;
  CheckValue: Double;
begin
  try
    if edConnFloor.Text = '' then
      edConnFloor.Text := '0';
    val := StrToFloat_My(edConnFloor.Text);
    ValRoom := StrToFloat_My(edRoomHeight.Text);
    if val > ValRoom then
    begin
      val := ValRoom;
      edConnFloor.Text := FormatFloat(ffMask, val);
    end;
    CheckValue := StrToFloat_My(edConnTotal.Text);
    if CheckValue = MetreToUOM(FCADParams.CADHeightConns) then
      edConnTotal.Style.Font.Color := clBlack
    else
      edConnTotal.Style.Font.Color := clBlue;
  except
    on E: Exception do AddExceptionToLogEx('TF_MasterNewListLite.edConnFloorExit', E.Message);
  end;
end;


procedure TF_MasterNewListLite.edLineCeilingExit(Sender: TObject);
var
  val: double;
  ValRoom: Double;
  CheckValue: Double;
begin
  try
    if edLineCeiling.Text = '' then
      edLineCeiling.Text := '0';
    val := StrToFloat_My(edLineCeiling.Text);
    ValRoom := StrToFloat_My(edRoomHeight.Text);
    if val > ValRoom then
    begin
      val := ValRoom;
      edLineCeiling.Text := FormatFloat(ffMask, val);
    end;
    CheckValue := StrToFloat_My(edLineTotal.Text);
    if CheckValue = MetreToUOM(FCADParams.CADHeightLines) then
      edLineTotal.Style.Font.Color := clBlack
    else
      edLineTotal.Style.Font.Color := clBlue;
  except
    on E: Exception do AddExceptionToLogEx('TF_MasterNewListLite.edLineCeilingExit', E.Message);
  end;
end;

procedure TF_MasterNewListLite.edLineFalseFloorExit(Sender: TObject);
var
  val: double;
  ValRoom: Double;
  ValFalseFloor: Double;
  CheckValue: Double;
begin
  try
    if edLineFalseFloor.Text = '' then
      edLineFalseFloor.Text := '0';
    val := StrToFloat_My(edLineFalseFloor.Text);
    ValRoom := StrToFloat_My(edRoomHeight.Text);
    ValFalseFloor := StrToFloat_My(edFalseFloorHeight.Text);
    if val > (ValRoom - ValFalseFloor) then
    begin
      val := (ValRoom - ValFalseFloor);
      edLineFalseFloor.Text := FormatFloat(ffMask, val);
    end;
    CheckValue := StrToFloat_My(edLineTotal.Text);
    if CheckValue = MetreToUOM(FCADParams.CADHeightLines) then
      edLineTotal.Style.Font.Color := clBlack
    else
      edLineTotal.Style.Font.Color := clBlue;
  except
    on E: Exception do AddExceptionToLogEx('TF_MasterNewListLite.edLineFalseFloorExit', E.Message);
  end;
end;

procedure TF_MasterNewListLite.edLineFloorExit(Sender: TObject);
var
  val: double;
  ValRoom: Double;
  CheckValue: Double;
begin
  try
    if edLineFloor.Text = '' then
      edLineFloor.Text := '0';
    val := StrToFloat_My(edLineFloor.Text);
    ValRoom := StrToFloat_My(edRoomHeight.Text);
    if val > ValRoom then
    begin
      val := ValRoom;
      edLineFloor.Text := FormatFloat(ffMask, val);
    end;
    CheckValue := StrToFloat_My(edLineTotal.Text);
    if CheckValue = MetreToUOM(FCADParams.CADHeightLines) then
      edLineTotal.Style.Font.Color := clBlack
    else
      edLineTotal.Style.Font.Color := clBlue;

  except
    on E: Exception do AddExceptionToLogEx('TF_MasterNewListLite.edLineFloorExit', E.Message);
  end;
end;

procedure TF_MasterNewListLite.edListNameExit(Sender: TObject);
begin
  try
//   if edListName.Text = '' then
//     edListName.Text := cMasterNewList_Mes6;
  except
    on E: Exception do AddExceptionToLogEx('TF_MasterNewListLite.edListNameExit', E.Message);
  end;
end;

procedure TF_MasterNewListLite.edRoomHeightExit(Sender: TObject);
var
  valLine: Double;
  valConn: Double;
  ValRoom: Double;
  ValFalseFloor: Double;
  CheckValue: double;
begin
  try
    if edRoomHeight.Text = '' then
      edRoomHeight.Text := '0';
    ValRoom := StrToFloat_My(edRoomHeight.Text);
    ValFalseFloor := StrToFloat_My(edFalseFloorHeight.Text);
    // Check FalseFloor
    if ValRoom < ValFalseFloor then
    begin
      ValFalseFloor := ValRoom;
      edFalseFloorHeight.Text := FormatFloat(ffMask, ValFalseFloor);
    end;
    // Check Conn
    valConn := StrToFloat_My(edConnFloor.Text);
    if ValRoom < valConn then
    begin
      valConn := ValRoom;
      edConnFloor.Text := FormatFloat(ffMask, valConn);
    end;
    // Check Line
    if rbLineCeiling.Checked then
    begin
      valLine := StrToFloat_My(edLineCeiling.Text);
      if ValRoom < valLine then
      begin
        valLine := ValRoom;
        edLineCeiling.Text := FormatFloat(ffMask, valLine);
      end;
    end;
    if rbLineFalseFloor.Checked then
    begin
      valLine := StrToFloat_My(edLineFalseFloor.Text);
      if (ValRoom - ValFalseFloor) < valLine then
      begin
        valLine := ValRoom - ValFalseFloor;
        edLineFalseFloor.Text := FormatFloat(ffMask, valLine);
      end;
    end;
    if rbLineFloor.Checked then
    begin
      valLine := StrToFloat_My(edLineFloor.Text);
      if ValRoom < valLine then
      begin
        valLine := ValRoom;
        edLineFloor.Text := FormatFloat(ffMask, valLine);
      end;
    end;
    if rbLineConnObjects.Checked then
    begin
      valLine := StrToFloat_My(edLineConnObjects.Text);
      if ValRoom - valConn < valLine then
      begin
        valLine := ValRoom - valConn;
        edLineConnObjects.Text := FormatFloat(ffMask, valLine);
      end;
    end;
    // CheckChange !!!
    CheckValue := StrToFloat_My(edRoomHeight.Text);
    if CheckValue = MetreToUOM(FCADParams.CADHeightRoom) then
      edRoomHeight.Style.Font.Color := clBlack
    else
      edRoomHeight.Style.Font.Color := clBlue;
  except
    on E: Exception do AddExceptionToLogEx('TF_MasterNewListLite.edRoomHeightExit', E.Message);
  end;
end;

procedure TF_MasterNewListLite.edFalseFloorHeightExit(Sender: TObject);
var
  valLine: Double;
  valConn: Double;
  ValRoom: Double;
  ValFalseFloor: Double;
  CheckValue: Double;
begin
  try
    if edFalseFloorHeight.Text = '' then
      edFalseFloorHeight.Text := '0';
    ValFalseFloor := StrToFloat_My(edFalseFloorHeight.Text);
    ValRoom := StrToFloat_My(edRoomHeight.Text);
    // Check Room
    if ValFalseFloor > ValRoom then
    begin
      ValRoom := ValFalseFloor;
      edRoomHeight.Text := FormatFloat(ffMask, ValRoom);
    end;
    // Check Conn
    valConn := StrToFloat_My(edConnFloor.Text);
    if ValRoom < valConn then
    begin
      valConn := ValRoom;
      edConnFloor.Text := FormatFloat(ffMask, valConn);
    end;
    // Check Line
    if rbLineCeiling.Checked then
    begin
      valLine := StrToFloat_My(edLineCeiling.Text);
      if ValRoom < valLine then
      begin
        valLine := ValRoom;
        edLineCeiling.Text := FormatFloat(ffMask, valLine);
      end;
    end;
    if rbLineFalseFloor.Checked then
    begin
      valLine := StrToFloat_My(edLineFalseFloor.Text);
      if (ValRoom - ValFalseFloor) < valLine then
      begin
        valLine := ValRoom - ValFalseFloor;
        edLineFalseFloor.Text := FormatFloat(ffMask, valLine);
      end;
    end;
    if rbLineFloor.Checked then
    begin
      valLine := StrToFloat_My(edLineFloor.Text);
      if ValRoom < valLine then
      begin
        valLine := ValRoom;
        edLineFloor.Text := FormatFloat(ffMask, valLine);
      end;
    end;
    if rbLineConnObjects.Checked then
    begin
      valLine := StrToFloat_My(edLineConnObjects.Text);
      if ValRoom - valConn < valLine then
      begin
        valLine := ValRoom - valConn;
        edLineConnObjects.Text := FormatFloat(ffMask, valLine);
      end;
    end;
    // CheckChange
    CheckValue := StrToFloat_My(edFalseFloorHeight.Text);
    if CheckValue = MetreToUOM(FCADParams.CADHeightFalseFloor) then
      edFalseFloorHeight.Style.Font.Color := clBlack
    else
      edFalseFloorHeight.Style.Font.Color := clBlue;
  except
    on E: Exception do AddExceptionToLogEx('TF_MasterNewListLite.edFalseFloorHeightExit', E.Message);
  end;
end;

procedure TF_MasterNewListLite.edLengthKoefExit(Sender: TObject);
begin
  try
    if edLengthKoef.Text = '' then
      edLengthKoef.Text := '0';
  except
    on E: Exception do AddExceptionToLogEx('TF_MasterNewListLite.edLengthKoefExit', E.Message);
  end;
end;

procedure TF_MasterNewListLite.edCableChannelFullnessKoefExit(Sender: TObject);
begin
  try
    if edCableChannelFullnessKoef.Text = '' then
      edCableChannelFullnessKoef.Text := '0';
  except
    on E: Exception do AddExceptionToLogEx('TF_MasterNewListLite.edCableChannelFullnessKoefExit', E.Message);
  end;
end;

procedure TF_MasterNewListLite.edPortReservExit(Sender: TObject);
begin
  try
    if edPortReserv.Text = '' then
      edPortReserv.Text := '0';
  except
    on E: Exception do AddExceptionToLogEx('TF_MasterNewListLite.edPortReservExit', E.Message);
  end;
end;

procedure TF_MasterNewListLite.edMultiportReservExit(Sender: TObject);
begin
  try
    if edMultiportReserv.Text = '' then
      edMultiportReserv.Text := '0';
  except
    on E: Exception do AddExceptionToLogEx('TF_MasterNewListLite.edMultiportReservExit', E.Message);
  end;
end;

procedure TF_MasterNewListLite.edTwistedPairMaxLengthExit(Sender: TObject);
begin
  try
    if edTwistedPairMaxLength.Text = '' then
      edTwistedPairMaxLength.Text := '0';
  except
    on E: Exception do AddExceptionToLogEx('TF_MasterNewListLite.edTwistedPairMaxLengthExit', E.Message);
  end;
end;

procedure TF_MasterNewListLite.edLineConnObjectsExit(Sender: TObject);
var
  val: double;
  ValRoom: Double;
  ValConn: Double;
  CheckValue: Double;
begin
  try
    if edLineConnObjects.Text = '' then
      edLineConnObjects.Text := '0';
    val := StrToFloat_My(edLineConnObjects.Text);
    ValRoom := StrToFloat_My(edRoomHeight.Text);
    ValConn := StrToFloat_My(edConnFloor.Text);
    if val > (ValRoom - ValConn) then
    begin
      val := (ValRoom - ValConn);
      edLineConnObjects.Text := FormatFloat(ffMask, val);
    end;
    CheckValue := StrToFloat_My(edLineTotal.Text);
    if CheckValue = MetreToUOM(FCADParams.CADHeightLines) then
      edLineTotal.Style.Font.Color := clBlack
    else
      edLineTotal.Style.Font.Color := clBlue;
    
  except
    on E: Exception do AddExceptionToLogEx('TF_MasterNewListLite.edLineConnObjectsExit', E.Message);
  end;
end;

procedure TF_MasterNewListLite.edStepGridExit(Sender: TObject);
var
  CheckValue: Double;
begin
  try
//    if edStepGrid.Text = '' then
//      edStepGrid.Text := '1';
//    if edStepGrid.Text = '0' then
//      edStepGrid.Text := '1';
//    CheckValue := StrToFloat_My(edStepGrid.Text);
//    if rbExternalSCS.Checked then
//      if CheckValue > 1 then
//      begin
//        CheckValue := 1;
//        edStepGrid.Text := '1';
//      end;
//    if CheckValue = FCADParams.CADGridStep then
//      edStepGrid.Style.Font.Color := clBlack
//    else
//      edStepGrid.Style.Font.Color := clBlue;
  except
    on E: Exception do AddExceptionToLogEx('TF_MasterNewListLite.edStepGridExit', E.Message);
  end;
end;

procedure TF_MasterNewListLite.edTraceWidthExit(Sender: TObject);
var
  CheckValue: Integer;
begin
  try
//    CheckValue := StrToInt(edTraceWidth.Text);
//    if CheckValue = FCADParams.CADTraceWidth then
//      edTraceWidth.Style.Font.Color := clBlack
//    else
//      edTraceWidth.Style.Font.Color := clBlue;
  except
    on E: Exception do AddExceptionToLogEx('TF_MasterNewListLite.edTraceWidthExit', E.Message);
  end;
end;

procedure TF_MasterNewListLite.edBlockStepExit(Sender: TObject);
var
  CheckValue: Double;
begin
  try
//    if edBlockStep.Text = '' then
//      edBlockStep.Text := '1';
//    if edTraceWidth.Text = '' then
//      edTraceWidth.Text := '1';
//    CheckValue := StrToFloat_My(edBlockStep.Text);
//    if CheckValue = FCADParams.CADBlockStep then
//      edBlockStep.Style.Font.Color := clBlack
//    else
//      edBlockStep.Style.Font.Color := clBlue;
  except
    on E: Exception do AddExceptionToLogEx('TF_MasterNewListLite.edBlockStepExit', E.Message);
  end;
end;

procedure TF_MasterNewListLite.seCurrIndexKeyPress(Sender: TObject;
  var Key: Char);
begin
  if (Key = '-') or (Key = '+') then
    Key := #0;
end;

procedure TF_MasterNewListLite.seProjectIndexKeyPress(Sender: TObject;
  var Key: Char);
begin
  if (Key = '-') or (Key = '+') then
    Key := #0;
end;

procedure TF_MasterNewListLite.cbTraceStylePropertiesCloseUp(Sender: TObject);
var
  CheckValue: Integer;
begin
  try
//    CheckValue := cbTraceStyle.ItemIndex;
//    if CheckValue = ord(FCADParams.CADTraceStyle) then
//      cbTraceStyle.Style.Color := clWhite
//    else
//      cbTraceStyle.Style.Color := clBlue;
  except
    on E: Exception do AddExceptionToLogEx('TF_MasterNewListLite.cbTraceStylePropertiesCloseUp', E.Message);
  end;
end;

procedure TF_MasterNewListLite.edTraceWidthPropertiesEditValueChanged(Sender: TObject);
var
  Val: Integer;
begin
  try
//    Val := StrToInt(edTraceWidth.Text);
  except
    on E: Exception do AddExceptionToLogEx('TF_MasterNewListLite.edTraceWidthPropertiesEditValueChanged', E.Message);
  end;
end;

procedure TF_MasterNewListLite.ListPageControlChange(Sender: TObject);
begin
  try
    if Visible then
    begin
//      if ListPageControl.ActivePage = TabAll then
//        edRoomHeight.SetFocus;
//      if ListPageControl.ActivePage = TabPageParams then
//        edStepGrid.SetFocus;
//      if ListPageControl.ActivePage = TabCAD then
//        edTraceWidth.SetFocus;
//      if ListPageControl.ActivePage = TabPM then
//        cbGroupObjectsByType.SetFocus;
//      if ListPageControl.ActivePage = TabLinesTypes then
//        cbKeepLineTypesRules.SetFocus;
//      if ListPageControl.ActivePage = tsListSpravochniki then
//        tsListSpravochniki.SetFocus;
    end;
  except
    on E: Exception do AddExceptionToLogEx('TF_MasterNewListLite.ListPageControlChange', E.Message);
  end;
end;

procedure TF_MasterNewListLite.GlobalPageControlChange(Sender: TObject);
begin
  try
//    if GlobalPageControl.ActivePage = TabProjectProperties then
//    begin
//      if Visible then
//        if pcProjectOptions.ActivePage = tsProjOptionsGeneral then
//          edProjectName.SetFocus;
//      SetNBCurrencyToForm;
//      SetProjCurrencyMToForm(false);
//    end;
//    if GlobalPageControl.ActivePage = TabListProperties then
//      ListPageControlChange(Sender);
  except
    on E: Exception do AddExceptionToLogEx('TF_MasterNewListLite.GlobalPageControlChange', E.Message);
  end;
end;

procedure TF_MasterNewListLite.seIndexPointObjKeyPress(Sender: TObject;
  var Key: Char);
begin
  if Key = '-' then
    Key := #0;
end;

procedure TF_MasterNewListLite.seIndexConnectorKeyPress(Sender: TObject;
  var Key: Char);
begin
  if Key = '-' then
    Key := #0;
end;

procedure TF_MasterNewListLite.seIndexLineKeyPress(Sender: TObject;
  var Key: Char);
begin
  if Key = '-' then
    Key := #0;
end;

procedure TF_MasterNewListLite.seIndexPointObjExit(Sender: TObject);
var
  CheckValue: Double;
begin
  try
//    CheckValue := StrToFloat_My(seIndexPointObj.Text);
//    if CheckValue = FCADParams.CADIndexPointObjects then
//      seIndexPointObj.Style.Font.Color := clBlack
//    else
//      seIndexPointObj.Style.Font.Color := clBlue;
  except
    on E: Exception do AddExceptionToLogEx('TF_MasterNewListLite.seIndexPointObjExit', E.Message);
  end;
end;

procedure TF_MasterNewListLite.seIndexConnectorExit(Sender: TObject);
var
  CheckValue: Double;
begin
  try
//    CheckValue := StrToFloat_My(seIndexConnector.Text);
//    if CheckValue = FCADParams.CADIndexConnector then
//      seIndexConnector.Style.Font.Color := clBlack
//    else
//      seIndexConnector.Style.Font.Color := clBlue;
  except
    on E: Exception do AddExceptionToLogEx('TF_MasterNewListLite.seIndexConnectorExit', E.Message);
  end;
end;

procedure TF_MasterNewListLite.seIndexLineExit(Sender: TObject);
var
  CheckValue: Double;
begin
  try
//    CheckValue := StrToFloat_My(seIndexLine.Text);
//    if CheckValue = FCADParams.CADIndexLine then
//      seIndexLine.Style.Font.Color := clBlack
//    else
//      seIndexLine.Style.Font.Color := clBlue;
  except
    on E: Exception do AddExceptionToLogEx('TF_MasterNewListLite.seIndexLineExit', E.Message);
  end;
end;

procedure TF_MasterNewListLite.ClearAllChangedColor;
var
  MapScaleResult: Double;
begin
  try
    //
    edRoomHeight.Style.Font.Color := clBlack;
    edFalseFloorHeight.Style.Font.Color := clBlack;
    edConnTotal.Style.Font.Color := clBlack;
    edLineTotal.Style.Font.Color := clBlack;
//    seIndexPointObj.Style.Font.Color := clBlack;
//    seIndexConnector.Style.Font.Color := clBlack;
//    seIndexLine.Style.Font.Color := clBlack;
    //
    cbPageSize.Style.Font.Color := clBlack;
    edWidth.Style.Font.Color := clBlack;
    edHeight.Style.Font.Color := clBlack;
    edListCountX.Style.Font.Color := clBlack;
    edListCountY.Style.Font.Color := clBlack;

//    edStepGrid.Style.Font.Color := clBlack;
    cbFontName.Font.Color := clBlack;
    rbPortrait.Font.Color := clBlack;
    rbLandscape.Font.Color := clBlack;
    rbSimple.Font.Color := clBlack;
    rbExtended.Font.Color := clBlack;
    rbDetailed.Font.Color := clBlack;
    rbUkr.Font.Color := clBlack;
    rbRus.Font.Color := clBlack;
    rbUkrDSTU.Font.Color := clBlack;
    seStampMarginLeft.Style.Font.Color := clBlack;
    seStampMarginRight.Style.Font.Color := clBlack;
    seStampMarginTop.Style.Font.Color := clBlack;
    seStampMarginBottom.Style.Font.Color := clBlack;

    edSizeAllMetric.Style.Font.Color := clBlack;
    edSizeAsMetric.Style.Font.Color := clBlack;
    edSizeAllWhitworth.Style.Font.Color := clBlack;
    edSizeAsWhitworth.Style.Font.Color := clBlack;

//    cbTraceColor.Style.Color := clWhite;
//    cbTraceStyle.Style.Color := clWhite;
//    edStepGrid.Style.Font.Color := clBlack;
//    edBlockStep.Style.Font.Color := clBlack;

//    cbCADCaptions_Short.Font.Color := clBlack;
//    cbCADCaptions_Full.Font.Color := clBlack;
//    cbCADCaptionsDetail.Font.Color := clBlack;
//    cbCADCaptionsSimple.Font.Color := clBlack;
//    cbCADNotes_Short.Font.Color := clBlack;
//    cbCADNotes_Full.Font.Color := clBlack;
//    cbCADNotesDetail.Font.Color := clBlack;
//    cbCADNotesSimple.Font.Color := clBlack;
//    edNotePrefix.Style.Font.Color := clBlack;
//    cbShowLinesCaptions.Font.Color := clBlack;
//    cbShowLinesLength.Font.Color := clBlack;
//    cbShowLinesNotes.Font.Color := clBlack;
//    cbShowConnectorsCaptions.Font.Color := clBlack;
//    cbShowConnectorsNotes.Font.Color := clBlack;
//    cbShowRaise.Font.Color := clBlack;
//    cbPutCableOnTrace.Font.Color := clBlack;

//    cbLinesCaptionsColor.Style.Color := clWhite;
//    cbConnectorsCaptionsColor.Style.Color := clWhite;
//    cbLinesNotesColor.Style.Color := clWhite;
//    cbConnectorsNotesColor.Style.Color := clWhite;

//    cbLinesCaptionsFontSize.Font.Color := clBlack;
//    cbConnectorsCaptionsFontSize.Font.Color := clBlack;
//    cbLinesNotesFontSize.Font.Color := clBlack;
//    cbConnectorsNotesFontSize.Font.Color := clBlack;
//    cbCrossATSFontSize.Font.Color := clBlack;
//    cbDistribCabFontSize.Font.Color := clBlack;

//    cbLinesCaptionsFontBold.Font.Color := clBlack;
//    cbCrossATSFontBold.Font.Color := clBlack;
//    cbDistribCabFontBold.Font.Color := clBlack;

//    rbInternalSCS.Font.Color := clBlack;
//    rbExternalSCS.Font.Color := clBlack;
//    edTraceStepRotate.Style.Font.Color := clBlack;

//    cbAutoCadMouse.Font.Color := clBlack;
//    cbScaleByCursor.Font.Color := clBlack;
//    cbAutoPosTraceBetweenRM.Font.Color := clBlack;

    cbShowMainStamp.Font.Color := clBlack;
    cbShowUpperStamp.Font.Color := clBlack;
    cbShowSideStamp.Font.Color := clBlack;

    //    edSaveUndoCount.Style.Font.Color := clBlack;

//    cbAllowSuppliesKind.Font.Color := clBlack;

    if FParentCADParams <> nil then
    begin
      if Not CmpFloatByCP(StrToFloat_My(edRoomHeight.Text), MetreToUOM(FCADParams.CADHeightRoom)) then
        edRoomHeight.Style.Font.Color := clBlue;
      if Not CmpFloatByCP(StrToFloat_My(edFalseFloorHeight.Text), MetreToUOM(FCADParams.CADHeightFalseFloor)) then
        edFalseFloorHeight.Style.Font.Color := clBlue;
      if Not CmpFloatByCP(StrToFloat_My(edConnTotal.Text), MetreToUOM(FCADParams.CADHeightConns)) then
        edConnTotal.Style.Font.Color := clBlue;
      if Not CmpFloatByCP(StrToFloat_My(edLineTotal.Text), MetreToUOM(FCADParams.CADHeightLines)) then
        edLineTotal.Style.Font.Color := clBlue;
      if cbPageSize.ItemIndex <> FCADParams.CADPageSizeIndex then
        cbPageSize.Style.Font.Color := clBlue;
      if StrToInt(edWidth.Text) <> FCADParams.CADWidth then
        edWidth.Style.Font.Color := clBlue;
      if StrToInt(edHeight.Text) <> FCADParams.CADHeight then
        edHeight.Style.Font.Color := clBlue;
      if StrToInt(edListCountX.Text) <> FCADParams.CADListCountX then
        edListCountX.Style.Font.Color := clBlue;
      if StrToInt(edListCountY.Text) <> FCADParams.CADListCountY then
        edListCountY.Style.Font.Color := clBlue;
      if cbFontName.FontName <> FCADParams.CADFontName then
        cbFontName.Font.Color := clBlue;

      if rbPortrait.Checked and (FCADParams.CADPageOrient <> poPortrait) then
        rbPortrait.Font.Color := clBlue;
      if rbPortrait.Checked and (FCADParams.CADPageOrient <> poLandscape) then
        rbLandscape.Font.Color := clBlue;

      if rbSimple.Checked and (FCADParams.CADStampType <> stt_simple) then
        rbSimple.Font.Color := clBlue;
      if rbExtended.Checked and (FCADParams.CADStampType <> stt_extended) then
        rbExtended.Font.Color := clBlue;
      if rbDetailed.Checked and (FCADParams.CADStampType <> stt_detailed) then
        rbDetailed.Font.Color := clBlue;

      if rbUkr.Checked and (FCADParams.CADStampLang <> stl_ukr) then
        rbUkr.Font.Color := clBlue;
      if rbRus.Checked and (FCADParams.CADStampLang <> stl_rus) then
        rbRus.Font.Color := clBlue;
      if rbUkrDSTU.Checked and (FCADParams.CADStampLang <> stl_ukr_dstu) then
        rbUkrDSTU.Font.Color := clBlue;

      if Not CmpFloatByPrecision(seStampMarginLeft.Value, Round4(FloatInUOM(FCADParams.CADStampMargins.Left, umMM, ConvertUOMToMin(FCurrProjUnitOfMeasure))), 3) then
        seStampMarginLeft.Style.Font.Color := clBlue;
      if Not CmpFloatByPrecision(seStampMarginRight.Value, Round4(FloatInUOM(FCADParams.CADStampMargins.Right, umMM, ConvertUOMToMin(FCurrProjUnitOfMeasure))), 3) then
        seStampMarginRight.Style.Font.Color := clBlue;
      if Not CmpFloatByPrecision(seStampMarginTop.Value, Round4(FloatInUOM(FCADParams.CADStampMargins.Top, umMM, ConvertUOMToMin(FCurrProjUnitOfMeasure))), 3) then
        seStampMarginTop.Style.Font.Color := clBlue;
      if Not CmpFloatByPrecision(seStampMarginBottom.Value, Round4(FloatInUOM(FCADParams.CADStampMargins.Bottom, umMM, ConvertUOMToMin(FCurrProjUnitOfMeasure))), 3) then
        seStampMarginBottom.Style.Font.Color := clBlue;

      MapScaleResult := CheckMapScaleResult;
      if (rbmm1.Checked or rbsm1.Checked or rbm1.Checked or rbmm2.Checked or rbsm2.Checked or rbm2.Checked) and
        Not CmpFloatByCP(MapScaleResult, FCADParams.CADMapScale) then
      begin
        edSizeAsMetric.Style.Font.Color := clBlue;
        edSizeAllMetric.Style.Font.Color := clBlue;
      end;
      if (rbin2.Checked or rbft2.Checked or rbin1.Checked or rbft1.Checked) and
        Not CmpFloatByCP(MapScaleResult, FCADParams.CADMapScale) then
      begin
        edSizeAllWhitworth.Style.Font.Color := clBlue;
        edSizeAsWhitworth.Style.Font.Color := clBlue;
      end;

      if cbShowMainStamp.Checked <> FCADParams.CADShowMainStamp then
        cbShowMainStamp.Font.Color := clBlue;
      if cbShowUpperStamp.Checked <> FCADParams.CADShowUpperStamp then
        cbShowUpperStamp.Font.Color := clBlue;
      if cbShowSideStamp.Checked <> FCADParams.CADShowSideStamp then
        cbShowSideStamp.Font.Color := clBlue;
    end;
  except
    on E: Exception do AddExceptionToLogEx('TF_MasterNewListLite.ClearAllChangedColor', E.Message);
  end;
end;

procedure TF_MasterNewListLite.edWidthExit(Sender: TObject);
var
  CheckValue: Integer;
begin
  try
    CheckValue := StrToInt(edWidth.Text);
    if CheckValue = FCADParams.CADWidth then
      edWidth.Style.Font.Color := clBlack
    else
      edWidth.Style.Font.Color := clBlue;
  except
    on E: Exception do AddExceptionToLogEx('TF_MasterNewListLite.edWidthExit', E.Message);
  end;
end;

procedure TF_MasterNewListLite.edHeightExit(Sender: TObject);
var
  CheckValue: Integer;
begin
  try
    CheckValue := StrToInt(edHeight.Text);
    if CheckValue = FCADParams.CADHeight then
      edHeight.Style.Font.Color := clBlack
    else
      edHeight.Style.Font.Color := clBlue;
  except
    on E: Exception do AddExceptionToLogEx('TF_MasterNewListLite.edHeightExit', E.Message);
  end;
end;

procedure TF_MasterNewListLite.cbFontNameCloseUp(Sender: TObject);
var
  CheckValue: String;
begin
  try
    CheckValue := cbFontName.FontName;
    if CheckValue = FCADParams.CADFontName then
      cbFontName.Font.Color := clBlack
    else
      cbFontName.Font.Color := clBlue;
  except
    on E: Exception do AddExceptionToLogEx('TF_MasterNewListLite.cbFontNameCloseUp', E.Message);
  end;
end;

procedure TF_MasterNewListLite.rbSimpleClick(Sender: TObject);
begin
  try
    if FCADParams.CADStampType = stt_simple then
    begin
      rbSimple.Font.Color := clBlack;
      rbExtended.Font.Color := clBlack;
      rbDetailed.Font.Color := clBlack;
    end
    else
    begin
      rbSimple.Font.Color := clBlue;
      rbExtended.Font.Color := clBlack;
      rbDetailed.Font.Color := clBlack;
    end;
    SetMaket;
  except
    on E: Exception do AddExceptionToLogEx('TF_MasterNewListLite.rbSimpleClick', E.Message);
  end;
end;

procedure TF_MasterNewListLite.rbExtendedClick(Sender: TObject);
begin
  try
    if FCADParams.CADStampType = stt_extended then
    begin
      rbSimple.Font.Color := clBlack;
      rbExtended.Font.Color := clBlack;
      rbDetailed.Font.Color := clBlack;
    end
    else
    begin
      rbSimple.Font.Color := clBlack;
      rbExtended.Font.Color := clBlue;
      rbDetailed.Font.Color := clBlack;
    end;
    SetMaket;
  except
    on E: Exception do AddExceptionToLogEx('TF_MasterNewListLite.rbExtendedClick', E.Message);
  end;
end;

procedure TF_MasterNewListLite.rbDetailedClick(Sender: TObject);
begin
  try
    if FCADParams.CADStampType = stt_detailed then
    begin
      rbSimple.Font.Color := clBlack;
      rbExtended.Font.Color := clBlack;
      rbDetailed.Font.Color := clBlack;
    end
    else
    begin
      rbSimple.Font.Color := clBlack;
      rbExtended.Font.Color := clBlack;
      rbDetailed.Font.Color := clBlue;
    end;
    SetMaket;
  except
    on E: Exception do AddExceptionToLogEx('TF_MasterNewListLite.rbDetailedClick', E.Message);
  end;
end;

procedure TF_MasterNewListLite.rbUkrClick(Sender: TObject);
begin
  try
    if FCADParams.CADStampLang = stl_ukr then
    begin
      rbUkr.Font.Color := clBlack;
      rbUkrDSTU.Font.Color := clBlack;
      rbRus.Font.Color := clBlack;
    end
    else
    begin
      rbUkr.Font.Color := clBlue;
      rbUkrDSTU.Font.Color := clBlack;
      rbRus.Font.Color := clBlack;
    end;
    SetMaket;
  except
    on E: Exception do AddExceptionToLogEx('TF_MasterNewListLite.rbUkrClick', E.Message);
  end;
end;

procedure TF_MasterNewListLite.rbUkrDSTUClick(Sender: TObject);
begin
  try
    if FCADParams.CADStampLang = stl_ukr_dstu then
    begin
      rbUkr.Font.Color := clBlack;
      rbRus.Font.Color := clBlack;
      rbUkrDSTU.Font.Color := clBlack;
    end
    else
    begin
      rbUkr.Font.Color := clBlack;
      rbRus.Font.Color := clBlack;
      rbUkrDSTU.Font.Color := clBlue;
    end;
  except
    on E: Exception do AddExceptionToLogExt(ClassName, MethodName(@TF_MasterNewListLite.rbUkrDSTUClick), E.Message);
  end;
end;

procedure TF_MasterNewListLite.rbRusClick(Sender: TObject);
begin
  try
    if FCADParams.CADStampLang = stl_rus then
    begin
      rbUkr.Font.Color := clBlack;
      rbUkrDSTU.Font.Color := clBlack;
      rbRus.Font.Color := clBlack;
    end
    else
    begin
      rbUkr.Font.Color := clBlack;
      rbUkrDSTU.Font.Color := clBlack;
      rbRus.Font.Color := clBlue;
    end;
    SetMaket;
  except
    on E: Exception do AddExceptionToLogEx('TF_MasterNewListLite.rbRusClick', E.Message);
  end;
end;

function TF_MasterNewListLite.CheckMapScaleResult: Double;
var
  ScaleAs: double;
  ScaleAll: double;
  KoefAs: double;
  KoefAll: double;
  PageKoef: double;

  PageWidth: Integer;
  PageHeight: Integer;
begin
  try
    Result := -1;
    // ЛИНЕЙКА
    ScaleAs := 0;
    ScaleAll := 0;
    KoefAs := 0;
    KoefAll := 0;
    PageKoef := 0;

    PageWidth := edWidth.Value * edListCountX.Value;
    PageHeight := edHeight.Value * edListCountY.Value;

    // МЕТРИЧЕСКАЯ
    if gbRulerModeMetric.Visible then
    begin
      // для показа отдельного отрезка на экране
      if rbm1.Checked then
        KoefAs := 100;
      if rbsm1.Checked then
        KoefAs := 1;
      if rbmm1.Checked then
        KoefAs := 0.1;
      if (rbm1.Checked) Or (rbsm1.Checked) Or (rbmm1.Checked) then
      begin
        //21.09.2010
        //if edSizeAsMetric.Text <> '' then
//        begin
//          ScaleAs := StrToFloat_My(edSizeAsMetric.Text) * KoefAs;
//          Result := ScaleAs;
//        end;
        Result := StrToFloatDef_My(edSizeAsMetric.Text, 1) * KoefAs;
      end;
      // для отображения общей длинны на странице
      if rbm2.Checked then
        KoefAll := 1;
      if rbsm2.Checked then
        KoefAll := 100;
      if rbmm2.Checked then
        KoefAll := 1000;
      if (rbm2.Checked) Or (rbsm2.Checked) Or (rbmm2.Checked) then
      begin
        //21.09.2010
        //if edSizeAllMetric.Text <> '' then
//        begin
//          PageKoef := PageWidth / 1000; //21.09.2010 GCadForm.PCad.WorkWidth / 1000;
//          ScaleAll := StrToFloat_My(edSizeAllMetric.Text) / PageKoef / KoefAll;
//          Result := ScaleAll;
//        end;
        PageKoef := PageWidth / 1000;
        Result := StrToFloatDef_My(edSizeAllMetric.Text, 50) / PageKoef / KoefAll;
      end;
    end
    else
    // ДЮЙМОВАЯ
    begin
      // для показа отдельного отрезка на экране
      if rbin1.Checked then
        KoefAs := 1;
      if rbft1.Checked then
        KoefAs := 12;
      if (rbin1.Checked) Or (rbft1.Checked) then
      begin
        //21.09.2010
        //if edSizeAsWhitworth.Text <> '' then
//        begin
//          ScaleAs := StrToFloat_My(edSizeAsWhitworth.Text) * KoefAs;
//          Result := ScaleAs;
//        end;
        Result := StrToFloatDef_My(edSizeAsWhitworth.Text, 1) * KoefAs;
      end;
      // для отображения общей длинны на странице
      if rbin2.Checked then
        KoefAll := 12;
      if rbft2.Checked then
        KoefAll := 1;
      if (rbin2.Checked) Or (rbft2.Checked) then
      begin
        //if edSizeAllWhitworth.Text <> '' then
//        begin
//          PageKoef := PageWidth / 304.8; //21.09.2010 GCadForm.PCad.WorkWidth / 1000;
//          ScaleAll := StrToFloat_My(edSizeAllWhitworth.Text) / PageKoef / KoefAll;
//          Result := ScaleAll;
//        end;
        PageKoef := PageWidth / 304.8;
        Result := StrToFloatDef_My(edSizeAllWhitworth.Text, 50) / PageKoef / KoefAll;
      end;
    end;
  except
    on E: Exception do AddExceptionToLogEx('TF_MasterNewListLite.CheckMapScaleResult', E.Message);
  end;
end;

function TF_MasterNewListLite.GetRuleStep(AOnlyifChecked: Boolean): Double;
var
  KoefAs: double;
begin
  Result := 0;
  try
    KoefAs := 0;

    // МЕТРИЧЕСКАЯ
    if gbRulerModeMetric.Visible then
    begin
      if Not AOnlyifChecked then
        Result := StrToFloatDef_My(edSizeAsMetric.Text, 1);

      // для показа отдельного отрезка на экране
      if rbm1.Checked then
        KoefAs := 1;
      if rbsm1.Checked then
        KoefAs := 100;
      if rbmm1.Checked then
        KoefAs := 1000; //0.1;
      if (rbm1.Checked) Or (rbsm1.Checked) Or (rbmm1.Checked) then
        Result := StrToFloatDef_My(edSizeAsMetric.Text, 1) / KoefAs;
    end
    else
    // ДЮЙМОВАЯ
    begin
      if Not AOnlyifChecked then
        Result := StrToFloatDef_My(edSizeAsWhitworth.Text, 1);

      // для показа отдельного отрезка на экране
      if rbin1.Checked then
        KoefAs := 12;
      if rbft1.Checked then
        KoefAs := 1;
      if (rbin1.Checked) Or (rbft1.Checked) then
        Result := StrToFloatDef_My(edSizeAsWhitworth.Text, 1) / KoefAs;
    end;
  except
    on E: Exception do AddExceptionToLogEx('TF_MasterNewListLite.GetRuleStep', E.Message);
  end;
end;

function TF_MasterNewListLite.GetRuleAllSize(AOnlyifChecked: Boolean): Double;
var
  KoefAll: double;
begin
  Result := 0;
  try
    // ЛИНЕЙКА
    KoefAll := 0;

    // МЕТРИЧЕСКАЯ
    if gbRulerModeMetric.Visible then
    begin
      if Not AOnlyifChecked then
        Result := StrToFloatDef_My(edSizeAllMetric.Text, 1);

      // для отображения общей длинны на странице
      if rbm2.Checked then
        KoefAll := 1;
      if rbsm2.Checked then
        KoefAll := 100;
      if rbmm2.Checked then
        KoefAll := 1000;
      if (rbm2.Checked) Or (rbsm2.Checked) Or (rbmm2.Checked) then
      begin
        Result := StrToFloatDef_My(edSizeAllMetric.Text, 50) / KoefAll;
      end;
    end
    else
    // ДЮЙМОВАЯ
    begin
      if Not AOnlyifChecked then
        Result := StrToFloatDef_My(edSizeAllWhitworth.Text, 1);

      // для отображения общей длинны на странице
      if rbin2.Checked then
        KoefAll := 12;
      if rbft2.Checked then
        KoefAll := 1;
      if (rbin2.Checked) Or (rbft2.Checked) then
      begin
        Result := StrToFloatDef_My(edSizeAllWhitworth.Text, 50) / KoefAll;
      end;
    end;
  except
    on E: Exception do AddExceptionToLogEx('TF_MasterNewListLite.GetRuleAllSize', E.Message);
  end;
end;

procedure TF_MasterNewListLite.rbmm1Click(Sender: TObject);
var
  CheckValue: Double;
begin
  try
    CheckValue := CheckMapScaleResult;
    if CheckValue = FCADParams.CADMapScale then
      edSizeAsMetric.Style.Font.Color := clBlack
    else
      edSizeAsMetric.Style.Font.Color := clBlue;
  except
    on E: Exception do AddExceptionToLogEx('TF_MasterNewListLite.rbmm1Click', E.Message);
  end;
end;

procedure TF_MasterNewListLite.rbsm1Click(Sender: TObject);
var
  CheckValue: Double;
begin
  try
    CheckValue := CheckMapScaleResult;
    if CheckValue = FCADParams.CADMapScale then
      edSizeAsMetric.Style.Font.Color := clBlack
    else
      edSizeAsMetric.Style.Font.Color := clBlue;
  except
    on E: Exception do AddExceptionToLogEx('TF_MasterNewListLite.rbsm1Click', E.Message);
  end;
end;

procedure TF_MasterNewListLite.rbm1Click(Sender: TObject);
var
  CheckValue: Double;
begin
  try
    CheckValue := CheckMapScaleResult;
    if CheckValue = FCADParams.CADMapScale then
      edSizeAsMetric.Style.Font.Color := clBlack
    else
      edSizeAsMetric.Style.Font.Color := clBlue;
  except
    on E: Exception do AddExceptionToLogEx('TF_MasterNewListLite.rbm1Click', E.Message);
  end;
end;

procedure TF_MasterNewListLite.rbmm2Click(Sender: TObject);
var
  CheckValue: Double;
begin
  try
    CheckValue := CheckMapScaleResult;
    if CheckValue = FCADParams.CADMapScale then
      edSizeAllMetric.Style.Font.Color := clBlack
    else
      edSizeAllMetric.Style.Font.Color := clBlue;
  except
    on E: Exception do AddExceptionToLogEx('TF_MasterNewListLite.rbmm2Click', E.Message);
  end;
end;

procedure TF_MasterNewListLite.rbsm2Click(Sender: TObject);
var
  CheckValue: Double;
begin
  try
    CheckValue := CheckMapScaleResult;
    if CheckValue = FCADParams.CADMapScale then
      edSizeAllMetric.Style.Font.Color := clBlack
    else
      edSizeAllMetric.Style.Font.Color := clBlue;
  except
    on E: Exception do AddExceptionToLogEx('TF_MasterNewListLite.rbsm2Click', E.Message);
  end;
end;

procedure TF_MasterNewListLite.rbm2Click(Sender: TObject);
var
  CheckValue: Double;
begin
  try
    CheckValue := CheckMapScaleResult;
    if CheckValue = FCADParams.CADMapScale then
      edSizeAllMetric.Style.Font.Color := clBlack
    else
      edSizeAllMetric.Style.Font.Color := clBlue;
  except
    on E: Exception do AddExceptionToLogEx('TF_MasterNewListLite.rbm2Click', E.Message);
  end;
end;

procedure TF_MasterNewListLite.cbTraceColorPropertiesCloseUp(Sender: TObject);
var
  CheckValue: TColor;
begin
  try
//    CheckValue := cbTraceColor.ColorValue;
//    if CheckValue = FCADParams.CADTraceColor then
//      cbTraceColor.Style.Color := clWhite
//    else
//      cbTraceColor.Style.Color := clBlue;
  except
    on E: Exception do AddExceptionToLogEx('TF_MasterNewListLite.cbTraceColorPropertiesCloseUp', E.Message);
  end;
end;

procedure TF_MasterNewListLite.edSizeAsMetricExit(Sender: TObject);
var
  CheckValue: Double;
begin
  try
    CheckValue := CheckMapScaleResult;
    if CheckValue = FCADParams.CADMapScale then
      edSizeAsMetric.Style.Font.Color := clBlack
    else
      edSizeAsMetric.Style.Font.Color := clBlue;
  except
    on E: Exception do AddExceptionToLogEx('TF_MasterNewListLite.edSizeAsExit', E.Message);
  end;
end;

procedure TF_MasterNewListLite.edSizeAllMetricExit(Sender: TObject);
var
  CheckValue: Double;
begin
  try
    CheckValue := CheckMapScaleResult;
    if CheckValue = FCADParams.CADMapScale then
      edSizeAllMetric.Style.Font.Color := clBlack
    else
      edSizeAllMetric.Style.Font.Color := clBlue;
  except
    on E: Exception do AddExceptionToLogEx('TF_MasterNewListLite.edSizeAllExit', E.Message);
  end;
end;

procedure TF_MasterNewListLite.cbCADCaptions_ShortClick(Sender: TObject);
begin
  try
//    if FCADParams.CADObjectCaptions = st_Short then
//    begin
//      cbCADCaptions_Short.Font.Color := clBlack;
//      cbCADCaptions_Full.Font.Color := clBlack;
//    end
//    else
//    begin
//      cbCADCaptions_Short.Font.Color := clBlue;
//      cbCADCaptions_Full.Font.Color := clBlack;
//    end;
  except
    on E: Exception do AddExceptionToLogEx('TF_MasterNewListLite.cbCADCaptions_ShortClick', E.Message);
  end;
end;

procedure TF_MasterNewListLite.cbCADCaptions_FullClick(Sender: TObject);
begin
  try
//    if FCADParams.CADObjectCaptions = st_Full then
//    begin
//      cbCADCaptions_Short.Font.Color := clBlack;
//      cbCADCaptions_Full.Font.Color := clBlack;
//    end
//    else
//    begin
//      cbCADCaptions_Short.Font.Color := clBlack;
//      cbCADCaptions_Full.Font.Color := clBlue;
//    end;
  except
    on E: Exception do AddExceptionToLogEx('TF_MasterNewListLite.cbCADCaptions_FullClick', E.Message);
  end;
end;

procedure TF_MasterNewListLite.cbCADCaptionsDetailClick(Sender: TObject);
begin
  try
//    if FCADParams.CADLinesCaptions = skDetail then
//    begin
//      cbCADCaptionsDetail.Font.Color := clBlack;
//      cbCADCaptionsSimple.Font.Color := clBlack;
//      cbCADCaptionsExternalSCS.Font.Color := clBlack;
//    end
//    else
//    begin
//      cbCADCaptionsDetail.Font.Color := clBlue;
//      cbCADCaptionsSimple.Font.Color := clBlack;
//      cbCADCaptionsExternalSCS.Font.Color := clBlack;
//    end;
//    cbAutoApplyHeights.Enabled := True;
  except
    on E: Exception do AddExceptionToLogEx('TF_MasterNewListLite.cbCADCaptionsDetailClick', E.Message);
  end;
end;

procedure TF_MasterNewListLite.cbCADCaptionsSimpleClick(Sender: TObject);
begin
  try
//    if FCADParams.CADLinesCaptions = skSimple then
//    begin
//      cbCADCaptionsDetail.Font.Color := clBlack;
//      cbCADCaptionsSimple.Font.Color := clBlack;
//      cbCADCaptionsExternalSCS.Font.Color := clBlack;
//    end
//    else
//    begin
//      cbCADCaptionsDetail.Font.Color := clBlack;
//      cbCADCaptionsSimple.Font.Color := clBlue;
//      cbCADCaptionsExternalSCS.Font.Color := clBlack;
//    end;
//    cbAutoApplyHeights.Enabled := True;
  except
    on E: Exception do AddExceptionToLogEx('TF_MasterNewListLite.cbCADCaptionsSimpleClick', E.Message);
  end;
end;

procedure TF_MasterNewListLite.cbCADNotes_ShortClick(Sender: TObject);
begin
  try
//    if FCADParams.CADObjectNotes = st_Short then
//    begin
//      cbCADNotes_Short.Font.Color := clBlack;
//      cbCADNotes_Full.Font.Color := clBlack;
//    end
//    else
//    begin
//      cbCADNotes_Short.Font.Color := clBlue;
//      cbCADNotes_Full.Font.Color := clBlack;
//    end;
  except
    on E: Exception do AddExceptionToLogEx('TF_MasterNewListLite.cbCADNotes_ShortClick', E.Message);
  end;
end;

procedure TF_MasterNewListLite.cbCADNotes_FullClick(Sender: TObject);
begin
  try
//    if FCADParams.CADObjectNotes = st_Full then
//    begin
//      cbCADNotes_Short.Font.Color := clBlack;
//      cbCADNotes_Full.Font.Color := clBlack;
//    end
//    else
//    begin
//      cbCADNotes_Short.Font.Color := clBlack;
//      cbCADNotes_Full.Font.Color := clBlue;
//    end;
  except
    on E: Exception do AddExceptionToLogEx('TF_MasterNewListLite.cbCADNotes_FullClick', E.Message);
  end;
end;

procedure TF_MasterNewListLite.cbCADNotesDetailClick(Sender: TObject);
begin
  try
//    if FCADParams.CADLinesNotes = skDetail then
//    begin
//      cbCADNotesDetail.Font.Color := clBlack;
//      cbCADNotesSimple.Font.Color := clBlack;
//    end
//    else
//    begin
//      cbCADNotesDetail.Font.Color := clBlue;
//      cbCADNotesSimple.Font.Color := clBlack;
//    end;
  except
    on E: Exception do AddExceptionToLogEx('TF_MasterNewListLite.cbCADNotesDetailClick', E.Message);
  end;
end;

procedure TF_MasterNewListLite.cbCADNotesSimpleClick(Sender: TObject);
begin
  try
//    if FCADParams.CADLinesNotes = skSimple then
//    begin
//      cbCADNotesDetail.Font.Color := clBlack;
//      cbCADNotesSimple.Font.Color := clBlack;
//    end
//    else
//    begin
//      cbCADNotesDetail.Font.Color := clBlack;
//      cbCADNotesSimple.Font.Color := clBlue;
//    end;
  except
    on E: Exception do AddExceptionToLogEx('TF_MasterNewListLite.cbCADNotesSimpleClick', E.Message);
  end;
end;

procedure TF_MasterNewListLite.edNotePrefixExit(Sender: TObject);
var
  CheckValue: string[1];
begin
  try
//    CheckValue := edNotePrefix.Text;
//    if CheckValue = FCADParams.CADNotePrefix then
//      edNotePrefix.Style.Font.Color := clBlack
//    else
//      edNotePrefix.Style.Font.Color := clBlue;
  except
    on E: Exception do AddExceptionToLogEx('TF_MasterNewListLite.edNotePrefixExit', E.Message);
  end;
end;

procedure TF_MasterNewListLite.cbShowLinesLengthClick(Sender: TObject);
begin
  try
//    if not cbShowLinesLength.Enabled then
//    begin
//      if cbShowLinesLength.Checked = FCADParams.CADShowLineObjectLength then
//        cbShowLinesLength.Font.Color := clBlack
//      else
//        cbShowLinesLength.Font.Color := clBlue;
//    end
//    else
//    begin
//      cbShowLinesLength.Font.Color := clBlack;
//    end;
  except
    on E: Exception do AddExceptionToLogEx('TF_MasterNewListLite.cbShowLinesLengthClick', E.Message);
  end;
end;

procedure TF_MasterNewListLite.cbShowLinesNotesClick(Sender: TObject);
begin
  try
//    if cbShowLinesNotes.State <> cbGrayed then
//    begin
//      if cbShowLinesNotes.Checked = FCADParams.CADShowLineObjectNote then
//        cbShowLinesNotes.Font.Color := clBlack
//      else
//        cbShowLinesNotes.Font.Color := clBlue;
//    end
//    else
//    begin
//      cbShowLinesNotes.Font.Color := clBlack;
//    end;
  except
    on E: Exception do AddExceptionToLogEx('TF_MasterNewListLite.cbShowLinesNotesClick', E.Message);
  end;
end;

procedure TF_MasterNewListLite.cbShowConnectorsCaptionsClick(Sender: TObject);
begin
  try
//    if cbShowConnectorsCaptions.State <> cbGrayed then
//    begin
//      if cbShowConnectorsCaptions.Checked = FCADParams.CADShowConnObjectCaption then
//        cbShowConnectorsCaptions.Font.Color := clBlack
//      else
//        cbShowConnectorsCaptions.Font.Color := clBlue;
//    end
//    else
//    begin
//      cbShowConnectorsCaptions.Font.Color := clBlack;
//    end;
  except
    on E: Exception do AddExceptionToLogEx('TF_MasterNewListLite.cbShowConnectorsCaptionsClick', E.Message);
  end;
end;

procedure TF_MasterNewListLite.cbShowConnectorsNotesClick(Sender: TObject);
begin
  try
//    if cbShowConnectorsNotes.State <> cbGrayed then
//    begin
//      if cbShowConnectorsNotes.Checked = FCADParams.CADShowConnObjectNote then
//        cbShowConnectorsNotes.Font.Color := clBlack
//      else
//        cbShowConnectorsNotes.Font.Color := clBlue;
//    end
//    else
//    begin
//      cbShowConnectorsNotes.Font.Color := clBlack;
//    end;
  except
    on E: Exception do AddExceptionToLogEx('TF_MasterNewListLite.cbShowConnectorsNotesClick', E.Message);
  end;
end;

procedure TF_MasterNewListLite.cbShowRaiseClick(Sender: TObject);
begin
  try
//    if cbShowRaise.Checked = FCADParams.CADShowRaise then
//      cbShowRaise.Font.Color := clBlack
//    else
//      cbShowRaise.Font.Color := clBlue;
  except
    on E: Exception do AddExceptionToLogEx('TF_MasterNewListLite.cbShowRaiseClick', E.Message);
  end;
end;

procedure TF_MasterNewListLite.cbPutCableOnTraceClick(Sender: TObject);
begin
  try
//    if cbPutCableOnTrace.Checked = FCADParams.CADPutCableInTrace then
//      cbPutCableOnTrace.Font.Color := clBlack
//    else
//      cbPutCableOnTrace.Font.Color := clBlue;
  except
    on E: Exception do AddExceptionToLogEx('TF_MasterNewListLite.cbPutCableOnTraceClick', E.Message);
  end;
end;

procedure TF_MasterNewListLite.cbApplyForAllSCSObjectsClick(Sender: TObject);
begin
  try
//    if cbApplyForAllSCSObjects.Checked then
//      cbApplyForSelectedOnly.Enabled := True
//    else
//      cbApplyForSelectedOnly.Enabled := False;
  except
    on E: Exception do AddExceptionToLogEx('TF_MasterNewListLite.cbApplyForAllSCSObjectsClick', E.Message);
  end;
end;

procedure TF_MasterNewListLite.cbGroupObjectsByTypePropertiesChange(
  Sender: TObject);
begin
  //
end;

procedure TF_MasterNewListLite.cbReindexComponentsClick(Sender: TObject);
begin
//  cbReindexInChangedTypes.Enabled := cbReindexComponents.Checked;
end;

procedure TF_MasterNewListLite.cbCADCaptionsExternalSCSClick(Sender: TObject);
begin
  try
//    if FCADParams.CADLinesCaptions = skExternalSCS then
//    begin
//      cbCADCaptionsDetail.Font.Color := clBlack;
//      cbCADCaptionsSimple.Font.Color := clBlack;
//      cbCADCaptionsExternalSCS.Font.Color := clBlack;
//    end
//    else
//    begin
//      cbCADCaptionsDetail.Font.Color := clBlack;
//      cbCADCaptionsSimple.Font.Color := clBlack;
//      cbCADCaptionsExternalSCS.Font.Color := clBlue;
//    end;
//    cbAutoApplyHeights.Enabled := False;
  except
    on E: Exception do AddExceptionToLogEx('TF_MasterNewListLite.cbCADCaptionsExternalSCSClick', E.Message);
  end;
end;

procedure TF_MasterNewListLite.cbLinesCaptionsColorPropertiesCloseUp(Sender: TObject);
var
  CheckValue: TColor;
begin
  try
//    CheckValue := cbLinesCaptionsColor.ColorValue;
//    if CheckValue = FCADParams.CADLinesCaptionsColor then
//      cbLinesCaptionsColor.Style.Color := clWhite
//    else
//      cbLinesCaptionsColor.Style.Color := clBlue;
  except
    on E: Exception do AddExceptionToLogEx('TF_MasterNewListLite.cbLinesCaptionsColorPropertiesCloseUp', E.Message);
  end;
end;

procedure TF_MasterNewListLite.cbConnectorsCaptionsColorPropertiesCloseUp(Sender: TObject);
var
  CheckValue: TColor;
begin
  try
//    CheckValue := cbConnectorsCaptionsColor.ColorValue;
//    if CheckValue = FCADParams.CADConnectorsCaptionsColor then
//      cbConnectorsCaptionsColor.Style.Color := clWhite
//    else
//      cbConnectorsCaptionsColor.Style.Color := clBlue;
  except
    on E: Exception do AddExceptionToLogEx('TF_MasterNewListLite.cbConnectorsCaptionsColorPropertiesCloseUp', E.Message);
  end;
end;

procedure TF_MasterNewListLite.cbLinesNotesColorPropertiesCloseUp(Sender: TObject);
var
  CheckValue: TColor;
begin
  try
//    CheckValue := cbLinesNotesColor.ColorValue;
//    if CheckValue = FCADParams.CADLinesNotesColor then
//      cbLinesNotesColor.Style.Color := clWhite
//    else
//      cbLinesNotesColor.Style.Color := clBlue;
  except
    on E: Exception do AddExceptionToLogEx('TF_MasterNewListLite.cbLinesNotesColorPropertiesCloseUp', E.Message);
  end;
end;

procedure TF_MasterNewListLite.cbConnectorsNotesColorPropertiesCloseUp(Sender: TObject);
var
  CheckValue: TColor;
begin
  try
//    CheckValue := cbConnectorsNotesColor.ColorValue;
//    if CheckValue = FCADParams.CADConnectorsNotesColor then
//      cbConnectorsNotesColor.Style.Color := clWhite
//    else
//      cbConnectorsNotesColor.Style.Color := clBlue;
  except
    on E: Exception do AddExceptionToLogEx('TF_MasterNewListLite.cbConnectorsNotesColorPropertiesCloseUp', E.Message);
  end;
end;

procedure TF_MasterNewListLite.cbLinesNotesFontSizeCloseUp(Sender: TObject);
var
  CheckValue: Integer;
begin
  try
//    CheckValue := StrToInt(cbLinesNotesFontSize.Text);
//    if CheckValue = FCADParams.CADLinesNotesFontSize then
//      cbLinesNotesFontSize.Font.Color := clBlack
//    else
//      cbLinesNotesFontSize.Font.Color := clBlue;
  except
    on E: Exception do AddExceptionToLogEx('TF_MasterNewListLite.cbLinesNotesFontSizeCloseUp', E.Message);
  end;
end;

procedure TF_MasterNewListLite.cbConnectorsNotesFontSizeCloseUp(Sender: TObject);
var
  CheckValue: Integer;
begin
  try
//    CheckValue := StrToInt(cbConnectorsNotesFontSize.Text);
//    if CheckValue = FCADParams.CADConnectorsNotesFontSize then
//      cbConnectorsNotesFontSize.Font.Color := clBlack
//    else
//      cbConnectorsNotesFontSize.Font.Color := clBlue;
  except
    on E: Exception do AddExceptionToLogEx('TF_MasterNewListLite.cbConnectorsNotesFontSizeCloseUp', E.Message);
  end;
end;

procedure TF_MasterNewListLite.cbLinesCaptionsFontSizeCloseUp(Sender: TObject);
var
  CheckValue: Integer;
begin
  try
//    CheckValue := StrToInt(cbLinesCaptionsFontSize.Text);
//    if CheckValue = FCADParams.CADLinesCaptionsFontSize then
//      cbLinesCaptionsFontSize.Font.Color := clBlack
//    else
//      cbLinesCaptionsFontSize.Font.Color := clBlue;
  except
    on E: Exception do AddExceptionToLogEx('TF_MasterNewListLite.cbLinesCaptionsFontSizeCloseUp', E.Message);
  end;
end;

procedure TF_MasterNewListLite.cbConnectorsCaptionsFontSizeCloseUp(Sender: TObject);
var
  CheckValue: Integer;
begin
  try
//    CheckValue := StrToInt(cbConnectorsCaptionsFontSize.Text);
//    if CheckValue = FCADParams.CADConnectorsCaptionsFontSize then
//      cbConnectorsCaptionsFontSize.Font.Color := clBlack
//    else
//      cbConnectorsCaptionsFontSize.Font.Color := clBlue;
  except
    on E: Exception do AddExceptionToLogEx('TF_MasterNewListLite.cbConnectorsCaptionsFontSizeCloseUp', E.Message);
  end;
end;

procedure TF_MasterNewListLite.cbLinesCaptionsFontSizeKeyPress(Sender: TObject; var Key: Char);
begin
  if (Key < '0') or (Key > '9') then
    Key := #0;
end;

procedure TF_MasterNewListLite.cbConnectorsCaptionsFontSizeKeyPress(
  Sender: TObject; var Key: Char);
begin
  if (Key < '0') or (Key > '9') then
    Key := #0;
end;

procedure TF_MasterNewListLite.cbLinesNotesFontSizeKeyPress(Sender: TObject;
  var Key: Char);
begin
  if (Key < '0') or (Key > '9') then
    Key := #0;
end;

procedure TF_MasterNewListLite.cbConnectorsNotesFontSizeKeyPress(
  Sender: TObject; var Key: Char);
begin
  if (Key < '0') or (Key > '9') then
    Key := #0;
end;

procedure TF_MasterNewListLite.cbLinesNotesFontSizeExit(Sender: TObject);
begin
  try
//    if cbLinesNotesFontSize.Text = '' then
//      cbLinesNotesFontSize.Text := IntToStr(FCADParams.CADLinesNotesFontSize);
  except
    on E: Exception do AddExceptionToLogEx('TF_MasterNewListLite.cbLinesNotesFontSizeExit', E.Message);
  end;
end;

procedure TF_MasterNewListLite.cbConnectorsNotesFontSizeExit(Sender: TObject);
begin
  try
//    if cbConnectorsNotesFontSize.Text = '' then
//      cbConnectorsNotesFontSize.Text := IntToStr(FCADParams.CADConnectorsNotesFontSize);
  except
    on E: Exception do AddExceptionToLogEx('TF_MasterNewListLite.cbConnectorsNotesFontSizeExit', E.Message);
  end;
end;

procedure TF_MasterNewListLite.cbLinesCaptionsFontSizeExit(Sender: TObject);
begin
  try
//    if cbLinesCaptionsFontSize.Text = '' then
//      cbLinesCaptionsFontSize.Text := IntToStr(FCADParams.CADLinesCaptionsFontSize);
  except
    on E: Exception do AddExceptionToLogEx('TF_MasterNewListLite.cbLinesCaptionsFontSizeExit', E.Message);
  end;
end;

procedure TF_MasterNewListLite.cbConnectorsCaptionsFontSizeExit(Sender: TObject);
begin
  try
//    if cbConnectorsCaptionsFontSize.Text = '' then
//      cbConnectorsCaptionsFontSize.Text := IntToStr(FCADParams.CADConnectorsCaptionsFontSize);
  except
    on E: Exception do AddExceptionToLogEx('TF_MasterNewListLite.cbConnectorsCaptionsFontSizeExit', E.Message);
  end;
end;

procedure TF_MasterNewListLite.cbLinesCaptionsFontBoldClick(Sender: TObject);
begin
  try
//    if cbLinesCaptionsFontBold.Checked = FCADParams.CADLinesCaptionsFontBold then
//      cbLinesCaptionsFontBold.Font.Color := clBlack
//    else
//      cbLinesCaptionsFontBold.Font.Color := clBlue;
  except
    on E: Exception do AddExceptionToLogEx('TF_MasterNewListLite.cbLinesCaptionsFontBoldClick', E.Message);
  end;
end;

procedure TF_MasterNewListLite.cbCrossATSFontBoldClick(Sender: TObject);
begin
  try
//    if cbCrossATSFontBold.Checked = FCADParams.CADCrossATSFontBold then
//      cbCrossATSFontBold.Font.Color := clBlack
//    else
//      cbCrossATSFontBold.Font.Color := clBlue;
  except
    on E: Exception do AddExceptionToLogEx('TF_MasterNewListLite.cbCrossATSFontBoldClick', E.Message);
  end;
end;

procedure TF_MasterNewListLite.cbDistribCabFontBoldClick(Sender: TObject);
begin
  try
//    if cbDistribCabFontBold.Checked = FCADParams.CADDistribCabFontBold then
//      cbDistribCabFontBold.Font.Color := clBlack
//    else
//      cbDistribCabFontBold.Font.Color := clBlue;
  except
    on E: Exception do AddExceptionToLogEx('TF_MasterNewListLite.cbDistribCabFontBoldClick', E.Message);
  end;
end;

procedure TF_MasterNewListLite.cbCrossATSFontSizeKeyPress(Sender: TObject;
  var Key: Char);
begin
  if (Key < '0') or (Key > '9') then
    Key := #0;
end;

procedure TF_MasterNewListLite.cbDistribCabFontSizeKeyPress(Sender: TObject;
  var Key: Char);
begin
  if (Key < '0') or (Key > '9') then
    Key := #0;
end;

procedure TF_MasterNewListLite.cbCrossATSFontSizeExit(Sender: TObject);
begin
  try
//    if cbCrossATSFontSize.Text = '' then
//      cbCrossATSFontSize.Text := IntToStr(FCADParams.CADCrossATSFontSize);
  except
    on E: Exception do AddExceptionToLogEx('TF_MasterNewListLite.cbCrossATSFontSizeExit', E.Message);
  end;
end;

procedure TF_MasterNewListLite.cbDistribCabFontSizeExit(Sender: TObject);
begin
  try
//    if cbDistribCabFontSize.Text = '' then
//      cbDistribCabFontSize.Text := IntToStr(FCADParams.CADDistribCabFontSize);
  except
    on E: Exception do AddExceptionToLogEx('TF_MasterNewListLite.cbDistribCabFontSizeExit', E.Message);
  end;
end;

procedure TF_MasterNewListLite.cbCrossATSFontSizeCloseUp(Sender: TObject);
var
  CheckValue: Integer;
begin
  try
//    CheckValue := StrToInt(cbCrossATSFontSize.Text);
//    if CheckValue = FCADParams.CADCrossATSFontSize then
//      cbCrossATSFontSize.Font.Color := clBlack
//    else
//      cbCrossATSFontSize.Font.Color := clBlue;
  except
    on E: Exception do AddExceptionToLogEx('TF_MasterNewListLite.cbCrossATSFontSizeCloseUp', E.Message);
  end;
end;

procedure TF_MasterNewListLite.cbDistribCabFontSizeCloseUp(Sender: TObject);
var
  CheckValue: Integer;
begin
  try
//    CheckValue := StrToInt(cbDistribCabFontSize.Text);
//    if CheckValue = FCADParams.CADDistribCabFontSize then
//      cbDistribCabFontSize.Font.Color := clBlack
//    else
//      cbDistribCabFontSize.Font.Color := clBlue;
  except
    on E: Exception do AddExceptionToLogEx('TF_MasterNewListLite.cbDistribCabFontSizeCloseUp', E.Message);
  end;
end;

procedure TF_MasterNewListLite.cbBlackPrintClick(Sender: TObject);
begin
  try
//    if FCADParams.CADPrintType = pt_Black then
//    begin
//      cbBlackPrint.Font.Color := clBlack;
//      cbColorPrint.Font.Color := clBlack;
//    end
//    else
//    begin
//      cbBlackPrint.Font.Color := clBlue;
//      cbColorPrint.Font.Color := clBlack;
//    end;
  except
    on E: Exception do AddExceptionToLogEx('TF_MasterNewListLite.cbBlackPrintClick', E.Message);
  end;
end;

procedure TF_MasterNewListLite.cbColorPrintClick(Sender: TObject);
begin
  try
//    if FCADParams.CADPrintType = pt_Color then
//    begin
//      cbBlackPrint.Font.Color := clBlack;
//      cbColorPrint.Font.Color := clBlack;
//    end
//    else
//    begin
//      cbBlackPrint.Font.Color := clBlack;
//      cbColorPrint.Font.Color := clBlue;
//    end;
  except
    on E: Exception do AddExceptionToLogEx('TF_MasterNewListLite.cbColorPrintClick', E.Message);
  end;
end;

procedure TF_MasterNewListLite.rbInternalSCSClick(Sender: TObject);
begin
  try
//    bOK.Enabled := True;
    {///
    rbInternalSCSP.Checked := rbInternalSCS.Checked;
    if FCADParams.SCSType = st_Internal then
    begin
      rbInternalSCS.Font.Color := clBlack;
      rbExternalSCS.Font.Color := clBlack;
    end
    else
    begin
      rbInternalSCS.Font.Color := clBlue;
      rbExternalSCS.Font.Color := clBlack;
    end;

    cbCADCaptionsDetail.Enabled := True;
    cbCADCaptionsSimple.Enabled := True;
    cbCADCaptionsExternalSCS.Enabled := False;

    //
    if FCADParams.CADLinesCaptions = skSimple then
    begin
      cbCADCaptionsSimple.Checked := True;
      cbCADCaptionsDetail.Font.Color := clBlack;
      cbCADCaptionsSimple.Font.Color := clBlack;
      cbCADCaptionsExternalSCS.Font.Color := clBlack;
    end
    else
    begin
      cbCADCaptionsDetail.Checked := True;    
      cbCADCaptionsDetail.Font.Color := clBlack;
      cbCADCaptionsSimple.Font.Color := clBlue;
      cbCADCaptionsExternalSCS.Font.Color := clBlack;
    end;

    rbLineFloorClick(Sender);
    edLineFloor.Text := FormatFloat(ffMask, MetreToUOM(FListParams.Settings.HeightCorob));
    edLineFloorExit(Sender);
    rbConnFloorClick(Sender);
    edConnFloor.Text := FormatFloat(ffMask, MetreToUOM(FListParams.Settings.HeightSocket));
    edConnFloorExit(Sender);
    // разблочить все что касается высот
    rbConnFloor.Enabled := True;
    edConnFloor.Enabled := True;
    rbLineCeiling.Enabled := True;
    rbLineConnObjects.Enabled := True;
    rbLineFalseFloor.Enabled := True;
    rbLineFloor.Enabled := True;
    if rbLineCeiling.Checked then
    begin
      edLineCeiling.Enabled := True;
      edLineConnObjects.Enabled := False;
      edLineFalseFloor.Enabled := False;
      edLineFloor.Enabled := False;
    end;
    if rbLineConnObjects.Checked then
    begin
      edLineConnObjects.Enabled := True;
      edLineCeiling.Enabled := False;
      edLineFalseFloor.Enabled := False;
      edLineFloor.Enabled := False;
    end;
    if rbLineFalseFloor.Checked then
    begin
      edLineFalseFloor.Enabled := True;
      edLineCeiling.Enabled := False;
      edLineConnObjects.Enabled := False;
      edLineFloor.Enabled := False;
    end;
    if rbLineFloor.Checked then
    begin
      edLineFloor.Enabled := True;
      edLineCeiling.Enabled := False;
      edLineConnObjects.Enabled := False;
      edLineFalseFloor.Enabled := False;
    end;

    cbAutoApplyHeights.Enabled := True;

    gbGridStep.Caption := cMasterNewList_Mes12;
    edStepGrid.Text := '1';
    edStepGrid.Properties.EditMask := '[0-4],[1-9]|[1-5],[0]';
    ///}
  except
    on E: Exception do AddExceptionToLogEx('TF_MasterNewListLite.rbInternalSCSClick', E.Message);
  end;
end;

procedure TF_MasterNewListLite.rbExternalSCSClick(Sender: TObject);
var
  GridStepValue: Double;
begin
  try
//    bOK.Enabled := True;
    {///
    rbExternalSCSP.Checked := rbExternalSCS.Checked;
    if FCADParams.SCSType = st_External then
    begin
      rbInternalSCS.Font.Color := clBlack;
      rbExternalSCS.Font.Color := clBlack;
    end
    else
    begin
      rbInternalSCS.Font.Color := clBlack;
      rbExternalSCS.Font.Color := clBlue;
    end;

    cbCADCaptionsDetail.Enabled := False;
    cbCADCaptionsSimple.Enabled := False;
    cbCADCaptionsExternalSCS.Enabled := True;
    cbCADCaptionsExternalSCS.Checked := True;
    cbCADCaptionsExternalSCSClick(Sender);

    GridStepValue := StrToFloat_My(edStepGrid.Text);
    if GridStepValue > 1 then
      edStepGrid.Text := '1';

    //
    if FCADParams.CADLinesCaptions = skExternalSCS then
    begin
      cbCADCaptionsDetail.Font.Color := clBlack;
      cbCADCaptionsSimple.Font.Color := clBlack;
      cbCADCaptionsExternalSCS.Font.Color := clBlack;
    end
    else
    begin
      cbCADCaptionsDetail.Font.Color := clBlack;
      cbCADCaptionsSimple.Font.Color := clBlack;
      cbCADCaptionsExternalSCS.Font.Color := clBlue;
    end;

    rbLineFloorClick(Sender);
    edLineFloor.Text := '0';
    edLineFloorExit(Sender);
    rbConnFloorClick(Sender);
    edConnFloor.Text := '0';
    edConnFloorExit(Sender);
    // заблочить все что касается высот
    rbConnFloor.Enabled := False;
    edConnFloor.Enabled := False;

    rbLineCeiling.Enabled := False;
    rbLineConnObjects.Enabled := False;
    rbLineFalseFloor.Enabled := False;
    rbLineFloor.Enabled := False;
    edLineCeiling.Enabled := False;
    edLineConnObjects.Enabled := False;
    edLineFalseFloor.Enabled := False;
    edLineFloor.Enabled := False;

    cbAutoApplyHeights.Enabled := False;

    gbGridStep.Caption := cMasterNewList_Mes13;
    edStepGrid.Text := '1';
    edStepGrid.Properties.EditMask := '[0],[1-9]|[1],[0]';
    ///}
  except
    on E: Exception do AddExceptionToLogEx('TF_MasterNewListLite.rbExternalSCSClick', E.Message);
  end;
end;

procedure TF_MasterNewListLite.rbInternalSCSPClick(Sender: TObject);
begin
  try
    //rbInternalSCS.Checked := rbInternalSCSP.Checked;
    //rbInternalSCSClick(Sender);

    //SetControlsByProjType; //#From Oleg#
  except
    on E: Exception do AddExceptionToLogEx('TF_MasterNewListLite.rbInternalSCSPClick', E.Message);
  end;
end;

procedure TF_MasterNewListLite.rbExternalSCSPClick(Sender: TObject);
begin
  try
    //rbExternalSCS.Checked := rbExternalSCSP.Checked;
    //rbExternalSCSClick(Sender);

    //SetControlsByProjType; //#From Oleg#
  except
    on E: Exception do AddExceptionToLogEx('TF_MasterNewListLite.rbExternalSCSPClick', E.Message);
  end;
end;

function TF_MasterNewListLite.CanShowlbSettings: Boolean;
begin
  Result := true;
  if FItemType = itList then
    if FListParams.Settings.ListType <> lt_Normal then
      Result := false;
end;

procedure TF_MasterNewListLite.DefineStyleRBNewTracesLengthType(Sender: TObject);
begin
  SetRadioGrpBoxStyleByIntVal(FArrNewTracesLengthRB, FArrNewTracesLengthVal, FCADParams.CADNewTraceLengthType);
end;

function TF_MasterNewListLite.EnableLoadDefSettings: Boolean;
begin
  Result := false;
  try
    if FItemType = itProject then
      Result := FileExists(GetPathToDefProjSettings) or FileExists(GetPathToDefListSettings);
    if FItemType = itList then
      Result := FileExists(GetPathToDefListSettings);
  except
    on E: Exception do AddExceptionToLogEx('TF_MasterNewListLite.EnableLoadDefSettings', E.Message);
  end;
end;

procedure TF_MasterNewListLite.SetControlsByComponMarkMode;
begin
//  gbMarkTIAEIA606AParams.Enabled := rbMarkByTIAEIA606A.Checked;
end;

procedure TF_MasterNewListLite.SetControlsByPointComponIndexingMode;
var
  PointComonIndexingMode: TPointComonIndexingMode;
begin
  //lbWarningToReindexPointCompons.Visible := false;
  FReindexPointCompons := false;
  if FMakeEditMode = meEdit then
  begin
    PointComonIndexingMode := GetPointComonIndexingModeFromForm;
    if FProjectParams.Setting.PointComonIndexingMode <> PointComonIndexingMode then
      FReindexPointCompons := true;
      //lbWarningToReindexPointCompons.Visible := true;
  end;
end;

procedure TF_MasterNewListLite.SetControlsByProjType;
begin
//  cbRemarkAllCompons.Visible := FMakeEditMode = meEdit;
//  if rbInternalSCS.Checked then
//    gbMarkMode.Enabled := true
//  else
//  if rbExternalSCS.Checked then
//  begin
//    rbMarkByTemplate.Checked := true;
//    gbMarkMode.Enabled := false;
//  end;
end;

procedure TF_MasterNewListLite.SetControlsByRoomNameShortSrcType;
begin
//  edRoomNameShortDefault.Enabled := rbRoomNameShortFromDefStr.Checked;
end;

procedure TF_MasterNewListLite.SetEditsToZero;
begin
  edRoomHeight.Text := IntToStr(0);
  edFalseFloorHeight.Text := IntToStr(0);
  edConnFloor.Text := IntToStr(0);
  edLineFloor.Text := IntToStr(0);
end;

procedure TF_MasterNewListLite.lbSaveDefSettingsClick(Sender: TObject);
var
  NewDefProjParams: TProjectParams;
  NewDefListParams: TListParams;
  FileStream: TFileStream;
begin
  try
//    if FItemType = itProject then
//    begin
//      NewDefProjParams := GetProjectParamsFromForm(false);
//      FileStream := TFileStream.Create(GetPathToDefProjSettings, fmCreate);
//     try
//        FileStream.WriteBuffer(NewDefProjParams.Setting, SizeOf(NewDefProjParams.Setting));
//      finally
//        FileStream.Free;
//      end;
//    end;

//    if (FItemType = itProject) or (FItemType = itList) then
//    begin
//      NewDefListParams := GetListParamsFromForm(false);
//     FileStream := TFileStream.Create(GetPathToDefListSettings, fmCreate);
//      try
//        FileStream.WriteBuffer(NewDefListParams.Settings, SizeOf(NewDefListParams.Settings));
//      finally
//        FileStream.Free;
//      end;
//      lbLoadDefSettings.Enabled := FileExists(GetPathToDefListSettings);
//    end;
  except
    on E: Exception do AddExceptionToLogEx('TF_MasterNewListLite.lbSaveDefSettingsClick', E.Message);
  end;
end;

procedure TF_MasterNewListLite.lbLoadDefSettingsClick(Sender: TObject);
var
  OldDefProjParams: TProjectParams;
  OldDefListParams: TListParams;
begin
  try
//    if (FItemType = itProject) or (FItemType = itList) then
//    begin
//      if FileExists(GetPathToDefListSettings) then
//        DeleteFile(GetPathToDefListSettings);
//    end;

//    if FItemType = itProject then
//    begin
//      if FileExists(GetPathToDefProjSettings) then
//        DeleteFile(GetPathToDefProjSettings);
//    end;

//    lbLoadDefSettings.Enabled := EnableLoadDefSettings;
  except
    on E: Exception do AddExceptionToLogEx('TF_MasterNewListLite.lbLoadDefSettingsClick', E.Message);
  end;
end;

procedure TF_MasterNewListLite.lbOtherComponIndexingParamsClick(Sender: TObject);
begin
  try
//    GlobalPageControl.ActivePage := TabListProperties;
//    ListPageControl.ActivePage := tsListSpravochniki;
  except
    on E: Exception do AddExceptionToLogEx('TF_MasterNewListLite.lbOtherComponIndexingParamsClick', E.Message);
  end;
end;

procedure TF_MasterNewListLite.edTraceStepRotateExit(Sender: TObject);
var
  CheckValue: Integer;
begin
  try
//    if edTraceStepRotate.Text = '' then
//      edTraceStepRotate.Text := '5';
//    CheckValue := StrToInt(edTraceStepRotate.Text);
//    if CheckValue = FCADParams.CADTraceStepRotate then
//      edTraceStepRotate.Style.Font.Color := clBlack
//    else
//      edTraceStepRotate.Style.Font.Color := clBlue;
  except
    on E: Exception do AddExceptionToLogEx('TF_MasterNewListLite.edTraceStepRotateExit', E.Message);
  end;
end;

procedure TF_MasterNewListLite.edTraceStepRotatePropertiesChange(Sender: TObject);
var
  CheckValue: Integer;
begin
  try
//    if edTraceStepRotate.Text <> '' then
//    begin
//      CheckValue := StrToInt(edTraceStepRotate.Text);
//      if CheckValue = 0 then
//        edTraceStepRotate.Text := '1';
//      if CheckValue > 360 then
//        edTraceStepRotate.Text := '360';
//    end;
  except
    on E: Exception do AddExceptionToLogEx('TF_MasterNewListLite.edTraceStepRotatePropertiesChange', E.Message);
  end;
end;

procedure TF_MasterNewListLite.cbAutoCadMouseClick(Sender: TObject);
begin
  try
//    if cbAutoCadMouse.Checked = FCADParams.AutoCadMouse then
//      cbAutoCadMouse.Font.Color := clBlack
//    else
//      cbAutoCadMouse.Font.Color := clBlue;
  except
    on E: Exception do AddExceptionToLogEx('TF_MasterNewListLite.cbAutoCadMouseClick', E.Message);
  end;
end;

procedure TF_MasterNewListLite.cbScaleByCursorClick(Sender: TObject);
begin
  try
//    if cbScaleByCursor.Checked = FCADParams.ScaleByCursor then
//      cbScaleByCursor.Font.Color := clBlack
//    else
//      cbScaleByCursor.Font.Color := clBlue;
  except
    on E: Exception do AddExceptionToLogEx('TF_MasterNewListLite.cbScaleByCursorClick', E.Message);
  end;
end;

procedure TF_MasterNewListLite.cbAutoPosTraceBetweenRMClick(Sender: TObject);
begin
  try
//    if cbAutoPosTraceBetweenRM.Checked = FCADParams.AutoPosTraceBetweenRM then
//      cbAutoPosTraceBetweenRM.Font.Color := clBlack
//    else
//      cbAutoPosTraceBetweenRM.Font.Color := clBlue;
  except
    on E: Exception do AddExceptionToLogEx('TF_MasterNewListLite.cbAutoPosTraceBetweenRMClick', E.Message);
  end;
end;

procedure TF_MasterNewListLite.edListCountXPropertiesChange(Sender: TObject);
var
  CheckValue: Integer;
  CheckPageSizeIndex: Integer;
  CheckListCountX: Integer;
  CheckListCountY: Integer;
  CheckPageOrient: TPageOrient;
begin
  try
    if (edListCountX.Text = '') or (edListCountX.Text = '0') then
      edListCountX.Value := 1;
    SetPageParamsOnChange;
    CheckValue := StrToInt(edListCountX.Text);
    if CheckValue = FCADParams.CADListCountX then
      edListCountX.Style.Font.Color := clBlack
    else
      edListCountX.Style.Font.Color := clBlue;
    if cbPageSize.ItemIndex <> 11 then
      SetMaket;
  except
    on E: Exception do AddExceptionToLogEx('TF_MasterNewListLite.edListCountXPropertiesChange', E.Message);
  end;
end;

procedure TF_MasterNewListLite.edListCountYPropertiesChange(Sender: TObject);
var
  CheckValue: Integer;
  CheckPageSizeIndex: Integer;
  CheckListCountX: Integer;
  CheckListCountY: Integer;
  CheckPageOrient: TPageOrient; 
begin
  try
    if (edListCountY.Text = '') or (edListCountY.Text = '0') then
      edListCountY.Value := 1;
    SetPageParamsOnChange;
    CheckValue := StrToInt(edListCountY.Text);
    if CheckValue = FCADParams.CADListCountY then
      edListCountY.Style.Font.Color := clBlack
    else
      edListCountY.Style.Font.Color := clBlue;
    if cbPageSize.ItemIndex <> 11 then
      SetMaket;
  except
    on E: Exception do AddExceptionToLogEx('TF_MasterNewListLite.edListCountYPropertiesChange', E.Message);
  end;
end;

procedure TF_MasterNewListLite.cbShowMainStampClick(Sender: TObject);
begin
  try
    if cbShowMainStamp.Checked = FCADParams.CADShowMainStamp then
      cbShowMainStamp.Font.Color := clBlack
    else
      cbShowMainStamp.Font.Color := clBlue;
    SetMaket;      
  except
    on E: Exception do AddExceptionToLogEx('TF_MasterNewListLite.cbShowMainStampClick', E.Message);
  end;
end;

procedure TF_MasterNewListLite.cbShowUpperStampClick(Sender: TObject);
begin
  try
    if cbShowUpperStamp.Checked = FCADParams.CADShowUpperStamp then
      cbShowUpperStamp.Font.Color := clBlack
    else
      cbShowUpperStamp.Font.Color := clBlue;
    SetMaket;      
  except
    on E: Exception do AddExceptionToLogEx('TF_MasterNewListLite.cbShowUpperStampClick', E.Message);
  end;
end;

procedure TF_MasterNewListLite.cbShowSideStampClick(Sender: TObject);
begin
  try
    if cbShowSideStamp.Checked = FCADParams.CADShowSideStamp then
      cbShowSideStamp.Font.Color := clBlack
    else
      cbShowSideStamp.Font.Color := clBlue;
    SetMaket;      
  except
    on E: Exception do AddExceptionToLogEx('TF_MasterNewListLite.cbShowSideStampClick', E.Message);
  end;
end;

procedure TF_MasterNewListLite.lbTracingParamsClick(Sender: TObject);
begin
  ChoiceAutoTraceConnectOrder(@FProjectParams.Setting, false);
end;

procedure TF_MasterNewListLite.lbSaveLoadSettingsClick(Sender: TObject);
var
  CursorPos: TPoint;
begin
//  GetCursorPos(CursorPos);
//  pmSaveLoadSettings.Popup(CursorPos.X, CursorPos.Y);
end;

procedure TF_MasterNewListLite.pmiSaveSettingsToFileClick(Sender: TObject);
var
  SaveDialog: TSaveDialog;
  StreamList: TStreamList;

  ProjSettingsStream: TMemoryStream;
  ListSettingsStream: TMemoryStream;
  OldStream: TStream;

  CurrProjParams: TProjectParams;
  CurrListParams: TListParams;
  IndexOfListSettings: Integer;
begin
  {///
  SaveDialog := TSaveDialog.Create(Self);
  SaveDialog.Title := cMasterNewList_Mes10_1;
  SaveDialog.InitialDir := ExtractSaveSettingsDir;
  SaveDialog.DefaultExt := '*.'+enSCSProjSettings;
  SaveDialog.FileName := '';
  SaveDialog.Filter := GetDialogFilter(exdSCSProjSettings, enSCSProjSettings);
  SaveDialog.Options := SaveDialog.Options - [ofNoChangeDir];
  if FItemType = itProject then
    SaveDialog.Options := SaveDialog.Options + [ofOverwritePrompt];

  if SaveDialog.Execute then
  begin
    case FItemType of
      itProject:
        begin
          StreamList := TStreamList.Create(fcSCSProjSettings, true);

          CurrProjParams := GetCurrProjectParams;
          CurrListParams := GetListParamsFromForm(false);

          ProjSettingsStream := TMemoryStream.Create;
          ProjSettingsStream.WriteBuffer(CurrProjParams.Setting, SizeOf(CurrProjParams.Setting));
          ProjSettingsStream.Position := 0;

          ListSettingsStream := TMemoryStream.Create;
          ListSettingsStream.WriteBuffer(CurrListParams.Settings, SizeOf(CurrListParams.Settings));
          ListSettingsStream.Position := 0;

          StreamList.Add(ProjSettingsStream, fscSCSProjSettingsProj);
          StreamList.Add(ListSettingsStream, fscSCSProjSettingsList);

          StreamList.SaveToFile(SaveDialog.FileName);

          FreeAndNil(StreamList);
        end;
      itList:
        if Not FileExists(SaveDialog.FileName) then
          MessageModal(cFileOf+' '+SaveDialog.FileName+' '+cNoFound+'.', ApplicationName, MB_OK or MB_ICONINFORMATION)
        else
        begin
          StreamList := TStreamList.Create(fcSCSProjSettings, true);

          if StreamList.LoadFromFile(SaveDialog.FileName) then
          begin
            if StreamList.FileCode <> fcSCSProjSettings then
              MessageModal(cFileOf+' '+SaveDialog.FileName+' '+cFileIsNotFileOfProjectSettings+'.',
                ApplicationName, MB_OK or MB_ICONINFORMATION)
            else
            begin
              IndexOfListSettings := StreamList.StreamsCodes.IndexOf(fscSCSProjSettingsList);
              if IndexOfListSettings <> -1 then
              begin
                ListSettingsStream := TMemoryStream.Create;

                CurrListParams := GetListParamsFromForm(false);
                ListSettingsStream.WriteBuffer(CurrListParams.Settings, SizeOf(CurrListParams.Settings));
                ListSettingsStream.Position := 0;

                //*** Старый стрим чиститься автоматом, из-за параметра AOwnObjects в TStreamList.Create(fcSCSProjSettings, true)
                StreamList.Streams[IndexOfListSettings] := ListSettingsStream;

                StreamList.SaveToFile(SaveDialog.FileName);
              end
            end;
          end;
          FreeAndNil(StreamList);
        end;
    end;
  end;
  FreeAndNil(SaveDialog);
  ///}
end;

procedure TF_MasterNewListLite.pmiSaveNewProjSettingsToFileClick(
  Sender: TObject);
var
  SaveDialog: TSaveDialog;
  StreamList: TStreamList;

  FileStream: TFileStream;

  ProjSettingsStream: TMemoryStream;
  ListSettingsStream: TMemoryStream;
begin
  {///
  if FileExists(GetPathToDefProjSettings) then
  begin
    SaveDialog := TSaveDialog.Create(Self);
    SaveDialog.Title := cMasterNewList_Mes10_1;
    SaveDialog.InitialDir := ExtractSaveSettingsDir;
    SaveDialog.DefaultExt := '*.'+enSCSProjSettings;
    SaveDialog.FileName := '';
    SaveDialog.Filter := GetDialogFilter(exdSCSProjSettings, enSCSProjSettings);
    SaveDialog.Options := SaveDialog.Options - [ofNoChangeDir];
    SaveDialog.Options := SaveDialog.Options + [ofOverwritePrompt];

    if SaveDialog.Execute then
    begin
      StreamList := TStreamList.Create(fcSCSProjSettings, true);

      //*** Настройки проекта по умолчанию
      FileStream := TFileStream.Create(GetPathToDefProjSettings, fmOpenRead);
      FileStream.Position := 0;
      ProjSettingsStream := TMemoryStream.Create;
      ProjSettingsStream.CopyFrom(FileStream, 0);
      ProjSettingsStream.Position := 0;
      FreeAndNil(FileStream);

      StreamList.Add(ProjSettingsStream, fscSCSProjSettingsProj);

      //*** Настройки листа по умолчаниюЫ
      if FileExists(GetPathToDefListSettings) then
      begin
        FileStream := TFileStream.Create(GetPathToDefListSettings, fmOpenRead);
        FileStream.Position := 0;
        ListSettingsStream := TMemoryStream.Create;
        ListSettingsStream.CopyFrom(FileStream, 0);
        ListSettingsStream.Position := 0;
        FreeAndNil(FileStream);

        StreamList.Add(ListSettingsStream, fscSCSProjSettingsList);
      end;
      StreamList.SaveToFile(SaveDialog.FileName);

      FreeAndNil(StreamList);
    end;
  end;
  ///}
end;


procedure TF_MasterNewListLite.pmiLoadSettingsFromFileClick(Sender: TObject);
var
  OpenDialog: TOpenDialog;
  StreamList: TStreamList;

  NewProjParams: TProjectParams;
  NewListParams: TListParams;

  i: Integer;
  CurrStream: TMemoryStream;
  ReadSize: Integer;
begin
  {///
  OpenDialog := TOpenDialog.Create(Self);
  OpenDialog.Title := cMasterNewList_Mes10_2;
  OpenDialog.InitialDir := ExtractSaveSettingsDir;
  OpenDialog.DefaultExt := '*.'+enSCSProjSettings;
  OpenDialog.FileName := '';
  OpenDialog.Filter := GetDialogFilter(exdSCSProjSettings, enSCSProjSettings);
  OpenDialog.Options := OpenDialog.Options - [ofNoChangeDir] + [ofOverwritePrompt, ofFileMustExist];

  if OpenDialog.Execute then
    if Not FileExists(OpenDialog.FileName) then
      MessageModal(cFileOf+' '+OpenDialog.FileName+' '+cNoFound+'.', ApplicationName, MB_OK or MB_ICONINFORMATION)
    else
    begin
      StreamList := TStreamList.Create(fcSCSProjSettings, true);
      StreamList.LoadFromFile(OpenDialog.FileName);

      if StreamList.FileCode <> fcSCSProjSettings then
        MessageModal(cFileOf+' '+OpenDialog.FileName+' '+cFileIsNotFileOfProjectSettings+'.', ApplicationName, MB_OK or MB_ICONINFORMATION)
      else
      begin
        for i := 0 to StreamList.StreamsCodes.Count - 1 do
        begin
          if StreamList.StreamsCodes[i] = fscSCSProjSettingsList then
          begin
            CurrStream := TMemoryStream(StreamList.Streams[i]);

            NewListParams := GetListParamsFromForm(false);
            ReadSize := CurrStream.Size;
            if ReadSize > SizeOf(NewListParams.Settings) then
              ReadSize := SizeOf(NewListParams.Settings);
            CurrStream.ReadBuffer(NewListParams.Settings, ReadSize);
            SetListParamsToForm(NewListParams, false);
          end
          else
          if (FItemType = itProject) and (StreamList.StreamsCodes[i] = fscSCSProjSettingsProj) then
          begin
            CurrStream := TMemoryStream(StreamList.Streams[i]);

            NewProjParams := GetProjectParamsFromForm(false);
            ReadSize := CurrStream.Size;
            if ReadSize > SizeOf(NewProjParams.Setting) then
              ReadSize := SizeOf(NewProjParams.Setting);
            CurrStream.ReadBuffer(NewProjParams.Setting, ReadSize);
            SetProjectParamsToForm(NewProjParams, false);
          end;
        end;
      end;

      FreeAndNil(StreamList);
    end;
  FreeAndNil(OpenDialog);
  ///}
end;


procedure TF_MasterNewListLite.pmSaveLoadSettingsPopup(Sender: TObject);
begin
//  pmiSaveNewProjSettingsToFile.Enabled := FileExists(GetPathToDefProjSettings);
end;

procedure TF_MasterNewListLite.edSaveUndoCountExit(Sender: TObject);
var
  CheckValue: integer;
begin
//  if edSaveUndoCount.Text = '' then
//    edSaveUndoCount.Text := '1';
//  if edSaveUndoCount.Text = '0' then
//    edSaveUndoCount.Text := '1';

//  CheckValue := StrToInt(edSaveUndoCount.Text);
//  if CheckValue = FCADParams.CADSaveUndoCount then
//    edSaveUndoCount.Style.Font.Color := clBlack
//  else
//    edSaveUndoCount.Style.Font.Color := clBlue;
end;

procedure TF_MasterNewListLite.cbAllowSuppliesKindClick(Sender: TObject);
begin
//  if cbAllowSuppliesKind.Checked = FCADParams.CADAllowSupplieskind then
//    cbAllowSuppliesKind.Font.Color := clBlack
//  else
//    cbAllowSuppliesKind.Font.Color := clBlue;
end;

procedure TF_MasterNewListLite.rbIndexPointComponInRoomClick(Sender: TObject);
begin
  SetControlsByPointComponIndexingMode;
end;

procedure TF_MasterNewListLite.rbIndexPointComponInListClick(Sender: TObject);
begin
  SetControlsByPointComponIndexingMode;
end;

procedure TF_MasterNewListLite.rbIndexPointComponInProjectClick(
  Sender: TObject);
begin
  SetControlsByPointComponIndexingMode;
end;

procedure TF_MasterNewListLite.rbMarkByTemplateClick(Sender: TObject);
begin
  SetControlsByComponMarkMode;
end;

procedure TF_MasterNewListLite.rbMarkByTIAEIA606AClick(Sender: TObject);
begin
  SetControlsByComponMarkMode;
end;

procedure TF_MasterNewListLite.rbRoomNameShortFromNameClick(Sender: TObject);
begin
  SetControlsByRoomNameShortSrcType;
end;

procedure TF_MasterNewListLite.rbRoomNameShortFromDefStrClick(Sender: TObject);
begin
  SetControlsByRoomNameShortSrcType;
end;

procedure TF_MasterNewListLite.edRoomHeightKeyPress(Sender: TObject; var Key: Char);
begin
  try
    if (Key = '.') or (Key = ',') then
      if Key <> DecimalSeparator then
        Key := #0;
  except
    on E: Exception do AddExceptionToLogEx('TF_MasterNewListLite.edRoomHeightKeyPress', E.Message);
  end;
end;

procedure TF_MasterNewListLite.rbMetric_smClick(Sender: TObject);
var
  OldUOM, NewUOM: Integer;
  Val: Double;
begin
  gbRulerModeMetric.Visible := True;
  gbRulerModeWhitworth.Visible := False;

  OldUOM := FCurrProjUnitOfMeasure;
  NewUOM := umSM;

  Val := StrToFloat_My(seHeightThroughFloor.Text);
  seHeightThroughFloor.Text := FormatFloat(ffMask, FloatInUOM(Val, OldUOM, NewUOM));

  Val := StrToFloat_My(edRoomHeight.Text);
  edRoomHeight.Text := FormatFloat(ffMask, FloatInUOM(Val, OldUOM, NewUOM));
  Val := StrToFloat_My(edFalseFloorHeight.Text);
  edFalseFloorHeight.Text := FormatFloat(ffMask, FloatInUOM(Val, OldUOM, NewUOM));
  Val := StrToFloat_My(edConnFloor.Text);
  edConnFloor.Text := FormatFloat(ffMask, FloatInUOM(Val, OldUOM, NewUOM));

  if edLineCeiling.Enabled then
  begin
    Val := StrToFloat_My(edLineCeiling.Text);
    edLineCeiling.Text := FormatFloat(ffMask, FloatInUOM(Val, OldUOM, NewUOM));
  end;
  if edLineFalseFloor.Enabled then
  begin
    Val := StrToFloat_My(edLineFalseFloor.Text);
    edLineFalseFloor.Text := FormatFloat(ffMask, FloatInUOM(Val, OldUOM, NewUOM));
  end;
  if edLineFloor.Enabled then
  begin
    Val := StrToFloat_My(edLineFloor.Text);
    edLineFloor.Text := FormatFloat(ffMask, FloatInUOM(Val, OldUOM, NewUOM));
  end;
  if edLineConnObjects.Enabled then
  begin
    Val := StrToFloat_My(edLineConnObjects.Text);
    edLineConnObjects.Text := FormatFloat(ffMask, FloatInUOM(Val, OldUOM, NewUOM));
  end;

  Val := StrToFloat_My(edPortReserv.Text);
  edPortReserv.Text := FormatFloat(ffMask, FloatInUOM(Val, OldUOM, NewUOM));
  Val := StrToFloat_My(edMultiportReserv.Text);
  edMultiportReserv.Text := FormatFloat(ffMask, FloatInUOM(Val, OldUOM, NewUOM));
  Val := StrToFloat_My(edTwistedPairMaxLength.Text);
  edTwistedPairMaxLength.Text := FormatFloat(ffMask, FloatInUOM(Val, OldUOM, NewUOM));
  SetUOM(NewUOM, true);
end;

procedure TF_MasterNewListLite.rbMetric_mClick(Sender: TObject);
var
  OldUOM, NewUOM: Integer;
  Val: Double;
begin
  gbRulerModeMetric.Visible := True;
  gbRulerModeWhitworth.Visible := False;

  OldUOM := FCurrProjUnitOfMeasure;
  NewUOM := umM;

  Val := StrToFloat_My(seHeightThroughFloor.Text);
  seHeightThroughFloor.Text := FormatFloat(ffMask, FloatInUOM(Val, OldUOM, NewUOM));

  Val := StrToFloat_My(edRoomHeight.Text);
  edRoomHeight.Text := FormatFloat(ffMask, FloatInUOM(Val, OldUOM, NewUOM));
  Val := StrToFloat_My(edFalseFloorHeight.Text);
  edFalseFloorHeight.Text := FormatFloat(ffMask, FloatInUOM(Val, OldUOM, NewUOM));
  Val := StrToFloat_My(edConnFloor.Text);
  edConnFloor.Text := FormatFloat(ffMask, FloatInUOM(Val, OldUOM, NewUOM));

  if edLineCeiling.Enabled then
  begin
    Val := StrToFloat_My(edLineCeiling.Text);
    edLineCeiling.Text := FormatFloat(ffMask, FloatInUOM(Val, OldUOM, NewUOM));
  end;
  if edLineFalseFloor.Enabled then
  begin
    Val := StrToFloat_My(edLineFalseFloor.Text);
    edLineFalseFloor.Text := FormatFloat(ffMask, FloatInUOM(Val, OldUOM, NewUOM));
  end;
  if edLineFloor.Enabled then
  begin
    Val := StrToFloat_My(edLineFloor.Text);
    edLineFloor.Text := FormatFloat(ffMask, FloatInUOM(Val, OldUOM, NewUOM));
  end;
  if edLineConnObjects.Enabled then
  begin
    Val := StrToFloat_My(edLineConnObjects.Text);
    edLineConnObjects.Text := FormatFloat(ffMask, FloatInUOM(Val, OldUOM, NewUOM));
  end;

  Val := StrToFloat_My(edPortReserv.Text);
  edPortReserv.Text := FormatFloat(ffMask, FloatInUOM(Val, OldUOM, NewUOM));
  Val := StrToFloat_My(edMultiportReserv.Text);
  edMultiportReserv.Text := FormatFloat(ffMask, FloatInUOM(Val, OldUOM, NewUOM));
  Val := StrToFloat_My(edTwistedPairMaxLength.Text);
  edTwistedPairMaxLength.Text := FormatFloat(ffMask, FloatInUOM(Val, OldUOM, NewUOM));
  SetUOM(NewUOM, true);  
end;

procedure TF_MasterNewListLite.rbWhitworth_inClick(Sender: TObject);
var
  OldUOM, NewUOM: Integer;
  Val: Double;
begin
  gbRulerModeMetric.Visible := False;
  gbRulerModeWhitworth.Visible := True;

  OldUOM := FCurrProjUnitOfMeasure;
  NewUOM := umIn;

  Val := StrToFloat_My(seHeightThroughFloor.Text);
  seHeightThroughFloor.Text := FormatFloat(ffMask, FloatInUOM(Val, OldUOM, NewUOM));

  Val := StrToFloat_My(edRoomHeight.Text);
  edRoomHeight.Text := FormatFloat(ffMask, FloatInUOM(Val, OldUOM, NewUOM));
  Val := StrToFloat_My(edFalseFloorHeight.Text);
  edFalseFloorHeight.Text := FormatFloat(ffMask, FloatInUOM(Val, OldUOM, NewUOM));
  Val := StrToFloat_My(edConnFloor.Text);
  edConnFloor.Text := FormatFloat(ffMask, FloatInUOM(Val, OldUOM, NewUOM));

  if edLineCeiling.Enabled then
  begin
    Val := StrToFloat_My(edLineCeiling.Text);
    edLineCeiling.Text := FormatFloat(ffMask, FloatInUOM(Val, OldUOM, NewUOM));
  end;
  if edLineFalseFloor.Enabled then
  begin
    Val := StrToFloat_My(edLineFalseFloor.Text);
    edLineFalseFloor.Text := FormatFloat(ffMask, FloatInUOM(Val, OldUOM, NewUOM));
  end;
  if edLineFloor.Enabled then
  begin
    Val := StrToFloat_My(edLineFloor.Text);
    edLineFloor.Text := FormatFloat(ffMask, FloatInUOM(Val, OldUOM, NewUOM));
  end;
  if edLineConnObjects.Enabled then
  begin
    Val := StrToFloat_My(edLineConnObjects.Text);
    edLineConnObjects.Text := FormatFloat(ffMask, FloatInUOM(Val, OldUOM, NewUOM));
  end;

  Val := StrToFloat_My(edPortReserv.Text);
  edPortReserv.Text := FormatFloat(ffMask, FloatInUOM(Val, OldUOM, NewUOM));
  Val := StrToFloat_My(edMultiportReserv.Text);
  edMultiportReserv.Text := FormatFloat(ffMask, FloatInUOM(Val, OldUOM, NewUOM));
  Val := StrToFloat_My(edTwistedPairMaxLength.Text);
  edTwistedPairMaxLength.Text := FormatFloat(ffMask, FloatInUOM(Val, OldUOM, NewUOM));
  SetUOM(NewUOM, true);  
end;

procedure TF_MasterNewListLite.rbWhitworth_ftClick(Sender: TObject);
var
  OldUOM, NewUOM: Integer;
  Val: Double;
begin
  gbRulerModeMetric.Visible := False;
  gbRulerModeWhitworth.Visible := True;

  OldUOM := FCurrProjUnitOfMeasure;
  NewUOM := umFt;

  Val := StrToFloat_My(seHeightThroughFloor.Text);
  seHeightThroughFloor.Text := FormatFloat(ffMask, FloatInUOM(Val, OldUOM, NewUOM));

  Val := StrToFloat_My(edRoomHeight.Text);
  edRoomHeight.Text := FormatFloat(ffMask, FloatInUOM(Val, OldUOM, NewUOM));
  Val := StrToFloat_My(edFalseFloorHeight.Text);
  edFalseFloorHeight.Text := FormatFloat(ffMask, FloatInUOM(Val, OldUOM, NewUOM));
  Val := StrToFloat_My(edConnFloor.Text);
  edConnFloor.Text := FormatFloat(ffMask, FloatInUOM(Val, OldUOM, NewUOM));

  if edLineCeiling.Enabled then
  begin
    Val := StrToFloat_My(edLineCeiling.Text);
    edLineCeiling.Text := FormatFloat(ffMask, FloatInUOM(Val, OldUOM, NewUOM));
  end;
  if edLineFalseFloor.Enabled then
  begin
    Val := StrToFloat_My(edLineFalseFloor.Text);
    edLineFalseFloor.Text := FormatFloat(ffMask, FloatInUOM(Val, OldUOM, NewUOM));
  end;
  if edLineFloor.Enabled then
  begin
    Val := StrToFloat_My(edLineFloor.Text);
    edLineFloor.Text := FormatFloat(ffMask, FloatInUOM(Val, OldUOM, NewUOM));
  end;
  if edLineConnObjects.Enabled then
  begin
    Val := StrToFloat_My(edLineConnObjects.Text);
    edLineConnObjects.Text := FormatFloat(ffMask, FloatInUOM(Val, OldUOM, NewUOM));
  end;

  Val := StrToFloat_My(edPortReserv.Text);
  edPortReserv.Text := FormatFloat(ffMask, FloatInUOM(Val, OldUOM, NewUOM));
  Val := StrToFloat_My(edMultiportReserv.Text);
  edMultiportReserv.Text := FormatFloat(ffMask, FloatInUOM(Val, OldUOM, NewUOM));
  Val := StrToFloat_My(edTwistedPairMaxLength.Text);
  edTwistedPairMaxLength.Text := FormatFloat(ffMask, FloatInUOM(Val, OldUOM, NewUOM));
  SetUOM(NewUOM, true);  
end;

procedure TF_MasterNewListLite.SetMaskEdits;
begin
  try
    // MaskEdit
    edRoomHeight.Properties.EditMask := '\d?\d?\d?' + DecimalSeparator + '\d?\d?';
    edFalseFloorHeight.Properties.EditMask := '\d?\d?\d?' + DecimalSeparator + '\d?\d?';
    edConnCeiling.Properties.EditMask := '\d?\d?\d?' + DecimalSeparator + '\d?\d?';
    edConnFalseFloor.Properties.EditMask := '\d?\d?\d?' + DecimalSeparator + '\d?\d?';
    edConnFloor.Properties.EditMask := '\d?\d?\d?' + DecimalSeparator + '\d?\d?';
    edConnTotal.Properties.EditMask := '\d?\d?\d?' + DecimalSeparator + '\d?\d?';
    edLineCeiling.Properties.EditMask := '\d?\d?\d?' + DecimalSeparator + '\d?\d?';
    edLineFalseFloor.Properties.EditMask := '\d?\d?\d?' + DecimalSeparator + '\d?\d?';
    edLineFloor.Properties.EditMask := '\d?\d?\d?' + DecimalSeparator + '\d?\d?';
    edLineConnObjects.Properties.EditMask := '\d?\d?\d?' + DecimalSeparator + '\d?\d?';
    edLineTotal.Properties.EditMask := '\d?\d?\d?' + DecimalSeparator + '\d?\d?';
    edLengthKoef.Properties.EditMask := '\d?\d?\d?' + DecimalSeparator + '\d?\d?';
    edCableChannelFullnessKoef.Properties.EditMask := '\d?\d?\d?' + DecimalSeparator + '\d?\d?';
    edPortReserv.Properties.EditMask := '\d?\d?\d?' + DecimalSeparator + '\d?\d?';
    edMultiportReserv.Properties.EditMask := '\d?\d?\d?' + DecimalSeparator + '\d?\d?';
    edTwistedPairMaxLength.Properties.EditMask := '\d?\d?\d?\d?\d?' +DecimalSeparator + '\d?\d?';
//    edBlockStep.Properties.EditMask := '\d?\d?\d?' + DecimalSeparator + '\d?\d?';
//    edStepGrid.Properties.EditMask := '[0-4]' + DecimalSeparator + '[1-9]|[1-5]' + DecimalSeparator + '[0]';
    edSizeAsMetric.Properties.EditMask := '\d?\d?\d?\d?' + DecimalSeparator + '\d?\d?';
    edSizeAllMetric.Properties.EditMask := '\d?\d?\d?\d?' + DecimalSeparator + '\d?\d?';
    edSizeAsWhitworth.Properties.EditMask := '\d?\d?\d?\d?' + DecimalSeparator + '\d?\d?';
    edSizeAllWhitworth.Properties.EditMask := '\d?\d?\d?\d?' + DecimalSeparator + '\d?\d?';
  except
    on E: Exception do AddExceptionToLogEx('TF_MasterNewListLite.SetMaskEdits', E.Message);
  end;
end;

procedure TF_MasterNewListLite.SetUOM(aUOM: Integer; AIsChanging: Boolean=false);
var
  OldUOMMin, UOMMin: Integer;
begin
  try
    // система измерений
    if aUOM = umSM then
    begin
      Label64.Caption := cMetric_sm;
      Label1.Caption := cMetric_sm;
      Label2.Caption := cMetric_sm;
      Label22.Caption := cMetric_sm;
      Label23.Caption := cMetric_sm;
      Label27.Caption := cMetric_sm;
      Label3.Caption := cMetric_sm;
      Label4.Caption := cMetric_sm;
      Label9.Caption := cMetric_sm;
      Label10.Caption := cMetric_sm;
      Label11.Caption := cMetric_sm;
      Label12.Caption := cMetric_sm;
      Label13.Caption := cMetric_sm;
    end;
    if aUOM = umM then
    begin
      Label64.Caption := cMetric_m;
      Label1.Caption := cMetric_m;
      Label2.Caption := cMetric_m;
      Label22.Caption := cMetric_m;
      Label23.Caption := cMetric_m;
      Label27.Caption := cMetric_m;
      Label3.Caption := cMetric_m;
      Label4.Caption := cMetric_m;
      Label9.Caption := cMetric_m;
      Label10.Caption := cMetric_m;
      Label11.Caption := cMetric_m;
      Label12.Caption := cMetric_m;
      Label13.Caption := cMetric_m;
    end;
    if aUOM = umIn then
    begin
      Label64.Caption := cWhitworth_in;
      Label1.Caption := cWhitworth_in;
      Label2.Caption := cWhitworth_in;
      Label22.Caption := cWhitworth_in;
      Label23.Caption := cWhitworth_in;
      Label27.Caption := cWhitworth_in;
      Label3.Caption := cWhitworth_in;
      Label4.Caption := cWhitworth_in;
      Label9.Caption := cWhitworth_in;
      Label10.Caption := cWhitworth_in;
      Label11.Caption := cWhitworth_in;
      Label12.Caption := cWhitworth_in;
      Label13.Caption := cWhitworth_in;
    end;
    if aUOM = umFt then
    begin
      Label64.Caption := cWhitworth_ft;
      Label1.Caption := cWhitworth_ft;
      Label2.Caption := cWhitworth_ft;
      Label22.Caption := cWhitworth_ft;
      Label23.Caption := cWhitworth_ft;
      Label27.Caption := cWhitworth_ft;
      Label3.Caption := cWhitworth_ft;
      Label4.Caption := cWhitworth_ft;
      Label9.Caption := cWhitworth_ft;
      Label10.Caption := cWhitworth_ft;
      Label11.Caption := cWhitworth_ft;
      Label12.Caption := cWhitworth_ft;
      Label13.Caption := cWhitworth_ft;
    end;
    OldUOMMin := ConvertUOMToMin(FCurrProjUnitOfMeasure);
    UOMMin := ConvertUOMToMin(aUOM);
    FCurrProjUnitOfMeasure := aUOM;
    if AIsChanging then
    begin
      seStampMarginLeft.Value := Round4(FloatInUOM(seStampMarginLeft.Value, OldUOMMin, UOMMin));
      seStampMarginRight.Value := Round4(FloatInUOM(seStampMarginRight.Value, OldUOMMin, UOMMin));
      seStampMarginTop.Value := Round4(FloatInUOM(seStampMarginTop.Value, OldUOMMin, UOMMin));
      seStampMarginBottom.Value := Round4(FloatInUOM(seStampMarginBottom.Value, OldUOMMin, UOMMin));
    end;
    gbStampMargins.Caption := cMasterNewList_Mes18 +', '+ GetNameUOM(UOMMin, true);

    SetUOMToPM(aUOM); //#From Oleg#
    //FProjectSpravochnikForm.SetUOMToCaptions; //#From Oleg#
    //FListSpravochnikForm.SetUOMToCaptions; //#From Oleg#
  except
    on E: Exception do AddExceptionToLogEx('TF_MasterNewListLite.SetUOM', E.Message);
  end;
end;

procedure TF_MasterNewListLite.edSizeAsWhitworthExit(Sender: TObject);
var
  CheckValue: Double;
begin
  try
    CheckValue := CheckMapScaleResult;
    if CheckValue = FCADParams.CADMapScale then
      edSizeAsWhitworth.Style.Font.Color := clBlack
    else
      edSizeAsWhitworth.Style.Font.Color := clBlue;
  except
    on E: Exception do AddExceptionToLogEx('TF_MasterNewListLite.edSizeAsWhitworthExit', E.Message);
  end;
end;

procedure TF_MasterNewListLite.edSizeAllWhitworthExit(Sender: TObject);
var
  CheckValue: Double;
begin
  try
    CheckValue := CheckMapScaleResult;
    if CheckValue = FCADParams.CADMapScale then
      edSizeAllWhitworth.Style.Font.Color := clBlack
    else
      edSizeAllWhitworth.Style.Font.Color := clBlue;
  except
    on E: Exception do AddExceptionToLogEx('TF_MasterNewListLite.edSizeAllWhitworthExit', E.Message);
  end;
end;

procedure TF_MasterNewListLite.rbin1Click(Sender: TObject);
var
  CheckValue: Double;
begin
  try
    CheckValue := CheckMapScaleResult;
    if CheckValue = FCADParams.CADMapScale then
      edSizeAsWhitworth.Style.Font.Color := clBlack
    else
      edSizeAsWhitworth.Style.Font.Color := clBlue;
  except
    on E: Exception do AddExceptionToLogEx('TF_MasterNewListLite.rbin1Click', E.Message);
  end;
end;

procedure TF_MasterNewListLite.rbft1Click(Sender: TObject);
var
  CheckValue: Double;
begin
  try
    CheckValue := CheckMapScaleResult;
    if CheckValue = FCADParams.CADMapScale then
      edSizeAsWhitworth.Style.Font.Color := clBlack
    else
      edSizeAsWhitworth.Style.Font.Color := clBlue;
  except
    on E: Exception do AddExceptionToLogEx('TF_MasterNewListLite.rbin1Click', E.Message);
  end;
end;


procedure TF_MasterNewListLite.rbin2Click(Sender: TObject);
var
  CheckValue: Double;
begin
  try
    CheckValue := CheckMapScaleResult;
    if CheckValue = FCADParams.CADMapScale then
      edSizeAllWhitworth.Style.Font.Color := clBlack
    else
      edSizeAllWhitworth.Style.Font.Color := clBlue;
  except
    on E: Exception do AddExceptionToLogEx('TF_MasterNewListLite.rbmm2Click', E.Message);
  end;
end;

procedure TF_MasterNewListLite.rbft2Click(Sender: TObject);
var
  CheckValue: Double;
begin
  try
    CheckValue := CheckMapScaleResult;
    if CheckValue = FCADParams.CADMapScale then
      edSizeAllWhitworth.Style.Font.Color := clBlack
    else
      edSizeAllWhitworth.Style.Font.Color := clBlue;
  except
    on E: Exception do AddExceptionToLogEx('TF_MasterNewListLite.rbmm2Click', E.Message);
  end;
end;


procedure TF_MasterNewListLite.cbCreateListClick(Sender: TObject);
begin
  if cbCreateList.Checked then
  begin
    bNext.Caption := cMasterNewListLite_Mes1;
    bNext.ModalResult := mrNone;
  end
  else
  begin
    bNext.Caption := cMasterNewListLite_Mes2;
    bNext.ModalResult := mrOK;
  end;
end;

procedure TF_MasterNewListLite.bNextClick(Sender: TObject);
begin
  try
    bPrev.Enabled := True;
    if PageControl.ActivePageIndex < 3 then
      PageControl.ActivePageIndex := PageControl.ActivePageIndex + 1;
    if PageControl.ActivePageIndex = 3 then
    begin
      bNext.Caption := cMasterNewListLite_Mes2;
      bNext.ModalResult := mrOK;
      // Tolik 03/07/2017 -- сброс для CashedCompon (чтобы не пришли значения с предидущего проекта)
      if Assigned(F_ProjMan) then
        if TF_Main(F_ProjMan).CashedCompon <> nil then
          TF_Main(F_ProjMan).CashedCompon.Clear;
      if Assigned(F_NormBase) then
        if TF_Main(F_NormBase).CashedCompon <> nil then
          TF_Main(F_NormBase).CashedCompon.Clear;
      //
    end;
    GIfMasterUsed := True;
  except
    on E: Exception do AddExceptionToLogEx('TF_MasterNewListLite.bNextClick', E.Message);
  end;
end;

procedure TF_MasterNewListLite.bPrevClick(Sender: TObject);
begin
  try
    bNext.Caption := cMasterNewListLite_Mes1;
    bNext.ModalResult := mrNone;

    PageControl.ActivePageIndex := PageControl.ActivePageIndex - 1;
    if FMasterAsList then
    begin
      if PageControl.ActivePageIndex = 1 then
        bPrev.Enabled := False;
    end
    else
    begin
      if PageControl.ActivePageIndex = 0 then
        bPrev.Enabled := False;
    end;
  except
    on E: Exception do AddExceptionToLogEx('TF_MasterNewListLite.bPrevClick', E.Message);
  end;
end;

procedure TF_MasterNewListLite.bLoadSubClick(Sender: TObject);
var
  OpenDialog: TOpenDialog;
begin
  try
    OpenDialog := TOpenDialog.Create(nil);
    OpenDialog.Title := cMasterNewListLite_Mes3;
    OpenDialog.InitialDir := ExtractDirByCategoryType(dctPictures);//ExtractSaveDirForCategory('Stamp');//FDir;
    OpenDialog.DefaultExt := 'scb';
    OpenDialog.Filter := cMasterNewListLite_Mes4;
    if OpenDialog.Execute then
    begin
      // Tolik 01/08/2019 -- сохранить последний путь
      if GStoreLastPaths then
        WriteEnvironmentDir(dctPictures, ExtractFileDir(OpenDialog.FileName));
        //
      edSubPath.Text := OpenDialog.FileName;
    end;
    OpenDialog.Free;
  except
    on E: Exception do AddExceptionToLogEx('TF_MasterNewListLite.bLoadSubClick', E.Message);
  end;
end;


procedure TF_MasterNewListLite.SetMaket;
var
  cadSize: Double;
  makSize: Double;
  w, h: double;
  Koef: double;
begin
  try
    cadSize := cadMaket.Width;
    w := StrToFloat_My(edWidth.Value);
    h := StrToFloat_My(edHeight.Value);
    makSize := Max(w, h);
    Koef := CadSize / MakSize;
    cadMaket.ZoomScale := trunc(24 * Koef);
    cadMaket.WorkWidth := w;
    cadMaket.WorkHeight := h;
    if rbPortrait.Checked then
      cadMaket.PageOrient := poPortrait
    else
    if rbLandscape.Checked then
      cadMaket.PageOrient := poLandscape;
    LoadFrameOnMaket(cadMaket);      
  except
    on E: Exception do AddExceptionToLogEx('TF_MasterNewListLite.SetMaket', E.Message);
  end;
end;

procedure TF_MasterNewListLite.edWidthPropertiesChange(Sender: TObject);
begin
  try
    if cbPageSize.ItemIndex = 11 then
      setMaket;
  except
    on E: Exception do AddExceptionToLogEx('TF_MasterNewListLite.edWidthPropertiesChange', E.Message);
  end;
end;

procedure TF_MasterNewListLite.edHeightPropertiesChange(Sender: TObject);
begin
  try
    if cbPageSize.ItemIndex = 11 then
      setMaket;
  except
    on E: Exception do AddExceptionToLogEx('TF_MasterNewListLite.edWidthPropertiesChange', E.Message);
  end;
end;

procedure TF_MasterNewListLite.cbCurrencyChange(Sender: TObject);
var
  NewCurrencyGUID: String;
  NewCurrency: TCurrency;
begin
  NewCurrencyGUID := GetGUIDFromStrings(cbCurrency.Items, cbCurrency.ItemIndex);
  if NewCurrencyGUID <> '' then
  begin
    NewCurrency := ChangeCurrencyMainMT(
                      F_MasterNewList.F_ProjectSpravochnikForm.mtCurrency,
                      F_MasterNewList.F_ProjectSpravochnikForm.mtNorms,
                      F_MasterNewList.F_ProjectSpravochnikForm.mtResources, NewCurrencyGUID);
    SetNBCurrencyToForm;
    SetProjCurrencyToForm(NewCurrency, false);
    F_MasterNewList.F_ProjectSpravochnikForm.SetCurrencyBriefToControls(NewCurrency);
  end;
end;

procedure TF_MasterNewListLite.seStampMarginLeftPropertiesChange(
  Sender: TObject);
begin
  //if CmpFloatByPrecision(FloatInUOM(seStampMarginLeft.Value, ConvertUOMToMin(FCurrProjUnitOfMeasure), umMM), FCADParams.CADStampMargins.Left, 3) then
  if CmpFloatByPrecision(seStampMarginLeft.Value, Round4(FloatInUOM(FCADParams.CADStampMargins.Left, umMM, ConvertUOMToMin(FCurrProjUnitOfMeasure))), 3) then
    seStampMarginLeft.Style.Font.Color := clBlack
  else
    seStampMarginLeft.Style.Font.Color := clBlue;
  SetMaket;
end;

procedure TF_MasterNewListLite.seStampMarginRightPropertiesChange(
  Sender: TObject);
begin
  //if CmpFloatByPrecision(FloatInUOM(seStampMarginRight.Value, ConvertUOMToMin(FCurrProjUnitOfMeasure), umMM), FCADParams.CADStampMargins.Right, 3) then
  if CmpFloatByPrecision(seStampMarginRight.Value, Round4(FloatInUOM(FCADParams.CADStampMargins.Right, umMM, ConvertUOMToMin(FCurrProjUnitOfMeasure))), 3) then
    seStampMarginRight.Style.Font.Color := clBlack
  else
    seStampMarginRight.Style.Font.Color := clBlue;
  SetMaket;
end;

procedure TF_MasterNewListLite.seStampMarginTopPropertiesChange(
  Sender: TObject);
begin
  //if CmpFloatByPrecision(FloatInUOM(seStampMarginTop.Value, ConvertUOMToMin(FCurrProjUnitOfMeasure), umMM), FCADParams.CADStampMargins.Top, 3) then
  if CmpFloatByPrecision(seStampMarginTop.Value, Round4(FloatInUOM(FCADParams.CADStampMargins.Top, umMM, ConvertUOMToMin(FCurrProjUnitOfMeasure))), 3) then
    seStampMarginTop.Style.Font.Color := clBlack
  else
    seStampMarginTop.Style.Font.Color := clBlue;
  SetMaket;
end;

procedure TF_MasterNewListLite.seStampMarginBottomPropertiesChange(
  Sender: TObject);
begin
  //if CmpFloatByPrecision(FloatInUOM(seStampMarginBottom.Value, ConvertUOMToMin(FCurrProjUnitOfMeasure), umMM), FCADParams.CADStampMargins.Bottom, 3) then
  if CmpFloatByPrecision(seStampMarginBottom.Value, Round4(FloatInUOM(FCADParams.CADStampMargins.Bottom, umMM, ConvertUOMToMin(FCurrProjUnitOfMeasure))), 3) then 
    seStampMarginBottom.Style.Font.Color := clBlack
  else
    seStampMarginBottom.Style.Font.Color := clBlue;
  SetMaket;
end;

procedure TF_MasterNewListLite.btSetStampMarginsByPrinterClick(
  Sender: TObject);
var
  Rect: TDoubleRect;
begin
  Rect := GetStampMarginsFromForm(Self, GCurrProjUnitOfMeasure);
  Rect := DefineFrameByPrinter(Rect);
  SetStampMarginsToForm(Rect, Self, GCurrProjUnitOfMeasure);
  FCADStampForPrinter := true;
end;

procedure TF_MasterNewListLite.btSetDefStampMarginsClick(Sender: TObject);
var
  DefSettings: TListSettingRecord;
begin
  DefSettings := GetDefaultListSettings(false, GCurrProjUnitOfMeasure);
  SetStampMarginsToForm(DefSettings.CADStampMargins, Self, GCurrProjUnitOfMeasure);
  FCADStampForPrinter := false;
end;



procedure TF_MasterNewListLite.rbNewTracesLengthTypeClick(Sender: TObject);
begin
  FNewTracesLengthTypeChanged := true;
  DefineStyleRBNewTracesLengthType(Sender);
end;

end.
