unit U_MasterNewList;

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, EnJpgGr, Math,
  cxGraphics, cxLookAndFeels, XPMenu, LibJpeg, jpeg;

type
  TF_MasterNewList = class(TForm)
    GlobalPageControl: TRzPageControl;
    TabProjectProperties: TRzTabSheet;
    TabListProperties: TRzTabSheet;
    ListPageControl: TRzPageControl;
    TabAll: TRzTabSheet;
    gbListName: TRzGroupBox;
    edListName: TcxTextEdit;
    RzGroupBox3: TRzGroupBox;
    Label7: TLabel;
    Label8: TLabel;
    Label1: TLabel;
    Label2: TLabel;
    edRoomHeight: TcxMaskEdit;
    edFalseFloorHeight: TcxMaskEdit;
    RzGroupBox4: TRzGroupBox;
    Label3: TLabel;
    Label4: TLabel;
    Label9: TLabel;
    rbConnCeiling: TcxRadioButton;
    rbConnFalseFloor: TcxRadioButton;
    rbConnFloor: TcxRadioButton;
    edConnCeiling: TcxMaskEdit;
    edConnFalseFloor: TcxMaskEdit;
    edConnFloor: 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;
    edConnTotal: TcxMaskEdit;
    edLineTotal: 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;
    TabCAD: TRzTabSheet;
    gbShowCaptionsTypeInCAD: TRzGroupBox;
    gbViewOptions: TRzGroupBox;
    gbShowNetTypes: TRzGroupBox;
    gbShowNotesTypeInCAD: TRzGroupBox;
    TabPM: TRzTabSheet;
    RzGroupBox9: TRzGroupBox;
    bMasksCoponTypes: TcxButton;
    gbShowTypeInPM: TRzGroupBox;
    cbPM_Short: TcxRadioButton;
    cbPM_Full: TcxRadioButton;
    gbPrefixInCAD: TRzGroupBox;
    edNotePrefix: TcxTextEdit;
    Label33: TLabel;
    TabLinesTypes: TRzTabSheet;
    GroupBox_ControlComplectJoin: TRzGroupBox;
    tsListSpravochniki: TRzTabSheet;
    RzGroupBox20: TRzGroupBox;
    bOK: TRzBitBtn;
    bCancle: TRzBitBtn;
    lbCurrIndex: TLabel;
    seCurrIndex: TRzSpinEdit;
    RzGroupBox23: TRzGroupBox;
    rbCornerNone: TcxRadioButton;
    rbCornerOut: TcxRadioButton;
    rbCornerVertical: TcxRadioButton;
    rbCornerAdapter: TcxRadioButton;
    rbCornerIn: TcxRadioButton;
    gbIndexesForNewObjects: TRzGroupBox;
    seIndexPointObj: TcxSpinEdit;
    seIndexConnector: TcxSpinEdit;
    seIndexLine: TcxSpinEdit;
    Label53: TLabel;
    Label57: TLabel;
    Label62: TLabel;
    RzPanel3: TRzPanel;
    cbCADNotes_Short: TcxRadioButton;
    cbCADNotes_Full: TcxRadioButton;
    tsProjectSpravochniki: TRzTabSheet;
    RzGroupBox26: TRzGroupBox;
    cbCADCaptions_Short: TcxRadioButton;
    cbCADCaptions_Full: TcxRadioButton;
    RzGroupBox27: TRzGroupBox;
    cbCADCaptionsDetail: TcxRadioButton;
    cbCADCaptionsSimple: TcxRadioButton;
    RzGroupBox28: TRzGroupBox;
    cbCADNotesDetail: TcxRadioButton;
    cbCADNotesSimple: TcxRadioButton;
    pnComponentType: TRzPanel;
    cbCADCaptionsExternalSCS: TcxRadioButton;
    lng_Forms: TsiLangLinked;
    pcViewOptions: TRzPageControl;
    TabSheet1: TRzTabSheet;
    TabSheet2: TRzTabSheet;
    cbLinesCaptionsColor: TcxColorComboBox;
    cbConnectorsCaptionsColor: TcxColorComboBox;
    cbConnectorsNotesColor: TcxColorComboBox;
    cbLinesNotesColor: TcxColorComboBox;
    TabPageParams: TRzTabSheet;
    RzGroupBox1: TRzGroupBox;
    gbPageSize: TRzGroupBox;
    Label5: TLabel;
    Label6: TLabel;
    cbPageSize: TcxComboBox;
    edWidth: TcxSpinEdit;
    edHeight: TcxSpinEdit;
    RzGroupBox2: TRzGroupBox;
    rbPortrait: TcxRadioButton;
    rbLandscape: TcxRadioButton;
    gbGridStep: TRzGroupBox;
    Label41: TLabel;
    edStepGrid: TcxMaskEdit;
    RzGroupBox22: TRzGroupBox;
    cbFontName: TRzFontComboBox;
    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;
    cbLinesNotesFontSize: TRzComboBox;
    cbConnectorsNotesFontSize: TRzComboBox;
    cbLinesCaptionsFontSize: TRzComboBox;
    cbConnectorsCaptionsFontSize: TRzComboBox;
    TabSheet3: TRzTabSheet;
    cbCrossATSFontSize: TRzComboBox;
    cbDistribCabFontSize: TRzComboBox;
    cxLabel1: TcxLabel;
    cxLabel2: TcxLabel;
    TabSheet4: TRzTabSheet;
    cbBlackPrint: TcxRadioButton;
    cbColorPrint: TcxRadioButton;
    gbPrefixCountType: TRzGroupBox;
    rbBeforePrefix: TcxRadioButton;
    rbAfterPrefix: TcxRadioButton;
    gbSCSType: TRzGroupBox;
    rbInternalSCS: TcxRadioButton;
    rbExternalSCS: TcxRadioButton;
    RzPanel1: TRzPanel;
    lbLoadDefSettings: TRzLabel;
    lbSaveDefSettings: TRzLabel;
    RzGroupBox34: TRzGroupBox;
    RzGroupBox35: TRzGroupBox;
    Label66: TLabel;
    edTraceStepRotate: TcxMaskEdit;
    Label67: TLabel;
    RzGroupBox36: TRzGroupBox;
    Label68: TLabel;
    Label69: TLabel;
    edListCountX: TcxSpinEdit;
    edListCountY: TcxSpinEdit;
    RzGroupBox37: TRzGroupBox;
    RzGroupBox16: TRzGroupBox;
    rbSimple: TcxRadioButton;
    rbDetailed: TcxRadioButton;
    rbExtended: TcxRadioButton;
    RzGroupBox13: TRzGroupBox;
    rbUkr: TcxRadioButton;
    rbRus: TcxRadioButton;
    RzGroupBox38: TRzGroupBox;
    lbSaveLoadSettings: TRzLabel;
    pmSaveLoadSettings: TPopupMenu;
    pmiSaveSettingsToFile: TMenuItem;
    pmiLoadSettingsFromFile: TMenuItem;
    pmiSaveNewProjSettingsToFile: TMenuItem;
    RzGroupBox7: TRzGroupBox;
    Label70: TLabel;
    edSaveUndoCount: TcxMaskEdit;
    cbApplyForAllSCSObjects: TRzCheckBox;
    cbApplyForSelectedOnly: TRzCheckBox;
    cbAutoApplyHeights: TRzCheckBox;
    cbShowMainStamp: TRzCheckBox;
    cbShowUpperStamp: TRzCheckBox;
    cbShowSideStamp: TRzCheckBox;
    cbReindexComponents: TRzCheckBox;
    cbReindexInChangedTypes: TRzCheckBox;
    cbGroupObjectsByType: TRzCheckBox;
    cbCanSetCorkBetweenTraces: TRzCheckBox;
    cbControlJoinByNetType: TRzCheckBox;
    cbControlComplectByProducer: TRzCheckBox;
    cbControlJoinByProperties: TRzCheckBox;
    cbControlComplectByProperties: TRzCheckBox;
    cbAllNetworks: TRzCheckBox;
    cbComputerNetwork: TRzCheckBox;
    cbTelephonNetwork: TRzCheckBox;
    cbElectricNetwork: TRzCheckBox;
    cbTelevisionNetwork: TRzCheckBox;
    cbGasNetwork: TRzCheckBox;
    cbAutoCadMouse: TRzCheckBox;
    cbScaleByCursor: TRzCheckBox;
    cbShowRaise: TRzCheckBox;
    cbPutCableOnTrace: TRzCheckBox;
    cbAllowSuppliesKind: TRzCheckBox;
    cbAutoPosTraceBetweenRM: TRzCheckBox;
    cbCrossATSFontBold: TRzCheckBox;
    cbDistribCabFontBold: TRzCheckBox;
    cbLinesCaptionsFontBold: TRzCheckBox;
    cbShowLinesCaptions: TRzCheckBox;
    cbShowLinesLength: TRzCheckBox;
    cbShowConnectorsCaptions: TRzCheckBox;
    cbShowLinesNotes: TRzCheckBox;
    cbShowConnectorsNotes: TRzCheckBox;
    pcProjectOptions: TRzPageControl;
    tsProjOptionsGeneral: TRzTabSheet;
    RzGroupBox10: TRzGroupBox;
    Label49: TLabel;
    edProjectName: TRzEdit;
    seProjectIndex: TRzSpinEdit;
    cbProjectIsIndexWithName: TRzCheckBox;
    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;
    RzGroupBox14: TRzGroupBox;
    Label58: TLabel;
    Label59: TLabel;
    Label60: TLabel;
    Label61: TLabel;
    edNBCurrencyName: TRzEdit;
    edNBCurrencyNameBrief: TRzEdit;
    neNBCurrencyRatio: TRzNumericEdit;
    seNBCurrencyKolvo: TRzSpinEdit;
    gbSCSTypePrj: TRzGroupBox;
    rbInternalSCSP: TcxRadioButton;
    rbExternalSCSP: TcxRadioButton;
    tsProjOptionsObjectProps: TRzTabSheet;
    RzGroupBox18: TRzGroupBox;
    Label32: TLabel;
    Label50: TLabel;
    edDefListName: TRzMaskEdit;
    edDefRoomName: TRzEdit;
    RzGroupBox15: TRzGroupBox;
    RzGroupBox39: TRzGroupBox;
    RzGroupBox21: TRzGroupBox;
    rbIndexPointComponInRoom: TRzRadioButton;
    rbIndexPointComponInList: TRzRadioButton;
    rbIndexPointComponInProject: TRzRadioButton;
    RzGroupBox32: TRzGroupBox;
    RzGroupBox33: TRzGroupBox;
    cbReindexAllPointComponents: TRzCheckBox;
    lbOtherComponIndexingParams: TRzLabel;
    cbUseNormsFromInterfaces: TRzCheckBox;
    rbIndexingModeProject: TRzRadioButton;
    rbIndexingModeCompon: TRzRadioButton;
    rbReindexOrderTypeCreate: TRzRadioButton;
    rbReindexOrderTypePosPM: TRzRadioButton;
    lbTracingParams: TRzLabel;
    RzGroupBox31: TRzGroupBox;
    Label63: TLabel;
    Label64: TLabel;
    seHeightThroughFloor: TRzSpinEdit;
    cbRescaleDrawing: TRzCheckBox;
    gbMarkMode: TRzGroupBox;
    rbMarkByTemplate: TRzRadioButton;
    rbMarkByTIAEIA606A: TRzRadioButton;
    gbMarkTIAEIA606AParams: TRzGroupBox;
    RzGroupBox41: TRzGroupBox;
    rbRoomNameShortFromName: TRzRadioButton;
    rbRoomNameShortFromDefStr: TRzRadioButton;
    edRoomNameShortDefault: TRzEdit;
    edRoomNameShortIfNoRoom: TRzEdit;
    Label55: TLabel;
    cbIsMarkByTemplateIfNoAtOtherMode: TRzCheckBox;
    cbRemarkAllCompons: TRzCheckBox;
    RzGroupBox42: TRzGroupBox;
    Label56: TLabel;
    Label71: TLabel;
    rbMetric_sm: TRzRadioButton;
    rbMetric_m: TRzRadioButton;
    rbWhitworth_in: TRzRadioButton;
    rbWhitworth_ft: TRzRadioButton;
    gbRulerModeWhitworth: TRzGroupBox;
    Label72: TLabel;
    Label73: TLabel;
    Label74: TLabel;
    Label75: TLabel;
    Bevel2: TBevel;
    edSizeAsWhitworth: TcxMaskEdit;
    edSizeAllWhitworth: TcxMaskEdit;
    rbin1: TcxRadioButton;
    rbft1: TcxRadioButton;
    rbin2: TcxRadioButton;
    rbft2: TcxRadioButton;
    TabSheet5: TRzTabSheet;
    cbShowCabinetsBounds: TRzCheckBox;
    cbShowCabinetsNumbers: TRzCheckBox;
    cbListIsIndexWithName: TRzCheckBox;
    RzGroupBox6: TRzGroupBox;
    cxImage1: TcxImage;
    cxImage2: TcxImage;
    cxImage8: TcxImage;
    cxImage9: TcxImage;
    cxImage3: TcxImage;
    cxImage4: TcxImage;
    cxImage7: TcxImage;
    cxImage5: TcxImage;
    cxImage6: TcxImage;
    Label34: TLabel;
    Label35: TLabel;
    Label42: TLabel;
    Label43: TLabel;
    Label36: TLabel;
    Label37: TLabel;
    Label40: TLabel;
    Label38: TLabel;
    Label39: TLabel;
    cxImage10: TcxImage;
    cxImage11: TcxImage;
    cxImage12: TcxImage;
    cxImage13: TcxImage;
    cxImage14: TcxImage;
    Label44: TLabel;
    Label45: TLabel;
    Label46: TLabel;
    Label47: TLabel;
    Label48: TLabel;
    cbKeepLineTypesRules: TRzCheckBox;
    gbViewTracesOptions: TRzGroupBox;
    Label28: TLabel;
    Label29: TLabel;
    Label30: TLabel;
    Label31: TLabel;
    cbTraceColor: TcxColorComboBox;
    edBlockStep: TcxMaskEdit;
    cbTraceStyle: TcxImageComboBox;
    edTraceWidth: TcxMaskEdit;
    RzGroupBox29: TRzGroupBox;
    rbNone: TcxRadioButton;
    rbRow: TcxRadioButton;
    rbStroke: TcxRadioButton;
    bMaster: TRzBitBtn;
    rbIndexingModeTopCompon: TRzRadioButton;
    cbCurrency: TRzComboBox;
    cbRecalcPricesByNDSChange: TRzCheckBox;
    gbStampMargins: TRzGroupBox;
    Label76: TLabel;
    Label77: TLabel;
    Label78: TLabel;
    Label79: TLabel;
    seStampMarginLeft: TcxSpinEdit;
    seStampMarginRight: TcxSpinEdit;
    seStampMarginTop: TcxSpinEdit;
    seStampMarginBottom: TcxSpinEdit;
    lbStampDeveloper: TLabel;
    lbStampChecker: TLabel;
    edStampDeveloper: TcxTextEdit;
    edStampChecker: TcxTextEdit;
    btSetStampMarginsByPrinter: TSpeedButton;
    btSetDefStampMargins: TSpeedButton;
    rbUkrDSTU: TcxRadioButton;
    lbStampMainEngineer: TLabel;
    edStampMainEngineer: TcxTextEdit;
    lbStampApproved: TLabel;
    edStampApproved: TcxTextEdit;
    lbStampDesignStage: TLabel;
    edStampDesignStage: TcxTextEdit;
    lbStampListSign: TLabel;
    edStampListSign: TcxTextEdit;
    gbNewTracesLengthType: TRzGroupBox;
    rbNewTracesLengthAuto: TRzRadioButton;
    rbNewTracesLengthUser: TRzRadioButton;
    cbShowRaiseDrawFigure: TRzCheckBox;
    lbResetIndex: TRzLabel;
    Label80: TLabel;
    edCableSwervesCount: TcxMaskEdit;
    Label81: TLabel;
    edCableSwervesMinAngle: TcxMaskEdit;
    Label82: TLabel;
    TabSheet6: TRzTabSheet;
    RzGroupBox11: TRzGroupBox;
    Label65: TLabel;
    edOrganization: TRzEdit;
    RzGroupBox25: TRzGroupBox;
    lbCustomer: TLabel;
    edCustomer: TRzEdit;
    RzGroupBox30: TRzGroupBox;
    edContractor: TRzEdit;
    lbContractor: TLabel;
    Label83: TLabel;
    Label84: TLabel;
    edCustomerInfo: TMemo;
    edContractorInfo: TMemo;
    RzGroupBox40: TRzGroupBox;
    Label85: TLabel;
    edDesignerInfo: TRzEdit;
    RzGroupBox43: TRzGroupBox;
    edJobInfo: TMemo;
    Label86: TLabel;
    edTagAdd: TRzMaskEdit;
    Bevel3: TBevel;
    cbShowRaiseHeights: TRzCheckBox;
    XPMenu: TXPMenu;

    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 bListOKClick(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 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);
    procedure cbShowRaiseDrawFigureClick(Sender: TObject);
    procedure lbResetIndexClick(Sender: TObject);
    procedure edCableSwervesCountExit(Sender: TObject);
    procedure edCableSwervesMinAngleExit(Sender: TObject);
    procedure edCableSwervesCountKeyPress(Sender: TObject; var Key: Char);
    procedure edCableSwervesMinAngleKeyPress(Sender: TObject; var Key: Char);
    procedure cbShowConnectorsCaptionsMouseUp(Sender: TObject;
      Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
  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;
  public
    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;
    function CreateSpravochniki: Boolean;
    procedure FormAsList(AAsList: Boolean);
    procedure FormModeAsProject(AAsProject: Boolean);

    function GetPointComonIndexingModeFromForm: TPointComonIndexingMode;
    function GetMarkModeFrom: TMarkMode;

    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;

    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;

    // MAIN
    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);

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

function GetStampMarginsFromForm(AForm: TForm; aUOM: Integer): TDoubleRect;
procedure SetStampMarginsToForm(AMargins: TDoubleRect; AForm: TForm;
  aUOM: Integer);

var
  F_MasterNewList: TF_MasterNewList;

implementation

uses USCS_Main, U_CAD, U_Main, U_SCSObjectsProp, PCDrawBox, U_Constants, DB,
  U_MasterNewListLite, U_SCSComponent;
{$R *.dfm}

procedure TF_MasterNewList.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_PageParams.cbPageSizePropertiesCloseUp',
        E.Message);
  end;
end;

procedure TF_MasterNewList.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;
    // автоподгонка изображения
    if F_MasterNewList.Tag = 1 then
    begin
      CheckPageSizeIndex := cbPageSize.ItemIndex;
      CheckListCountX := StrToInt(edListCountX.Text);
      CheckListCountY := StrToInt(edListCountY.Text);
      if rbPortrait.Checked then
        CheckPageOrient := poPortrait
      else
        CheckPageOrient := poLandscape;
      if (CheckPageSizeIndex = FCADParams.CADPageSizeIndex) and
        (CheckListCountX = FCADParams.CADListCountX) and
        (CheckListCountY = FCADParams.CADListCountY) and
        (CheckPageOrient = FCADParams.CADPageOrient) then
      begin
        cbRescaleDrawing.Enabled := false;
        cbRescaleDrawing.Checked := false;
      end
      else if (GCadForm.FListType = lt_Normal) then
      begin
        cbRescaleDrawing.Enabled := true;
        cbRescaleDrawing.Checked := false;
      end;
    end;
  except
    on E: Exception do
      AddExceptionToLogEx('TF_MasterNewList.rbPortraitClick', E.Message);
  end;
end;

procedure TF_MasterNewList.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;
    // автоподгонка изображения
    if F_MasterNewList.Tag = 1 then
    begin
      CheckPageSizeIndex := cbPageSize.ItemIndex;
      CheckListCountX := StrToInt(edListCountX.Text);
      CheckListCountY := StrToInt(edListCountY.Text);
      if rbPortrait.Checked then
        CheckPageOrient := poPortrait
      else
        CheckPageOrient := poLandscape;
      if (CheckPageSizeIndex = FCADParams.CADPageSizeIndex) and
        (CheckListCountX = FCADParams.CADListCountX) and
        (CheckListCountY = FCADParams.CADListCountY) and
        (CheckPageOrient = FCADParams.CADPageOrient) then
      begin
        cbRescaleDrawing.Enabled := false;
        cbRescaleDrawing.Checked := false;
      end
      else if (GCadForm.FListType = lt_Normal) then
      begin
        cbRescaleDrawing.Enabled := true;
        cbRescaleDrawing.Checked := false;
      end;
    end;
  except
    on E: Exception do
      AddExceptionToLogEx('TF_MasterNewList.rbLandscapeClick', E.Message);
  end;
end;

procedure TF_MasterNewList.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;
    // автоподгонка изображения
    if F_MasterNewList.Tag = 1 then
    begin
      CheckPageSizeIndex := cbPageSize.ItemIndex;
      CheckListCountX := StrToInt(edListCountX.Text);
      CheckListCountY := StrToInt(edListCountY.Text);
      if rbPortrait.Checked then
        CheckPageOrient := poPortrait
      else
        CheckPageOrient := poLandscape;
      if (CheckPageSizeIndex = FCADParams.CADPageSizeIndex) and
        (CheckListCountX = FCADParams.CADListCountX) and
        (CheckListCountY = FCADParams.CADListCountY) and
        (CheckPageOrient = FCADParams.CADPageOrient) then
      begin
        cbRescaleDrawing.Enabled := false;
        cbRescaleDrawing.Checked := false;
      end
      else if (GCadForm.FListType = lt_Normal) then
      begin
        cbRescaleDrawing.Enabled := true;
        cbRescaleDrawing.Checked := false;
      end;
    end;
  except
    on E: Exception do
      AddExceptionToLogEx('TF_MasterNewList.cbPageSizePropertiesCloseUp',
        E.Message);
  end;
end;

procedure TF_MasterNewList.FormShow(Sender: TObject);
var
  ListParams: TListParams;
  ListSettings: TListSettingRecord;
  CurMapScale: Double;
  i: Integer;
  List: TSCSList;
  text: string;
begin
  try
    ClearAllChangedColor;
    // СИ
    SetUOM(FProjectParams.Setting.UnitOfMeasure);
    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_MasterNewList.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_MasterNewList.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
    else if F_MasterNewList.Tag = 1 then
    begin
      cbShowLinesCaptions.AllowGrayed := true;
      cbShowLinesCaptions.State := cbGrayed;
      cbShowLinesNotes.AllowGrayed := true;
      cbShowLinesNotes.State := cbGrayed;
      cbShowConnectorsCaptions.AllowGrayed := true;
      cbShowConnectorsCaptions.State := cbGrayed;
      cbShowConnectorsNotes.AllowGrayed := true;
      cbShowConnectorsNotes.State := cbGrayed;
      // типы сетей
      if nt_All in GCadForm.FShowNetworkTypes then
      begin
        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
      else
      begin
        cbAllNetworks.Checked := false;
        cbComputerNetwork.Enabled := true;
        cbTelephonNetwork.Enabled := true;
        cbElectricNetwork.Enabled := true;
        cbTelevisionNetwork.Enabled := true;
        cbGasNetwork.Enabled := true;
        cbComputerNetwork.Checked := false;
        cbTelephonNetwork.Checked := false;
        cbElectricNetwork.Checked := false;
        cbTelevisionNetwork.Checked := false;
        cbGasNetwork.Checked := false;

        if nt_Computer in GCadForm.FShowNetworkTypes then
          cbComputerNetwork.Checked := true;
        if nt_Telephon in GCadForm.FShowNetworkTypes then
          cbTelephonNetwork.Checked := true;
        if nt_Electric in GCadForm.FShowNetworkTypes then
          cbElectricNetwork.Checked := true;
        if nt_Television in GCadForm.FShowNetworkTypes then
          cbTelevisionNetwork.Checked := true;
        if nt_Gas in GCadForm.FShowNetworkTypes then
          cbGasNetwork.Checked := true;
      end;
    end;

    // Prop
    if F_MasterNewList.Tag = 1 then
    begin
      // формат листа
      if cbPageSize.ItemIndex = 11 then
      begin
        edWidth.Value := GCadForm.PCad.WorkWidth;
        edHeight.Value := GCadForm.PCad.WorkHeight;
      end
      else
      begin
        edWidth.Value := GCadForm.PCad.WorkWidth;
        edHeight.Value := GCadForm.PCad.WorkHeight;
      end;
      if GCadForm.PCad.PageOrient = poLandscape then
        rbLandscape.Checked := true;
      if GCadForm.PCad.PageOrient = poPortrait then
        rbPortrait.Checked := true;
      // шаг сетки
      edStepGrid.Text := FormatFloat(ffMask, GCadForm.PCad.GridStep);
      // MapScale
      CurMapScale := GCadForm.PCad.MapScale;
      rbmm1.Checked := false;
      rbsm1.Checked := false;
      rbm1.Checked := true;
      rbmm2.Checked := false;
      rbsm2.Checked := false;
      rbm2.Checked := false;
      //Tolik 23/11/2021 --
      //edSizeAsMetric.Text := FormatFloat(ffMask, CurMapScale / 100);
      //edSizeAsMetric.Text := FormatFloat('#.#######', CurMapScale / 100);
      text := FloatTostr(RoundN(CurMapScale / 100, 9));
      edSizeAsMetric.Text := text;
      //
      rbin1.Checked := false;
      rbft1.Checked := true;
      rbin2.Checked := false;
      rbft2.Checked := false;
      //edSizeAsWhitworth.Text := FormatFloat(ffMask, CurMapScale / 12);
      //Tolik 09/02/2022 -- закомментил это нах ...
      //edSizeAsWhitworth.Text := FloatTostr(RoundN(CurMapScale / 12, 7));
      //

      // настройки в зависимости от типа листа
      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;
        ListPageControl.Pages[5].TabVisible := false;
        cbApplyForAllSCSObjects.Enabled := false;
        cbApplyForSelectedOnly.Enabled := false;
      end;
      if GCadForm.FListType = lt_Normal then
      begin
        ListPageControl.Pages[0].TabVisible := true;
        if ExistsSCSObjectInList(GCadForm.FCADListID) then
          gbSCSType.Enabled := false
        else
          gbSCSType.Enabled := true;
        ListPageControl.Pages[2].TabVisible := true;
{$IF Not Defined(ES_GRAPH_SC)}
        ListPageControl.Pages[3].TabVisible := true;
        ListPageControl.Pages[4].TabVisible := true;
{$IFEND}
        ListPageControl.Pages[5].TabVisible := true;
        cbApplyForAllSCSObjects.Enabled := true;
        cbApplyForSelectedOnly.Enabled := true;
      end;
      // настройки в зависимости от типа листа
      if GCadForm.FListType = 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;
        cbApplyForAllSCSObjects.Enabled := false;
        cbApplyForSelectedOnly.Enabled := false;
      end;
      // настройки в зависимости от типа листа
      // Tolik 04/06/2021 -- для однолинейной схемы электрики
      if GCadForm.FListType = lt_ElScheme 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;
        cbApplyForAllSCSObjects.Enabled := false;
        cbApplyForSelectedOnly.Enabled := false;
      end;
      //Tolik 06/02/2023 -- схема электрического щитка монтажная
      if GCadForm.FListType = lt_AScheme 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;
        cbApplyForAllSCSObjects.Enabled := false;
        cbApplyForSelectedOnly.Enabled := false;
      end;
      //
    end;
    SetPageParamsOnChange;
    if Not FIsFromMaster then
    begin
      cbApplyForAllSCSObjects.Checked := true;
      cbApplyForSelectedOnly.Checked := false;
    end;

    cbRescaleDrawing.Enabled := false;
    cbRescaleDrawing.Checked := false;

    try
      lbLoadDefSettings.Enabled := EnableLoadDefSettings and CanShowlbSettings;
      lbSaveDefSettings.Enabled := CanShowlbSettings;
      lbSaveLoadSettings.Enabled := CanShowlbSettings;
    except
    end;
  except
    on E: Exception do
      AddExceptionToLogEx('TF_MasternewList.FormShow', E.Message);
  end;
{$IF Defined(ES_GRAPH_SC) AND (Defined(FINAL_SCS) OR Defined(TRIAL_SCS))}
  try

    // TabLinesTypes.TabVisible := False;
    RzGroupBox6.Visible := false;
    gbViewTracesOptions.Visible := false;
    RzGroupBox29.Top := 2;
    RzGroupBox29.Left := 5;

    RzGroupBox35.Visible := false;
    cbAutoCadMouse.Visible := false;

    TabPM.TabVisible := false;

    tsListSpravochniki.TabVisible := false;
    GroupBox_ControlComplectJoin.Visible := false;
    RzGroupBox34.Visible := false;
    bMasksCoponTypes.Visible := false;
    gbShowNetTypes.Visible := false;
    gbShowCaptionsTypeInCAD.Visible := false;
    gbShowNotesTypeInCAD.Visible := false;

    gbPrefixInCAD.Visible := false;
    gbPrefixInCAD.Top := 2;

    RzGroupBox36.Top := 2;
    gbViewOptions.Visible := false;
    cbPutCableOnTrace.Visible := false;
    cbAutoPosTraceBetweenRM.Visible := false;
    cbAllowSuppliesKind.Visible := false;
    RzGroupBox3.Visible := false;
    RzGroupBox12.Visible := false;
    gbIndexesForNewObjects.Visible := false;

    gbSCSType.Visible := false;
    cbAutoApplyHeights.Visible := false;
    RzGroupBox4.Visible := false;
    RzGroupBox5.Visible := false;
    RzGroupBox23.Visible := false;
    RzGroupBox7.Top := 2;
    edConnTotal.Visible := false;
    edLineTotal.Visible := false;
    RzGroupBox15.Visible := false;
    RzGroupBox19.Visible := false;
    RzGroupBox31.Visible := false;
    gbSCSTypePrj.Visible := false;
    gbSCSType.Visible := false;
    tsProjectSpravochniki.TabVisible := false;
    bMaster.Visible := false;
    Label50.Visible := false;
    edDefRoomName.Visible := false;

    tsListSpravochniki.TabVisible := false;

  except
  end;
{$IFEND}
  lbResetIndex.Visible := false;
  if not TabProjectProperties.TabVisible then
  begin
{$IF Not Defined(ES_GRAPH_SC)}
    // продолжить индексы компонент
    if (FMakeEditMode = meEdit) and (FItemType = itList) then
    begin
      List := F_ProjMan.GSCSBase.CurrProject.GetListBySCSID(FItemID);
      if List <> nil then
      begin
        for i := 0 to List.Spravochnik.ComponentTypes.Count - 1 do
        begin
          if TNBComponentType(List.Spravochnik.ComponentTypes[i])
            .ComponentType.ComponentIndex > 0 then
          begin
            lbResetIndex.Visible := true;
            break;
          end;
        end;
      end;
    end;
{$IFEND}
    pnComponentType.Visible := lbResetIndex.Visible;
  end
  else
    pnComponentType.Visible := cbReindexComponents.Visible;

  if GReadOnlyMode then
  begin
    bOK.Enabled := false;
    bMaster.Enabled := false;
    // bOk.Visible := False;
    // bMaster.Visible := False;
  end;
  //Tolik 16/02/2022 --
  if bOK.Enabled then
    bOk.SetFocus;
  //
end;

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

procedure TF_MasterNewList.rbConnCeilingClick(Sender: TObject);
begin
  try
    //Tolik 09/06/2021 --
    if edRoomHeight.Text = '' then
      edRoomHeight.Text := '0';
    //
    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_MasterNewList.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_MasterNewList.rbConnCeilingClick', E.Message);
  end;
end;

procedure TF_MasterNewList.rbConnFalseFloorClick(Sender: TObject);
begin
  try
    //Tolik 09/06/2021 --
    if edRoomHeight.Text = '' then
      edRoomHeight.Text := '0';
    //
    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_MasterNewList.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_MasterNewList.rbConnFalseFloorClick', E.Message);
  end;
end;

procedure TF_MasterNewList.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_MasterNewList.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_MasterNewList.rbConnFloorClick', E.Message);
  end;
end;

procedure TF_MasterNewList.rbLineCeilingClick(Sender: TObject);
var
  CheckValue: Double;
begin
  try
    //Tolik 09/06/2021 --
    if edRoomHeight.Text = '' then
      edRoomHeight.Text := '0';
    //
    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_MasterNewList.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_MasterNewList.rbLineCeilingClick', E.Message);
  end;
end;

procedure TF_MasterNewList.rbLineFalseFloorClick(Sender: TObject);
var
  CheckValue: Double;
begin
  try
    //Tolik 09/06/2021 --
    if edRoomHeight.Text = '' then
      edRoomHeight.Text := '0';
    //
    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_MasterNewList.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_MasterNewList.rbLineFalseFloorClick', E.Message);
  end;
end;

procedure TF_MasterNewList.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_MasterNewList.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_MasterNewList.rbLineFloorClick', E.Message);
  end;
end;

procedure TF_MasterNewList.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_MasterNewList.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_MasterNewList.rbLineConnObjectsClick', E.Message);
  end;
end;

procedure TF_MasterNewList.FormAsList(AAsList: Boolean);
begin
  try
    // pnComponentType.Visible := Not AAsList;
    cbReindexComponents.Visible := Not AAsList;
    cbReindexInChangedTypes.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(FProjectSpravochnikForm,
        F_ProjMan.GSCSBase.CurrProject.CurrID, itProject, false, [vkProperty]);
    end;
  except
    on E: Exception do
      AddExceptionToLogEx('TF_MasterNewList.FormAsList', E.Message);
  end;
end;

procedure TF_MasterNewList.FormModeAsProject(AAsProject: Boolean);
begin
  try
    TabProjectProperties.TabVisible := AAsProject;
    TabListProperties.TabVisible := AAsProject;
    tsProjectSpravochniki.TabVisible := AAsProject;
    //Tolik 21/01/2022 -- если создается проект - нужно все-таки дать отредактировать пользователю наименование листа
    //gbListName.Enabled := Not AAsProject;
    gbListName.Enabled := true;
    //
    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;
    if AAsProject then
      RzGroupBox12.Height := 243
    else
      RzGroupBox12.Height := 192;

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

    if AAsProject then
    begin
      if Not FIsFromMaster then
      begin
        cbReindexAllPointComponents.Checked := false;
        cbReindexComponents.Checked := false;
        cbReindexInChangedTypes.Checked := true;
        cbRemarkAllCompons.Checked := false;
      end;
      lbSaveDefSettings.Caption := cMasterNewList_Mes7_1;
      lbLoadDefSettings.Caption := cMasterNewList_Mes8_1;
      pmiSaveSettingsToFile.Caption := cMasterNewList_Mes9_1;
      pmiLoadSettingsFromFile.Caption := cMasterNewList_Mes9_2;
      cbRecalcPricesByNDSChange.Visible := FMakeEditMode <> meMake;
    end;

    if AAsProject then
    begin
{$IF Defined (SCS_PE)  or Defined(SCS_PANDUIT)}
    //Tolik 21/01/2022 -- это здесь закомментил, чтобы при созании проекта пользователь видел свойства проекта, а не листа
      //GlobalPageControl.ActivePage := TabListProperties;
      GlobalPageControl.ActivePage := TabProjectProperties;
      pcProjectOptions.ActivePage := tsProjOptionsGeneral;
    //
      // pcProjectOptions.ActivePage := tsProjOptionsGeneral;
{$ELSE}
      GlobalPageControl.ActivePage := TabProjectProperties;
      pcProjectOptions.ActivePage := tsProjOptionsGeneral;
{$IFEND}
    end
    else
      GlobalPageControl.ActivePage := TabListProperties;
  except
    on E: Exception do
      AddExceptionToLogEx('TF_MasterNewList.FormModeAsProject', E.Message);
  end;
end;

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

function TF_MasterNewList.CreateSpravochniki: Boolean;

  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
  Result := false;
  try
    if (FProjectSpravochnikForm = nil) and (FListSpravochnikForm = nil) then
    begin
      Result := true;
      FProjectSpravochnikForm := TF_CaseForm.Create(F_ProjMan, F_ProjMan, Self,
        itProject);
      FListSpravochnikForm := TF_CaseForm.Create(F_ProjMan, F_ProjMan,
        Self, itList);

      SetFormToTabSheet(FProjectSpravochnikForm, tsProjectSpravochniki);

{$IF Not Defined(ES_GRAPH_SC)}
      SetFormToTabSheet(FListSpravochnikForm, tsListSpravochniki);
{$IFEND}
      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;

      // FProjectSpravochnikForm.GT_Interfaces.OnDblClick := FProjectSpravochnikForm.Act_EditExecute;
      // FListSpravochnikForm.GT_ComponentTypes.OnDblClick := FListSpravochnikForm.Act_EditExecute;
    end;
  except
    on E: Exception do
      AddExceptionToLogEx('TF_MasterNewList.CreateSpravochniki: ', E.Message);
  end;
end;

function TF_MasterNewList.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);
    // Tolik 14/11/2016 --
    // Result.Caption := Result.Name + ' ' + IntTostr(Result.MarkID);
    Result.Caption := Result.Name;
    if Result.IsIndexWithName = biTrue then
      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;
    Result.Settings.CADStampListSign := edStampListSign.Text;
    Result.Settings.CADStampMainEngineer := edStampMainEngineer.Text;
    Result.Settings.CADStampApproved := edStampApproved.Text;
    Result.Settings.CADStampDesignStage := edStampDesignStage.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.CADShowRaiseDrawFigure := cbShowRaiseDrawFigure.Checked;

    // Шаг трассы по умолчанию
    Result.Settings.CADBlockStep := StrToFloat_My(edBlockStep.Text);
    //Tolik 09/06/2021 --
    if edRoomHeight.Text = '' then
      edRoomHeight.Text := '0';
    //
    Result.Settings.HeightRoom :=
      UOMToMetre(StrToFloat_My(F_MasterNewList.edRoomHeight.Text));
    Result.Settings.HeightCeiling :=
      UOMToMetre(StrToFloat_My(F_MasterNewList.edFalseFloorHeight.Text));
    Result.Settings.HeightSocket :=
      UOMToMetre(StrToFloat_My(F_MasterNewList.edConnTotal.Text));
    Result.Settings.HeightCorob :=
      UOMToMetre(StrToFloat_My(F_MasterNewList.edLineTotal.Text));

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

    Result.Settings.CADFontName := F_MasterNewList.cbFontName.FontName;
    // Added by Tolik
    Result.Settings.CableSwervesMaxCount :=
      StrToInt(F_MasterNewList.edCableSwervesCount.Text);
    // кол-во поворотов кабеля
    Result.Settings.CableSwervesAngle :=
      StrToInt(F_MasterNewList.edCableSwervesMinAngle.Text);
    // минимально допустимый угол поворота кабеля
    // Tolik -- 16/09/2016 --
    Result.Settings.ShowRaiseHeights :=
      F_MasterNewList.cbShowRaiseHeights.Checked;
    // тип уголка по дефолту
    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.CADSaveUndoCount := StrToInt(edSaveUndoCount.Text);
    Result.Settings.CADAllowSuppliesKind := cbAllowSuppliesKind.Checked;

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

    // if rbNewTracesLengthAuto.Checked then
    // Result.Settings.CADNewTraceLengthType := Ord(tltAuto)
    // else if rbNewTracesLengthUser.Checked then
    // Result.Settings.CADNewTraceLengthType := Ord(tltUser);
    Result.Settings.CADNewTraceLengthType :=
      GetRadioGrpBoxIntVal(FArrNewTracesLengthRB, FArrNewTracesLengthVal,
      Ord(tltNone));

    // if FMakeEditMode = meMake then
    // SaveMaskTemplatesFromForm(F_ComponTypesMarkMask, FItemID, FItemType, false, true);
    // if FMakeEditMode = meEdit then
    // SaveMaskTemplatesFromForm(F_ComponTypesMarkMask, FItemID, FItemType, false, false);

    if ALoadSpravochnik then
      LoadFromFormToItemSpravochnik(FListSpravochnikForm, FItemID, FItemType,
        itList, cbApplyForAllSCSObjects.Checked, cbApplyForSelectedOnly.Checked,
        false, false, false, FMakeEditMode = meMake, [vkComponentType],
        @Result);
    { if FMakeEditMode = meMake then
      LoadFromFormToItemSpravochnik(FListSpravochnikForm, FItemID, FItemType,
      cbApplyForAllSCSObjects.Checked, cbApplyForSelectedOnly.Checked,
      cbReindexComponents.Checked, cbReindexInChangedTypes.Checked, true, [cdComponentType]);
      if FMakeEditMode = meEdit then
      LoadFromFormToItemSpravochnik(FListSpravochnikForm, FItemID, FItemType,
      cbApplyForAllSCSObjects.Checked, cbApplyForSelectedOnly.Checked,
      cbReindexComponents.Checked, cbReindexInChangedTypes.Checked, false, [cdComponentType]); }
  except
    on E: Exception do
      AddExceptionToLogEx('TF_MasterNewList.GetListParamsFromForm', E.Message);
  end;
end;

function TF_MasterNewList.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_MasterNewList.GetMarkModeFrom: TMarkMode;
begin
  Result := mmTemplate;
  if rbMarkByTemplate.Checked then
    Result := mmTemplate
  else if rbMarkByTIAEIA606A.Checked then
    Result := mmTIAEIA606A;
end;

function TF_MasterNewList.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 := true;

    // *** Валюты
    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
    else if rbIndexingModeTopCompon.Checked then
      Result.Setting.PointComplIndexingMode := pcimInTopCompon;
    // Способ индексации точечных компонент
    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;


    // *** Высота межэтажных перекрытий
    // Tolik 27/10/2020 -- GCurrProjUnitOfMeasure  еще не поменялся, а эта функция его юзает... получается х
    // Result.Setting.HeightThroughFloor := UOMToMetre(RoundCP(seHeightThroughFloor.Value));
    //

    // *** Добавлять нормы на компонент из интерфейсов
    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;
      Result.Setting.HeightThroughFloor :=
        UOMToMetre(RoundCP(seHeightThroughFloor.Value));
      ApplyUOMForProject(OldUOMValue, GCurrProjUnitOfMeasure);
      // если открыта форма Св-в обьектов - закрыть
      if F_SCSObjectsProp.Showing then
        F_SCSObjectsProp.Close;
      // обновить длины трасс
      UpdateAllTracesLengthOnAllLists;
    end
    // Tolik 27/10/2020 --
    else
      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));

    Result.Setting.DesignerInfo := edDesignerInfo.Text;
    Result.Setting.TagAdd := edTagAdd.Text;

    // описание работ
    FillChar(Result.Setting.JobInfo, 1000, #0);
    if (Length(edJobInfo.Text)) > 0 then
      Move(edJobInfo.Text[1], Result.Setting.JobInfo,
        Min(Length(edJobInfo.Text), 1000));
    FillChar(Result.Setting.CustomerInfo, 1000, #0);
    if (Length(edCustomerInfo.Text)) > 0 then
      Move(edCustomerInfo.Text[1], Result.Setting.CustomerInfo,
        Min(Length(edCustomerInfo.Text), 1000));
    FillChar(Result.Setting.ContractorInfo, 1000, #0);
    if (Length(edContractorInfo.Text)) > 0 then
      Move(edContractorInfo.Text[1], Result.Setting.ContractorInfo,
        Min(Length(edContractorInfo.Text), 1000));

    if ALoadSpravochnik then
      LoadFromFormToItemSpravochnik(FProjectSpravochnikForm, FItemID, FItemType,
        itProject, false, false, cbReindexComponents.Checked,
        cbReindexInChangedTypes.Checked, cbReindexAllPointComponents.Checked or
        FReindexPointCompons, FMakeEditMode = meMake, [vkAll], @Result);
    { if FMakeEditMode = meMake then
      LoadFromFormToItemSpravochnik(FProjectSpravochnikForm, FItemID, FItemType, false, false, false, false, true, [cdInterfaces]);
      if FMakeEditMode = meEdit then
      LoadFromFormToItemSpravochnik(FProjectSpravochnikForm, FItemID, FItemType, false, false, false, false, false, [cdInterfaces]); }

    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_MasterNewList.GetProjectParamsFromForm',
        E.Message);
  end;
end;

procedure TF_MasterNewList.SetProjCurrencyMToForm(AShowCurrencyM: Boolean);
var
  CurrencyM: TCurrency;
  // BookmarkStr: String;
  BookMark: TBookMark;
begin
  try
    ZeroMemory(@CurrencyM, SizeOf(TCurrency));
    // BookmarkStr := FProjectSpravochnikForm.mtCurrency.GetBookmarkStr;
    BookMark := FProjectSpravochnikForm.mtCurrency.GetBookmark;
    try
      if FProjectSpravochnikForm.mtCurrency.Active then
        if FProjectSpravochnikForm.mtCurrency.Locate(fnMain, ctMain, []) then
          CurrencyM := GetCurrencyFromMemTable
            (FProjectSpravochnikForm.mtCurrency);
    finally
      if Not AShowCurrencyM then
        // FProjectSpravochnikForm.mtCurrency.Bookmark := BookmarkStr
        if BookMark <> nil then
        begin
          // FProjectSpravochnikForm.mtCurrency.SetBookmarkStr( BookmarkStr);
          FProjectSpravochnikForm.mtCurrency.GotoBookMark(BookMark);
          FProjectSpravochnikForm.mtCurrency.FreeBookMark(BookMark);
        end;
    end;
    if CurrencyM.ID > 0 then
    begin
      SetProjCurrencyToForm(CurrencyM);
      FProjectCurrency := CurrencyM;
      if AShowCurrencyM then
      begin
        GlobalPageControl.ActivePage := tsProjectSpravochniki;
        FProjectSpravochnikForm.pcDirectories.ActivePage :=
          FProjectSpravochnikForm.tsCurrency;
        // FProjectSpravochnikForm.PrepareForm(vkCurrency, FProjectSpravochnikForm.FormMode);

        if FProjectSpravochnikForm.mtCurrency.RecordCount > 0 then
          if FProjectSpravochnikForm.Act_Edit.Enabled then
            FProjectSpravochnikForm.Act_Edit.Execute;
      end;
    end;
  except
    on E: Exception do
      AddExceptionToLogEx('TF_MasterNewList.SetProjCurrencyMToForm', E.Message);
  end;
end;

procedure TF_MasterNewList.SetProjCurrencyToForm(ACurrency: TCurrency;
  AReloadCombo: Boolean = true);
var
  CurrIdx: Integer;
begin
  try
    edCurrencyName.Text := ACurrency.Name;
    edCurrencyNameBrief.Text := ACurrency.NameBrief;
    // seCurrencyKolvo.Value := ProjectCurrency.Kolvo;
    // neCurrencyRatio.Value := ProjectCurrency.Ratio;

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

    // lbCurrencyAccordance.Caption := IntToStr(FNBCurrency.Kolvo)+FNBCurrency.NameBrief +' = '+
    // FloatToStr(GetPriceAfterChangeCurrency(FNBCurrency.Ratio, FNBCurrency, ACurrency))+ACurrency.NameBrief;

    // lbCurrencyAccordance.Caption := IntToStr(FProjectCurrency.Kolvo)+FProjectCurrency.NameBrief+
    // ' = '+FloatToStr(Round2(FProjectCurrency.Ratio))+FNBCurrency.NameBrief;

    if AReloadCombo then
    begin
      cbCurrency.Sorted := true;
      AddGUIDIDToStringsFromMT(cbCurrency.Items,
        FProjectSpravochnikForm.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_MasterNewList.SetProjCurrencyToForm', E.Message);
  end;
end;

procedure TF_MasterNewList.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_MasterNewList.SetProjCurrencyToFormByID',
        E.Message);
  end;
end;

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

    // FProjectParams.Setting.UnitOfMeasure
    if AFirstLoading then
      ListPageControl.ActivePageIndex := 0;

    // тип СКС //21.09.2010 перенесено из конца процедуры в начало, так как на событиях rbInternalSCSClick, происходит установка значений
    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;

    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;
    edStampListSign.Text := AListParams.Settings.CADStampListSign;
    edStampMainEngineer.Text := AListParams.Settings.CADStampMainEngineer;
    edStampApproved.Text := AListParams.Settings.CADStampApproved;
    edStampDesignStage.Text := AListParams.Settings.CADStampDesignStage;

    // 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;
    cbShowRaiseDrawFigure.Checked :=
      AListParams.Settings.CADShowRaiseDrawFigure;

    // Шаг трассы по умолчанию
    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;
    // added by Tolik
    edCableSwervesCount.Text :=
      IntTostr(AListParams.Settings.CableSwervesMaxCount);
    edCableSwervesMinAngle.Text :=
      IntTostr(AListParams.Settings.CableSwervesAngle);
    // Tolik -- 16/09/2016--
    cbShowRaiseHeights.Checked := AListParams.Settings.ShowRaiseHeights;
    //
    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);

    // 21.09.2010
    // тип СКС
    // 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;

    // SetValueToRzRadioButtonAsNoChange(rbNewTracesLengthAuto, false);
    // SetValueToRzRadioButtonAsNoChange(rbNewTracesLengthUser, false);
    // if AListParams.Settings.CADNewTraceLengthType = Ord(tltAuto) then
    // SetValueToRzRadioButtonAsNoChange(rbNewTracesLengthAuto, true)
    // else if AListParams.Settings.CADNewTraceLengthType = Ord(tltUser) then
    // SetValueToRzRadioButtonAsNoChange(rbNewTracesLengthUser, true);
    SetRadioGrpBoxIntVal(FArrNewTracesLengthRB, FArrNewTracesLengthVal,
      AListParams.Settings.CADNewTraceLengthType, true);

    if gbRulerModeMetric.Visible then
    begin
      //Tolik 23/11/2021 - -
      //edSizeAsMetric.Text := FormatFloat(ffMask,
      //  AListParams.Settings.CADRuleStep);
      {edSizeAsMetric.Text := FormatFloat('0.000000000',
        AListParams.Settings.CADRuleStep);}
      edSizeAsMetric.Text := FloatTostr(RoundN(AListParams.Settings.CADRuleStep, 9));
      //
      edSizeAllMetric.Text := FormatFloat(ffMask,
        AListParams.Settings.CADRuleAllSize);
    end
    else
    begin
    {
      edSizeAsWhitworth.Text := FormatFloat(ffMask,
        AListParams.Settings.CADRuleStep);
     }
     //Tolik 24/01/2022 -- на создании проекта формы еще нет, поэтому тут бьет АВ...(а на вызове свойств листа уже будет)
     //edSizeAsWhitworth.Text := FloatTostr(RoundN(GCadForm.PCad.MapScale,7));
     try
      if Assigned(GCadForm) then
         edSizeAsWhitworth.Text := FloatTostr(RoundN(GCadForm.PCad.MapScale,7)/12)
       else
         edSizeAsWhitworth.Text := FormatFloat(ffMask, AListParams.Settings.CADRuleStep);
     except
       on e: Exception do
         edSizeAsWhitworth.Text := FormatFloat(ffMask, AListParams.Settings.CADRuleStep);
     end;
     //
      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(FListSpravochnikForm, FItemID, FItemType,
          true, [vkComponentType]);
      if FMakeEditMode = meEdit then
        LoadFromItemSpravochnikToForm(FListSpravochnikForm, FItemID, FItemType,
          false, [vkComponentType]);
    end;
  except
    on E: Exception do
      AddExceptionToLogEx('TF_MasterNewList.SetListParamsToForm', E.Message);
  end;
end;

procedure TF_MasterNewList.SetNBCurrencyToForm;
var
  // BookmarkStr: String;
  BookMark: TBookMark;
begin
  try
    FNBCurrency := F_NormBase.DM.GetCurrencyByType(ctMain);
    if FNBCurrency.GUID <> '' then
    begin
      // BookmarkStr := FProjectSpravochnikForm.mtCurrency.GetBookmarkStr;
      BookMark := FProjectSpravochnikForm.mtCurrency.GetBookmark;

      if FProjectSpravochnikForm.mtCurrency.Active then
        if FProjectSpravochnikForm.mtCurrency.Locate(fnGuid,
          FNBCurrency.GUID, []) then
          FNBCurrency := GetCurrencyFromMemTable
            (FProjectSpravochnikForm.mtCurrency);

      // FProjectSpravochnikForm.mtCurrency.SetBookmarkStr( BookmarkStr);
      if BookMark <> nil then
      begin
        // FProjectSpravochnikForm.mtCurrency.SetBookmarkStr( BookmarkStr);
        FProjectSpravochnikForm.mtCurrency.GotoBookMark(BookMark);
        FProjectSpravochnikForm.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_MasterNewList.SetNBCurrencyToForm', E.Message);
  end;
end;

procedure TF_MasterNewList.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
    else if AProjectParams.Setting.PointComplIndexingMode = pcimInTopCompon then
      rbIndexingModeTopCompon.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;
    // added by Tolik
    // описание работ, реквизиты заказчика и подрядчика
    edJobInfo.Text := trim(AProjectParams.Setting.JobInfo);
    edCustomerInfo.Text := trim(AProjectParams.Setting.CustomerInfo);
    edContractorInfo.Text := trim(AProjectParams.Setting.ContractorInfo);
    edDesignerInfo.Text := AProjectParams.Setting.DesignerInfo;
    edTagAdd.Text := AProjectParams.Setting.TagAdd;
    // *** Добавлять нормы на компонент из интерфейсов
    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);

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

    // *** Параметры листа
    ListParams.MarkID := 0;
    ListParams.Name := '';
    ListParams.Settings := AProjectParams.DefListSetting;
    //Tolik 10/02/2022 --
    if (AProjectParams.Setting.UnitOfMeasure = umSm) or (AProjectParams.Setting.UnitOfMeasure = umM) then
    begin
      gbRulerModeMetric.Visible := true;
      gbRulerModeWhitworth.Visible := false;
    end
    else
    if (AProjectParams.Setting.UnitOfMeasure = umIn) or (AProjectParams.Setting.UnitOfMeasure = umFt) then
    begin
      gbRulerModeMetric.Visible := false;
      gbRulerModeWhitworth.Visible := true;
    end;
    //

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

    if AFirstLoading and Not FIsFromMaster then
    begin
      if FMakeEditMode = meMake then
        LoadFromItemSpravochnikToForm(FProjectSpravochnikForm, FItemID,
          FItemType, true, [vkAll]);
      if FMakeEditMode = meEdit then
        LoadFromItemSpravochnikToForm(FProjectSpravochnikForm, FItemID,
          FItemType, false, [vkAll]);
    end;
    // if Not FIsFromMaster  then
    begin
      SetNBCurrencyToForm;
      SetProjCurrencyMToForm(false);
    end;
    SetControlsByPointComponIndexingMode;
    SetControlsByProjType;
  except
    on E: Exception do
      AddExceptionToLogEx('TF_MasterNewList.SetProjectParamsToForm', E.Message);
  end;
end;

procedure TF_MasterNewList.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_MasterNewList.ShowListSpravochnik', E.Message);
  end;
end;

procedure TF_MasterNewList.ShowProjectSpravochnik(ASpravochnikKind: TViewKind;
  AGUIDToLocate: String);
begin
  try
    if (ASpravochnikKind <> vkNone) { and (AGUIDToLocate <> '') } 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_MasterNewList.ShowProjectSpravochnik', E.Message);
  end;
end;

procedure TF_MasterNewList.edConnRoomPropertiesChange(Sender: TObject);
var
  data: Double;
begin
  try
    //Tolik 09/06/2021 --
    if edRoomHeight.Text = '' then
      edRoomHeight.Text := '0';
    //
    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_MasterNewList.edConnRoomPropertiesChange',
        E.Message);
  end;
end;

procedure TF_MasterNewList.edConnFalseFloorPropertiesChange(Sender: TObject);
var
  data: Double;
begin
  try
    //Tolik 09/06/2021 --
    if edRoomHeight.Text = '' then
      edRoomHeight.Text := '0';
    //
    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_MasterNewList.edConnFalseFloorPropertiesChange',
        E.Message);
  end;
end;

procedure TF_MasterNewList.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_MasterNewList.edConnFloorPropertiesChange',
        E.Message);
  end;
end;

procedure TF_MasterNewList.edLineRoomPropertiesChange(Sender: TObject);
var
  data: Double;
begin
  try
    //Tolik 09/06/2021 --
    if edRoomHeight.Text = '' then
      edRoomHeight.Text := '0';
    //
    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_MasterNewList.edLineRoomPropertiesChange',
        E.Message);
  end;
end;

procedure TF_MasterNewList.edLineFalseFloorPropertiesChange(Sender: TObject);
var
  data: Double;
begin
  try
    //Tolik 09/06/2021 --
    if edRoomHeight.Text = '' then
      edRoomHeight.Text := '0';
    //
    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_MasterNewList.edLineFalseFloorPropertiesChange',
        E.Message);
  end;
end;

procedure TF_MasterNewList.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_MasterNewList.edLineFloorPropertiesChange',
        E.Message);
  end;
end;

procedure TF_MasterNewList.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_MasterNewList.edLineConnObjectsPropertiesChange',
        E.Message);
  end;
end;

procedure TF_MasterNewList.bListOKClick(Sender: TObject);
begin
  if F_MasterNewList.Tag = 1 then
  begin
  end;
end;

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

procedure TF_MasterNewList.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_MasterNewList.cbAllNetworksClick', E.Message);
  end;
end;

procedure TF_MasterNewList.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_MasterNewList.cbShowLinesCaptionsClick',
        E.Message);
  end;
end;

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

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

procedure TF_MasterNewList.FormCreate(Sender: TObject);
begin
  try
    // Tolik 01/11/2019 --
    seCurrIndex.Min := 1;
    seCurrIndex.Max := 1000;
    seProjectIndex.Min := 1;
    seProjectIndex.Max := 10000000;
    seAutoSaveProjectMinutes.Min := 1;
    seAutoSaveProjectMinutes.Max := 10000;
    seNBCurrencyKolvo.Min := 0;
    seNBCurrencyKolvo.Max := 10000000;
    seHeightThroughFloor.Min := 0;
    seHeightThroughFloor.Max := 10000;
    //
    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)}
    Label25.Top := edCableChannelFullnessKoef.Top + 4;
    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)]);
    // FArrNewTracesLengthRB := [rbNewTracesLengthAuto, rbNewTracesLengthUser];
    // FArrNewTracesLengthVal := (Ord(tltAuto), Ord(tltUser));
  except
    on E: Exception do
      AddExceptionToLogEx('TF_MasterNewList.FormCreate', E.Message);
  end;

  if GReadOnlyMode then
  begin
    bOK.Enabled := false;
    bMaster.Enabled := false;
    // bOk.Visible := False;
    // bMaster.Visible := False;
  end;
end;

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

  // FreeAndNil(FComponTypesMarkMask);
end;

procedure TF_MasterNewList.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
    // 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;
    //

    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
    begin
      if not GProjectChanged then // Tolik 28/08/2019 --
        SetProjectChanged(true);
    end;
    if F_MasterNewList.Tag = 1 then
    begin
    end;
    GIfMasterUsed := false;
  except
    on E: Exception do
      AddExceptionToLogEx('TF_MasterNewList.bOKClick', E.Message);
  end;
end;

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

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

function TF_MasterNewList.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
  Result := false;
  try
    CreateSpravochniki;
    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;

      case AMakeEdit of
        meMake:
          begin
            Caption := cMasterNewList_Mes2;
            // FProjectParams := GetProjectParamsForNew(true);
          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);

{$IF Not Defined(ES_GRAPH_SC)}
      bMaster.Visible := ASpravochnikKind = vkNone;
{$IFEND}
      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_MasterNewListLite.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_MasterNewList.MakeEditProject', E.Message);
  end;
end;

function TF_MasterNewList.ChangeListParams(AMakeEdit: TMakeEdit;
  var AListParams: TListParams; AShowForm: Boolean; { aCADParams: TCADParams }
  ASpravochnikKind: TViewKind = vkNone; AGUIDToLocate: String = '';
  AIsFromMaster: Boolean = false; AParentCADParams: PCADParams = nil): Boolean;
var xAction: TUndoAction; // Tolik 03/06/2021 --
begin
  Result := false;
  try
    try
      CreateSpravochniki;

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

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

      case AMakeEdit of
        meMake:
          begin
            Caption := cMasterNewList_Mes4;
          end;
        meEdit:
          begin
            Caption := cMasterNewList_Mes5;
            // ListParams := GetListParamsFromForm;
          end;
      end;
      FItemType := itList;
      FListID := AListParams.ID;
      FItemID := AListParams.ID;
      FListParams := AListParams;
      FProjectParams := GetCurrProjectParams;
      //Tolik 09/02/2022 -- выставить линейку
      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;

      //FListParams.Settings.CADRuleStep := GetRuleStep(false); // Tolik 10/02/2022 --
      //
      FormAsList(true);
      SetListParamsToForm(FListParams);

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

{$IF Not Defined(ES_GRAPH_SC)}
      bMaster.Visible := ASpravochnikKind = vkNone;
{$IFEND}
      // if (AShowForm) or ((AShowForm = false) and (ShowModal = mrOK)) then
      if AShowForm then
      begin
        // !!!
        if AListParams.Settings.ListType = lt_Normal then
        begin
          ListPageControl.Pages[0].TabVisible := true;
          ListPageControl.Pages[2].TabVisible := true;
{$IF Not Defined(ES_GRAPH_SC)}
          ListPageControl.Pages[3].TabVisible := true;
          ListPageControl.Pages[4].TabVisible := true;
{$IFEND}
          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 and
            Not GAllowExternalListCoordZ 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
        else
        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
        else
        //Tolik 04/06/2021 --
        //if AListParams.Settings.ListType = lt_DesignBox then
        if (AListParams.Settings.ListType = lt_DesignBox) or (AListParams.Settings.ListType = lt_ElScheme) or
           (AListParams.Settings.ListType = lt_AScheme) 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
                // Tolik 03/06/2021 --
                // GCadForm.SaveForUndo(uat_None, True, False);
                //GCadForm.SaveForUndo(uat_None, true, false, 0, true);
                //if GCadForm.FListType = lt_ElScheme then
                if ((GCadForm.FListType = lt_ElScheme) or (GCadForm.FListType = lt_AScheme)) then // Tolik 06/02/2023 --
                begin
                  GCadForm.SaveForUndo(uat_None, true, false, 0, true);
                  xAction := TUndoAction.Create(uaList);
                  GCadForm.PCad.InsertUndoAction(xAction);
                end
                else
                if GCadForm.FListType = lt_DesignBox then
                begin
                  GCadForm.SaveForUndo(uat_None, true, false, 0, true);
                  xAction := TUndoAction.Create(uaDesignList);
                  GCadForm.PCad.InsertUndoAction(xAction);
                end
                else
                if GCadForm.FListType = lt_ProjectPlan then
                begin
                  GCadForm.SaveForUndo(uat_None, true, false, 0, true);
                  xAction := TUndoAction.Create(uaProjectPlan);
                  GCadForm.PCad.InsertUndoAction(xAction);
                end
                else
                  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_MasterNewListLite.ChangeListParams(AMakeEdit, AListParams,
            AShowForm { , CADParams } , ASpravochnikKind, AGUIDToLocate, true,
            @FCADParams);
        end;
      end;
      if Not AShowForm then
        Result := true;
    except
      on E: Exception do
        AddExceptionToLogEx('TF_MasterNewList.ChangeListParams', E.Message);
    end;
  finally
    FormAsList(false);
  end;
end;

procedure TF_MasterNewList.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;
{$IF Not Defined(ES_GRAPH_SC)}
          ListPageControl.Pages[3].TabVisible := true;
          ListPageControl.Pages[4].TabVisible := true;
{$IFEND}
          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_MasterNewList.GlobalPageControlTabClick',
        E.Message);
  end;
end;

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

procedure TF_MasterNewList.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_MasterNewList.SetParamsOnLineTracingType',
        E.Message);
  end;
end;

procedure TF_MasterNewList.edConnFloorExit(Sender: TObject);
var
  val: Double;
  ValRoom: Double;
  CheckValue: Double;
begin
  try
    if edConnFloor.Text = '' then
      edConnFloor.Text := '0';
    val := StrToFloat_My(edConnFloor.Text);
    //Tolik 09/06/2021 --
    if edRoomHeight.Text = '' then
      edRoomHeight.Text := '0';
    //
    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_MasterNewList.edConnFloorExit', E.Message);
  end;
end;

procedure TF_MasterNewList.edLineCeilingExit(Sender: TObject);
var
  val: Double;
  ValRoom: Double;
  CheckValue: Double;
begin
  try
    if edLineCeiling.Text = '' then
      edLineCeiling.Text := '0';
    val := StrToFloat_My(edLineCeiling.Text);
    //Tolik 09/06/2021 --
    if edRoomHeight.Text = '' then
      edRoomHeight.Text := '0';
    //
    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_MasterNewList.edLineCeilingExit', E.Message);
  end;
end;

procedure TF_MasterNewList.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);
    //Tolik 09/06/2021 --
    if edRoomHeight.Text = '' then
      edRoomHeight.Text := '0';
    //
    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_MasterNewList.edLineFalseFloorExit', E.Message);
  end;
end;

procedure TF_MasterNewList.edLineFloorExit(Sender: TObject);
var
  val: Double;
  ValRoom: Double;
  CheckValue: Double;
begin
  try
    if edLineFloor.Text = '' then
      edLineFloor.Text := '0';
    val := StrToFloat_My(edLineFloor.Text);
    //Tolik 09/06/2021 --
    if edRoomHeight.Text = '' then
      edRoomHeight.Text := '0';
    //
    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_MasterNewList.edLineFloorExit', E.Message);
  end;
end;

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

procedure TF_MasterNewList.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_MasterNewList.edRoomHeightExit', E.Message);
  end;
end;

procedure TF_MasterNewList.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);
    //Tolik 09/06/2021 --
    if edRoomHeight.Text = '' then
      edRoomHeight.Text := '0';
    //
    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_MasterNewList.edFalseFloorHeightExit', E.Message);
  end;
end;

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

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

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

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

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

procedure TF_MasterNewList.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);
    //Tolik 09/06/2021 --
    if edRoomHeight.Text = '' then
      edRoomHeight.Text := '0';
    //
    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_MasterNewList.edLineConnObjectsExit', E.Message);
  end;
end;

procedure TF_MasterNewList.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_MasterNewList.edStepGridExit', E.Message);
  end;
end;

procedure TF_MasterNewList.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_MasterNewList.edTraceWidthExit', E.Message);
  end;
end;

procedure TF_MasterNewList.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_MasterNewList.edBlockStepExit', E.Message);
  end;
end;

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

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

procedure TF_MasterNewList.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_MasterNewList.cbTraceStylePropertiesCloseUp',
        E.Message);
  end;
end;

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

procedure TF_MasterNewList.ListPageControlChange(Sender: TObject);
begin
  try
    if Visible then
    begin
{$IF Not Defined(ES_GRAPH_SC)}
      if ListPageControl.ActivePage = TabAll then
        edRoomHeight.SetFocus;
      if ListPageControl.ActivePage = TabPageParams then
        edStepGrid.SetFocus;
      if ListPageControl.ActivePage = TabCAD then
        edNotePrefix.SetFocus;
      if ListPageControl.ActivePage = TabPM then
        cbGroupObjectsByType.SetFocus;
      if ListPageControl.ActivePage = TabLinesTypes then
        cbKeepLineTypesRules.SetFocus;
      if ListPageControl.ActivePage = tsListSpravochniki then
        tsListSpravochniki.SetFocus;
{$IFEND}
    end;
  except
    on E: Exception do
      AddExceptionToLogEx('TF_MasterNewList.ListPageControlChange', E.Message);
  end;
end;

procedure TF_MasterNewList.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_MasterNewList.GlobalPageControlChange',
        E.Message);
  end;
end;

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

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

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

procedure TF_MasterNewList.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_MasterNewList.seIndexPointObjExit', E.Message);
  end;
end;

procedure TF_MasterNewList.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_MasterNewList.seIndexConnectorExit', E.Message);
  end;
end;

procedure TF_MasterNewList.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_MasterNewList.seIndexLineExit', E.Message);
  end;
end;

procedure TF_MasterNewList.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;
    cbCADCaptionsExternalSCS.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;

    rbNewTracesLengthAuto.Font.Color := clBlack;
    rbNewTracesLengthUser.Font.Color := clBlack;

    if FParentCADParams <> nil then
    begin
      //Tolik 09/06/2021 --
      if edRoomHeight.Text = '' then
        edRoomHeight.Text := '0';
      //
      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;

      if cbTraceColor.ColorValue <> FCADParams.CADTraceColor then
        cbTraceColor.Style.Color := clBlue;
      if cbTraceStyle.ItemIndex <> Ord(FCADParams.CADTraceStyle) then
        cbTraceStyle.Style.Color := clBlue;
      if edStepGrid.Text <> FloatToStr(FCADParams.CADGridStep) then
        edStepGrid.Style.Font.Color := clBlue;
      if edStepGrid.Text <> FloatToStr(FCADParams.CADBlockStep) then
        edBlockStep.Style.Font.Color := clBlue;

      if cbCADCaptions_Short.Checked and
        (FCADParams.CADObjectCaptions <> st_Short) then
        cbCADCaptions_Short.Font.Color := clBlue;
      if cbCADCaptions_Full.Checked and
        (FCADParams.CADObjectCaptions <> st_Full) then
        cbCADCaptions_Full.Font.Color := clBlue;

      if cbCADCaptionsDetail.Checked and
        (FCADParams.CADLinesCaptions <> skDetail) then
        cbCADCaptionsDetail.Font.Color := clBlue;
      if cbCADCaptionsSimple.Checked and
        (FCADParams.CADLinesCaptions <> skSimple) then
        cbCADCaptionsSimple.Font.Color := clBlue;
      if cbCADCaptionsExternalSCS.Checked and
        (FCADParams.CADLinesCaptions <> skExternalSCS) then
        cbCADCaptionsExternalSCS.Font.Color := clBlue;

      if cbCADNotes_Short.Checked and
        (FCADParams.CADObjectNotes <> st_Short) then
        cbCADNotes_Short.Font.Color := clBlue;
      if cbCADNotes_Full.Checked and (FCADParams.CADObjectNotes <> st_Full) then
        cbCADNotes_Full.Font.Color := clBlue;

      if cbCADNotesDetail.Checked and
        (FCADParams.CADLinesNotes <> skDetail) then
        cbCADNotesDetail.Font.Color := clBlue;
      if cbCADNotesSimple.Checked and
        (FCADParams.CADLinesNotes <> skSimple) then
        cbCADNotesSimple.Font.Color := clBlue;

      if edNotePrefix.Text <> FCADParams.CADNotePrefix then
        edNotePrefix.Style.Font.Color := clBlue;

      if (cbShowLinesCaptions.State <> cbGrayed) and
        (cbShowLinesCaptions.Checked <>
        FCADParams.CADShowLineObjectCaption) then
        cbShowLinesCaptions.Font.Color := clBlue;
      if not cbShowLinesLength.Enabled and
        (cbShowLinesLength.Checked <> FCADParams.CADShowLineObjectLength) then
        cbShowLinesLength.Font.Color := clBlue;

      if (cbShowLinesNotes.State <> cbGrayed) and
        (cbShowLinesNotes.Checked <> FCADParams.CADShowLineObjectNote) then
        cbShowLinesNotes.Font.Color := clBlue;
      if (cbShowConnectorsCaptions.State <> cbGrayed) and
        (cbShowConnectorsCaptions.Checked <>
        FCADParams.CADShowConnObjectCaption) then
        cbShowConnectorsCaptions.Font.Color := clBlue;
      if (cbShowConnectorsNotes.State <> cbGrayed) and
        (cbShowConnectorsNotes.Checked <> FCADParams.CADShowConnObjectNote) then
        cbShowConnectorsNotes.Font.Color := clBlue;

      if cbShowRaise.Checked <> FCADParams.CADShowRaise then
        cbShowRaise.Font.Color := clBlue;
      if cbPutCableOnTrace.Checked <> FCADParams.CADPutCableInTrace then
        cbPutCableOnTrace.Font.Color := clBlue;

      if cbLinesCaptionsColor.ColorValue <>
        FCADParams.CADLinesCaptionsColor then
        cbLinesCaptionsColor.Style.Color := clBlue;
      if cbConnectorsCaptionsColor.ColorValue <>
        FCADParams.CADConnectorsCaptionsColor then
        cbConnectorsCaptionsColor.Style.Color := clBlue;
      if cbLinesNotesColor.ColorValue <> FCADParams.CADLinesNotesColor then
        cbLinesNotesColor.Style.Color := clBlue;
      if cbConnectorsNotesColor.ColorValue = FCADParams.
        CADConnectorsNotesColor then
        cbConnectorsNotesColor.Style.Color := clBlue;

      if cbLinesCaptionsFontSize.Text <>
        IntTostr(FCADParams.CADLinesCaptionsFontSize) then
        cbLinesCaptionsFontSize.Font.Color := clBlue;

      if cbConnectorsCaptionsFontSize.Text <>
        IntTostr(FCADParams.CADConnectorsCaptionsFontSize) then
        cbConnectorsCaptionsFontSize.Font.Color := clBlue;
      if cbLinesNotesFontSize.Text <>
        IntTostr(FCADParams.CADLinesNotesFontSize) then
        cbLinesNotesFontSize.Font.Color := clBlue;
      if cbConnectorsNotesFontSize.Text <>
        IntTostr(FCADParams.CADConnectorsNotesFontSize) then
        cbConnectorsNotesFontSize.Font.Color := clBlue;
      if cbCrossATSFontSize.Text <>
        IntTostr(FCADParams.CADCrossATSFontSize) then
        cbCrossATSFontSize.Font.Color := clBlue;
      if cbDistribCabFontSize.Text <>
        IntTostr(FCADParams.CADDistribCabFontSize) then
        cbDistribCabFontSize.Font.Color := clBlue;

      if cbLinesCaptionsFontBold.Checked <>
        FCADParams.CADLinesCaptionsFontBold then
        cbLinesCaptionsFontBold.Font.Color := clBlue;
      if cbCrossATSFontBold.Checked <> FCADParams.CADCrossATSFontBold then
        cbCrossATSFontBold.Font.Color := clBlue;
      if cbDistribCabFontBold.Checked <> FCADParams.CADDistribCabFontBold then
        cbDistribCabFontBold.Font.Color := clBlue;

      if rbInternalSCS.Checked and (FCADParams.SCSType <> st_Internal) then
        rbInternalSCS.Font.Color := clBlue;
      if rbExternalSCS.Checked and (FCADParams.SCSType <> st_External) then
        rbInternalSCS.Font.Color := clBlue;

      if edTraceStepRotate.Text <> IntTostr(FCADParams.CADTraceStepRotate) then
        edTraceStepRotate.Style.Font.Color := clBlue;
      if cbAutoCadMouse.Checked <> FCADParams.AutoCadMouse then
        cbAutoCadMouse.Font.Color := clBlue;
      if cbScaleByCursor.Checked <> FCADParams.ScaleByCursor then
        cbScaleByCursor.Font.Color := clBlue;
      if cbAutoPosTraceBetweenRM.Checked <>
        FCADParams.AutoPosTraceBetweenRM then
        cbAutoPosTraceBetweenRM.Font.Color := clBlue;

      if edSaveUndoCount.Text <> IntTostr(FCADParams.CADSaveUndoCount) then
        edSaveUndoCount.Style.Font.Color := clBlue;
      if cbAllowSuppliesKind.Checked <> FCADParams.CADAllowSuppliesKind then
        cbAllowSuppliesKind.Font.Color := clBlue;

      DefineStyleRBNewTracesLengthType(nil);
      SetCheckBoxStyleByVal(cbShowRaiseDrawFigure,
        FCADParams.CADShowRaiseDrawFigure);
    end;
  except
    on E: Exception do
      AddExceptionToLogEx('TF_MasterNewList.ClearAllChangedColor', E.Message);
  end;
end;

procedure TF_MasterNewList.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_MasterNewList.edWidthExit', E.Message);
  end;
end;

procedure TF_MasterNewList.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_MasterNewList.edHeightExit', E.Message);
  end;
end;

procedure TF_MasterNewList.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_MasterNewList.cbFontNameCloseUp', E.Message);
  end;
end;

procedure TF_MasterNewList.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;
  except
    on E: Exception do
      AddExceptionToLogEx('TF_MasterNewList.rbSimpleClick', E.Message);
  end;
end;

procedure TF_MasterNewList.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;
  except
    on E: Exception do
      AddExceptionToLogEx('TF_MasterNewList.rbExtendedClick', E.Message);
  end;
end;

procedure TF_MasterNewList.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;
  except
    on E: Exception do
      AddExceptionToLogEx('TF_MasterNewList.rbDetailedClick', E.Message);
  end;
end;

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

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

procedure TF_MasterNewList.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_MasterNewList.rbUkrDSTUClick), E.Message);
  end;
end;

function TF_MasterNewList.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;
        //Tolik 10/02/2022 --
        //Result := StrToFloatDef_My(edSizeAsMetric.Text, 1) * KoefAs;
        Result := FListParams.Settings.CadRuleStep*100;
        //
      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;
        // 21.09.2010 GCadForm.PCad.WorkWidth / 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;
        //Tolik 10/02/2022 --
        //Result := StrToFloatDef_My(edSizeAsWhitworth.Text, 1) * KoefAs;
        Result := FListParams.Settings.CadRuleStep * 12;
        //
      end;
      // для отображения общей длинны на странице
      if rbin2.Checked then
        KoefAll := 12;
      if rbft2.Checked then
        KoefAll := 1;
      if (rbin2.Checked) Or (rbft2.Checked) then
      begin
        // 21.09.2010
        // 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_MasterNewList.CheckMapScaleResult', E.Message);
  end;
end;

function TF_MasterNewList.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_MasterNewList.GetRuleStep', E.Message);
  end;
end;

function TF_MasterNewList.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_MasterNewList.GetRuleAllSize', E.Message);
  end;
end;

procedure TF_MasterNewList.rbmm1Click(Sender: TObject);
var
  CheckValue: Double;
begin
  try
    FListParams.Settings.CADRuleStep := GetRuleStep(false);//Tolik 10/02/2022 --
    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_MasterNewList.rbmm1Click', E.Message);
  end;
end;

procedure TF_MasterNewList.rbsm1Click(Sender: TObject);
var
  CheckValue: Double;
begin
  try
    FListParams.Settings.CADRuleStep := GetRuleStep(false);//Tolik 10/02/2022 --
    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_MasterNewList.rbsm1Click', E.Message);
  end;
end;

procedure TF_MasterNewList.rbm1Click(Sender: TObject);
var
  CheckValue: Double;
begin
  try
    FListParams.Settings.CADRuleStep := GetRuleStep(false);//Tolik 10/02/2022 --
    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_MasterNewList.rbm1Click', E.Message);
  end;
end;

procedure TF_MasterNewList.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_MasterNewList.rbmm2Click', E.Message);
  end;
end;

procedure TF_MasterNewList.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_MasterNewList.rbsm2Click', E.Message);
  end;
end;

procedure TF_MasterNewList.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_MasterNewList.rbm2Click', E.Message);
  end;
end;

procedure TF_MasterNewList.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_MasterNewList.cbTraceColorPropertiesCloseUp',
        E.Message);
  end;
end;

procedure TF_MasterNewList.edSizeAsMetricExit(Sender: TObject);
var
  CheckValue: Double;
begin
  try
    FListParams.Settings.CADRuleStep := GetRuleStep(false);//Tolik 10/02/2022 --
    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_MasterNewList.edSizeAsExit', E.Message);
  end;
end;

procedure TF_MasterNewList.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_MasterNewList.edSizeAllExit', E.Message);
  end;
end;

procedure TF_MasterNewList.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_MasterNewList.cbCADCaptions_ShortClick',
        E.Message);
  end;
end;

procedure TF_MasterNewList.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_MasterNewList.cbCADCaptions_FullClick',
        E.Message);
  end;
end;

procedure TF_MasterNewList.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;
    {
      rbLineFloorClick(Sender);
      edLineFloor.Text := FloatToStr(FListParams.Settings.HeightCorob);
      edLineFloorExit(Sender);
      rbConnFloorClick(Sender);
      edConnFloor.Text := FloatToStr(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;
  except
    on E: Exception do
      AddExceptionToLogEx('TF_MasterNewList.cbCADCaptionsDetailClick',
        E.Message);
  end;
end;

procedure TF_MasterNewList.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;
    {
      rbLineFloorClick(Sender);
      edLineFloor.Text := FloatToStr(FListParams.Settings.HeightCorob);
      edLineFloorExit(Sender);
      rbConnFloorClick(Sender);
      edConnFloor.Text := FloatToStr(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;
  except
    on E: Exception do
      AddExceptionToLogEx('TF_MasterNewList.cbCADCaptionsSimpleClick',
        E.Message);
  end;
end;

procedure TF_MasterNewList.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_MasterNewList.cbCADNotes_ShortClick', E.Message);
  end;
end;

procedure TF_MasterNewList.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_MasterNewList.cbCADNotes_FullClick', E.Message);
  end;
end;

procedure TF_MasterNewList.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_MasterNewList.cbCADNotesDetailClick', E.Message);
  end;
end;

procedure TF_MasterNewList.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_MasterNewList.cbCADNotesSimpleClick', E.Message);
  end;
end;

procedure TF_MasterNewList.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_MasterNewList.edNotePrefixExit', E.Message);
  end;
end;

procedure TF_MasterNewList.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_MasterNewList.cbShowLinesLengthClick', E.Message);
  end;
end;

procedure TF_MasterNewList.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_MasterNewList.cbShowLinesNotesClick', E.Message);
  end;
end;

procedure TF_MasterNewList.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_MasterNewList.cbShowConnectorsCaptionsClick',
        E.Message);
  end;
end;
//Tolik 03/02/2022 -- для Игоря, чтобы выставить дефолтный
procedure TF_MasterNewList.cbShowConnectorsCaptionsMouseUp(Sender: TObject;
  Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
begin
  if Button = mbRight then
    cbConnectorsCaptionsColor.ColorValue :=  $00E8731A;
end;
//

procedure TF_MasterNewList.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_MasterNewList.cbShowConnectorsNotesClick',
        E.Message);
  end;
end;

procedure TF_MasterNewList.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_MasterNewList.cbShowRaiseClick', E.Message);
  end;
end;

procedure TF_MasterNewList.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_MasterNewList.cbPutCableOnTraceClick', E.Message);
  end;
end;

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

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

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

procedure TF_MasterNewList.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;
    {
      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;
  except
    on E: Exception do
      AddExceptionToLogEx('TF_MasterNewList.cbCADCaptionsExternalSCSClick',
        E.Message);
  end;
end;

procedure TF_MasterNewList.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_MasterNewList.cbLinesCaptionsColorPropertiesCloseUp', E.Message);
  end;
end;

procedure TF_MasterNewList.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_MasterNewList.cbConnectorsCaptionsColorPropertiesCloseUp',
        E.Message);
  end;
end;

procedure TF_MasterNewList.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_MasterNewList.cbLinesNotesColorPropertiesCloseUp',
        E.Message);
  end;
end;

procedure TF_MasterNewList.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_MasterNewList.cbConnectorsNotesColorPropertiesCloseUp', E.Message);
  end;
end;

procedure TF_MasterNewList.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_MasterNewList.cbLinesNotesFontSizeCloseUp',
        E.Message);
  end;
end;

procedure TF_MasterNewList.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_MasterNewList.cbConnectorsNotesFontSizeCloseUp',
        E.Message);
  end;
end;

procedure TF_MasterNewList.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_MasterNewList.cbLinesCaptionsFontSizeCloseUp',
        E.Message);
  end;
end;

procedure TF_MasterNewList.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_MasterNewList.cbConnectorsCaptionsFontSizeCloseUp', E.Message);
  end;
end;

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

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

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

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

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

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

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

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

procedure TF_MasterNewList.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_MasterNewList.cbLinesCaptionsFontBoldClick',
        E.Message);
  end;
end;

procedure TF_MasterNewList.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_MasterNewList.cbCrossATSFontBoldClick',
        E.Message);
  end;
end;

procedure TF_MasterNewList.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_MasterNewList.cbDistribCabFontBoldClick',
        E.Message);
  end;
end;

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

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

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

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

procedure TF_MasterNewList.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_MasterNewList.cbCrossATSFontSizeCloseUp',
        E.Message);
  end;
end;

procedure TF_MasterNewList.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_MasterNewList.cbDistribCabFontSizeCloseUp',
        E.Message);
  end;
end;

procedure TF_MasterNewList.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_MasterNewList.cbBlackPrintClick', E.Message);
  end;
end;

procedure TF_MasterNewList.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_MasterNewList.cbColorPrintClick', E.Message);
  end;
end;

procedure TF_MasterNewList.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]';

    if Not FNewTracesLengthTypeChanged then
    begin
      SetValueToRzRadioButtonAsNoChange(rbNewTracesLengthAuto, true);
      DefineStyleRBNewTracesLengthType(rbNewTracesLengthAuto);
    end;
  except
    on E: Exception do
      AddExceptionToLogEx('TF_MasterNewList.rbInternalSCSClick', E.Message);
  end;
end;

procedure TF_MasterNewList.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 := GAllowExternalListCoordZ; // 22.08.2012 False;
    edConnFloor.Enabled := GAllowExternalListCoordZ; // 22.08.2012 False;

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

    cbAutoApplyHeights.Enabled := GAllowExternalListCoordZ; // 22.08.2012 False;

    gbGridStep.Caption := cMasterNewList_Mes13;
    edStepGrid.Text := '1';
    edStepGrid.Properties.EditMask := '[0],[1-9]|[1],[0]';

    if Not FNewTracesLengthTypeChanged then
    begin
      SetValueToRzRadioButtonAsNoChange(rbNewTracesLengthUser, true);
      DefineStyleRBNewTracesLengthType(rbNewTracesLengthUser);
    end;
  except
    on E: Exception do
      AddExceptionToLogEx('TF_MasterNewList.rbExternalSCSClick', E.Message);
  end;
end;

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

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

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

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

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

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

function TF_MasterNewList.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_MasterNewList.EnableLoadDefSettings', E.Message);
  end;
end;

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

procedure TF_MasterNewList.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_MasterNewList.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_MasterNewList.SetControlsByRoomNameShortSrcType;
begin
  edRoomNameShortDefault.Enabled := rbRoomNameShortFromDefStr.Checked;
end;

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

procedure TF_MasterNewList.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_MasterNewList.lbSaveDefSettingsClick', E.Message);
  end;
end;

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

      {
        if Not FileExists(GetPathToDefListSettings) then
        begin
        OldDefListParams := GetListParamsForNewList;
        OldDefListParams.Settings := GetDefaultListSettings;
        SetListParamsToForm(OldDefListParams, false);
        end; }
    end;

    if FItemType = itProject then
    begin
      if FileExists(GetPathToDefProjSettings) then
        DeleteFile(GetPathToDefProjSettings);
      {
        if Not FileExists(GetPathToDefProjSettings) then
        begin
        OldDefProjParams := GetProjectParamsForNew(false);
        SetProjectParamsToForm(OldDefProjParams, false);
        end; }
    end;

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

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

procedure TF_MasterNewList.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_MasterNewList.edTraceStepRotateExit', E.Message);
  end;
end;

procedure TF_MasterNewList.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_MasterNewList.edTraceStepRotatePropertiesChange',
        E.Message);
  end;
end;

procedure TF_MasterNewList.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_MasterNewList.cbAutoCadMouseClick', E.Message);
  end;
end;

procedure TF_MasterNewList.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_MasterNewList.cbScaleByCursorClick', E.Message);
  end;
end;

procedure TF_MasterNewList.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_MasterNewList.cbAutoPosTraceBetweenRMClick',
        E.Message);
  end;
end;

procedure TF_MasterNewList.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 F_MasterNewList.Tag = 1 then
    begin
      CheckPageSizeIndex := cbPageSize.ItemIndex;
      CheckListCountX := StrToInt(edListCountX.Text);
      CheckListCountY := StrToInt(edListCountY.Text);
      if rbPortrait.Checked then
        CheckPageOrient := poPortrait
      else
        CheckPageOrient := poLandscape;
      if (CheckPageSizeIndex = FCADParams.CADPageSizeIndex) and
        (CheckListCountX = FCADParams.CADListCountX) and
        (CheckListCountY = FCADParams.CADListCountY) and
        (CheckPageOrient = FCADParams.CADPageOrient) then
      begin
        cbRescaleDrawing.Enabled := false;
        cbRescaleDrawing.Checked := false;
      end
      else if (GCadForm.FListType = lt_Normal) then
      begin
        cbRescaleDrawing.Enabled := true;
        cbRescaleDrawing.Checked := false;
      end;
    end;
  except
    on E: Exception do
      AddExceptionToLogEx('TF_MasterNewList.edListCountXPropertiesChange',
        E.Message);
  end;
end;

procedure TF_MasterNewList.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 F_MasterNewList.Tag = 1 then
    begin
      CheckPageSizeIndex := cbPageSize.ItemIndex;
      CheckListCountX := StrToInt(edListCountX.Text);
      CheckListCountY := StrToInt(edListCountY.Text);
      if rbPortrait.Checked then
        CheckPageOrient := poPortrait
      else
        CheckPageOrient := poLandscape;
      if (CheckPageSizeIndex = FCADParams.CADPageSizeIndex) and
        (CheckListCountX = FCADParams.CADListCountX) and
        (CheckListCountY = FCADParams.CADListCountY) and
        (CheckPageOrient = FCADParams.CADPageOrient) then
      begin
        cbRescaleDrawing.Enabled := false;
        cbRescaleDrawing.Checked := false;
      end
      else if (GCadForm.FListType = lt_Normal) then
      begin
        cbRescaleDrawing.Enabled := true;
        cbRescaleDrawing.Checked := false;
      end;
    end;
  except
    on E: Exception do
      AddExceptionToLogEx('TF_MasterNewList.edListCountYPropertiesChange',
        E.Message);
  end;
end;

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

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

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

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

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

procedure TF_MasterNewList.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 := GetProjectParamsFromForm(false);
          // 21.09.2010 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;

                // OldStream := TStream(StreamList.Streams[IndexOfListSettings]);
                // FreeAndNil(OldStream);

                // *** Старый стрим чиститься автоматом, из-за параметра 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_MasterNewList.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_MasterNewList.pmiLoadSettingsFromFileClick(Sender: TObject);
var
  OpenDialog: TOpenDialog;
  StreamList: TStreamList;

  NewProjParams: TProjectParams;
  NewListParams: TListParams;

  i: Integer;
  CurrStream: TMemoryStream;
  ReadSize: Integer;
begin
  // 21.09.2010 Test
  // StreamList := TStreamList.Create(fcSCSProjSettings, true);
  //
  // NewProjParams := GetCurrProjectParams;
  // NewListParams := GetListParamsFromForm(false);
  //
  // CurrStream := TMemoryStream.Create;
  // // Write
  // CurrStream.WriteBuffer(NewProjParams.Setting, SizeOf(NewProjParams.Setting));
  // CurrStream.Position := 0;
  // StreamList.Add(CurrStream, fscSCSProjSettingsProj);
  // CurrStream := TMemoryStream.Create;
  // CurrStream.WriteBuffer(NewListParams.Settings, SizeOf(NewListParams.Settings));
  // CurrStream.Position := 0;
  // StreamList.Add(CurrStream, fscSCSProjSettingsList);
  //
  // StreamList.SaveToFile('c:\temp\proj_settings.tmp');
  // StreamList.Free;
  //
  // // Read
  // //CurrStream := TMemoryStream(StreamList.Streams[0]);
  // //ReadSize := CurrStream.Size;
  // //if ReadSize > SizeOf(NewProjParams.Setting) then
  // //  ReadSize := SizeOf(NewProjParams.Setting);
  // //CurrStream.ReadBuffer(NewProjParams.Setting, ReadSize);
  // //CurrStream.Free;
  //
  // NewProjParams := GetProjectParamsFromForm(false); //ZeroMemory(@NewProjParams.Setting, SizeOf(NewProjParams.Setting));
  // StreamList := TStreamList.Create(fcSCSProjSettings, true);
  // StreamList.LoadFromFile('c:\temp\proj_settings.tmp');
  // CurrStream := TMemoryStream(StreamList.Streams[0]);
  // ReadSize := CurrStream.Size;
  // if ReadSize > SizeOf(NewProjParams.Setting) then
  // ReadSize := SizeOf(NewProjParams.Setting);
  // CurrStream.ReadBuffer(NewProjParams.Setting, ReadSize);
  // StreamList.Free;
  // Exit;

  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);

            // Для линейки указываем в основной ед. изм.
            rbm1.Checked := true;
            rbft1.Checked := true;
            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_MasterNewList.pmSaveLoadSettingsPopup(Sender: TObject);
begin
  pmiSaveNewProjSettingsToFile.Enabled := FileExists(GetPathToDefProjSettings);
end;

procedure TF_MasterNewList.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_MasterNewList.cbAllowSuppliesKindClick(Sender: TObject);
begin
  if cbAllowSuppliesKind.Checked = FCADParams.CADAllowSuppliesKind then
    cbAllowSuppliesKind.Font.Color := clBlack
  else
    cbAllowSuppliesKind.Font.Color := clBlue;
end;

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

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

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

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

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

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

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

procedure TF_MasterNewList.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_MasterNewList.edRoomHeightKeyPress', E.Message);
  end;
end;

procedure TF_MasterNewList.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));
  //Tolik 09/06/2021 --
  if edRoomHeight.Text = '' then
    edRoomHeight.Text := '0';
  //
  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_MasterNewList.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));
  //Tolik 09/06/2021 --
  if edRoomHeight.Text = '' then
    edRoomHeight.Text := '0';
  //
  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_MasterNewList.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));
  //Tolik 09/06/2021 --
  if edRoomHeight.Text = '' then
    edRoomHeight.Text := '0';
  //
  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_MasterNewList.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));
  //Tolik 09/06/2021 --
  if edRoomHeight.Text = '' then
    edRoomHeight.Text := '0';
  //
  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_MasterNewList.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
    //Tolik 25/11/2021 --
    //  + '\d?\d?';
      + '\d?\d?\d?\d?\d?\d?\d?';
    //
    edSizeAllMetric.Properties.EditMask := '\d?\d?\d?\d?' + DecimalSeparator
      + '\d?\d?';
    edSizeAsWhitworth.Properties.EditMask := '\d?\d?\d?\d?' + DecimalSeparator
    //Tolik 25/11/2021 --
    //  + '\d?\d?';
    + '\d?\d?\d?\d?\d?\d?\d?';
    //
    edSizeAllWhitworth.Properties.EditMask := '\d?\d?\d?\d?' + DecimalSeparator
      + '\d?\d?';
    edCableSwervesCount.Properties.EditMask := '\d?\d?\d?\d?';
    edCableSwervesMinAngle.Properties.EditMask := '\d?\d?\d?';
  except
    on E: Exception do
      AddExceptionToLogEx('TF_MasterNewList.SetMaskEdits', E.Message);
  end;
end;

procedure TF_MasterNewList.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_MasterNewList.SetUOM', E.Message);
  end;
end;

procedure TF_MasterNewList.edSizeAsWhitworthExit(Sender: TObject);
var
  CheckValue: Double;
begin
  try
    FListParams.Settings.CADRuleStep := GetRuleStep(false);//Tolik 10/02/2022 --
    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_MasterNewList.edSizeAsWhitworthExit', E.Message);
  end;
end;

procedure TF_MasterNewList.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_MasterNewList.edSizeAllWhitworthExit', E.Message);
  end;
end;

procedure TF_MasterNewList.rbin1Click(Sender: TObject);
var
  CheckValue: Double;
begin
  try
    FListParams.Settings.CADRuleStep := GetRuleStep(false);//Tolik 10/02/2022 --
    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_MasterNewList.rbin1Click', E.Message);
  end;
end;

procedure TF_MasterNewList.rbft1Click(Sender: TObject);
var
  CheckValue: Double;
begin
  try
    FListParams.Settings.CADRuleStep := GetRuleStep(false);//Tolik 10/02/2022 --
    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_MasterNewList.rbin1Click', E.Message);
  end;
end;

procedure TF_MasterNewList.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_MasterNewList.rbmm2Click', E.Message);
  end;
end;

procedure TF_MasterNewList.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_MasterNewList.rbmm2Click', E.Message);
  end;
end;

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

procedure TF_MasterNewList.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;
end;

procedure TF_MasterNewList.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;
end;

procedure TF_MasterNewList.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;
end;

procedure TF_MasterNewList.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;
end;

function GetStampMarginsFromForm(AForm: TForm; aUOM: Integer): TDoubleRect;
  procedure LoadParam(var param: Double; const AControlName: String);
  var
    Control: TComponent;
  begin
    Control := AForm.FindComponent(AControlName);
    if Control is TcxSpinEdit then
      param := FloatInUOM(TcxSpinEdit(Control).Value,
        ConvertUOMToMin(aUOM), umMM);
  end;

begin
  LoadParam(Result.Left, 'seStampMarginLeft');
  LoadParam(Result.Right, 'seStampMarginRight');
  LoadParam(Result.Top, 'seStampMarginTop');
  LoadParam(Result.Bottom, 'seStampMarginBottom');
end;

procedure SetStampMarginsToForm(AMargins: TDoubleRect; AForm: TForm;
  aUOM: Integer);
  procedure SetParam(var param: Double; const AControlName: String);
  var
    Control: TComponent;
  begin
    Control := AForm.FindComponent(AControlName);
    if Control is TcxSpinEdit then
      TcxSpinEdit(Control).Value := FloatInUOM(param, umMM,
        ConvertUOMToMin(aUOM));
  end;

begin
  SetParam(AMargins.Left, 'seStampMarginLeft');
  SetParam(AMargins.Right, 'seStampMarginRight');
  SetParam(AMargins.Top, 'seStampMarginTop');
  SetParam(AMargins.Bottom, 'seStampMarginBottom');
end;

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

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

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

procedure TF_MasterNewList.cbShowRaiseDrawFigureClick(Sender: TObject);
begin
  SetCheckBoxStyleByVal(cbShowRaiseDrawFigure,
    FCADParams.CADShowRaiseDrawFigure);
end;

procedure TF_MasterNewList.lbResetIndexClick(Sender: TObject);
var
  i: Integer;
  List: TSCSList;
begin
  // продолжить индексы компонент
  if not TabProjectProperties.TabVisible then
  begin
    lbResetIndex.Visible := false;
    if not TabProjectProperties.TabVisible then
    begin
      if (FMakeEditMode = meEdit) and (FItemType = itList) then
      begin
        List := F_ProjMan.GSCSBase.CurrProject.GetListBySCSID(FItemID);
        if List <> nil then
        begin
          for i := 0 to List.Spravochnik.ComponentTypes.Count - 1 do
          begin
            TNBComponentType(List.Spravochnik.ComponentTypes[i])
              .ComponentType.ComponentIndex := 0;
          end;
        end;
      end;
      pnComponentType.Visible := lbResetIndex.Visible;
    end;
  end;
end;

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

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

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

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

end.
