//--------------------------------------------------------------------- #include #include #pragma hdrstop #include "Main.h" #include "About.h" #include "ColorChart.h" #include "ColorLibrary_f.h" #include "Common.h" #include "Define.h" #include "EnlargeCanvas.h" #include "Environment.h" #include "Exception.h" #include "FileManager_F.h" #include "FullView.h" #include "History.h" #include "ProtectCard.h" #include "MainMenu_F.h" #include "NewCanvas.h" #include "Palette.h" #include "StatusProgress.h" #include "YarnDesign_F.h" #include "YarnTable_F.h" #include "UserColor_F.h" #include "PilePrint.h" #include "Printers.hpp" //--------------------------------------------------------------------------- /* #define IDS_WTEXPIADESIGNCAD StringTable[0] #define IDS_WNEWCANVAS StringTable[1] #define IDS_WFILEMANAGER StringTable[2] #define IDS_WREOPEN StringTable[3] #define IDS_WCLOSE StringTable[4] #define IDS_WCLOSEALL StringTable[5] #define IDS_WENLARGECANVAS StringTable[6] #define IDS_WPRINTERSETUP StringTable[7] #define IDS_WPRINTING StringTable[8] #define IDS_WOPTIONS StringTable[9] #define IDS_WFONT StringTable[10] #define IDS_ENVIRONMENT StringTable[11] #define IDS_WEDIT StringTable[12] #define IDS_WCOPY StringTable[13] #define IDS_WYARNDESIGN StringTable[14] #define IDS_WYARNMAKER StringTable[15] #define IDS_WYARNSCAN StringTable[16] #define IDS_WTEXTUREDESIGN StringTable[17] #define IDS_WPATTERNDESIGN StringTable[18] #define IDS_WYARN StringTable[19] #define IDS_WTEXTURE StringTable[20] #define IDS_WSIMULATION StringTable[21] #define IDS_WVIEW StringTable[22] #define IDS_WFULLVIEW StringTable[23] #define IDS_WPALETTE StringTable[24] #define IDS_WMAINMENU StringTable[25] #define IDS_WSTATUSBAR StringTable[26] #define IDS_WTOOLSREARRANGE StringTable[27] #define IDS_WWINDOW StringTable[28] #define IDS_WCASCADE StringTable[29] #define IDS_WTILE StringTable[30] #define IDS_WARRANGEICONS StringTable[31] #define IDS_WMINIMIZEALL StringTable[32] #define IDS_WHELP StringTable[33] #define IDS_WABOUT StringTable[34] #define IDS_WFILE StringTable[35] #define IDS_WEXIT StringTable[36] */ #define IDS_WTEXPIADESIGNCAD StringTable[0] #define IDS_WNEWCANVAS StringTable[1] #define IDS_WFILEMANAGER StringTable[2] #define IDS_WREOPEN StringTable[3] #define IDS_WCLOSE StringTable[4] #define IDS_WENLARGECANVAS StringTable[5] #define IDS_WPRINTERSETUP StringTable[6] #define IDS_WPRINTING StringTable[7] #define IDS_WFONT StringTable[8] #define IDS_WENVIRONMENT StringTable[9] #define IDS_WEDIT StringTable[10] #define IDS_WCOPY StringTable[11] #define IDS_WYARNDESIGN StringTable[12] #define IDS_WPATTERNDESIGN StringTable[13] #define IDS_WYARN StringTable[14] #define IDS_WTEXTURE StringTable[15] #define IDS_WSIMULATION StringTable[16] #define IDS_WVIEW StringTable[17] #define IDS_WFULLVIEW StringTable[18] #define IDS_WPALETTE StringTable[19] #define IDS_WMAINMENU StringTable[20] #define IDS_WSTATUSBAR StringTable[21] #define IDS_WTOOLSREARRANGE StringTable[22] #define IDS_WWINDOW StringTable[23] #define IDS_WCASCADE StringTable[24] #define IDS_WTILE StringTable[25] #define IDS_WARRANGEICONS StringTable[26] #define IDS_WMINIMIZEALL StringTable[27] #define IDS_WHELP StringTable[28] #define IDS_WABOUT StringTable[29] #define IDS_WFILE StringTable[30] #define IDS_WEXIT StringTable[31] //--------------------------------------------------------------------------- #pragma resource "*.dfm" TMainForm *MainForm; //--------------------------------------------------------------------- __fastcall TMainForm::TMainForm(TComponent *Owner) : TForm(Owner) { bFirst = 0; if(GetSystemMetrics(SM_CXSCREEN)>=1280&&GetSystemMetrics(SM_CYSCREEN)>=1024){ HorzScrollBar->Tracking=false; HorzScrollBar->Visible=false; VertScrollBar->Tracking=false; VertScrollBar->Visible=false; } else { HorzScrollBar->Tracking=true; HorzScrollBar->Visible=true; VertScrollBar->Tracking=true; VertScrollBar->Visible=true; } } //--------------------------------------------------------------------------- void __fastcall TMainForm::FormActivate(TObject *Sender) { TMainImageForm *Child = NULL; TPCanvasInfor p; TPException ec = EC_NONE; AnsiString FileName, DirName; if (bFirst==1) { if (ParamStr(1) != "") { FileName = ExtractFileName(ParamStr(1)); DirName = ExtractFileDir(ParamStr(1)); OpenFile(DirName, DirName + "\\" + FileName, gffPIL, 8); } else { if ((Child = new TMainImageForm(Application))==NULL) { ec = EC_FORM_NOT_CREATE; goto fail; } p.Orientation = coPortrait; p.DotsPerInch = 160; p.SetSize(cstA4); if ((ec = Child->InitForm(p))!=EC_NONE) goto fail; } bFirst = 2; ToolsRearrange(); } return; fail: if (Child) delete Child; EXCEPTION_MESSAGE_OK(ec); } //--------------------------------------------------------------------- void __fastcall TMainForm::FormCreate(TObject *Sender) { int Items; TIniFile *IniFile; TPException ec = EC_NONE; Application->OnActivate = ApplicationActivate; Application->OnHint = ShowHint; Screen->OnActiveFormChange = UpdateMenuItems; 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_PILE)!=PCN_PILE) { ec = EC_INTERFACE_NONE; goto fail; } if (!ProtectCard->CheckPassword()) { ec = EC_INTERFACE_NONE; goto fail; } #else Items = ProtectCard->Init(Password); if (Items<1 || (Items&PCN_PILE)!=PCN_PILE) { ec = EC_INTERFACE_NONE; goto fail; } #endif #endif CommonStringTable.Create(DirectoryBin, Language, "Common"); if ((SmallFont = new TFont)==NULL) { ec = EC_MEMORY_LACK; goto fail; } IniFile = new TIniFile(AppDataItem + "\\Environment.ini"); if (IniFile) { LoadFont(IniFile, SmallFont, "Font"); for (int i=0; i<7; i++) { YarnBrightness[i] = IniFile->ReadFloat("YarnBrightness", AnsiString(i), -0.03+i*0.01); } 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) { //k3dogs Palette¿¡¼­ ec = EC_MEMORY_LACK; goto fail; //Pantone Color Code¸¦ } //ã±â À§Çؼ­ if ((PantoneTextile = new TPantoneTextile(DirectoryColor+"\\Textile.ptc"))==NULL) { //20001211 ec = EC_MEMORY_LACK; goto fail; } if ((MainMenuForm = new TMainMenuForm(this))==NULL) goto fail; MainMenuForm->Parent = this; MainMenuForm->Visible = true; MainMenuForm->OnUpdateMenu = UpdateMenuItems; if ((FullViewForm = new TFullViewForm(this))==NULL) goto fail; FullViewForm->Parent = this; FullViewForm->Visible = true; FullViewForm->OnUpdateMenu = UpdateMenuItems; if ((PaletteForm = new TPaletteForm(this))==NULL) goto fail; PaletteForm->Parent = this; PaletteForm->Visible = true; 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 = ::RepaintColor; if ((UserColorLibForm = new TUserColorLibForm(this))==NULL) goto fail; UserColorLibForm->Parent = this; ClipboardFormat = RegisterClipboardFormat("Texpro"); 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; } bFirst = 1; PileMenuItem = P_NONE; YarnRatio = 0.4; CompressMethod = cmZLib; //===================================================== StringTable.Create(DirectoryItem, Language, "Main"); SetSmallFont(Font); SetSmallFont(StatusBar->Font); /* // before code ifdef lock_crypkey..... // Caption = IDS_WTEXPIADESIGNCAD; #ifdef LOCK_IFC Caption = "Texpro Design CAD System - Pile (Professional)"; #else switch (Items >> 14) { case 1: Caption = "Texpro Design CAD System - Pile (Education)"; break; case 2: Caption = "Texpro Design CAD System - Pile (Demo)"; break; default: Caption = "Texpro Design CAD System - Pile (Professional)"; break; } #endif */ #ifdef LOCK_CRYPKEY #ifdef EDUCATION Caption = "Texpro Design CAD System - Pile (Education)"; #endif #ifdef DEMO Caption = "Texpro Design CAD System - Pile (Demo)"; #endif #ifdef PROFESSIONAL Caption = "Texpro Design CAD System - Pile (Professional)"; #endif #else #ifdef LOCK_IFC Caption = "Texpro Design CAD System - Pile (Professional)"; #else switch (Items >> 14) { case 1: Caption = "Texpro Design CAD System - Pile (Education)"; break; case 2: Caption = "Texpro Design CAD System - Pile (Demo)"; break; default: Caption = "Texpro Design CAD System - Pile (Professional)"; break; } #endif #endif FileItem->Caption = IDS_WTEXPIADESIGNCAD; FNewCanvasItem->Caption = IDS_WNEWCANVAS; FFileManagerItem->Caption = IDS_WFILEMANAGER; FReopenItem->Caption = IDS_WREOPEN; FCloseItem->Caption = IDS_WCLOSE; FEnlargeCanvasItem->Caption = IDS_WENLARGECANVAS; FPrinterSetupItem->Caption = IDS_WPRINTERSETUP; FPrintingItem->Caption = IDS_WPRINTING; FFontItem->Caption = IDS_WFONT; FEnvironment->Caption = IDS_WENVIRONMENT; EditItem->Caption = IDS_WEDIT; ECopyItem->Caption = IDS_WCOPY; YarnDesignItem->Caption = IDS_WYARNDESIGN; PatternDesignItem->Caption = IDS_WPATTERNDESIGN; PYarnItem->Caption = IDS_WYARN; PTextureItem->Caption = IDS_WTEXTURE; PSimulationItem->Caption = IDS_WSIMULATION; ViewItem->Caption = IDS_WVIEW; VFullViewItem->Caption = IDS_WFULLVIEW; VPaletteItem->Caption = IDS_WPALETTE; VMainMenuItem->Caption = IDS_WMAINMENU; VStatusBarItem->Caption = IDS_WSTATUSBAR; VToolsRearrangeItem->Caption = IDS_WTOOLSREARRANGE; WindowItem->Caption = IDS_WWINDOW; WCascadeItem->Caption = IDS_WCASCADE; WTileItem->Caption = IDS_WTILE; WArrangeItem->Caption = IDS_WARRANGEICONS; WMinimizeItem->Caption = IDS_WMINIMIZEALL; HelpItem->Caption = IDS_WHELP; HAboutItem->Caption = IDS_WABOUT; FileItem->Caption = IDS_WFILE; FExitItem->Caption = IDS_WEXIT; return; fail: ::doDestroy(FileHistory); ::doDestroy(StatusProgress); ::doDestroy(UserColorLibForm); ::doDestroy(ColorLibraryForm); ::doDestroy(ColorChartForm); ::doDestroy(PaletteForm); ::doDestroy(FullViewForm); ::doDestroy(MainMenuForm); ::doDestroy(PantoneTextile); //k3dogs ::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::FormDestroy(TObject *Sender) { ExitMenuItem(); ::doDestroy(FileHistory); ::doDestroy(StatusProgress); ::doDestroy(ColorLibraryForm); ::doDestroy(UserColorLibForm); ::doDestroy(ColorChartForm); ::doDestroy(PaletteForm); ::doDestroy(FullViewForm); ::doDestroy(MainMenuForm); ::doDestroy(PantoneTextile); ::doDestroy(Pantone1000); ::doDestroy(TextileColor); ::doDestroy(StandardColor); ::doDestroy(PrinterColor); ::doDestroy(Tablet); ::doDestroy(SmallFont); ::doDestroy(ProtectCard); Screen->OnActiveFormChange = NULL; } //--------------------------------------------------------------------------- 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 = EC_NONE; ExitMenuItem(); 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) { cur = Screen->Cursor; Screen->Cursor = crHourGlass; if ((Child = new TMainImageForm(Application))==NULL) { ec = EC_FORM_NOT_CREATE; goto fail; } if ((ec = Child->InitForm(Form->CanvasInfor))!=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::FFileManagerItemClick(TObject *Sender) { TFileManagerForm *Form = NULL; ExitMenuItem(); MainMenuForm->ExitForm(); #ifndef LOCK_CRYPKEY #ifdef LOCK_IFC if (ProtectCard->CheckPassword()) { #else ProtectCard->Read(); #endif #endif if ((Form = new TFileManagerForm(this)) == NULL) goto fail; if (MainImageForm) { Form->Extension = MainImageForm->iMainImage->Bitmap->BitsPerPixel; } else { Form->Extension = 8; } Form->CompressCheckBox->Checked = (CompressMethod == cmNone) ? false: true; Form->FilterComboBox->Filter = "Texpro Weave File (*.pil)|*.pil"; Form->OnRead = FMOnRead; Form->OnFileName = FMOnFileName; 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) { ExitMenuItem(); MainMenuForm->ExitForm(); if (ActiveMDIChild) ActiveMDIChild->Close(); } //--------------------------------------------------------------------------- /* void __fastcall TMainForm::FCloseAllItemClick(TObject *Sender) { ExitMenuItem(); MainMenuForm->ExitForm(); for (int i=MDIChildCount-1; i>=0; i--) MDIChildren[i]->Close(); } */ //--------------------------------------------------------------------- void __fastcall TMainForm::FEnlargeCanvasItemClick(TObject *Sender) { TCursor cur; TEnlargeCanvasForm *Form; ExitMenuItem(); 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::FPrinterSetupItemClick(TObject *Sender) { PrinterSetupDialog->Execute(); } //--------------------------------------------------------------------------- void __fastcall TMainForm::FPrintingItemClick(TObject *Sender) { TPrintForm *Form; TTexpiaBitmap *Pattern; int DPI, len, item, zoom, mx, my, A4Width, A4Height; TSize r; ExitMenuItem(); MainMenuForm->ExitForm(); Form = new TPrintForm(this); if (Form->ShowModal() == mrOk) { Pattern = new TTexpiaBitmap; DPI = MainImageForm->CanvasInfor.DotsPerInch; A4Width = GetDeviceCaps(Printer()->Handle, HORZRES)*160/ GetDeviceCaps(Printer()->Handle, LOGPIXELSX); A4Height = GetDeviceCaps(Printer()->Handle, VERTRES)*160/ GetDeviceCaps(Printer()->Handle, LOGPIXELSY); switch (Form->Method) { case 0: // A4 Header No if (MainImageForm->Plan->mode) MainImageForm->A4YesModePrint(Pattern, A4Width, A4Height); else MainImageForm->A4NoModePrint(Pattern, A4Width, A4Height); break; case 1: // A4 Header Yes MainImageForm->A4YesPrint(Pattern, A4Width, A4Height); break; case 2: //A4 Image & Yarn MainImageForm->A4Image_YarnPrint(Pattern, A4Width, A4Height); break; case 3: // A4 Yarn Data MainImageForm->A4YarnPrint(Pattern, A4Width, A4Height); break; case 4: // A4 Texture Data MainImageForm->A4TexturePrint(Pattern, A4Width, A4Height); break; case 5: // Free MainImageForm->FreePrint(Pattern); break; } SendToPrinter(Pattern, DPI, "Pile - "+MainImageForm->FileName, Form->pspPage->Value, Form->cbMethod->ItemIndex); delete Pattern; } delete Form; } //--------------------------------------------------------------------------- void __fastcall TMainForm::FFontItemClick(TObject *Sender) { ExitMenuItem(); MainMenuForm->ExitForm(); FontDialog1->Font->Assign(SmallFont); if (FontDialog1->Execute()) { FontDialog1->Font->Size = 10; SmallFont->Assign(FontDialog1->Font); TIniFile *IniFile = new TIniFile(AppDataItem + "\\Environment.ini"); if (IniFile) { SaveFont(IniFile, SmallFont, "Font"); delete IniFile; } FullViewForm->SetFont(); PaletteForm->SetFont(); AboutBox->SetFont(); } } //--------------------------------------------------------------------------- void __fastcall TMainForm::FEnvironmentClick(TObject *Sender) { int unit; ExitMenuItem(); MainMenuForm->ExitForm(); TEnvironmentForm *Form = new TEnvironmentForm(this); if (Form->ShowModal()==mrOk) { TIniFile *IniFile = new TIniFile(AppDataItem+"\\Environment.ini"); if (IniFile) { for (int i=0; i<7; i++) { YarnBrightness[i] = IniFile->ReadFloat("YarnBrightness", AnsiString(i), -0.03+i*0.01); } unit = IniFile->ReadInteger("MainImage", "Unit", 0); if (unit == 0) MainImageForm->CurrentUnit = uCm; else MainImageForm->CurrentUnit = uInch; MainImageForm->UnitChange(); delete IniFile; } } delete Form; if (MainImageForm) MainImageForm->ApplyEnvironment(); } //--------------------------------------------------------------------------- void __fastcall TMainForm::FExitItemClick(TObject *Sender) { ExitMenuItem(); MainMenuForm->ExitForm(); Close(); } //--------------------------------------------------------------------- void __fastcall TMainForm::ECopyItemClick(TObject *Sender) { MainImageForm->EditCopy(); } //--------------------------------------------------------------------- void __fastcall TMainForm::YarnDesignItemClick(TObject *Sender) { ExitMenuItem(); MainMenuForm->ExitForm(); InitMenuItem(P_YARN); } //--------------------------------------------------------------------- void __fastcall TMainForm::PYarnItemClick(TObject *Sender) { MainMenuForm->sbYarnClick(NULL); } //--------------------------------------------------------------------------- void __fastcall TMainForm::PTextureItemClick(TObject *Sender) { MainMenuForm->sbTextureClick(NULL); } //--------------------------------------------------------------------------- void __fastcall TMainForm::PSimulationItemClick(TObject *Sender) { MainMenuForm->sbSimulationClick(NULL); } //--------------------------------------------------------------------------- void __fastcall TMainForm::VFullViewItemClick(TObject *Sender) { if (VFullViewItem->Checked) { VFullViewItem->Checked = false; FullViewForm->Visible = false; } else { VFullViewItem->Checked = true; FullViewForm->Visible = true;; 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::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) { Cascade(); } //--------------------------------------------------------------------- void __fastcall TMainForm::WTileItemClick(TObject *Sender) { 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::Timer200msTimer(TObject *Sender) { if (MainImageForm) MainImageForm->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 } //--------------------------------------------------------------------- void __fastcall TMainForm::UpdateMenuItems(TObject *Sender) { if (bFirst==0) return; UpdateTools(Sender); FCloseItem->Enabled = MDIChildCount > 0; // FCloseAllItem->Enabled = MDIChildCount > 0; FPrintingItem->Enabled = MDIChildCount > 0; EditItem->Enabled = MDIChildCount > 0; PatternDesignItem->Enabled = MDIChildCount > 0; PSimulationItem->Enabled = false; if (MainImageForm && MainImageForm->Plan) { PSimulationItem->Enabled = MainImageForm->Plan->Finish; } ViewItem->Enabled = MDIChildCount > 0; VFullViewItem->Checked = FullViewForm->Visible; VPaletteItem->Checked = PaletteForm->Visible; VMainMenuItem->Checked = MainMenuForm->Visible; VStatusBarItem->Checked = StatusBar->Visible; WCascadeItem->Enabled = MDIChildCount > 0; WTileItem->Enabled = MDIChildCount > 0; WArrangeItem->Enabled = MDIChildCount > 0; WMinimizeItem->Enabled = MDIChildCount > 0; Timer200ms->Enabled = MDIChildCount > 0; Timer1000ms->Enabled = MDIChildCount > 0; FullViewForm->Enabled = MDIChildCount > 0; PaletteForm->Enabled = MDIChildCount > 0; MainMenuForm->Enabled = MDIChildCount > 0; } //--------------------------------------------------------------------- // Private Function //--------------------------------------------------------------------- void TMainForm::WTPacket(TMessage &msg) { WTPKT Result = Tablet->WTMPacket(msg); } //-------------------------------------------------------------------------- void TMainForm::TPMExitFunction(TMessage &msg) { ExitMenuItem(); } //--------------------------------------------------------------------- void __fastcall TMainForm::ApplicationActivate(TObject *Sender) { TMainImageForm *mif = (TMainImageForm *)ActiveMDIChild; if (Tablet) Tablet->Activate(); if (mif) mif->FormActivate(mif); } //--------------------------------------------------------------------- void __fastcall TMainForm::ShowHint(TObject *Sender) { Application->HintPause = 100; StatusBar->Panels->Items[StatusBarHint]->Text = Application->Hint; } //--------------------------------------------------------------------------- void __fastcall TMainForm::ToolsRearrange() { FullViewFormPos = Point(ClientWidth-FullViewForm->Width-2, 2); PaletteFormPos = Point(ClientWidth-PaletteForm->Width-2, FullViewFormPos.y+FullViewForm->Height+1); MainMenuFormPos = Point(ClientWidth-MainMenuForm->Width-2, PaletteFormPos.y+PaletteForm->Height+1); 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 = EC_NONE; MainMenuForm->ExitForm(); cur = Screen->Cursor; Screen->Cursor = crHourGlass; if ((Child = new TMainImageForm(Application)) == NULL) { ec = EC_FORM_NOT_CREATE; goto fail; } if ((ec = Child->InitFormFile(rp.DirName, rp.FileName)) != EC_NONE) goto fail; Screen->Cursor = cur; return EC_NONE; fail: if (Child) delete Child; Screen->Cursor = cur; return ec; } //--------------------------------------------------------------------- AnsiString __fastcall TMainForm::FMOnFileName(AnsiString FileName, TGraphicFileFormat ExtIndex) { char *s; s = AnsiStrScan(FileName.c_str(), '.'); if (s==NULL) { return FileName+".pil"; } 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, cm); } //--------------------------------------------------------------------------- void __fastcall TMainForm::OpenFile(AnsiString DirName, AnsiString FileName, int Index, WORD bpp) { TCursor cur; TMainImageForm *Child = NULL; TPException ec = EC_NONE; #ifndef LOCK_CRYPKEY #ifndef LOCK_IFC ProtectCard->Read(); #endif #endif MainMenuForm->ExitForm(); cur = Screen->Cursor; Screen->Cursor = crHourGlass; if ((Child = new TMainImageForm(Application)) == NULL) { ec = EC_FORM_NOT_CREATE; goto fail; }; if ((ec = Child->InitFormFile(DirName, FileName)) != EC_NONE) goto fail; Screen->Cursor = cur; return; fail: if (Child) delete Child; Screen->Cursor = cur; EXCEPTION_MESSAGE_OK(ec); } //--------------------------------------------------------------------- void __fastcall TMainForm::InitMenuItem(TPileMenuItem pmi) { PileMenuItem = pmi; switch (PileMenuItem) { case P_YARN: YarnTableForm = new TYarnTableForm(this); YarnTableForm->Parent = MainForm; YarnTableForm->Visible = false; YarnDesignForm = new TYarnDesignForm(this); YarnDesignForm->Parent = MainForm; YarnDesignForm->Visible = true; break; case P_TEXTURE: break; } } //--------------------------------------------------------------------- // Public Function //--------------------------------------------------------------------------- void __fastcall TMainForm::UpdateTools(TObject *Sender) { MainImageForm = (TMainImageForm *)ActiveMDIChild; if (MainImageForm) { ::RepaintColor(); } else { PaletteForm->InitForm(NULL); } } //--------------------------------------------------------------------- void __fastcall TMainForm::ExitMenuItem() { switch (PileMenuItem) { case P_YARN: if (YarnDesignForm) { delete YarnDesignForm; YarnDesignForm = NULL; } if (YarnTableForm) { delete YarnTableForm; YarnTableForm = NULL; } break; case P_TEXTURE: break; } PileMenuItem = P_NONE; } //--------------------------------------------------------------------------- void __fastcall TMainForm::FormKeyPress(TObject *Sender, char &Key) { //qe È®´ëÃà¼Ò ´ÜÃàŰ if((Key == 65) || (Key == 97) || (Key == 83) || (Key == 115)) MainImageForm->FormKeyPress(this, Key); } //---------------------------------------------------------------------------