//--------------------------------------------------------------------------- #include #pragma hdrstop #include "BaseYarnDesign_F.h" #include "common.h" #include "Exception.h" //--------------------------------------------------------------------------- #pragma package(smart_init) #pragma link "PColorGrid" #pragma link "PCMY" #pragma link "PHLS" #pragma link "DIB256s" #pragma link "TPSpin" #pragma link "RzButton" #pragma link "RzCmboBx" #pragma link "RzEdit" #pragma link "RzRadChk" #pragma link "RzSpnEdt" #pragma link "RzPanel" #pragma link "RzTabs" #pragma resource "*.dfm" TBaseYarnDesignForm *BaseYarnDesignForm; //--------------------------------------------------------------------------- #define IDS_TYPE StringTable[0] #define IDS_COLOR StringTable[1] #define IDS_COLORNUMBER StringTable[2] #define IDS_COLORTABLE StringTable[3] #define IDS_PALETTE StringTable[4] #define IDS_DATA StringTable[5] #define IDS_METHOD StringTable[6] #define IDS_COUNT StringTable[7] #define IDS_TPI StringTable[8] #define IDS_HAIREFFECT StringTable[9] #define IDS_OK StringTable[10] #define IDS_CANCEL StringTable[11] #define IDS_SDIRECTION StringTable[12] #define IDS_ZDIRECTION StringTable[13] #define RGB(r,g,b) ((DWORD)(((BYTE)(r) | ((WORD)((BYTE)(g)) << 8)) | (((DWORD)(BYTE)(b)) << 16))) //--------------------------------------------------------------------------- struct TBaseData { TYarnMethod Method; TColorData *Color; bool change; TBaseData() { Color = NULL; change = false; } }; //--------------------------------------------------------------------------- __fastcall TBaseYarnDesignForm::TBaseYarnDesignForm(TComponent* Owner) : TForm(Owner) { //=================================================================== 20051117 by lhskys tdw ¼öÁ¤ StringTable.Create(BaseDir, Language, "BaseYarnDesign"); SetSmallFont(Font); SetSmallFont(stTwist->Font); SetSmallFont(lbCount->Font); SetSmallFont(lbUnit->Font); SetSmallFont(lbChoiceIndex->Font); lnType->Caption = IDS_TYPE; gbColor->Caption = IDS_COLOR; Label1->Caption = IDS_COLORNUMBER; Label2->Caption = IDS_COLORTABLE; tsPalette->Caption = IDS_PALETTE; GroupBox1->Caption = IDS_DATA; Label6->Caption = IDS_METHOD; Label5->Caption = IDS_COUNT; lbTPI->Caption = "TPI :"; // Label7->Caption = IDS_TPI; cbHairEffect->Caption = IDS_HAIREFFECT; btnOK->Caption = IDS_OK; btnCancel->Caption = IDS_CANCEL; stTwist->Caption = IDS_SDIRECTION; //=================================================================== } //--------------------------------------------------------------------------- void __fastcall TBaseYarnDesignForm::FormCreate(TObject *Sender) { ColorIndex = 0; Item = 0; PalIndex = 2; Normal = new TColorData; Melange = new TList; Rainbow = new TList; DIB256Palette->ChoiceIndex = 2; SZ = false; type = false; } //--------------------------------------------------------------------------- void __fastcall TBaseYarnDesignForm::FormDestroy(TObject *Sender) { ClearData(); delete Normal; delete Melange; delete Rainbow; } //--------------------------------------------------------------------------- void __fastcall TBaseYarnDesignForm::FormShow(TObject *Sender) { cbUnit->ItemIndex = FindUnitIndex(FInfor->YarnUnit); cbType->ItemIndex = FInfor->Type; Item = FInfor->Type; // InitBaseData() Áغñ... type = true; seColors->IntValue = FInfor->Colors; type = false; InitBaseData(); cbTypeChange(cbType); if (FInfor->SZ) { stTwist->Caption = IDS_ZDIRECTION; SZ = true; } else { stTwist->Caption = IDS_SDIRECTION; SZ = false; } if (FInfor->IsTPIMethod()) { isTPI = true; seTPI->Value = FInfor->TPI; lbTPI->Caption = "TPI :"; } else { isTPI = false; seTPI->Value = FInfor->TPM; lbTPI->Caption = "TPM :"; } cbHairEffect->Checked = FInfor->Hair; seCount->Value = FInfor->Count; lbUnit->Caption = FInfor->YarnUnit.Name(); btnOK->SetFocus(); //lhskys ¿£ÅÍ·Î ½ÇÇàÇϱâ À§ÇØ focus¸¦ ÁØ´Ù } //--------------------------------------------------------------------------- void __fastcall TBaseYarnDesignForm::cbTypeChange(TObject *Sender) { type = true; Item = cbType->ItemIndex; switch (cbType->ItemIndex) { case 0: ChangeNormal(); seColors->Enabled = false; tsDensityLength->Caption = "None"; tsDensityLength->Enabled = false; lbDenLen->Caption = ""; break; case 1: ChangeMelange(); seColors->Enabled = true; tsDensityLength->Enabled = true; tsDensityLength->Caption = "Density"; lbDenLen->Caption = "%"; break; case 2: ChangeRainbow(); seColors->Enabled = true; tsDensityLength->Enabled = true; tsDensityLength->Caption = "Length"; lbDenLen->Caption = (inch)? "Inch" : "Cm"; break; } sbTable->Position = 0; sbTable->Enabled = (seColors->Value > 17)? 1 : 0; ColorIndex = 0; lbChoiceIndex->Caption = "1"; type = false; } //--------------------------------------------------------------------------- void __fastcall TBaseYarnDesignForm::seColorsChange(TObject *Sender) { int num, i, cnt, k; TBaseData *bd; if (type) return; if (seColors->Text.Length()>0) { if (seColors->Value < 1) { seColors->Value = 1; } if (seColors->Value > 8) { seColors->Value = 8; } ColorIndex = seColors->Value - 1; lbChoiceIndex->Caption = IntToStr((int)seColors->Value); //qe if (cgTable->ColorCount > seColors->Value) { cnt = cgTable->ColorCount - seColors->Value; for (i = 0; i < cnt; i++) DeleteData(); cgTable->ColorCount = seColors->Value; } else { k = cgTable->ColorCount; cnt = seColors->Value - k; cgTable->ColorCount = seColors->Value; for (i = 0; i < cnt; i++) { AddData(DIB256Palette->Palette->ColorData[PalIndex]); cgTable->ReDrawCell(k+i, DIB256Palette->Palette->ColorData[PalIndex]->Color); PalIndex++; } } CalculateMethodNumber(); if (Item == 1) { bd = (TBaseData *) Melange->Items[0]; edDenLen->Text = bd->Method.Number; } else if (Item == 2) { bd = (TBaseData *) Rainbow->Items[0]; if (inch) edDenLen->Text = Format("%.2f", OPENARRAY(TVarRec, (bd->Method.Number / 160.0))); else edDenLen->Text = Format("%.2f", OPENARRAY(TVarRec, (bd->Method.Number * 2.54 / 160.0))); } if (seColors->Value>17) { sbTable->Max = seColors->Value-17; sbTable->Enabled = true; } else { sbTable->Enabled = false; } } } //--------------------------------------------------------------------------- void __fastcall TBaseYarnDesignForm::cgTableMouseDown(TObject *Sender, TMouseButton Button, TShiftState Shift, int X, int Y) { ColorIndex = cgTable->GetColorIndex(X, Y); if (ColorIndex < 0) return; lbChoiceIndex->Caption = IntToStr(ColorIndex+1); if (pcColor->ActivePage == tsCMY) { CMY->Color = cgTable->CellColor[ColorIndex]; } else if (pcColor->ActivePage == tsHLS) { HLS->Color = cgTable->CellColor[ColorIndex]; } else if (pcColor->ActivePage == tsDensityLength) { shChoiceColor->Brush->Color = cgTable->CellColor[ColorIndex]; ChangeMethodData(ColorIndex); } } //--------------------------------------------------------------------------- void __fastcall TBaseYarnDesignForm::DIB256PaletteDblClick(TObject *Sender) { TBaseData *bd; //int r,g,b, temp; cgTable->ReDrawCell(ColorIndex, DIB256Palette->Palette->ColorData[DIB256Palette->ChoiceIndex]->Color); if (Item == 0) { Normal->Copy(DIB256Palette->Palette->ColorData[DIB256Palette->ChoiceIndex]); /* r = 0xFF & Normal->RGB.rgbRed; // int°ªÀ¸·Î Çϰųª byte·Î Çϰųª... g = 0xFF & Normal->RGB.rgbGreen; b = 0xFF & Normal->RGB.rgbBlue; temp = RGB(r,g,b); */ } else if (Item == 1) { bd = (TBaseData *) Melange->Items[ColorIndex]; bd->Color->Copy(DIB256Palette->Palette->ColorData[DIB256Palette->ChoiceIndex]); } else if (Item == 2) { bd = (TBaseData *) Rainbow->Items[ColorIndex]; bd->Color->Copy(DIB256Palette->Palette->ColorData[DIB256Palette->ChoiceIndex]); } } //--------------------------------------------------------------------------- void __fastcall TBaseYarnDesignForm::sbTableScroll(TObject *Sender, TScrollCode ScrollCode, int &ScrollPos) { cgTable->Pos = sbTable->Position; } //--------------------------------------------------------------------------- void __fastcall TBaseYarnDesignForm::pcColorChange(TObject *Sender) { if (pcColor->ActivePage == tsCMY) { CMY->Color = cgTable->CellColor[ColorIndex]; } else if (pcColor->ActivePage == tsHLS) { HLS->Color = cgTable->CellColor[ColorIndex]; } else if (pcColor->ActivePage == tsDensityLength) { shChoiceColor->Brush->Color = cgTable->CellColor[ColorIndex]; ChangeMethodData(ColorIndex); } } //--------------------------------------------------------------------------- void __fastcall TBaseYarnDesignForm::CMYColorChange(TObject *Sender) { Byte r, g, b; TBaseData *bd; cgTable->ReDrawCell(ColorIndex, CMY->Color); r = GetRValue(CMY->Color); g = GetGValue(CMY->Color); b = GetBValue(CMY->Color); if (Item == 0) { Normal->SetNormal(r, g, b); } else if (Item == 1) { bd = (TBaseData *) Melange->Items[ColorIndex]; bd->Color->SetNormal(r, g, b); } else { bd = (TBaseData *) Rainbow->Items[ColorIndex]; bd->Color->SetNormal(r, g, b); } } //--------------------------------------------------------------------------- void __fastcall TBaseYarnDesignForm::HLSColorChange(TObject *Sender) { Byte r, g, b; TBaseData *bd; cgTable->ReDrawCell(ColorIndex, HLS->Color); r = GetRValue(HLS->Color); g = GetGValue(HLS->Color); b = GetBValue(HLS->Color); if (Item == 0) { Normal->SetNormal(r, g, b); } else if (Item == 1) { bd = (TBaseData *) Melange->Items[ColorIndex]; bd->Color->SetNormal(r, g, b); } else { bd = (TBaseData *) Rainbow->Items[ColorIndex]; bd->Color->SetNormal(r, g, b); } } //--------------------------------------------------------------------------- void __fastcall TBaseYarnDesignForm::seCountChange(TObject *Sender) { if (seCount->Text.Length() > 0) { if (FInfor->YarnUnit.Method && (FInfor->YarnUnit.System == YU_WORSTED || FInfor->YarnUnit.System == YU_Y_S_W)) lbCount->Caption = Format("1/%d", OPENARRAY(TVarRec, ((int)seCount->Value))); else lbCount->Caption = Format("%d/1", OPENARRAY(TVarRec, ((int)seCount->Value))); } } //--------------------------------------------------------------------------- void __fastcall TBaseYarnDesignForm::btnOKClick(TObject *Sender) { int i; TBaseData *bd; FInfor->YarnUnit = IndexToUnit(cbUnit->ItemIndex); FInfor->Type = Item; FInfor->Hair = cbHairEffect->Checked; FInfor->Count = seCount->Value; FInfor->SZ = SZ; if (isTPI) { FInfor->TPI = seTPI->Value; } else { FInfor->TPM = seTPI->Value; } if (FInfor->Method) { delete[] FInfor->Method; FInfor->Method = NULL; } FInfor->Colors = seColors->Value; FInfor->Methods = (Item!=0)? seColors->Value : 0; if (FInfor->Colors > 0){ for (i = 0; i < FInfor->Colors; i++){ if (Item == 0){ FInfor->yColor[i] = Normal->RGB; } else if (Item == 1){ bd = (TBaseData *) Melange->Items[i]; FInfor->yColor[i] = bd->Color->RGB; } else { bd = (TBaseData *) Rainbow->Items[i]; FInfor->yColor[i] = bd->Color->RGB; } } } if (FInfor->Methods > 0 && Item > 0) { if ((FInfor->Method = new TYarnMethod[FInfor->Methods]) == NULL) { #ifdef TPDEBUG SHOWDEBUG; #endif } for (i = 0; i < FInfor->Methods; i++) { FInfor->Method[i].Code = i; if (Item == 1) bd = (TBaseData *) Melange->Items[i]; else bd = (TBaseData *) Rainbow->Items[i]; FInfor->Method[i].Number = bd->Method.Number; } } } //--------------------------------------------------------------------------- //// Private Method //////////////////////////////////////////////////// //--------------------------------------------------------------------------- void __fastcall TBaseYarnDesignForm::ClearData() { TBaseData *bd; while (Melange->Count) { bd = (TBaseData *) Melange->Last(); Melange->Remove(bd); delete bd->Color; delete bd; } while (Rainbow->Count) { bd = (TBaseData *) Rainbow->Last(); Rainbow->Remove(bd); delete bd->Color; delete bd; } } //--------------------------------------------------------------------------- void __fastcall TBaseYarnDesignForm::AddData(TColorData *cd) { TBaseData *bd; if ((bd = new TBaseData) == NULL) { #ifdef TPDEBUG SHOWDEBUG; #endif } if ((bd->Color = new TColorData) == NULL) { #ifdef TPDEBUG SHOWDEBUG; #endif } bd->Color->Copy(cd); bd->Method.Code = (Item == 1)? Melange->Count : Rainbow->Count; bd->Method.Number = 0; if (Item == 1) Melange->Add(bd); else Rainbow->Add(bd); } //--------------------------------------------------------------------------- void __fastcall TBaseYarnDesignForm::DeleteData() { TBaseData *bd; if (Item == 1) { bd = (TBaseData *) Melange->Last(); Melange->Remove(bd); } else { bd = (TBaseData *) Rainbow->Last(); Rainbow->Remove(bd); } delete bd->Color; delete bd; } //--------------------------------------------------------------------------- void __fastcall TBaseYarnDesignForm::InitBaseData() { TBaseData *bd; int i; if (FInfor->Colors > 0) { if (Item == 0) { if ((Normal = new TColorData) == NULL) { #ifdef TPDEBUG SHOWDEBUG; #endif } Normal->RGB = FInfor->yColor[0]; } else if (Item == 1) { for (i = 0; i < seColors->Value; i++) { if ((bd = new TBaseData) == NULL) { #ifdef TPDEBUG SHOWDEBUG; #endif } if ((bd->Color = new TColorData) == NULL) { #ifdef TPDEBUG SHOWDEBUG; #endif } bd->Color->RGB = FInfor->yColor[i]; if (FInfor->Method) { bd->Method.Code = FInfor->Method[i].Code; bd->Method.Number = FInfor->Method[i].Number; } else { bd->Method.Code = i; bd->Method.Number = 100 / seColors->Value; } Melange->Add(bd); } } else { for (i = 0; i < seColors->Value; i++) { if ((bd = new TBaseData) == NULL) { #ifdef TPDEBUG SHOWDEBUG; #endif } if ((bd->Color = new TColorData) == NULL) { #ifdef TPDEBUG SHOWDEBUG; #endif } bd->Color->RGB = FInfor->yColor[i]; if (FInfor->Method) { bd->Method.Code = FInfor->Method[i].Code; bd->Method.Number = FInfor->Method[i].Number; } else { bd->Method.Code = i; bd->Method.Number = 1; } Rainbow->Add(bd); } } } else { if (Item == 0) { if ((Normal = new TColorData) == NULL) { #ifdef TPDEBUG SHOWDEBUG; #endif } Normal->Copy(DIB256Palette->Palette->ColorData[PalIndex]); } else if (Item == 1) { if ((bd = new TBaseData) == NULL) { #ifdef TPDEBUG SHOWDEBUG; #endif } if ((bd->Color = new TColorData) == NULL) { #ifdef TPDEBUG SHOWDEBUG; #endif } bd->Color->Copy(DIB256Palette->Palette->ColorData[PalIndex]); bd->Method.Code = 0; bd->Method.Number = 100; Melange->Add(bd); } else { if ((bd = new TBaseData) == NULL) { #ifdef TPDEBUG SHOWDEBUG; #endif } if ((bd->Color = new TColorData) == NULL) { #ifdef TPDEBUG SHOWDEBUG; #endif } bd->Color->Copy(DIB256Palette->Palette->ColorData[PalIndex]); bd->Method.Code = 0; bd->Method.Number = 1; Rainbow->Add(bd); } PalIndex++; } } //--------------------------------------------------------------------------- void __fastcall TBaseYarnDesignForm::ChangeNormal() { seColors->Value = 1; cgTable->ColorCount = 1; cgTable->ReDrawCell(0, Normal->Color); } //--------------------------------------------------------------------------- void __fastcall TBaseYarnDesignForm::ChangeMelange() { TBaseData *bd; if (Melange->Count) { seColors->Value = Melange->Count; cgTable->ColorCount = Melange->Count; for (int i = 0; i < Melange->Count; i++) { bd = (TBaseData *) Melange->Items[i]; cgTable->ReDrawCell(i, bd->Color->Color); } } else { seColors->Value = 1; cgTable->ColorCount = 1; if ((bd = new TBaseData) == NULL) { #ifdef TPDEBUG SHOWDEBUG; #endif } if ((bd->Color = new TColorData) == NULL) { #ifdef TPDEBUG SHOWDEBUG; #endif } bd->Method.Code = 0; bd->Method.Number = 100; bd->Color->Copy(DIB256Palette->Palette->ColorData[PalIndex]); cgTable->ReDrawCell(0, bd->Color->Color); PalIndex++; Melange->Add(bd); } bd = (TBaseData *) Melange->Items[0]; edDenLen->Text = IntToStr((int)(bd->Method.Number + 0.5)); // doubleÇü º¯È¯À¸·Î.. //edDenLen->Text = IntToStr(bd->Method.Number); } //--------------------------------------------------------------------------- void __fastcall TBaseYarnDesignForm::ChangeRainbow() { TBaseData *bd; if (Rainbow->Count) { seColors->Value = Rainbow->Count; cgTable->ColorCount = Rainbow->Count; for (int i = 0; i < Rainbow->Count; i++) { bd = (TBaseData *) Rainbow->Items[i]; cgTable->ReDrawCell(i, bd->Color->Color); } } else { seColors->Value = 1; cgTable->ColorCount = 1; if ((bd = new TBaseData) == NULL) { #ifdef TPDEBUG SHOWDEBUG; #endif } if ((bd->Color = new TColorData) == NULL) { #ifdef TPDEBUG SHOWDEBUG; #endif } bd->Method.Code = 0; bd->Method.Number = 1; bd->Color->Copy(DIB256Palette->Palette->ColorData[PalIndex]); cgTable->ReDrawCell(0, bd->Color->Color); PalIndex++; Rainbow->Add(bd); } bd = (TBaseData *) Rainbow->Items[0]; if (inch) edDenLen->Text = Format("%.2f", OPENARRAY(TVarRec, (bd->Method.Number / 160.0))); else edDenLen->Text = Format("%.2f", OPENARRAY(TVarRec, (bd->Method.Number * 2.54 / 160.0))); } //--------------------------------------------------------------------------- void __fastcall TBaseYarnDesignForm::ChangeMethodData(int i) { TBaseData *bd; if (Item == 1) { if (Melange->Count) { bd = (TBaseData *) Melange->Items[i]; edDenLen->Text = IntToStr((int)(bd->Method.Number + 0.5)); //edDenLen->Text = IntToStr(bd->Method.Number); } } else { if (Rainbow->Count) { bd = (TBaseData *) Rainbow->Items[i]; if (inch) edDenLen->Text = Format("%.2f", OPENARRAY(TVarRec, (bd->Method.Number / 160.0))); else edDenLen->Text = Format("%.2f", OPENARRAY(TVarRec, (bd->Method.Number * 2.54 / 160.0))); } } } //--------------------------------------------------------------------------- bool __fastcall TBaseYarnDesignForm::ProperInput(double value) { int dot; if (Item == 1) { return (value <= 100); } else if (Item == 2) { if (inch) dot = value * 160 + 0.5; else dot = value / 2.54 * 160 + 0.5; return (dot <= 1024); } } //--------------------------------------------------------------------------- void __fastcall TBaseYarnDesignForm::CalculateMethodNumber() { TBaseData *bd; int i, count, value, cnt = 0, total = 0, tot = 0; if (Item == 1) { for (i = 0; i < Melange->Count; i++) { bd = (TBaseData *) Melange->Items[i]; if (bd->change) { total += bd->Method.Number; cnt++; } } if (total > 100 || cnt == Melange->Count) { for (i = 0; i < Melange->Count; i++) { bd = (TBaseData *) Melange->Items[i]; if (i != ColorIndex) { tot += bd->Method.Number; } } value = total - 100; for (i = 0; i < Melange->Count; i++) { bd = (TBaseData *) Melange->Items[i]; if (i != ColorIndex) { bd->Method.Number -= bd->Method.Number * value / tot; } } } else { count = Melange->Count - cnt; if (count == 0) count = 1; value = (100 - total) / count; cnt = 0; for (i = 0; i < Melange->Count; i++) { bd = (TBaseData *) Melange->Items[i]; if (!bd->change) { bd->Method.Number = value; total += value; cnt = i; } } bd = (TBaseData *) Melange->Items[cnt]; bd->Method.Number = value + (100 - total); } } else { for (i = 0; i < Rainbow->Count; i++) { bd = (TBaseData *) Rainbow->Items[i]; if (!bd->change) { bd->Method.Number = 160; } } } } //--------------------------------------------------------------------------- ///// Public Method //////////////////////////////////////////////////// //--------------------------------------------------------------------------- void __fastcall TBaseYarnDesignForm::TakeUnit(TYarnUnit unit, bool i) { FInfor->YarnUnit.Method = unit.Method; FInfor->YarnUnit.System = unit.System; inch = i; } //--------------------------------------------------------------------------- void __fastcall TBaseYarnDesignForm::stTwistClick(TObject *Sender) { if (SZ) { stTwist->Caption = IDS_SDIRECTION; SZ = false; } else { stTwist->Caption = IDS_ZDIRECTION; SZ = true; } } //--------------------------------------------------------------------------- void __fastcall TBaseYarnDesignForm::edDenLenKeyDown(TObject *Sender, WORD &Key, TShiftState Shift) { TBaseData *bd; double value; if (Key == VK_RETURN) { if (edDenLen->Text.Length() > 0) { value = StrToFloat(edDenLen->Text); if (ProperInput(value)) { if (Item == 1) { bd = (TBaseData *) Melange->Items[ColorIndex]; bd->Method.Number = value; bd->change = true; } else if (Item == 2) { bd = (TBaseData *) Rainbow->Items[ColorIndex]; if (inch) bd->Method.Number = value *160; else bd->Method.Number = value / 2.54 * 160; bd->change = true; } CalculateMethodNumber(); } else { if (Item == 1) { bd = (TBaseData *) Melange->Items[ColorIndex]; //edDenLen->Text = IntToStr(bd->Method.Number); edDenLen->Text = IntToStr((int)(bd->Method.Number + 0.5)); } else if (Item == 2) { bd = (TBaseData *) Rainbow->Items[ColorIndex]; if (inch) edDenLen->Text = Format("%.2f", OPENARRAY(TVarRec, (bd->Method.Number / 160.0))); else edDenLen->Text = Format("%.2f", OPENARRAY(TVarRec, (bd->Method.Number * 2.54 / 160.0))); } } } } } //--------------------------------------------------------------------------- void __fastcall TBaseYarnDesignForm::cbHairEffectKeyDown(TObject *Sender, WORD &Key, TShiftState Shift) { if (Key == 13)btnOK->SetFocus(); //lhskys ¿£ÅÍ·Î ½ÇÇàÇϱâ À§ÇØ focus¸¦ ÁØ´Ù } //--------------------------------------------------------------------------- void __fastcall TBaseYarnDesignForm::seCountKeyDown(TObject *Sender, WORD &Key, TShiftState Shift) { if (Key == 13)btnOK->SetFocus(); //lhskys ¿£ÅÍ·Î ½ÇÇàÇϱâ À§ÇØ focus¸¦ ÁØ´Ù } //--------------------------------------------------------------------------- void __fastcall TBaseYarnDesignForm::cbUnitChange(TObject *Sender) { UItem = cbUnit->ItemIndex; switch(UItem){ case 0 : FInfor->YarnUnit.Method = YU_DIRECT; FInfor->YarnUnit.System = YU_TEX; break; case 1: FInfor->YarnUnit.Method = YU_DIRECT; FInfor->YarnUnit.System = YU_DENIER; break; case 2: FInfor->YarnUnit.Method = YU_INDIRECT; FInfor->YarnUnit.System = YU_COTTON; break; case 3: FInfor->YarnUnit.Method = YU_INDIRECT; FInfor->YarnUnit.System = YU_WORSTED; break; case 4: FInfor->YarnUnit.Method = YU_INDIRECT; FInfor->YarnUnit.System = YU_Y_S_W; break; case 5: FInfor->YarnUnit.Method = YU_INDIRECT; FInfor->YarnUnit.System = YU_LINEN; break; } lbUnit->Caption = FInfor->YarnUnit.Name(); } //--------------------------------------------------------------------------- void __fastcall TBaseYarnDesignForm::lbTPIClick(TObject *Sender) { if (isTPI) { isTPI = false; lbTPI->Caption = "TPM :"; } else { isTPI = true; lbTPI->Caption = "TPI :"; } } //---------------------------------------------------------------------------