AreaClient.cpp 9.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341
  1. // AreaClient.cpp : implementation file
  2. #include "stdafx.h"
  3. #include "ylgl.h"
  4. #include "AreaClient.h"
  5. #include "MyMdi.H"
  6. #include "VcPlot.h"
  7. #include "VcAxis.h"
  8. #include "VcValueScale.h"
  9. #include "VcSeriesCollection.h"
  10. #include "VcSeries.h"
  11. #include "VcPen.h"
  12. #include "VcCategoryScale.h"
  13. #include "VcColor.h"
  14. #include "VcDataGrid.h"
  15. #include "VcBackdrop.h"
  16. #include "VcFill.h"
  17. #include "VcBrush.h"
  18. #include "VcDataPoints.h"
  19. #include "VcDataPoint.h"
  20. #include "VcDataPointLabel.h"
  21. #include "VcAxisTitle.h"
  22. #include "ShowMschart.h"
  23. #ifdef _DEBUG
  24. #define new DEBUG_NEW
  25. #undef THIS_FILE
  26. static char THIS_FILE[] = __FILE__;
  27. #endif
  28. /////////////////////////////////////////////////////////////////////////////
  29. // AreaClient
  30. IMPLEMENT_DYNCREATE(AreaClient, MyFormView)
  31. AreaClient::AreaClient()
  32. : MyFormView(AreaClient::IDD)
  33. {
  34. //{{AFX_DATA_INIT(AreaClient)
  35. m_year = atoi(g_date.Mid(0, 4));
  36. m_month = atoi(g_date.Mid(5, 2));
  37. m_day = atoi(g_date.Mid(8, 2));
  38. m_radio1 = 1;
  39. m_bInit = 0;
  40. //}}AFX_DATA_INIT
  41. }
  42. AreaClient::~AreaClient()
  43. {
  44. }
  45. void AreaClient::DoDataExchange(CDataExchange* pDX)
  46. {
  47. MyFormView::DoDataExchange(pDX);
  48. //{{AFX_DATA_MAP(AreaClient)
  49. DDX_Control(pDX, IDC_SPIN3, m_spinday);
  50. DDX_Control(pDX, IDC_SPIN2, m_spinmonth);
  51. DDX_Control(pDX, IDC_SPIN1, m_spinyear);
  52. DDX_Control(pDX, IDC_STATIC1, m_static1);
  53. DDX_Text(pDX, IDC_EDITyear, m_year);
  54. DDV_MinMaxUInt(pDX, m_year, 1900, 3000);
  55. DDX_Text(pDX, IDC_EDITmonth, m_month);
  56. DDV_MinMaxUInt(pDX, m_month, 1, 12);
  57. DDX_Text(pDX, IDC_EDITday, m_day);
  58. DDV_MinMaxUInt(pDX, m_day, 1, 31);
  59. DDX_Control(pDX, IDC_MSCHART1, m_Chart);
  60. DDX_Radio(pDX, IDC_RADIO3, m_radio1);
  61. //}}AFX_DATA_MAP
  62. }
  63. BEGIN_MESSAGE_MAP(AreaClient, MyFormView)
  64. //{{AFX_MSG_MAP(AreaClient)
  65. ON_BN_CLICKED(IDC_BUTclose, OnBUTclose)
  66. ON_EN_CHANGE(IDC_EDITyear, OnChangeEDITyear)
  67. ON_EN_CHANGE(IDC_EDITmonth, OnChangeEDITmonth)
  68. ON_EN_CHANGE(IDC_EDITday, OnChangeEDITday)
  69. ON_BN_CLICKED(IDC_RADIO3, OnRadio3)
  70. ON_BN_CLICKED(IDC_RADIO4, OnRadio4)
  71. ON_BN_CLICKED(IDC_RADIO5, OnRadio5)
  72. //}}AFX_MSG_MAP
  73. END_MESSAGE_MAP()
  74. /////////////////////////////////////////////////////////////////////////////
  75. // AreaClient diagnostics
  76. #ifdef _DEBUG
  77. void AreaClient::AssertValid() const
  78. {
  79. MyFormView::AssertValid();
  80. }
  81. void AreaClient::Dump(CDumpContext& dc) const
  82. {
  83. MyFormView::Dump(dc);
  84. }
  85. #endif //_DEBUG
  86. /////////////////////////////////////////////////////////////////////////////
  87. // AreaClient message
  88. void AreaClient::OnInitialUpdate()
  89. {
  90. MyFormView::OnInitialUpdate();
  91. // TODO: Add your specialized code here and/or call the base class
  92. CMyMdi Mdi;
  93. Mdi.SetSubView((CWnd*)GetParent(), (CWnd*)this);
  94. // Here we create the outbar control using the splitter as its parent
  95. // and setting its id to the first pane.
  96. CRect rc2;
  97. GetWindowRect(rc2);
  98. ::MoveWindow(m_hWnd, g_rc.left, g_rc.top, g_rc.Width(), g_rc.Height(), TRUE);
  99. EnumChildWindows(m_hWnd, (WNDENUMPROC)EnumChildProc, 0);
  100. m_static1.SetFont(&g_titlefont);
  101. m_spinyear.SetRange(1900, 3000);
  102. m_spinmonth.SetRange(1, 12);
  103. m_spinday.SetRange(1, 31);
  104. m_Chart.GetBackdrop().GetFill().SetStyle(1);
  105. m_Chart.GetBackdrop().GetFill().GetBrush().GetFillColor().Set(255, 255, 255);
  106. // m_Chart.SetShowLegend(TRUE);
  107. m_Chart.SetColumn(1);
  108. m_Chart.SetChartType(1);
  109. // 栈模式
  110. m_Chart.SetStacking(FALSE);
  111. VARIANT var;
  112. m_Chart.GetPlot().GetAxis(1, var).GetValueScale().SetAuto(1); // 不自动标注Y轴刻度
  113. m_Chart.GetPlot().GetAxis(0, var).GetCategoryScale().SetAuto(0); // 不自动标注X轴刻度
  114. m_Chart.GetPlot().GetAxis(0, var).GetCategoryScale().SetDivisionsPerLabel(1);// 每刻度一个标注
  115. m_Chart.GetPlot().GetAxis(0, var).GetCategoryScale().SetDivisionsPerTick(1); // 每刻度一个刻度线
  116. m_Chart.SetColumnCount(1);
  117. m_Chart.GetPlot().GetSeriesCollection().GetItem(1).GetDataPoints().GetItem(-1).GetBrush().GetFillColor().Set(255, 0, 0);
  118. // 线宽(对点线图有效)
  119. m_Chart.GetPlot().GetSeriesCollection().GetItem(1).GetPen().SetWidth(30);
  120. // 数据点类型显示数据值的模式(对柱柱状图和点线图有效)
  121. // 0: 不显示 1: 显示在柱状图外
  122. // 2: 显示在柱状图内上方 3: 显示在柱状图内中间 4: 显示在柱状图内下方
  123. m_Chart.GetPlot().GetSeriesCollection().GetItem(1).GetDataPoints().GetItem(-1).GetDataPointLabel().SetLocationType(1);
  124. //////////////////////
  125. GetDlgItem(IDC_STATIC2)->GetWindowRect(rc2);
  126. ScreenToClient(rc2);
  127. m_Chart.MoveWindow(rc2);
  128. m_bInit = 1;
  129. DateChange();
  130. }
  131. void AreaClient::FillGrid()
  132. {
  133. }
  134. void AreaClient::OnBUTclose()
  135. {
  136. // TODO: Add your control notification handler code
  137. GetParent()->SendMessage(WM_CLOSE);
  138. }
  139. void AreaClient::OnChangeEDITyear()
  140. {
  141. // TODO: If this is a RICHEDIT control, the control will not
  142. // send this notification unless you override the MyFormView::OnInitDialog()
  143. // function and call CRichEditCtrl().SetEventMask()
  144. // with the ENM_CHANGE flag ORed into the mask.
  145. DateChange();
  146. // TODO: Add your control notification handler code here
  147. }
  148. void AreaClient::OnChangeEDITmonth()
  149. {
  150. // TODO: If this is a RICHEDIT control, the control will not
  151. // send this notification unless you override the MyFormView::OnInitDialog()
  152. // function and call CRichEditCtrl().SetEventMask()
  153. // with the ENM_CHANGE flag ORed into the mask.
  154. // DateChange();
  155. // TODO: Add your control notification handler code here
  156. }
  157. void AreaClient::OnChangeEDITday()
  158. {
  159. // TODO: If this is a RICHEDIT control, the control will not
  160. // send this notification unless you override the MyFormView::OnInitDialog()
  161. // function and call CRichEditCtrl().SetEventMask()
  162. // with the ENM_CHANGE flag ORed into the mask.
  163. // DateChange();
  164. // TODO: Add your control notification handler code here
  165. }
  166. void AreaClient::DateChange()
  167. {
  168. if (m_bInit == 0)return;
  169. UpdateData();
  170. m_spinyear.EnableWindow(0);
  171. m_spinmonth.EnableWindow(0);
  172. m_spinday.EnableWindow(0);
  173. int g_nYearposTemp = g_nYearpos;
  174. #if JEFF_TEST_ON // 2015开始禁用跨年数据;
  175. if (m_year >= 2014 && m_year <= atoi(g_date.Left(4)) && g_hisyeararray.GetSize())
  176. {
  177. g_nYearpos = -1;
  178. }
  179. else if (m_year <= 2013 && g_hisyeararray.GetSize())
  180. {
  181. g_nYearpos = GetYearPos(m_year);
  182. }
  183. if ( g_nYearpos == -1 && m_year <=2013 )
  184. #else
  185. g_nYearpos = GetYearPos(m_year);
  186. if (g_nYearpos == -1 && m_year != atoi(g_date.Left(4)))
  187. #endif
  188. {
  189. m_List1array.RemoveAll();
  190. g_nYearpos = g_nYearposTemp;
  191. KindChange();
  192. m_spinyear.EnableWindow(1);
  193. m_spinmonth.EnableWindow(1);
  194. m_spinday.EnableWindow(1);
  195. return;
  196. }
  197. g_sendhead.bsql = 0;
  198. g_sendhead.code[0] = 52;
  199. g_sendhead.tabcount = 1;
  200. g_pMainWnd->ProcessChatMessageRequest2(1);
  201. if (g_bSendOK == 0)
  202. {
  203. g_nYearpos = g_nYearposTemp;
  204. m_spinyear.EnableWindow(1);
  205. m_spinmonth.EnableWindow(1);
  206. m_spinday.EnableWindow(1);
  207. return;
  208. }
  209. DataToArray(&m_List1array);
  210. g_nYearpos = -1;
  211. g_sendhead.bsql = 0;
  212. g_sendhead.code[0] = 82;
  213. g_sendhead.tabcount = 1;
  214. g_pMainWnd->ProcessChatMessageRequest2(1);
  215. if (g_bSendOK == 0)
  216. {
  217. g_nYearpos = g_nYearposTemp;
  218. m_spinyear.EnableWindow(1);
  219. m_spinmonth.EnableWindow(1);
  220. m_spinday.EnableWindow(1);
  221. return;
  222. }
  223. DataToArray(&m_List2array);
  224. g_nYearpos = g_nYearposTemp;
  225. KindChange();
  226. m_spinyear.EnableWindow(1);
  227. m_spinmonth.EnableWindow(1);
  228. m_spinday.EnableWindow(1);
  229. }
  230. void AreaClient::KindChange()
  231. {
  232. if (m_List2array.GetSize() == 0)return;
  233. int *pData = new int[m_List2array.GetSize()];
  234. memset(pData, 0, sizeof(int)*m_List2array.GetSize());
  235. for (int i = 0; i < m_List1array.GetSize(); i++)
  236. {
  237. if (m_List1array.ElementAt(i).ElementAt(13).IsEmpty() && m_List1array.ElementAt(i).ElementAt(14).IsEmpty())continue;
  238. for (int j = 0; j < m_List2array.GetSize(); j++)
  239. {
  240. if (m_List2array.ElementAt(j).ElementAt(0) == m_List1array.ElementAt(i).ElementAt(13))
  241. pData[j]++;
  242. else if (m_List2array.ElementAt(j).ElementAt(0) == m_List1array.ElementAt(i).ElementAt(14))
  243. pData[j]++;
  244. }
  245. }
  246. int nRowCount = m_List2array.GetSize();
  247. m_Chart.SetRowCount(nRowCount);
  248. for (int row = 1; row <= nRowCount; ++row)
  249. {
  250. m_Chart.SetRow(row);
  251. m_Chart.SetRowLabel(m_List2array.ElementAt(row - 1).ElementAt(0));
  252. m_Chart.GetDataGrid().SetData(row, 1, pData[row - 1], 0);
  253. }
  254. m_Chart.Refresh();
  255. delete[]pData;
  256. }
  257. void AreaClient::OnRadio3()
  258. {
  259. // TODO: Add your control notification handler code here
  260. UpdateData();
  261. if (m_radio1 == 0)
  262. {
  263. m_Chart.SetChartType(3);
  264. }
  265. else if (m_radio1 == 1)
  266. {
  267. m_Chart.SetChartType(1);
  268. }
  269. else if (m_radio1 == 2)
  270. {
  271. m_Chart.SetChartType(14);
  272. }
  273. }
  274. void AreaClient::OnRadio4()
  275. {
  276. // TODO: Add your control notification handler code here
  277. OnRadio3();
  278. }
  279. void AreaClient::OnRadio5()
  280. {
  281. // TODO: Add your control notification handler code here
  282. OnRadio3();
  283. }
  284. BEGIN_EVENTSINK_MAP(AreaClient, MyFormView)
  285. //{{AFX_EVENTSINK_MAP(AreaClient)
  286. ON_EVENT(AreaClient, IDC_MSCHART1, -601 /* DblClick */, OnDblClickMschart1, VTS_NONE)
  287. //}}AFX_EVENTSINK_MAP
  288. END_EVENTSINK_MAP()
  289. extern BOOL g_bShowMsChart;
  290. extern HWND g_hShowChartWnd;
  291. void AreaClient::OnDblClickMschart1()
  292. {
  293. // TODO: Add your control notification handler code here
  294. if (g_bShowMsChart)
  295. {
  296. ::SendMessage(g_hShowChartWnd, WM_CLOSE, 0, 0);
  297. return;
  298. }
  299. g_bShowMsChart = 1;
  300. CRect rc;
  301. m_Chart.GetWindowRect(rc);
  302. ScreenToClient(rc);
  303. ShowMschart dlg;
  304. dlg.m_pParent = this;
  305. dlg.m_pChart = &m_Chart;
  306. dlg.DoModal();
  307. m_Chart.MoveWindow(rc);
  308. g_bShowMsChart = 0;
  309. }
  310. // g_sendhead.code[0]=193;