//--------------------------------------------------------------------- #include #include #include #pragma hdrstop #include "Main.h" #include "About.h" #include "ColorChart.h" #include "ColorLibrary_f.h" #include "Define.h" #include "Des.h" #include "EnlargeCanvas.h" #include "Environment.h" #include "FileManager_F.h" #include "FullView.h" #include "History.h" #include "KNewCanvas.h" #include "KnitPrint.h" #include "Knitting_F.h" #include "KResizeCanvas.h" #include "MainImage.h" #include "MainMenu.h" #include "MarkChart_F.h" #include "Palette.h" #include "PenManager.h" #include "ProtectCard.h" #include "StatusProgress.h" //#include "TPrint_F.h" //2003.02.21 not used #include "Undo.h" #include "UserColor_F.h" #include "MarkEdit.h" #include "YarnDesign_F.h" #include "YarnScan_F.h" #include "YarnTable_F.h" //--------------------------------------------------------------------- #pragma package(smart_init) #pragma link "ltimg_bc.lib" #pragma link "lttwn_bc.lib" #pragma resource "*.dfm" #pragma resource "Cursor.res" //--------------------------------------------------------------------------- #define IDS_TDCSP StringTable[0] #define IDS_TDCSA StringTable[1) #define IDS_FILE StringTable[2] #define IDS_F256COLOR StringTable[3] #define IDS_FFILEMANAGER StringTable[4] #define IDS_FREOPEN StringTable[5] #define IDS_FCLOSE StringTable[6] #define IDS_FCLOSEALL StringTable[7] #define IDS_FRESIZECANVAS StringTable[8] #define IDS_FENLARGECANVAS StringTable[9] #define IDS_FSCANNING StringTable[10] #define IDS_FSCANNERSETUP StringTable[11] #define IDS_FEXIT StringTable[12] #define IDS_EDIT StringTable[13] #define IDS_ECUT StringTable[14] #define IDS_ECOPY StringTable[15] #define IDS_EPASTE StringTable[16] #define IDS_VIEW StringTable[17] #define IDS_VSPECIALPEN StringTable[18] #define IDS_VFULLVIEW StringTable[19] #define IDS_VPALETTE StringTable[20] #define IDS_VMAINMENU StringTable[21] #define IDS_VSTATUSBAR StringTable[22] #define IDS_WINDOW StringTable[23] #define IDS_WCASCADE StringTable[24] #define IDS_WTILE StringTable[25] #define IDS_WARRANGEICONS StringTable[26] #define IDS_WMINIMIZEALL StringTable[27] #define IDS_HELP StringTable[28] #define IDS_HABOUT StringTable[29] #define IDS_KN1 StringTable[30] #define IDS_KN2 StringTable[31] #define IDS_KN3 StringTable[32] #define IDS_KN4 StringTable[33] #define IDS_KN5 StringTable[34] #define IDS_KN6 StringTable[35] #define IDS_KN7 StringTable[36] #define IDS_KN8 StringTable[37] #define IDS_KN9 StringTable[38] #define IDS_KN10 StringTable[39] #define IDS_VMARKLIB StringTable[40] //--------------------------------------------------------------------------- TMainForm *MainForm; //--------------------------------------------------------------------------- // TMainForm //--------------------------------------------------------------------- __fastcall TMainForm::TMainForm(TComponent *Owner) : TForm(Owner) { // CBuilder 3 : TMainForm() -> FormCreate() -> bFirst = 1 // 5 : FromCreate() -> TMainForm() -> bFirst = 0 À̾ ¸·´Â´Ù. // bFirst = 0; int Items, Items_country; TIniFile *IniFile; TPException ec = EC_NONE; FILEOPEN = true; //2001.4.11. by lhskys Open Ãß°¡ Application->OnActivate = ApplicationActivate; Application->OnHint = ShowHint; Screen->OnActiveFormChange = UpdateMenuItems; Screen->Cursors[crPen] = LoadCursor(HInstance, "TEXPIAPEN"); LoadFromMainRegIniFile(); MessageStringTable.Create(DirectoryBin, Language, "Message"); if ((ProtectCard = new TProtectCard)==NULL) { ec = EC_INTERFACE_NONE; goto fail; } #ifndef LOCK_CRYPKEY #ifdef LOCK_IFC Items = ProtectCard->Init(RegFilename); if (Items==0 || (Items&PCN_KNIT)!=PCN_KNIT) { ec = EC_INTERFACE_NONE; goto fail; } if (!ProtectCard->CheckPassword()) { ec = EC_INTERFACE_NONE; goto fail; } #else Items = ProtectCard->Init(Password); if ((((Items>>14)&3)==3) || Items<1 || (Items&PCN_KNIT)!=PCN_KNIT) { ec = EC_INTERFACE_NONE; goto fail; } #ifdef JAPAN // country nomal(1) , Japan(2) üũ // »õ·Î Ãß°¡µÈ °ª Items_country = ProtectCard->Init_country(Password); if(Items_country<1 || Items_country != 2) { // Japan ec = EC_INTERFACE_NONE; goto fail; } #else Items_country = ProtectCard->Init_country(Password); if(Items_country<1 || Items_country != 1) { // normal ec = EC_INTERFACE_NONE; goto fail; } #endif #endif #endif CommonStringTable.Create(DirectoryBin, Language, "Common"); StringTable.Create(DirectoryItem, Language, "Main"); if ((SmallFont = new TFont) == NULL) { ec = EC_MEMORY_LACK; goto fail; } IniFile = new TIniFile(DirectoryItem + "\\Environment.ini"); if (IniFile) { LoadFont(IniFile, SmallFont, "Font"); delete IniFile; } else { SmallFont->Name = DefaultFontName; SmallFont->Size = 10; } if ((Tablet = new TTablet) == NULL) { ec = EC_MEMORY_LACK; goto fail; } Tablet->Init(Handle, RegFilename.c_str()); if ((PrinterColor = new TPrinterColor) == NULL) { ec = EC_MEMORY_LACK; goto fail; } if ((StandardColor = new TStandardColor(DirectoryColor+"\\Standard.tpc")) == NULL) { ec = EC_MEMORY_LACK; goto fail; } if ((TextileColor = new TTextileColor(DirectoryColor+"\\Textile.tpc")) == NULL) { ec = EC_MEMORY_LACK; goto fail; } if ((Pantone1000 = new TPantone1000(DirectoryColor+"\\Thousand.ptc")) == NULL) { ec = EC_MEMORY_LACK; goto fail; } if ((PantoneTextile = new TPantoneTextile(DirectoryColor+"\\Textile.ptc")) == NULL) { ec = EC_MEMORY_LACK; goto fail; } if ((MainMenuForm = new TMainMenuForm(this)) == NULL) goto fail; MainMenuForm->Parent = this; MainMenuForm->Visible = true; MainMenuForm->OnUpdateMenu = UpdateMenuItems; if ((PenManagerForm = new TPenManagerForm(this)) == NULL) goto fail; PenManagerForm->Parent = this; PenManagerForm->Visible = true; PenManagerForm->OnUpdateMenu = UpdateMenuItems; if ((FullViewForm = new TFullViewForm(this)) == NULL) goto fail; FullViewForm->Parent = this; FullViewForm->Visible = true; FullViewForm->OnSuperChange = MainMenuForm->SuperChange; FullViewForm->OnUpdateMenu = UpdateMenuItems; if ((PaletteForm = new TPaletteForm(this)) == NULL) goto fail; PaletteForm->Parent = this; PaletteForm->Visible = true; PaletteForm->OnChoiceColor = MainMenuForm->ChoiceColor; PaletteForm->OnColorChange = MainMenuForm->ColorChange; PaletteForm->OnCursorIndexChange = MainMenuForm->CursorIndexChange; PaletteForm->OnUpdateMenu = UpdateMenuItems; ToolsRearrange(); if ((ColorChartForm = new TColorChartForm(this)) == NULL) goto fail; ColorChartForm->Parent = this; if ((ColorLibraryForm = new TColorLibraryForm(this)) == NULL) goto fail; ColorLibraryForm->Parent = this; ColorLibraryForm->OnColorChange = ::KnitRepaintColor; if ((UserColorLibForm = new TUserColorLibForm(this)) == NULL) goto fail; UserColorLibForm->Parent = this; create_mark(); read_stitch_data(); if ((MarkEditForm = new TMarkEditForm(this)) == NULL) goto fail; MarkEditForm->Parent = this; if ((KnittingForm = new TKnittingForm(this)) == NULL) goto fail; KnittingForm->Parent = this; ClipboardFormat[0] = RegisterClipboardFormat("Texpro"); ClipboardFormat[1] = RegisterClipboardFormat("TPMark"); if ((StatusProgress = new TStatusProgress(StatusBar, StatusBarHint)) == NULL) { ec = EC_MEMORY_LACK; goto fail; } if ((FileHistory = new TFileHistory(DirectoryItem + "\\Main.ini", 8, FReopenItem, &OpenFile)) == NULL) { ec = EC_MEMORY_LACK; goto fail; } if ((Undo = new TUndo) == NULL) { ec = EC_MEMORY_LACK; goto fail; } Undo->Method = UM_STACK; bFirst = 1; CompressMethod = cmZLib; if (L_IsTwainAvailable(Handle)) { FScanningItem->Enabled = true; FScannerSetupItem->Enabled = true; } else { FScanningItem->Enabled = false; FScannerSetupItem->Enabled = false; } srand(clock()); //======================================== SetSmallFont(Font); SetSmallFont(StatusBar->Font); /* //before code ifdef lock_crypkey.... // Caption = IDS_TDCSP; #ifdef JAPAN switch (Items >> 14) { case 1: Caption = "Yuka & Alpha - Knit (Education)"; break; case 2: Caption = "Yuka & Alpha - Knit (Demo)"; break; default: Caption = "Yuka & Alpha - Knit (Professional)"; break; } #else #ifdef LOCK_IFC Caption = "Texpro Design CAD System - Knit (Professional)"; #else switch (Items >> 14) { case 1: Caption = "Texpro Design CAD System - Knit (Education)"; break; case 2: Caption = "Texpro Design CAD System - Knit (Demo)"; break; default: Caption = "Texpro Design CAD System - Knit (Professional)"; break; } #endif #endif */ #ifdef LOCK_CRYPKEY #ifdef JAPAN #ifdef EDUCATION Caption = "Yuka & Alpha - Knit (Education)"; #endif #ifdef DEMO Caption = "Yuka & Alpha - Knit (Demo)"; #endif #ifdef PROFESSIONAL Caption = "Yuka & Alpha - Knit (Professional)"; #endif #else #ifdef EDUCATION Caption = "Texpro Design CAD System - Knit (Education)"; #endif #ifdef DEMO Caption = "Texpro Design CAD System - Knit (Demo)"; #endif #ifdef PROFESSIONAL Caption = "Texpro Design CAD System - Knit (Professional)"; #endif #endif #else #ifdef JAPAN switch (Items >> 14) { case 1: Caption = "Yuka & Alpha - Knit (Education)"; break; case 2: Caption = "Yuka & Alpha - Knit (Demo)"; break; default: Caption = "Yuka & Alpha - Knit (Professional)"; break; } #else #ifdef LOCK_IFC Caption = "Texpro Design CAD System - Knit (Professional)"; #else switch (Items >> 14) { case 1: Caption = "Texpro Design CAD System - Knit (Education)"; break; case 2: Caption = "Texpro Design CAD System - Knit (Demo)"; break; default: Caption = "Texpro Design CAD System - Knit (Professional)"; break; } #endif #endif #endif FileItem->Caption = IDS_FILE; FNewCanvasItem->Caption = IDS_F256COLOR; FManagerItem->Caption = IDS_FFILEMANAGER; FReopenItem->Caption = IDS_FREOPEN; FCloseItem->Caption = IDS_FCLOSE; // FCloseAllItem->Caption = IDS_FCLOSEALL; FEnlargeCanvasItem->Caption = IDS_FENLARGECANVAS; FResizeCanvasItem->Caption = IDS_FRESIZECANVAS; FScannerSetupItem->Caption = IDS_FSCANNERSETUP; FScanningItem->Caption = IDS_FSCANNING; FPrinterSetupItem->Caption = IDS_COMMON_PRINTERSETUP; FPrintingItem->Caption = IDS_COMMON_PRINTING; FFontItem->Caption = IDS_COMMON_FONTSETUP; FEnvironmentItem->Caption = IDS_COMMON_ENVIRONMENTSETUP; // FExitItem->Caption = IDS_COMMON_EXIT; FExitItem->Caption = IDS_FEXIT; EditItem->Caption = IDS_EDIT; ECutItem->Caption = IDS_ECUT; ECopyItem->Caption = IDS_ECOPY; EPasteItem->Caption = IDS_EPASTE; ViewItem->Caption = IDS_VIEW; VPenItem->Caption = IDS_VSPECIALPEN; VFullViewItem->Caption = IDS_VFULLVIEW; VPaletteItem->Caption = IDS_VPALETTE; VMainMenuItem->Caption = IDS_VMAINMENU; VMarkLibItem->Caption = IDS_VMARKLIB; VStatusBarItem->Caption = IDS_VSTATUSBAR; WindowItem->Caption = IDS_WINDOW; WCascadeItem->Caption = IDS_WCASCADE; WTileItem->Caption = IDS_WTILE; WArrangeItem->Caption = IDS_WARRANGEICONS; WMinimizeItem->Caption = IDS_WMINIMIZEALL; HelpItem->Caption = IDS_HELP; HAboutItem->Caption = IDS_HABOUT; Knit11->Caption = IDS_KN1; knit2->Caption = IDS_KN2; knit3->Caption = IDS_KN3; knit4->Caption = IDS_KN4; knit5->Caption = IDS_KN5; knit6->Caption = IDS_KN6; Markchartform1->Caption = IDS_KN7; N6->Caption = IDS_KN8; knittingform1->Caption = IDS_KN9; N8->Caption = IDS_KN10; //======================================== return; fail: ::doDestroy(Undo); ::doDestroy(FileHistory); ::doDestroy(StatusProgress); ::doDestroy(KnittingForm); ::doDestroy(MarkEditForm); exit_stitch_data(); ::doDestroy(UserColorLibForm); ::doDestroy(ColorLibraryForm); ::doDestroy(ColorChartForm); ::doDestroy(PaletteForm); ::doDestroy(FullViewForm); ::doDestroy(PenManagerForm); ::doDestroy(MainMenuForm); ::doDestroy(PantoneTextile); ::doDestroy(Pantone1000); ::doDestroy(TextileColor); ::doDestroy(StandardColor); ::doDestroy(PrinterColor); ::doDestroy(Tablet); ::doDestroy(SmallFont); ::doDestroy(ProtectCard); if ( ec == EC_NONE) ec = EC_FORM_NOT_CREATE; EXCEPTION_MESSAGE_OK(ec); Application->Terminate(); } //--------------------------------------------------------------------------- void __fastcall TMainForm::FormActivate(TObject *Sender) { TMainImageForm *Child; TPCanvasInfor p; AnsiString FileName, DirName; int KnitDPI; if (bFirst==1) { //========================================== if (ParamStr(1) != "") { DirName = ExtractFileDir(ParamStr(1)); FileName = ExtractFileName(ParamStr(1)); OpenFile(DirName, FileName, gffKNT, 8); } else { Child = new TMainImageForm(Application); p.Orientation = coPortrait; //================================ //2001.4.10. by lhskys congi¿¡¼­ Á¾ÀÌ size ³Ö±â TIniFile *IniFile = new TIniFile(DirectoryItem+"\\Environment.ini"); int cst; if(Size_Type == "cstA4"){p.SetSize(cstA4); cst = 0; IniFile->WriteInteger("MainImage","Size",cst); }else if(Size_Type == "cstA3"){p.SetSize(cstA3); cst = 1; IniFile->WriteInteger("MainImage","Size",cst); }else if(Size_Type == "cstA2"){p.SetSize(cstA2); cst = 2; IniFile->WriteInteger("MainImage","Size",cst); }else if(Size_Type == "cstA1"){p.SetSize(cstA1); cst = 3; IniFile->WriteInteger("MainImage","Size",cst); }else if(Size_Type == "cstA0"){p.SetSize(cstA0); cst = 4; IniFile->WriteInteger("MainImage","Size",cst); }else if(Size_Type == "cstLetter"){p.SetSize(cstLetter); cst = 6; IniFile->WriteInteger("MainImage","Size",cst); }else if(Size_Type == "cstLegal"){p.SetSize(cstLegal); cst = 7; IniFile->WriteInteger("MainImage","Size",cst); }else if(Size_Type == "cstTabloid"){p.SetSize(cstTabloid); cst = 8; IniFile->WriteInteger("MainImage","Size",cst); } VMarkLibItem->Checked = IniFile->ReadBool("View", "Mark Library", true); //====================================== //2001.4.10. by lhskys ±îÁö KnitDPI = IniFile->ReadInteger("CanvasInfor", "DPI", 160); p.DotsPerInch = KnitDPI; // p.SetSize(cstA4); Child->InitForm(p, 12, 10); } //========================================== bFirst = 2; ToolsRearrange(); } } //--------------------------------------------------------------------------- void __fastcall TMainForm::FormCreate(TObject *Sender) { // } //--------------------------------------------------------------------------- void __fastcall TMainForm::FormClose(TObject *Sender, TCloseAction &Action) { TIniFile *IniFile = new TIniFile(DirectoryItem+"\\Environment.ini"); if (IniFile) { IniFile->WriteBool("View", "Mark Library", VMarkLibItem->Checked); delete IniFile; } } //--------------------------------------------------------------------------- void __fastcall TMainForm::FormDestroy(TObject *Sender) { ::doDestroy(Undo); ::doDestroy(FileHistory); ::doDestroy(StatusProgress); ::doDestroy(KnittingForm); ::doDestroy(MarkEditForm); exit_stitch_data(); delete_mark(); changeDueDay(); ::doDestroy(ColorLibraryForm); ::doDestroy(UserColorLibForm); ::doDestroy(ColorChartForm); ::doDestroy(PaletteForm); ::doDestroy(FullViewForm); ::doDestroy(PenManagerForm); ::doDestroy(MainMenuForm); ::doDestroy(PantoneTextile); ::doDestroy(Pantone1000); ::doDestroy(TextileColor); ::doDestroy(StandardColor); ::doDestroy(PrinterColor); ::doDestroy(Tablet); ::doDestroy(SmallFont); ::doDestroy(ProtectCard); Screen->OnActiveFormChange = NULL; } //--------------------------------------------------------------------------- void __fastcall TMainForm::changeDueDay() { unsigned char blk[8], newk[8] = {'^', '*', 'F', 'S', '0', '>', '?', '['}, k[8] = {'^', '*', 'F', 'S', '0', '>', '?', '['}; int nowJul, pastJul, due, sumDay; TRegIniFile *RegIniFile; AnsiString pw, str; int timePass[4]; RegIniFile = new TRegIniFile(RegFilename); RegIniFile->RootKey = HKEY_LOCAL_MACHINE; RegIniFile->OpenKey("SOFTWARE\\YoungWoo\\Texpro\\8.01\\",true); if (RegIniFile) { pw = RegIniFile->ReadString("Common", "Product No.", ""); if (pw == "") return; sscanf(pw.c_str(), "%d-%d-%d-%d", &timePass[0], &timePass[1], &timePass[2], &timePass[3]); delete RegIniFile; } else return; blk[0] = timePass[0] & 0xFF; blk[1] = (timePass[0] >> 8) & 0xFF; blk[2] = timePass[1] & 0xFF; blk[3] = (timePass[1] >> 8) & 0xFF; blk[4] = timePass[2] & 0xFF; blk[5] = (timePass[2] >> 8) & 0xFF; blk[6] = timePass[3] & 0xFF; blk[7] = (timePass[3] >> 8) & 0xFF; decrypt(k, blk); sumDay = blk[0]; sumDay |= blk[1] << 8; sumDay |= blk[2] << 16; sumDay |= blk[3] << 24; pastJul = sumDay; sumDay = blk[4]; sumDay |= blk[5] << 8; sumDay |= blk[6] << 16; sumDay |= blk[7] << 24; due = sumDay; nowJul = toJulian(); //======================================================= blk[0] = nowJul & 0xFF; blk[1] = (nowJul >> 8) & 0xFF; blk[2] = (nowJul >> 16) & 0xFF; blk[3] = (nowJul >> 24) & 0xFF; due = (pastJul+due) - nowJul; blk[4] = due & 0xFF; blk[5] = (due >> 8) & 0xFF; blk[6] = (due >> 16) & 0xFF; blk[7] = (due >> 24) & 0xFF; encrypt(newk, blk); str = Format("%d-%d-%d-%d", OPENARRAY(TVarRec, ((blk[1]<<8)|blk[0], (blk[3]<<8)|blk[2], (blk[5]<<8)|blk[4], (blk[7]<<8)|blk[6]))); RegIniFile = new TRegIniFile(RegFilename); RegIniFile->RootKey = HKEY_LOCAL_MACHINE; RegIniFile->OpenKey("SOFTWARE\\YoungWoo\\Texpro\\8.01\\",true); if (RegIniFile) { RegIniFile->WriteString("Common", "Product No.", str); delete RegIniFile; } //======================================================= } //--------------------------------------------------------------------------- void __fastcall TMainForm::InitMenuItem(TKnitMenuItem kmi) { KnitMenuItem = kmi; switch (KnitMenuItem) { case K_YARN_MAKE: YarnTableForm = new TYarnTableForm(this); YarnTableForm->Parent = this; YarnTableForm->Visible = false; YarnTableForm->InitForm(false); YarnDesignForm = new TYarnDesignForm(this); YarnDesignForm->Parent = this; YarnDesignForm->Visible = true; YarnDesignForm->MakeButton->SetFocus(); //lhskys ¿£ÅÍ·Î ½ÇÇàÇϱâÀ§ÇØ! break; case K_YARN_SCAN: YarnTableForm = new TYarnTableForm(this); YarnTableForm->Parent = this; YarnTableForm->Visible = false; YarnScanForm = new TYarnScanForm(this); YarnScanForm->Parent = this; YarnScanForm->Visible = true; break; } } //--------------------------------------------------------------------------- void __fastcall TMainForm::FormResize(TObject *Sender) { int w = StatusBar->Width-(160+80+100+100+200); StatusBar->Panels->Items[StatusBarHint]->Width = w<100 ? 100 : w; if (StatusProgress) StatusProgress->Resize(); } //--------------------------------------------------------------------------- void __fastcall TMainForm::FormShow(TObject *Sender) { if (MDIChildCount>0) ToolsRearrange(); } //--------------------------------------------------------------------- void __fastcall TMainForm::FNewCanvasItemClick(TObject *Sender) { TCursor cur; TMainImageForm *Child = NULL; TNewCanvasForm *Form = NULL; TPException ec; MainMenuForm->ExitForm(); #ifndef LOCK_CRYPKEY #ifdef LOCK_IFC if (ProtectCard->CheckPassword()) { #else ProtectCard->Read(); #endif #endif if ((Form = new TNewCanvasForm(NULL)) == NULL) { ec = EC_FORM_NOT_CREATE; goto fail; } if (Form->ShowModal()==mrOk) { DesignMode = D_YARN; cur = Screen->Cursor; Screen->Cursor = crHourGlass; if ((Child = new TMainImageForm(Application)) == NULL) { ec = EC_FORM_NOT_CREATE; goto fail; } MainMenuForm->NewForm(); if ((ec = Child->InitForm(Form->CanvasInfor, Form->seWPI->Value, Form->seCPI->Value)) != EC_NONE) goto fail; Screen->Cursor = cur; } delete Form; #ifndef LOCK_CRYPKEY #ifdef LOCK_IFC } else { EXCEPTION_MESSAGE_OK(EC_INTERFACE_NONE); Application->Terminate(); } #endif #endif return; fail: if (Form) { if (Child) delete Child; Screen->Cursor = cur; delete Form; } EXCEPTION_MESSAGE_OK(ec); } //--------------------------------------------------------------------------- void __fastcall TMainForm::FEnlargeCanvasItemClick(TObject *Sender) { TCursor cur; TEnlargeCanvasForm *Form; MainMenuForm->ExitForm(); #ifndef LOCK_CRYPKEY #ifdef LOCK_IFC if (ProtectCard->CheckPassword()) { #endif #endif Form = new TEnlargeCanvasForm(this); Form->CanvasInfor = MainImageForm->CanvasInfor; if (Form->ShowModal()==mrOk) { cur = Screen->Cursor; Screen->Cursor = crHourGlass; MainImageForm->EnlargeCanvas(Form->NewSize.cx, Form->NewSize.cy); Screen->Cursor = cur; } delete Form; #ifndef LOCK_CRYPKEY #ifdef LOCK_IFC } else { EXCEPTION_MESSAGE_OK(EC_INTERFACE_NONE); Application->Terminate(); } #endif #endif } //--------------------------------------------------------------------- void __fastcall TMainForm::FResizeCanvasItemClick(TObject *Sender) { TCursor cur; TResizeCanvasForm *Form; MainMenuForm->ExitForm(); #ifndef LOCK_CRYPKEY #ifdef LOCK_IFC if (ProtectCard->CheckPassword()) { #endif #endif Form = new TResizeCanvasForm(this); Form->CanvasInfor = MainImageForm->CanvasInfor; Form->InitForm(MainImageForm->Arrange->kdsn.wpi, MainImageForm->Arrange->kdsn.cpi); if (Form->ShowModal()==mrOk) { cur = Screen->Cursor; Screen->Cursor = crHourGlass; if (Form->Item) { MainImageForm->Arrange->kdsn.wpi = Form->sePWPI->Value; MainImageForm->Arrange->kdsn.cpi = Form->sePCPI->Value; } else { MainImageForm->Arrange->kdsn.wpi = Form->seWPI->Value; MainImageForm->Arrange->kdsn.cpi = Form->seCPI->Value; } MainImageForm->ResizeCanvas(MainImageForm->CanvasInfor.DotsPerInch, Form->NewSize.cx, Form->NewSize.cy); Screen->Cursor = cur; } delete Form; #ifndef LOCK_CRYPKEY #ifdef LOCK_IFC } else { EXCEPTION_MESSAGE_OK(EC_INTERFACE_NONE); Application->Terminate(); } #endif #endif } //--------------------------------------------------------------------------- void __fastcall TMainForm::FManagerItemClick(TObject *Sender) { TFileManagerForm *Form; MainMenuForm->ExitForm(); #ifndef LOCK_CRYPKEY #ifdef LOCK_IFC if (ProtectCard->CheckPassword()) { #else ProtectCard->Read(); #endif #endif if ((Form = new TFileManagerForm(this)) == NULL) goto fail; Form->Extension = 0; Form->CompressCheckBox->Checked = (CompressMethod == cmNone) ? false: true; Form->FilterComboBox->Filter = "Texpro Knit File (*.knt)|*.knt|" "Texpro Textile 256 Colors File (*.tex)|*.tex"; Form->OnRead = FMOnRead; // Form->OnMerge = FMOnMerge; Form->OnFileName = FMOnFileName; if (MainImageForm) { Form->SpeedButtonSave->Enabled = true; Form->SpeedButtonSaveAs->Enabled = true; Form->OnSave = FMOnSave; } else { Form->SpeedButtonSave->Enabled = false; Form->SpeedButtonSaveAs->Enabled = false; } // Form->OnSave = FMOnSave; Form->ShowModal(); delete Form; #ifndef LOCK_CRYPKEY #ifdef LOCK_IFC } else { EXCEPTION_MESSAGE_OK(EC_INTERFACE_NONE); Application->Terminate(); } #endif #endif return; fail: EXCEPTION_MESSAGE_OK(EC_FORM_NOT_CREATE); } //--------------------------------------------------------------------- void __fastcall TMainForm::FCloseItemClick(TObject *Sender) { if (ActiveMDIChild) ActiveMDIChild->Close(); } //--------------------------------------------------------------------------- /* void __fastcall TMainForm::FCloseAllItemClick(TObject *Sender) { MainMenuForm->ExitForm(); for (int i=MDIChildCount-1; i>=0; i--) MDIChildren[i]->Close(); } */ //--------------------------------------------------------------------- void __fastcall TMainForm::FScanningItemClick(TObject *Sender) { RECT r; BITMAPHANDLE hBitmap; int nRet; RGBQUAD rgb[256]; HDC dcSrc = NULL, dcDst = NULL; Byte c[256]; int x, y, w, h, ec; Byte *bp; TTexpiaBitmap *bmp; TCursor OldCursor = Screen->Cursor; Screen->Cursor = crDefault; bmp = &MainImageForm->iMainImage->ArrayBitmap[0]; memset(&hBitmap, 0, sizeof(BITMAPHANDLE)); if (L_InitBitmap(&hBitmap, 0, 0, 24)WorkArea->Reset(true); r.left = 0; r.top = 0; r.right = bmp->Width; r.bottom = bmp->Height; bmp->FillRect(r, PaletteForm->DIB256Palette->GetBGCOLORREF(8)); MainImageForm->iMainImage->ArrayBitmap[1].FillRect(r, 0); MainImageForm->iMainImage->ArrayBitmap[2].FillRect(r, PALETTEINDEX(1)); L_GetBitmapColors(&hBitmap, 0, 256, rgb); bmp->PutColors(0, 256, rgb); if (hBitmap.Width>bmp->Width) w = bmp->Width; else w = hBitmap.Width; if (hBitmap.Height>bmp->Height) h = bmp->Height; else h = hBitmap.Height; if ((dcSrc = L_CreateLeadDC(&hBitmap))==NULL) { ec = EC_RESOURCE_LACK; goto fail; } if ((dcDst = bmp->CreateDC())==NULL) { ec = EC_RESOURCE_LACK; goto fail; } BitBlt(dcDst, 0, bmp->Height - h, w, bmp->Height, dcSrc, 0, 0, SRCCOPY); bmp->DeleteDC(dcDst); dcDst = NULL; L_DeleteLeadDC(dcSrc); dcSrc = NULL; r.top = bmp->Height - h; r.right = w; r.bottom = bmp->Height; memset(c, 0, 256); if (!bmp->StartScanLine()) { ec = EC_MEMORY_LACK; goto fail; } for (y=r.top; yGetScanLine(y); for (x=0; xPutScanLine(y); } bmp->StopScanLine(); for (x=0; x<=249; x++) { MainImageForm->Palette->SetNormal(x+2, rgb[x].rgbRed, rgb[x].rgbGreen, rgb[x].rgbBlue); } MainImageForm->Palette->ToRGBQUAD(rgb, 256); bmp->PutColors(0, 256, rgb); for (x=251; x>=1; x--) { if (c[x]==1) { MainImageForm->Palette->UseColor = x; break; } } MainImageForm->WorkArea->SetRectangle(r); MainImageForm->WorkAreaChange(); L_FreeBitmap(&hBitmap); MainImageForm->iMainImage->SetMark(); ::RepaintColor(); Screen->Cursor = OldCursor; return; fail: bmp->StopScanLine(); if (dcSrc) { if (dcDst) bmp->DeleteDC(dcDst); L_DeleteLeadDC(dcSrc); } L_FreeBitmap(&hBitmap); EXCEPTION_MESSAGE_OK(ec); /* RECT r; BITMAPHANDLE hBitmap; TTexpiaBitmap *bmp; int nRet; RGBQUAD rgb[256]; HDC dcSrc, dcDst; Byte c[256]; int x, y, w, h; Byte *bp; TCursor OldCursor = Screen->Cursor; Screen->Cursor = crDefault; bmp = &MainImageForm->iMainImage->ArrayBitmap[0]; nRet = L_InitBitmap(&hBitmap, 0, 0, 8); if (nRetWorkArea->Reset(true); r.left = 0; r.top = 0; r.right = bmp->Width; r.bottom = bmp->Height; bmp->FillRect(r, PaletteForm->DIB256Palette->GetBGCOLORREF(8)); L_GetBitmapColors(&hBitmap, 0, 256, rgb); bmp->PutColors(0, 256, rgb); if (hBitmap.Width>bmp->Width) w = bmp->Width; else w = hBitmap.Width; if (hBitmap.Height>bmp->Height) h = bmp->Height; else h = hBitmap.Height; dcSrc = L_CreateLeadDC(&hBitmap); if (dcSrc) { dcDst = bmp->CreateDC(); if (dcDst) { BitBlt(dcDst, 0, 0, w, h, dcSrc, 0, 0, SRCCOPY); } bmp->DeleteDC(dcDst); } L_DeleteLeadDC(dcSrc); r.right = w; r.bottom = h; memset(c, 0, 256); bmp->StartScanLine(); for (y=0; yGetScanLine(y); for (x=0; xPutScanLine(y); } bmp->StopScanLine(); for (x=0; x<=249; x++) { MainImageForm->Palette->SetNormal(x+2, rgb[x].rgbRed, rgb[x].rgbGreen, rgb[x].rgbBlue); } MainImageForm->Palette->ToRGBQUAD(rgb, 256); bmp->PutColors(0, 256, rgb); for (x=251; x>=1; x--) { if (c[x]==1) { MainImageForm->Palette->UseColor = x; break; } } MainImageForm->WorkArea->SetRectangle(r); MainImageForm->WorkAreaChange(); } } L_FreeBitmap(&hBitmap); } RepaintColor(); Screen->Cursor = OldCursor; */ } //--------------------------------------------------------------------- void __fastcall TMainForm::FScannerSetupItemClick(TObject *Sender) { int nRet; nRet = L_TwainSelect(Handle); if (nRetArrange->kdsn.wpi; cpi = MainImageForm->Arrange->kdsn.cpi; Form = new TKnitPrintForm(this); DPI = MainImageForm->CanvasInfor.DotsPerInch; Form->DPI = DPI; wrate = (double)DPI/wpi; crate = (double)DPI/cpi; //-------------------------------------------- Initializing for Print Form->BPWidth[0] = MainImageForm->iMainImage->ArrayBitmap[0].Width*wrate; Form->BPHeight[0] = MainImageForm->iMainImage->ArrayBitmap[0].Height*crate; Form->BPWidth[1] = MainImageForm->iMainImage->ArrayBitmap[1].Width*16; Form->BPHeight[1] = MainImageForm->iMainImage->ArrayBitmap[1].Height*16; Form->BPWidth[2] = MainImageForm->iMainImage->ArrayBitmap[2].Width; Form->BPHeight[2] = MainImageForm->iMainImage->ArrayBitmap[2].Height; if (MainImageForm->WorkArea->Mask) { if (DesignMode == D_KNIT) { MainImageForm->ConvertRegion(MainImageForm->WorkArea->Range, &area, false); Form->FSWidth[0] = (area.right - area.left+1)*(DPI/wpi); Form->FSHeight[0] = (area.bottom - area.top+1)*(DPI/cpi); Form->FSWidth[1] = (area.right - area.left+1)*16; Form->FSHeight[1] = (area.bottom - area.top+1)*16; Form->FSWidth[2] = MainImageForm->WorkArea->Range.right - MainImageForm->WorkArea->Range.left; Form->FSHeight[2] = MainImageForm->WorkArea->Range.bottom - MainImageForm->WorkArea->Range.top; Form->sp[0].x = area.left*(DPI/wpi); Form->sp[0].y = area.top*(DPI/cpi); Form->sp[1].x = area.left*16; Form->sp[1].y = area.top*16; Form->sp[2].x = MainImageForm->WorkArea->Range.left; Form->sp[2].y = MainImageForm->WorkArea->Range.top; } else { MainImageForm->ConvertRegion(MainImageForm->WorkArea->Range, &area, true); Form->FSWidth[0] = (MainImageForm->WorkArea->Range.right - MainImageForm->WorkArea->Range.left)*(DPI/wpi); Form->FSHeight[0] = (MainImageForm->WorkArea->Range.bottom - MainImageForm->WorkArea->Range.top)*(DPI/cpi); Form->FSWidth[1] = (MainImageForm->WorkArea->Range.right - MainImageForm->WorkArea->Range.left)*16; Form->FSHeight[1] = (MainImageForm->WorkArea->Range.bottom - MainImageForm->WorkArea->Range.top)*16; Form->FSWidth[2] = area.right - area.left; Form->FSHeight[2] = area.bottom - area.top; Form->sp[0].x = MainImageForm->WorkArea->Range.left*(DPI/wpi); Form->sp[0].y = MainImageForm->WorkArea->Range.top*(DPI/cpi); Form->sp[1].x = MainImageForm->WorkArea->Range.left*16; Form->sp[1].y = MainImageForm->WorkArea->Range.top*16; Form->sp[2].x = area.left; Form->sp[2].y = area.top; } } else { for (i =0; i<3; i++) { Form->FSWidth[i]=Form->BPWidth[i]; Form->FSHeight[i]=Form->BPHeight[i]; Form->sp[i].x = 0; Form->sp[i].y = 0; } } //---------------------------------------------- Form->InitForm(); if (Form->ShowModal()== mrOk) { if (Form->unit == 1) { //Cm-->Dot w = Form->rxFSWidth->Value*DPI/2.54 ; h = Form->rxFSHeight->Value*DPI/2.54; } else if (Form->unit == 2) { //Inch-->Dot w = Form->rxFSWidth->Value*DPI ; h = Form->rxFSHeight->Value*DPI; } else { w = Form->rxFSWidth->Value; h =Form->rxFSHeight->Value; } Pattern = new TTexpiaBitmap; Header = Form->rgHeader->ItemIndex; switch(Form->Item) { case 0: //Image if (Form->rgSize->ItemIndex ==0) { MainImageForm->ImageA4Print(Pattern, Header ); } else { if (!MainImageForm->WorkArea->Mask) Form->sp[2].y = Form->BPHeight[2] - h; MainImageForm->ImageFreePrint(Pattern, w, h, Form->rxRCol->Value, Form->rxRRow->Value, Form->sp[2], Header); } break; case 1: //Yarn if (Form->rgSize->ItemIndex ==0) { MainImageForm->YarnA4Print(Pattern, Header); } else { if (!MainImageForm->WorkArea->Mask) Form->sp[0].y = Form->BPHeight[0] - h; Form->sp[0].x = Form->sp[0].x/(DPI/wpi); Form->sp[0].y = Form->sp[0].y/(DPI/cpi); MainImageForm->YarnFreePrint(Pattern, w, h, Form->sp[0], Header); } break; case 2: //Mark if (Form->rgSize->ItemIndex ==0) { MainImageForm->MarkA4Print(Pattern); } else { if (!MainImageForm->WorkArea->Mask) Form->sp[1].y = Form->BPHeight[1] - h; Form->sp[1].x = Form->sp[1].x/16; Form->sp[1].y = Form->sp[1].y/16; MainImageForm->MarkFreePrint(Pattern, w, h, Form->sp[1]); } break; case 3: //Mix if (Form->rgSize->ItemIndex ==0) { MainImageForm->MixA4Print(Pattern, Header); } else { if (!MainImageForm->WorkArea->Mask) Form->sp[1].y = Form->BPHeight[1] - h; Form->sp[1].x = Form->sp[1].x/16; Form->sp[1].y = Form->sp[1].y/16; MainImageForm->MixFreePrint(Pattern, w, h, Form->sp[1], Header); } break; } SendToPrinter(Pattern, DPI, "Knit - "+MainImageForm->FileName, Form->rxPage->Value, Form->cbMethod->ItemIndex); if (Pattern) delete Pattern; } delete Form; } //--------------------------------------------------------------------------- void __fastcall TMainForm::FPrinterSetupItemClick(TObject *Sender) { PrinterSetupDialog->Execute(); } //--------------------------------------------------------------------------- void __fastcall TMainForm::FFontItemClick(TObject *Sender) { MainMenuForm->ExitForm(); FontDialog1->Font->Assign(SmallFont); if (FontDialog1->Execute()) { FontDialog1->Font->Size = 10; SmallFont->Assign(FontDialog1->Font); TIniFile *IniFile = new TIniFile(DirectoryItem + "\\Environment.ini"); if (IniFile) { SaveFont(IniFile, SmallFont, "Font"); delete IniFile; } PenManagerForm->SetFont(); FullViewForm->SetFont(); PaletteForm->SetFont(); MarkEditForm->SetFont(); KnittingForm->SetFont(); } } //--------------------------------------------------------------------------- void __fastcall TMainForm::FEnvironmentItemClick(TObject *Sender) { int u; MainMenuForm->ExitForm(); TEnvironmentForm *Form = new TEnvironmentForm(this); Form->ShowModal(); if (DesignMode == D_KNIT) { TIniFile *IniFile = new TIniFile(DirectoryItem+"\\Environment.ini"); if (IniFile) { u = IniFile->ReadInteger("MainImage", "Unit", 0); if (u == 0) { MainImageForm->CurrentUnit = uCm; MainImageForm->UnitChange(uCm); } else if (u == 1) { MainImageForm->CurrentUnit = uInch; MainImageForm->UnitChange(uInch); } else { MainImageForm->CurrentUnit = uDot; MainImageForm->UnitChange(uDot); } delete IniFile; } } delete Form; if (MainImageForm) MainImageForm->ApplyEnvironment(); } //--------------------------------------------------------------------------- void __fastcall TMainForm::FExitItemClick(TObject *Sender) { Close(); } //--------------------------------------------------------------------- void __fastcall TMainForm::ECutItemClick(TObject *Sender) { MainImageForm->EditCut(); } //--------------------------------------------------------------------- void __fastcall TMainForm::ECopyItemClick(TObject *Sender) { MainImageForm->EditCopy(); } //--------------------------------------------------------------------- void __fastcall TMainForm::EPasteItemClick(TObject *Sender) { MainImageForm->EditPaste(); } //--------------------------------------------------------------------------- void __fastcall TMainForm::YYarnMakerItemClick(TObject *Sender) { // MainMenuForm->YarnMakerStart = 1; //lhskys ½Ç¸¸µé±â ½ÃÀÛÀ» ¾Ë¸² ExitMenuItem(); MainMenuForm->ExitForm(); InitMenuItem(K_YARN_MAKE); } //--------------------------------------------------------------------------- void __fastcall TMainForm::YYarnScanItemClick(TObject *Sender) { ExitMenuItem(); MainMenuForm->ExitForm(); InitMenuItem(K_YARN_SCAN); } //--------------------------------------------------------------------------- void __fastcall TMainForm::VPenItemClick(TObject *Sender) { if (VPenItem->Checked) { VPenItem->Checked = false; PenManagerForm->Visible = false; } else { VPenItem->Checked = true; PenManagerForm->Visible = true; } UpdateMenuItems(Sender); } //--------------------------------------------------------------------- void __fastcall TMainForm::VFullViewItemClick(TObject *Sender) { if (VFullViewItem->Checked) { VFullViewItem->Checked = false; FullViewForm->Visible = false; } else { VFullViewItem->Checked = true; FullViewForm->Visible = true;; if (DesignMode==D_MARK) { FullViewForm->InitForm(MainImageForm->iMainImage, MainImageForm->iMainImage->ArrayBitmap); } else { FullViewForm->InitForm(MainImageForm->iMainImage); } } UpdateMenuItems(Sender); } //--------------------------------------------------------------------- void __fastcall TMainForm::VPaletteItemClick(TObject *Sender) { if (VPaletteItem->Checked) { VPaletteItem->Checked = false; PaletteForm->Visible = false; } else { VPaletteItem->Checked = true; PaletteForm->Visible = true; PaletteForm->InitForm(MainImageForm->Palette); } UpdateMenuItems(Sender); } //--------------------------------------------------------------------- void __fastcall TMainForm::VMainMenuItemClick(TObject *Sender) { MainMenuForm->ExitForm(); if (VMainMenuItem->Checked) { VMainMenuItem->Checked = false; MainMenuForm->Visible = false; } else { VMainMenuItem->Checked = true; MainMenuForm->Visible = true; } UpdateMenuItems(Sender); } //--------------------------------------------------------------------- void __fastcall TMainForm::VMarkLibItemClick(TObject *Sender) { VMarkLibItem->Checked = !VMarkLibItem->Checked; if (DesignMode != D_YARN) MarkEditForm->Visible = VMarkLibItem->Checked; } //--------------------------------------------------------------------------- void __fastcall TMainForm::VStatusBarItemClick(TObject *Sender) { if (VStatusBarItem->Checked) { VStatusBarItem->Checked = false; StatusBar->Visible = false; } else { VStatusBarItem->Checked = true; StatusBar->Visible = true; } UpdateMenuItems(Sender); } //--------------------------------------------------------------------------- void __fastcall TMainForm::VToolsRearrangeItemClick(TObject *Sender) { ToolsRearrange(); } //--------------------------------------------------------------------- void __fastcall TMainForm::WCascadeItemClick(TObject *Sender) { int i; //---- Must be done backwards through the MDIChildren array ---- added by k3dogs(20001114) for (i=0; MDIChildCount-1 >= i; i++) if (MDIChildren[i]->WindowState == wsMinimized) MDIChildren[i]->WindowState = wsNormal; Cascade(); } //--------------------------------------------------------------------- void __fastcall TMainForm::WTileItemClick(TObject *Sender) { int i; //---- Must be done backwards through the MDIChildren array ---- for (i=0; MDIChildCount-1 >= i; i++) if (MDIChildren[i]->WindowState == wsMinimized) MDIChildren[i]->WindowState = wsNormal; Tile(); } //--------------------------------------------------------------------- void __fastcall TMainForm::WArrangeItemClick(TObject *Sender) { ArrangeIcons(); } //--------------------------------------------------------------------- void __fastcall TMainForm::WMinimizeItemClick(TObject *Sender) { int i; //---- Must be done backwards through the MDIChildren array ---- for (i=MDIChildCount-1; i >= 0; i--) MDIChildren[i]->WindowState = wsMinimized; } //--------------------------------------------------------------------------- void __fastcall TMainForm::HAboutItemClick(TObject *Sender) { AboutBox->ShowModal(); } //--------------------------------------------------------------------------- void __fastcall TMainForm::DevItemClick(TObject *Sender) { // DevItem->Visible = !DevItem->Visible; } //--------------------------------------------------------------------------- void __fastcall TMainForm::DMarkItemClick(TObject *Sender) { /* TMenuItem *MenuItem = dynamic_cast(Sender); if (MenuItem->Name == "DMarkItem") { if (MarkEditForm) { MarkEditForm->Parent = this; MarkEditForm->Visible = true; } else { MarkEditForm = new TMarkEditForm(NULL); MarkEditForm->Parent = this; MarkEditForm->Visible = true; } } else if (MenuItem->Name == "DProductItem") { if (ProductDataForm) { ProductDataForm->Parent = this; ProductDataForm->Visible = true; } else { ProductDataForm = new TProductDataForm(NULL); ProductDataForm->ShowModal(); delete ProductDataForm; ProductDataForm = NULL; // ProductDataForm->Parent = this; // ProductDataForm->Visible = true; } } return; */ } //--------------------------------------------------------------------------- void __fastcall TMainForm::Timer50msTimer(TObject *Sender) { if (MainImageForm) MainImageForm->Timer50ms(); } //--------------------------------------------------------------------------- void __fastcall TMainForm::Timer200msTimer(TObject *Sender) { if (MainImageForm) MainImageForm->Timer200ms(); MainMenuForm->Timer200ms(); } //--------------------------------------------------------------------------- void __fastcall TMainForm::Timer1000msTimer(TObject *Sender) { TDateTime Date1; Date1 = Now(); String S; DateTimeToString(S,"yyyy-mm-dd ampm hh-nn-ss",Date1.CurrentDateTime()); StatusBar->Panels->Items[StatusBarDate]->Text = S; //StatusBar->Panels->Items[StatusBarDate]->Text = DateTimeToStr(Now()); if (MainImageForm) MainImageForm->Timer1000ms(); #ifndef LOCK_CRYPKEY #ifndef LOCK_IFC if (ProtectCard->isHacking) Application->Terminate(); #endif #endif } //--------------------------------------------------------------------- // Private Function //--------------------------------------------------------------------- void TMainForm::WTPacket(TMessage &msg) { WTPKT Result = Tablet->WTMPacket(msg); // StatusBar->Panels->Items[StatusBarHint]->Text = Format("%d x %d", // OPENARRAY(TVarRec, ((int)Tablet->MaxNPressure, (int)Tablet->prsNew))); if (Result&PK_CURSOR) PenManagerForm->Pen->Cursor = Tablet->curNew; } //--------------------------------------------------------------------- void TMainForm::TPMDestroyChildForm(TMessage &msg) { UpdateMenuItems(NULL); MainImageForm = (TMainImageForm *)ActiveMDIChild; } //--------------------------------------------------------------------- void __fastcall TMainForm::ApplicationActivate(TObject *Sender) { if (MDIChildCount>0) { MainImageForm = (TMainImageForm *)ActiveMDIChild; if (Tablet) Tablet->Activate(); if (MainImageForm) MainImageForm->FormActivate(MainImageForm); } } //--------------------------------------------------------------------- void __fastcall TMainForm::ShowHint(TObject *Sender) { Application->HintPause = 100; StatusBar->Panels->Items[StatusBarHint]->Text = Application->Hint; } //--------------------------------------------------------------------------- void __fastcall TMainForm::ToolsRearrange() { PenFormPos = Point(ClientWidth-PenManagerForm->Width-2, 2); FullViewFormPos = Point(ClientWidth-FullViewForm->Width-2, PenFormPos.y+PenManagerForm->Height+1); PaletteFormPos = Point(ClientWidth-PaletteForm->Width-2, FullViewFormPos.y+FullViewForm->Height+1); MainMenuFormPos = Point(ClientWidth-MainMenuForm->Width-2, PaletteFormPos.y+PaletteForm->Height+1); PenManagerForm->Left = PenFormPos.x; PenManagerForm->Top = PenFormPos.y; FullViewForm->Left = FullViewFormPos.x; FullViewForm->Top = FullViewFormPos.y; PaletteForm->Left = PaletteFormPos.x; PaletteForm->Top = PaletteFormPos.y; MainMenuForm->Left = MainMenuFormPos.x; MainMenuForm->Top = MainMenuFormPos.y; } //--------------------------------------------------------------------- TPException __fastcall TMainForm::FMOnRead(TFMReadParameter rp) { TCursor cur; TMainImageForm *Child = NULL; TPException ec; MainMenuForm->ExitForm(); cur = Screen->Cursor; Screen->Cursor = crHourGlass; DesignMode = D_YARN; if ((Child = new TMainImageForm(Application)) == NULL) { ec = EC_MEMORY_LACK; goto fail; } if ((ec = Child->InitFormFile(rp)) != EC_NONE) goto fail; Screen->Cursor = cur; return EC_NONE; fail: if (Child) delete Child; Screen->Cursor = cur; return ec; } //--------------------------------------------------------------------- bool __fastcall TMainForm::FMOnMerge(AnsiString FileName, TGraphicFileFormat ExtIndex) { #ifndef LOCK_CRYPKEY #ifndef LOCK_IFC ProtectCard->Check(); #endif #endif return MainImageForm->InitMerge(FileName, ExtIndex); } //--------------------------------------------------------------------- AnsiString __fastcall TMainForm::FMOnFileName(AnsiString FileName, TGraphicFileFormat ExtIndex) { char *s; AnsiString fn; s = AnsiStrScan(FileName.c_str(), '.'); if (s==NULL) { switch (ExtIndex) { case gffKNT: fn = FileName+".knt"; break; case gffTEX: fn = FileName+".tex"; break; } return fn; } else { return FileName; } } //--------------------------------------------------------------------- TPException __fastcall TMainForm::FMOnSave(AnsiString DirName, AnsiString FileName, TGraphicFileFormat ExtIndex, TCompressMethod cm) { #ifndef LOCK_CRYPKEY #ifndef LOCK_IFC ProtectCard->Check(); #endif #endif return MainImageForm->SaveToFile(DirName, FileName, ExtIndex, cm); } //--------------------------------------------------------------------------- void __fastcall TMainForm::OpenFile(AnsiString DirName, AnsiString FileName, int Index, WORD bpp) { TCursor cur; TMainImageForm *Child = NULL; TFMReadParameter rp; TPException ec; MainMenuForm->ExitForm(); cur = Screen->Cursor; Screen->Cursor = crHourGlass; if ((Child = new TMainImageForm(Application)) == NULL) { ec = EC_MEMORY_LACK; goto fail; } rp.DirName = DirName; rp.FileName = FileName; rp.ExtIndex = Index; if ((ec = Child->InitFormFile(rp)) != EC_NONE) goto fail; Screen->Cursor = cur; return; fail: if (Child) delete Child; Screen->Cursor = cur; EXCEPTION_MESSAGE_OK(ec); } //--------------------------------------------------------------------- // Public Function //--------------------------------------------------------------------------- void __fastcall TMainForm::ExitMenuItem() { switch (KnitMenuItem) { case K_YARN_MAKE: ::doDestroy(YarnDesignForm); ::doDestroy(YarnTableForm); break; case K_YARN_SCAN: ::doDestroy(YarnScanForm); ::doDestroy(YarnTableForm); break; } KnitMenuItem = K_NONE; } //--------------------------------------------------------------------------- void __fastcall TMainForm::UpdateTools() { MainImageForm = (TMainImageForm *)ActiveMDIChild; if (MainImageForm) { MainMenuForm->UpdateItem(); RepaintColor(); } else { PaletteForm->InitForm(NULL); } } //---------------------------------------------------------------------------- void __fastcall TMainForm::UpdateMenuItems(TObject *Sender) { if (bFirst==0) return; UpdateTools(); FEnlargeCanvasItem->Enabled = MDIChildCount > 0; FResizeCanvasItem->Enabled = MDIChildCount > 0; FCloseItem->Enabled = MDIChildCount > 0; // FCloseAllItem->Enabled = MDIChildCount > 0; FPrintingItem->Enabled = MDIChildCount > 0; EditItem->Enabled = MDIChildCount > 0; ViewItem->Enabled = MDIChildCount > 0; VPenItem->Checked = PenManagerForm->Visible; VFullViewItem->Checked = FullViewForm->Visible; VPaletteItem->Checked = PaletteForm->Visible; VMainMenuItem->Checked = MainMenuForm->Visible; VStatusBarItem->Checked = StatusBar->Visible; VToolsRearrangeItem->Enabled = MDIChildCount > 0; WCascadeItem->Enabled = MDIChildCount > 0; WTileItem->Enabled = MDIChildCount > 0; WArrangeItem->Enabled = MDIChildCount > 0; WMinimizeItem->Enabled = MDIChildCount > 0; Timer50ms->Enabled = MDIChildCount > 0; Timer200ms->Enabled = MDIChildCount > 0; Timer1000ms->Enabled = MDIChildCount > 0; PenManagerForm->Enabled = MDIChildCount > 0; FullViewForm->Enabled = MDIChildCount > 0; PaletteForm->Enabled = MDIChildCount > 0; // MainMenuForm->Enabled = MDIChildCount > 0; if (MDIChildCount == 0) MainMenuForm->CloseMainMenuItem(); // MainMenu ´ÝÇôµµ Filemanager´Â »ç¿ë °¡´ÉÇÏ°Ô } //--------------------------------------------------------------------------- void __fastcall TMainForm::FormKeyUp(TObject *Sender, WORD &Key, TShiftState Shift) { MainMenuForm->iMainImageKeyUp(Key); } //--------------------------------------------------------------------------- void __fastcall TMainForm::FormKeyDown(TObject *Sender, WORD &Key, TShiftState Shift) { MainMenuForm->iMainImageKeyDown(Key); //added by qe ¹æÇâŰ´Â ´Ù¿îÀ¸·Î¹Û¿¡ ¸ø¹ÞÀ½.. if(Key == 65 || Key == 83) MainImageForm->iMainImageKeyDown(Key); //È®´ëÃà¼Ò ´ÜÃàŰ·Î } //--------------------------------------------------------------------------- void __fastcall TMainForm::FormKeyPress(TObject *Sender, char &Key) { MainMenuForm->iMainImageKeyPress(this, Key); // MainMenuForm->iMainImageKeyDown(Key); } //--------------------------------------------------------------------------- void __fastcall TMainForm::educationknit(AnsiString str) { AnsiString screencam, cam, camdir; TRegistry *Registry; SHELLEXECUTEINFO screeninfo; Registry = new TRegistry; if (!Registry) return; Registry->RootKey = HKEY_CURRENT_USER; Registry->OpenKey("SOFTWARE\\Youngwoo\\TexPro\\8.01\\Directory",TRUE); screencam = Registry->ReadString("screencam"); delete Registry; memset(&screeninfo,0,sizeof(screeninfo)); screeninfo.cbSize = sizeof(screeninfo); screeninfo.lpVerb = "open"; screeninfo.lpDirectory = screencam.c_str(); screeninfo.lpFile = "scplayer.exe"; cam = screencam + "\\knit\\" + str; camdir = "\"" + cam + "\""; screeninfo.lpParameters = camdir.c_str(); screeninfo.fMask = SEE_MASK_NOCLOSEPROCESS; screeninfo.nShow = SW_SHOWDEFAULT; if(!ShellExecuteEx(&screeninfo)) { ShowMessage("can't play screencam movie."); return; } } //-------------------------------------------------------------------------- void __fastcall TMainForm::Knit11Click(TObject *Sender) { AnsiString filename; filename = "all_knit.scm"; educationknit(filename); } //--------------------------------------------------------------------------- void __fastcall TMainForm::knit2Click(TObject *Sender) { AnsiString filename; filename = "window(knit).scm"; educationknit(filename); } //--------------------------------------------------------------------------- void __fastcall TMainForm::knit3Click(TObject *Sender) { AnsiString filename; filename = "copymove(knit).scm"; educationknit(filename); } //--------------------------------------------------------------------------- void __fastcall TMainForm::knit4Click(TObject *Sender) { AnsiString filename; filename = "clear(knit).scm"; educationknit(filename); } //--------------------------------------------------------------------------- void __fastcall TMainForm::knit5Click(TObject *Sender) { AnsiString filename; filename = "repeat(knit).scm"; educationknit(filename); } //--------------------------------------------------------------------------- void __fastcall TMainForm::knit6Click(TObject *Sender) { AnsiString filename; filename = "drawing(knit).scm"; educationknit(filename); } //--------------------------------------------------------------------------- void __fastcall TMainForm::Markchartform1Click(TObject *Sender) { AnsiString filename; filename = "markchartform.scm"; educationknit(filename); } //--------------------------------------------------------------------------- void __fastcall TMainForm::N6Click(TObject *Sender) { AnsiString filename; filename = "resize_canvas.scm"; educationknit(filename); } //--------------------------------------------------------------------------- void __fastcall TMainForm::knittingform1Click(TObject *Sender) { AnsiString filename; filename = "knitting.scm"; educationknit(filename); } //--------------------------------------------------------------------------- void __fastcall TMainForm::N8Click(TObject *Sender) { AnsiString filename; filename = "printer(knit).scm"; educationknit(filename); } //---------------------------------------------------------------------------