//--------------------------------------------------------------------------- #include #include #pragma hdrstop #include "Printer_F.h" #include "Plan.h" #include "NewProductData.h" #include "OldProductData.h" #include "MainImage.h" //--------------------------------------------------------------------------- #pragma package(smart_init) #pragma link "TPSpin" #pragma resource "*.dfm" //--------------------------------------------------------------------------- #define IDS_PRINTFORM StringTable[0] #define IDS_A4 StringTable[1] #define IDS_FREE StringTable[2] #define IDS_HEADER StringTable[3] #define IDS_PRODUCTIONDATA StringTable[4] #define IDS_FRONTBACK StringTable[5] #define IDS_HIGHRESOLUTION StringTable[6] #define IDS_SAVE StringTable[7] #define IDS_IMAGE StringTable[8] #define IDS_IMAGECOLORCHIP StringTable[9] //--------------------------------------------------------------------------- __fastcall TPrintForm::TPrintForm(TComponent* Owner) : TForm(Owner) { //============================================= StringTable.Create(DirectoryItem, Language, "Printer"); SetSmallFont(Font); Caption = IDS_PRINTFORM; lbPrinter->Caption = IDS_COMMON_PRINTER + " : " + Printer()->Printers->Strings[Printer()->PrinterIndex]; for (int i = 0; i < 3; i++) { cbMethod->Items->Strings[i] = IDS_COMMON_PRINTMETHOD + " - " + AnsiString(i+1); } Label1->Caption = IDS_COMMON_PAGE; rgSize->Caption = IDS_COMMON_SIZE; rgSize->Items->Strings[0] = IDS_A4; rgSize->Items->Strings[1] = IDS_FREE; rgA4Header->Caption = IDS_HEADER; rgA4Header->Items->Strings[0] = IDS_IMAGE; rgA4Header->Items->Strings[1] = IDS_IMAGECOLORCHIP; rgA4Header->Items->Strings[2] = IDS_FRONTBACK; rgA4Header->Items->Strings[3] = IDS_PRODUCTIONDATA+" A"; rgA4Header->Items->Strings[4] = IDS_PRODUCTIONDATA+" B"; rgFreeHeader->Caption = IDS_HEADER; rgFreeHeader->Items->Strings[0] = IDS_COMMON_BUTTONNO; rgFreeHeader->Items->Strings[1] = IDS_COMMON_BUTTONYES; PrinterSetupBtn->Caption = IDS_COMMON_SETUP; PrintBtn->Caption = IDS_COMMON_PRINT; CancelBtn->Caption = IDS_COMMON_BUTTONCANCEL; cbHigh->Caption = IDS_HIGHRESOLUTION; SaveBtn->Caption = IDS_SAVE; //============================================= } //--------------------------------------------------------------------------- void __fastcall TPrintForm::FormClose(TObject *Sender, TCloseAction &Action) { TIniFile *IniFile = new TIniFile(DirectoryItem + "\\Environment.ini"); if (IniFile) { IniFile->WriteBool("Printer", "Method", cbMethod->ItemIndex); delete IniFile; } } //--------------------------------------------------------------------------- void __fastcall TPrintForm::FormCreate(TObject *Sender) { Method = 0; TIniFile *IniFile = new TIniFile(DirectoryItem + "\\Environment.ini"); if (IniFile) { cbMethod->ItemIndex = IniFile->ReadBool("Printer", "Method", 0); delete IniFile; } } //--------------------------------------------------------------------------- void __fastcall TPrintForm::FormShow(TObject *Sender) { PrintBtn->Enabled = FbRun; } //--------------------------------------------------------------------------- void __fastcall TPrintForm::rgSizeClick(TObject *Sender) { if(rgSize->ItemIndex==0) { pnA4->BringToFront(); rgA4Header->ItemIndex = 0; Method = 0; SaveBtn->Enabled = true; } else { rgFreeHeader->BringToFront(); rgFreeHeader->ItemIndex = 0; Method = 5; SaveBtn->Enabled = false; } } //--------------------------------------------------------------------------- void __fastcall TPrintForm::rgHeaderClick(TObject *Sender) { TRadioGroup *rg = (TRadioGroup *) Sender; Method = rg->ItemIndex; if (rg->Tag) Method = rg->ItemIndex + 5; if (Method == 3) { ProductDataForm = NULL; ProductDataForm = new TProductDataForm(this); if (ProductDataForm == NULL) goto fail; ProductDataForm->ShowModal(); ActingReedWidth = ProductDataForm->arWidth; WeftDensity = ProductDataForm->weDensity; WeftWidth = ProductDataForm->weWidth; TotalWarpCnt = ProductDataForm->twCount; TotalWeight = ProductDataForm->tWeight; TotalWeights = ProductDataForm->tWeights; TotalLength[0] = ProductDataForm->TotalLength[0]; TotalLength[1] = ProductDataForm->TotalLength[1]; TotalYarns[0] = ProductDataForm->TotalCnt[0]; TotalYarns[1] = ProductDataForm->TotalCnt[1]; delete ProductDataForm; ProductDataForm = NULL; } else if (Method == 4) { NewProductDataForm = NULL; NewProductDataForm = new TNewProductDataForm(this); if (NewProductDataForm == NULL) goto fail; NewProductDataForm->ShowModal(); delete NewProductDataForm; NewProductDataForm = NULL; } return; fail: EXCEPTION_MESSAGE_OK(EC_MEMORY_LACK); } //--------------------------------------------------------------------------- void __fastcall TPrintForm::PrinterSetupBtnClick(TObject *Sender) { PrinterSetupDialog1->Execute(); lbPrinter->Caption = IDS_COMMON_PRINTER + " : " + Printer()->Printers->Strings[Printer()->PrinterIndex]; } //--------------------------------------------------------------------------- void __fastcall TPrintForm::SaveBtnClick(TObject *Sender) { TTexpiaBitmap *Pattern = NULL, *Pattern24 = NULL; AnsiString str, fn, ext; bool checkback = true; // Char *s = NULL; PChar s; int FileNameLength, last1, last2, last3, last4; char FileIndex1, FileIndex2, FileIndex3, FileIndex4; TIniFile *IniFile = new TIniFile(DirectoryItem + "\\Directory.ini"); if (IniFile) { str = IniFile->ReadString("ProductData", "Directory", "C:\\"); delete IniFile; } SaveDialog1->InitialDir = str; SaveDialog1->FileName = ""; if (SaveDialog1->Execute()){ if ((Pattern = new TTexpiaBitmap)==NULL) goto fail; if (Method == 0){ if (MainImageForm->A4NoPrint(Pattern) == false) goto fail; } else if (Method == 1){ if (MainImageForm->A4YesPrint(Pattern) == false) goto fail; } else if (Method == 2){ if (MainImageForm->A4FrontBackPrint(Pattern, checkback) == false) goto fail; } else if (Method == 3){ if (MainImageForm->A4ProductDataAPrint(Pattern, TotalLength, TotalYarns, ActingReedWidth, WeftDensity, TotalWarpCnt, WeftWidth, TotalWeight, TotalWeights) == false) goto fail; } else if (Method == 4){ if (MainImageForm->A4ProductDataBPrint(Pattern) == false) goto fail; } if (SaveDialog1->FilterIndex == 1) ext = ".jpg"; else if (SaveDialog1->FilterIndex == 2) ext = ".bmp"; str = ExtractFileName(SaveDialog1->FileName); //=============================================================== FileNameLength = str.Length(); if(FileNameLength > 4){ last1 = FileNameLength-3; last2 = FileNameLength-2; last3 = FileNameLength-1; last4 = FileNameLength; FileIndex1 = '.'; FileIndex2 = 'j'; FileIndex3 = 'q'; FileIndex4 = 'd'; if((FileIndex1 == str[last1])&&(FileIndex2 == str[last2]) && (FileIndex3 == str[last3])&&(FileIndex4 == str[last4])){ s = "PASS"; }else s=NULL; }else s=NULL; //=============================================================== // s = AnsiStrScan(str.c_str(), '.'); //"ÆÄÀϳ×ÀÓ¿¡ '.'ÀÌ µé¾î°¡¸é ¾ÈµÇ°ÚÁÒ? ¤Ñ.¤Ñ" if (s==NULL) fn = SaveDialog1->FileName+ext; else fn = SaveDialog1->FileName; if (SaveDialog1->FilterIndex == 1 && checkback) { if ((Pattern24 = new TTexpiaBitmap)==NULL) goto fail; Pattern24->Create(Pattern->Width, Pattern->Height, 24); Pattern24->Copy(Pattern, SRCCOPY); if (Pattern24->SaveToFile(fn, FILE_LEAD2JFIF, 30) == false) goto fail; delete Pattern24; } else if (SaveDialog1->FilterIndex == 2 && checkback) { if (Pattern->SaveToFile(fn, FILE_BMP) == false) goto fail; } IniFile = new TIniFile(DirectoryItem + "\\Directory.ini"); if (IniFile) { IniFile->WriteString("ProductData", "Directory", ExtractFileDir(SaveDialog1->FileName)); delete IniFile; } delete Pattern; } return; fail: if (Pattern) delete Pattern; if (Pattern24) delete Pattern24; } //---------------------------------------------------------------------------