FRAME_UtisStatusListF.cpp 9.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288
  1. //---------------------------------------------------------------------------
  2. #include <vcl.h>
  3. #include "ITSSkinF.h"
  4. #include "ITSUtilF.h"
  5. #include "FrmResourceF.h"
  6. #include "ITSLangTransF.h"
  7. #pragma hdrstop
  8. #include "FRAME_UtisStatusListF.h"
  9. #include "CDSUtisF.h"
  10. //---------------------------------------------------------------------------
  11. #pragma package(smart_init)
  12. #pragma link "cxClasses"
  13. #pragma link "cxControls"
  14. #pragma link "cxCustomData"
  15. #pragma link "cxData"
  16. #pragma link "cxDataStorage"
  17. #pragma link "cxEdit"
  18. #pragma link "cxFilter"
  19. #pragma link "cxGraphics"
  20. #pragma link "cxGrid"
  21. #pragma link "cxGridCustomTableView"
  22. #pragma link "cxGridCustomView"
  23. #pragma link "cxGridLevel"
  24. #pragma link "cxGridTableView"
  25. #pragma link "cxLookAndFeelPainters"
  26. #pragma link "cxLookAndFeels"
  27. #pragma link "cxPC"
  28. #pragma link "cxPCdxBarPopupMenu"
  29. #pragma link "cxStyles"
  30. #pragma link "cxTextEdit"
  31. #pragma link "dxSkinBlack"
  32. #pragma link "dxSkinBlue"
  33. #pragma link "dxSkinsCore"
  34. #pragma link "dxSkinscxPCPainter"
  35. #pragma resource "*.dfm"
  36. //TFRAMEUtisStatusList *FRAMEUtisStatusList;
  37. //---------------------------------------------------------------------------
  38. __fastcall TFRAMEUtisStatusList::TFRAMEUtisStatusList(TComponent* Owner)
  39. : TFrame(Owner)
  40. {
  41. FCodeCMS = ItsCodeManager->FLists.Find("CMS");
  42. FCodeCDS = ItsCodeManager->FLists.Find("CDS");
  43. InitList();
  44. }
  45. //---------------------------------------------------------------------------
  46. void __fastcall TFRAMEUtisStatusList::InitList()
  47. {
  48. InitUtisRun();
  49. InitRseRun();
  50. }
  51. //---------------------------------------------------------------------------
  52. void __fastcall TFRAMEUtisStatusList::InitUtisRun()
  53. {
  54. TcxGridTableView *pView= (TcxGridTableView *)TvUtisRun;
  55. TcxGridDataController *pGDC = (TcxGridDataController *)pView->DataController;
  56. CMM_ClearGridTableView(TvUtisRun);
  57. try
  58. {
  59. int nRow;
  60. pView->BeginUpdate();
  61. pGDC->BeginUpdate();
  62. nRow = pGDC->AppendRecord();
  63. pGDC->Values[nRow][ColUtisRunName->Index] = "정지영상";
  64. pGDC->Values[nRow][ColUtisRunCnt->Index] = FormatFloat("##,##0", ItsUtisManager->UtisRun.RunCnt[0]);
  65. pGDC->Values[nRow][ColUtisRunStatusCd->Index] = ItsUtisManager->UtisRun.Status[0];
  66. nRow = pGDC->AppendRecord();
  67. pGDC->Values[nRow][ColUtisRunName->Index] = "5분교통정보";
  68. pGDC->Values[nRow][ColUtisRunCnt->Index] = FormatFloat("##,##0", ItsUtisManager->UtisRun.RunCnt[1]);
  69. pGDC->Values[nRow][ColUtisRunStatusCd->Index] = ItsUtisManager->UtisRun.Status[1];
  70. nRow = pGDC->AppendRecord();
  71. pGDC->Values[nRow][ColUtisRunName->Index] = "5분교통정보(방향)";
  72. pGDC->Values[nRow][ColUtisRunCnt->Index] = "-";//FormatFloat("##,##0", ItsUtisManager->UtisRun.RunCnt[2]);
  73. pGDC->Values[nRow][ColUtisRunStatusCd->Index] = ItsUtisManager->UtisRun.Status[2];
  74. }
  75. __finally
  76. {
  77. pGDC->EndUpdate();
  78. pView->EndUpdate();
  79. }
  80. }
  81. //---------------------------------------------------------------------------
  82. void __fastcall TFRAMEUtisStatusList::InitRseRun()
  83. {
  84. TcxGridTableView *pView= (TcxGridTableView *)TvUtisRse;
  85. TcxGridDataController *pGDC = (TcxGridDataController *)pView->DataController;
  86. CMM_ClearGridTableView(TvUtisRse);
  87. try
  88. {
  89. int nRow;
  90. pView->BeginUpdate();
  91. pGDC->BeginUpdate();
  92. nRow = pGDC->AppendRecord();
  93. pGDC->Values[nRow][ColRseType->Index] = "전체";
  94. pGDC->Values[nRow][ColRseKind->Index] = "(대)";
  95. pGDC->Values[nRow][ColRseCnt->Index] = FormatFloat("##,##0 ", ItsUtisManager->RseRun[0]);
  96. nRow = pGDC->AppendRecord();
  97. pGDC->Values[nRow][ColRseType->Index] = "정보";
  98. pGDC->Values[nRow][ColRseKind->Index] = "업로드";
  99. pGDC->Values[nRow][ColRseCnt->Index] = FormatFloat("##,##0 ", ItsUtisManager->RseRun[1]);
  100. nRow = pGDC->AppendRecord();
  101. pGDC->Values[nRow][ColRseType->Index] = "정보";
  102. pGDC->Values[nRow][ColRseKind->Index] = "비업로드";
  103. pGDC->Values[nRow][ColRseCnt->Index] = FormatFloat("##,##0 ", ItsUtisManager->RseRun[0] - ItsUtisManager->RseRun[1]);
  104. }
  105. __finally
  106. {
  107. pGDC->EndUpdate();
  108. pView->EndUpdate();
  109. }
  110. }
  111. //---------------------------------------------------------------------------
  112. void __fastcall TFRAMEUtisStatusList::UpdateList()
  113. {
  114. RefreshList();
  115. }
  116. //---------------------------------------------------------------------------
  117. void __fastcall TFRAMEUtisStatusList::RefreshList()
  118. {
  119. TcxGridTableView *pView;
  120. TcxGridDataController *pGDC;
  121. pView= (TcxGridTableView *)TvUtisRun;
  122. pGDC = (TcxGridDataController *)pView->DataController;
  123. try
  124. {
  125. pView->BeginUpdate();
  126. pGDC->BeginUpdate();
  127. if (pGDC->RecordCount == 3)
  128. {
  129. pGDC->Values[0][ColUtisRunCnt->Index] = FormatFloat("##,##0", ItsUtisManager->UtisRun.RunCnt[0]);
  130. pGDC->Values[0][ColUtisRunStatusCd->Index] = ItsUtisManager->UtisRun.Status[0];
  131. pGDC->Values[1][ColUtisRunCnt->Index] = FormatFloat("##,##0", ItsUtisManager->UtisRun.RunCnt[1]);
  132. pGDC->Values[1][ColUtisRunStatusCd->Index] = ItsUtisManager->UtisRun.Status[1];
  133. pGDC->Values[2][ColUtisRunCnt->Index] = "-";//FormatFloat("##,##0", ItsUtisManager->UtisRun.RunCnt[2]);
  134. pGDC->Values[2][ColUtisRunStatusCd->Index] = ItsUtisManager->UtisRun.Status[2];
  135. }
  136. }
  137. __finally
  138. {
  139. pGDC->EndUpdate();
  140. pView->EndUpdate();
  141. }
  142. pView= (TcxGridTableView *)TvUtisRse;
  143. pGDC = (TcxGridDataController *)pView->DataController;
  144. try
  145. {
  146. pView->BeginUpdate();
  147. pGDC->BeginUpdate();
  148. if (pGDC->RecordCount == 3)
  149. {
  150. pGDC->Values[0][ColRseCnt->Index] = FormatFloat("##,##0 ", ItsUtisManager->RseRun[0]);
  151. pGDC->Values[1][ColRseCnt->Index] = FormatFloat("##,##0 ", ItsUtisManager->RseRun[1]);
  152. pGDC->Values[2][ColRseCnt->Index] = FormatFloat("##,##0 ", ItsUtisManager->RseRun[0] - ItsUtisManager->RseRun[1]);
  153. }
  154. }
  155. __finally
  156. {
  157. pGDC->EndUpdate();
  158. pView->EndUpdate();
  159. }
  160. }
  161. //---------------------------------------------------------------------------
  162. void __fastcall TFRAMEUtisStatusList::TvUtisRunCustomDrawCell(TcxCustomGridTableView *Sender, TcxCanvas *ACanvas, TcxGridTableDataCellViewInfo *AViewInfo,
  163. bool &ADone)
  164. {
  165. //OptionsSelection.InvertSelect = False
  166. //OptionsView.FocusRect = False
  167. if (AViewInfo->GridRecord->Selected)
  168. {
  169. //ACanvas->Brush->Color = Sender->LookAndFeelPainter->DefaultContentColor();
  170. //ACanvas->Font->Color = Sender->LookAndFeelPainter->DefaultContentTextColor();
  171. if (AViewInfo->GridRecord->Index % 2 == 0)
  172. {
  173. ACanvas->Brush->Color = Sender->LookAndFeelPainter->DefaultContentEvenColor();
  174. ACanvas->Font->Color = Sender->LookAndFeelPainter->DefaultContentTextColor();
  175. }
  176. else
  177. {
  178. ACanvas->Brush->Color = Sender->LookAndFeelPainter->DefaultContentOddColor();
  179. ACanvas->Font->Color = Sender->LookAndFeelPainter->DefaultContentTextColor();
  180. }
  181. }
  182. else
  183. {
  184. }
  185. }
  186. //---------------------------------------------------------------------------
  187. void __fastcall TFRAMEUtisStatusList::ColUtisRunStatusCustomDrawCell(TcxCustomGridTableView *Sender, TcxCanvas *ACanvas, TcxGridTableDataCellViewInfo *AViewInfo,
  188. bool &ADone)
  189. {
  190. if (AViewInfo->GridRecord->RecordIndex < 0) return;
  191. Graphics::TBitmap *pBmp = NULL;
  192. pBmp = ImgStop->Picture->Bitmap;
  193. if (!VarIsNull(AViewInfo->GridRecord->DisplayTexts[ColUtisRunStatusCd->Index]))
  194. {
  195. String sCode = AViewInfo->GridRecord->DisplayTexts[ColUtisRunStatusCd->Index];
  196. if (sCode == "0") pBmp = ImgStop->Picture->Bitmap;
  197. else if (sCode == "1") pBmp = ImgRun->Picture->Bitmap;
  198. else if (sCode == "2") pBmp = ImgModule->Picture->Bitmap;
  199. }
  200. if (!pBmp) return;
  201. pBmp->Transparent = true;
  202. int nW, nH;
  203. nW = nH = 21;
  204. try
  205. {
  206. TColor bBrush = ACanvas->Brush->Color;
  207. if (AViewInfo->GridRecord->Selected)
  208. {
  209. if (AViewInfo->GridRecord->Index % 2 == 0)
  210. {
  211. bBrush = Sender->LookAndFeelPainter->DefaultContentEvenColor();
  212. }
  213. else
  214. {
  215. bBrush = Sender->LookAndFeelPainter->DefaultContentOddColor();
  216. }
  217. }
  218. ACanvas->Brush->Color = bBrush;
  219. TRect rc;
  220. TRect rcOrg = AViewInfo->Bounds;
  221. ACanvas->FillRect(rcOrg);
  222. nW = rcOrg.Bottom - rcOrg.Top - 2;
  223. rc.Top = rcOrg.Top+1;
  224. rc.Bottom = rcOrg.Bottom - 1;
  225. rc.Left = rcOrg.Left + (rcOrg.Width() - nW) / 2;
  226. rc.Right = rc.Left + nW;
  227. ACanvas->Canvas->StretchDraw(rc, pBmp);
  228. //ACanvas->Draw(AViewInfo->ContentBounds.Left, AViewInfo->ContentBounds.Top, pBmp);
  229. ADone = true;
  230. }
  231. catch(...) {}
  232. }
  233. //---------------------------------------------------------------------------
  234. void __fastcall TFRAMEUtisStatusList::ColRseCntCustomDrawCell(TcxCustomGridTableView *Sender, TcxCanvas *ACanvas, TcxGridTableDataCellViewInfo *AViewInfo,
  235. bool &ADone)
  236. {
  237. if (AViewInfo->GridRecord->RecordIndex < 0) return;
  238. if (VarIsNull(AViewInfo->Value)) return;
  239. try
  240. {
  241. int nIdx = AViewInfo->GridRecord->RecordIndex;
  242. if (nIdx == 2 || nIdx == 4)
  243. {
  244. ACanvas->Font->Color = clRed;
  245. }
  246. else
  247. {
  248. ACanvas->Font->Color = clBlue;
  249. }
  250. }
  251. catch(...) {}
  252. }
  253. //---------------------------------------------------------------------------