VMSM580MF.cpp 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344
  1. //---------------------------------------------------------------------------
  2. #include <vcl.h>
  3. #include <IOUtils.hpp>
  4. #include "ITSSkinF.h"
  5. #include "ITSUtilF.h"
  6. #include "AppGlobalF.h"
  7. #pragma hdrstop
  8. #include "VMSM580MF.h"
  9. //---------------------------------------------------------------------------
  10. #pragma package(smart_init)
  11. #pragma link "cxButtons"
  12. #pragma link "cxCalendar"
  13. #pragma link "cxContainer"
  14. #pragma link "cxControls"
  15. #pragma link "cxDropDownEdit"
  16. #pragma link "cxEdit"
  17. #pragma link "cxGraphics"
  18. #pragma link "cxGroupBox"
  19. #pragma link "cxLabel"
  20. #pragma link "cxLookAndFeelPainters"
  21. #pragma link "cxLookAndFeels"
  22. #pragma link "cxMaskEdit"
  23. #pragma link "cxPC"
  24. #pragma link "cxPCdxBarPopupMenu"
  25. #pragma link "cxSpinEdit"
  26. #pragma link "cxSplitter"
  27. #pragma link "cxTextEdit"
  28. #pragma link "cxTimeEdit"
  29. #pragma link "dxSkinBlack"
  30. #pragma link "dxSkinBlue"
  31. #pragma link "dxSkinCaramel"
  32. #pragma link "dxSkinCoffee"
  33. #pragma link "dxSkinDarkRoom"
  34. #pragma link "dxSkinDarkSide"
  35. #pragma link "dxSkinFoggy"
  36. #pragma link "dxSkinGlassOceans"
  37. #pragma link "dxSkiniMaginary"
  38. #pragma link "dxSkinLilian"
  39. #pragma link "dxSkinLiquidSky"
  40. #pragma link "dxSkinLondonLiquidSky"
  41. #pragma link "dxSkinMcSkin"
  42. #pragma link "dxSkinMoneyTwins"
  43. #pragma link "dxSkinOffice2007Black"
  44. #pragma link "dxSkinOffice2007Blue"
  45. #pragma link "dxSkinOffice2007Green"
  46. #pragma link "dxSkinOffice2007Pink"
  47. #pragma link "dxSkinOffice2007Silver"
  48. #pragma link "dxSkinOffice2010Black"
  49. #pragma link "dxSkinOffice2010Blue"
  50. #pragma link "dxSkinOffice2010Silver"
  51. #pragma link "dxSkinsCore"
  52. #pragma link "dxSkinscxPCPainter"
  53. #pragma link "dxSkinSeven"
  54. #pragma link "dxSkinSharp"
  55. #pragma link "dxSkinSilver"
  56. #pragma link "dxSkinStardust"
  57. #pragma link "cxRadioGroup"
  58. #pragma link "cxClasses"
  59. #pragma link "cxCustomData"
  60. #pragma link "cxData"
  61. #pragma link "cxDataStorage"
  62. #pragma link "cxDBData"
  63. #pragma link "cxFilter"
  64. #pragma link "cxGrid"
  65. #pragma link "cxGridCustomTableView"
  66. #pragma link "cxGridCustomView"
  67. #pragma link "cxGridDBTableView"
  68. #pragma link "cxGridLevel"
  69. #pragma link "cxGridTableView"
  70. #pragma link "cxStyles"
  71. #pragma link "cxCheckBox"
  72. #pragma link "cxImage"
  73. #pragma link "cxButtonEdit"
  74. #pragma link "cxBlobEdit"
  75. #pragma link "cxCalc"
  76. #pragma resource "*.dfm"
  77. TVMSM580M *VMSM580M = NULL;
  78. //---------------------------------------------------------------------------
  79. __fastcall TVMSM580M::TVMSM580M(TComponent* Owner)
  80. : TForm(Owner)
  81. {
  82. ITSSkin_Load(this);
  83. //CMM_LoadForm(g_sFormsDir, this);
  84. FUpdate= false;
  85. FTitle = Caption;//"VMS 객체이미지 선택";
  86. FListSymb = new TList;
  87. EditMode = false;
  88. m_bSelected = false;
  89. TvList->OptionsView->DataRowHeight = 0;
  90. TvList->OptionsView->CellAutoHeight = true;
  91. TvList->OptionsView->Indicator = true;
  92. TvList->OptionsCustomize->ColumnMoving = false;
  93. TvList->OptionsCustomize->ColumnSorting = false;
  94. TvList->Columns[0]->Width = 50;
  95. TvList->Columns[0]->Options->HorzSizing = false;
  96. }
  97. //---------------------------------------------------------------------------
  98. void __fastcall TVMSM580M::CommClose()
  99. {
  100. try
  101. {
  102. ClearSymbloList();
  103. SAFE_DELETE(FListSymb);
  104. //CMM_SaveForm(g_sFormsDir, this);
  105. }
  106. catch(...)
  107. {
  108. }
  109. }
  110. //---------------------------------------------------------------------------
  111. void __fastcall TVMSM580M::FormShow(TObject *Sender)
  112. {
  113. Refresh();
  114. FormInit();
  115. TmrShow->Enabled = true;
  116. }
  117. //---------------------------------------------------------------------------
  118. void __fastcall TVMSM580M::FormInit()
  119. {
  120. EdPictId->Text = "";
  121. EdImagePath->Text = "";
  122. EdPictNm->Text = "";
  123. EdPictSize->Text = "";
  124. EdPictW->Text = "";
  125. EdPictH->Text = "";
  126. EdPictExt->Text = "";
  127. ImgPreView->Picture->Bitmap->FreeImage();
  128. ImgPreView->Picture->Bitmap = NULL;
  129. FNewDb = false;
  130. }
  131. //---------------------------------------------------------------------------
  132. void __fastcall TVMSM580M::TmrShowTimer(TObject *Sender)
  133. {
  134. TmrShow->Enabled = false;
  135. LoadImageSymbol();
  136. }
  137. //---------------------------------------------------------------------------
  138. void __fastcall TVMSM580M::BtnCloseClick(TObject *Sender)
  139. {
  140. Close();
  141. }
  142. //---------------------------------------------------------------------------
  143. void __fastcall TVMSM580M::FormClose(TObject *Sender, TCloseAction &Action)
  144. {
  145. CommClose();
  146. VMSM580M = NULL;
  147. Action = caFree;
  148. }
  149. //---------------------------------------------------------------------------
  150. void __fastcall TVMSM580M::FormCloseQuery(TObject *Sender, bool &CanClose)
  151. {
  152. //
  153. }
  154. //---------------------------------------------------------------------------
  155. void __fastcall TVMSM580M::DisplayInfo()
  156. {
  157. FormInit();
  158. int nRow = TvList->DataController->FocusedRecordIndex;
  159. if( nRow <= -1 )
  160. return;
  161. TcxGridDataController *pDc = TvList->DataController;
  162. nRow = pDc->FocusedRecordIndex;
  163. #if 0
  164. if (nRow < FListSymb->Count)
  165. {
  166. Graphics::TBitmap *bitmap = (Graphics::TBitmap*)FListSymb->Items[nRow];
  167. ImgPreView->Picture->Bitmap->Assign(bitmap);
  168. }
  169. #endif
  170. EdPictId->Text = VarToStr(pDc->Values[nRow][ColSYMB_NMBR->Index]);
  171. EdImagePath->Text = VarToStr(pDc->Values[nRow][ColImagePath->Index]);
  172. EdPictNm->Text = VarToStr(pDc->Values[nRow][ColSYMB_NM->Index]);
  173. EdPictSize->Text = VarToStr(pDc->Values[nRow][ColSYMB_SIZE->Index]);
  174. //EdPictW->Text = VarToStr(pDc->Values[nRow][ColPictW->Index]);
  175. //EdPictH->Text = VarToStr(pDc->Values[nRow][ColPictH->Index]);
  176. EdPictExt->Text = VarToStr(pDc->Values[nRow][ColSYMB_FILE_EXT->Index]);
  177. }
  178. //---------------------------------------------------------------------------
  179. void __fastcall TVMSM580M::ClearSymbloList()
  180. {
  181. for(int ii = 0; ii < FListSymb->Count; ii++)
  182. {
  183. Graphics::TBitmap *bitmap = (Graphics::TBitmap *)FListSymb->Items[ii];
  184. delete bitmap;
  185. }
  186. FListSymb->Clear();
  187. }
  188. //---------------------------------------------------------------------------
  189. void __fastcall TVMSM580M::LoadImageSymbol()
  190. {
  191. FormInit();
  192. CMM_ClearGridTableView(TvList);
  193. ClearSymbloList();
  194. String sQry;
  195. TADOQuery *pADO = NULL;
  196. sQry = "SELECT * \r\n"
  197. " FROM TB_VMS_FORM_OBJ_MOV \r\n"
  198. " WHERE 1=1 \r\n"
  199. " ORDER BY VMS_FORM_OBJ_ID \r\n";
  200. int nRowHeight = 0;
  201. try
  202. {
  203. int nRow;
  204. TcxDataController *pGDC = TvList->DataController;
  205. TvList->BeginUpdate();
  206. try
  207. {
  208. pADO = new TADOQuery(NULL);
  209. pADO->Close();
  210. pADO->Connection = ITSDb_GetConnection();
  211. ITSDb_SQLText(pADO, sQry);
  212. ITSDb_SQLOpen(pADO);
  213. String imageFilePath;
  214. String videoFilePath;
  215. String saveDirPath = TPath::GetTempPath() + "VMS\\";
  216. ForceDirectories(saveDirPath.c_str());
  217. for( ; !pADO->Eof; pADO->Next())
  218. {
  219. nRow = pGDC->AppendRecord();
  220. String VMS_FORM_OBJ_ID = pADO->FieldByName("VMS_FORM_OBJ_ID")->AsString;
  221. String MOV_TYPE = pADO->FieldByName("MOV_TYPE")->AsString;
  222. pGDC->Values[nRow][ColSYMB_NMBR->Index] = VMS_FORM_OBJ_ID;
  223. pGDC->Values[nRow][ColSYMB_NM->Index] = pADO->FieldByName("MOV_NM")->AsString;
  224. pGDC->Values[nRow][ColSYMB_DATA->Index] = pADO->FieldByName("THMB_IMG")->AsVariant;
  225. pGDC->Values[nRow][ColSYMB_FILE_EXT->Index] = DbMovieTypeToReal(MOV_TYPE);
  226. pGDC->Values[nRow][ColSYMB_SIZE->Index] = pADO->FieldByName("MOV_DATA_SZ")->AsInteger;
  227. //pGDC->Values[nRow][ColSYMB_WDTH->Index] = pADO->FieldByName("PICT_WDTH")->AsInteger;
  228. //pGDC->Values[nRow][ColSYMB_HGHT->Index] = pADO->FieldByName("PICT_HGHT")->AsInteger;
  229. pGDC->Values[nRow][ColMOV_TYPE->Index] = MOV_TYPE;
  230. String MOVIE_FILE_EXT = DbMovieTypeToReal(MOV_TYPE);
  231. TMemoryStream *pAviStream = new TMemoryStream();
  232. pAviStream->LoadFromStream(pADO->CreateBlobStream(pADO->FieldByName("MOV_DATA"), bmRead));
  233. videoFilePath = saveDirPath + VMS_FORM_OBJ_ID + "." + MOVIE_FILE_EXT;
  234. pAviStream->SaveToFile(videoFilePath);
  235. SAFE_DELETE(pAviStream);
  236. TMemoryStream *pImgStream = new TMemoryStream();
  237. pImgStream->LoadFromStream(pADO->CreateBlobStream(pADO->FieldByName("THMB_IMG"), bmRead));
  238. String MOVE_EXT = DbMovieTypeToReal(MOV_TYPE);
  239. imageFilePath = saveDirPath + VMS_FORM_OBJ_ID + ".bmp";
  240. pImgStream->SaveToFile(imageFilePath);
  241. SAFE_DELETE(pImgStream);
  242. pGDC->Values[nRow][ColImagePath->Index] = imageFilePath;
  243. pGDC->Values[nRow][ColVideoPath->Index] = videoFilePath;
  244. }
  245. }
  246. catch(EDatabaseError &E)
  247. {
  248. DBERRORMSG("TVMSM580M::LoadImageSymbol", String(E.ClassName()), E.Message, sQry);
  249. throw Exception(String(E.ClassName()) + E.Message);
  250. }
  251. catch(Exception &e)
  252. {
  253. DBERRORMSG("TVMSM580M::LoadImageSymbol", String(e.ClassName()), e.Message, sQry);
  254. throw Exception(String(e.ClassName()) + e.Message);
  255. }
  256. }
  257. __finally
  258. {
  259. if (pADO)
  260. {
  261. pADO->Close();
  262. delete pADO;
  263. }
  264. //TvList->OptionsView->DataRowHeight = nRowHeight;
  265. TvList->EndUpdate();
  266. }
  267. }
  268. //---------------------------------------------------------------------------
  269. void __fastcall TVMSM580M::TvListCellDblClick(TcxCustomGridTableView *Sender, TcxGridTableDataCellViewInfo *ACellViewInfo,
  270. TMouseButton AButton, TShiftState AShift,
  271. bool &AHandled)
  272. {
  273. if (!ACellViewInfo) return;
  274. DisplayInfo();
  275. Sleep(200);
  276. BtnSelImageClick((TObject*)BtnSelImage);
  277. }
  278. //---------------------------------------------------------------------------
  279. void __fastcall TVMSM580M::TvListFocusedRecordChanged(TcxCustomGridTableView *Sender,
  280. TcxCustomGridRecord *APrevFocusedRecord, TcxCustomGridRecord *AFocusedRecord,
  281. bool ANewItemRecordFocusingChanged)
  282. {
  283. if (!AFocusedRecord) return;
  284. DisplayInfo();
  285. }
  286. //---------------------------------------------------------------------------
  287. void __fastcall TVMSM580M::BtnSelImageClick(TObject *Sender)
  288. {
  289. if (EdPictId->Text == "" || EdImagePath->Text == "")
  290. {
  291. Application->MessageBox(L"VMS 동영상 객체 선택\r\nVMS 동영상 목록에서 동영상을 선택하세요.",
  292. FTitle.c_str(),
  293. MB_OK|MB_ICONERROR|MB_APPLMODAL);
  294. return;
  295. }
  296. m_bSelected = true;
  297. Close();
  298. }
  299. //---------------------------------------------------------------------------