AreaClient.cpp 9.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345
  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 i;
  174. int g_nYearposTemp = g_nYearpos;
  175. #if JEFF_TEST_ON // 2015开始禁用跨年数据;
  176. if (m_year >= 2014 && m_year <= atoi(g_date.Left(4)) && g_hisyeararray.GetSize())
  177. {
  178. g_nYearpos = -1;
  179. }
  180. else if (m_year <= 2013 && g_hisyeararray.GetSize())
  181. {
  182. g_nYearpos = GetYearPos(m_year);
  183. }
  184. if ( g_nYearpos == -1 && m_year <=2013 )
  185. #else
  186. g_nYearpos = GetYearPos(m_year);
  187. if (g_nYearpos == -1 && m_year != atoi(g_date.Left(4)))
  188. #endif
  189. {
  190. m_List1array.RemoveAll();
  191. g_nYearpos = g_nYearposTemp;
  192. KindChange();
  193. m_spinyear.EnableWindow(1);
  194. m_spinmonth.EnableWindow(1);
  195. m_spinday.EnableWindow(1);
  196. return;
  197. }
  198. g_sendhead.bsql = 0;
  199. g_sendhead.code[0] = 52;
  200. g_sendhead.tabcount = 1;
  201. g_pMainWnd->ProcessChatMessageRequest2(1);
  202. if (g_bSendOK == 0)
  203. {
  204. g_nYearpos = g_nYearposTemp;
  205. m_spinyear.EnableWindow(1);
  206. m_spinmonth.EnableWindow(1);
  207. m_spinday.EnableWindow(1);
  208. return;
  209. }
  210. DataToArray(&m_List1array);
  211. g_nYearpos = -1;
  212. g_sendhead.bsql = 0;
  213. g_sendhead.code[0] = 82;
  214. g_sendhead.tabcount = 1;
  215. g_pMainWnd->ProcessChatMessageRequest2(1);
  216. if (g_bSendOK == 0)
  217. {
  218. g_nYearpos = g_nYearposTemp;
  219. m_spinyear.EnableWindow(1);
  220. m_spinmonth.EnableWindow(1);
  221. m_spinday.EnableWindow(1);
  222. return;
  223. }
  224. DataToArray(&m_List2array);
  225. g_nYearpos = g_nYearposTemp;
  226. KindChange();
  227. m_spinyear.EnableWindow(1);
  228. m_spinmonth.EnableWindow(1);
  229. m_spinday.EnableWindow(1);
  230. }
  231. void AreaClient::KindChange()
  232. {
  233. if (m_List2array.GetSize() == 0)return;
  234. int *pData = new int[m_List2array.GetSize()];
  235. memset(pData, 0, sizeof(int)*m_List2array.GetSize());
  236. for (int i = 0; i < m_List1array.GetSize(); i++)
  237. {
  238. if (m_List1array.ElementAt(i).ElementAt(13).IsEmpty() && m_List1array.ElementAt(i).ElementAt(14).IsEmpty())continue;
  239. for (int j = 0; j < m_List2array.GetSize(); j++)
  240. {
  241. if (m_List2array.ElementAt(j).ElementAt(0) == m_List1array.ElementAt(i).ElementAt(13))
  242. pData[j]++;
  243. else if (m_List2array.ElementAt(j).ElementAt(0) == m_List1array.ElementAt(i).ElementAt(14))
  244. pData[j]++;
  245. }
  246. }
  247. int nRowCount = m_List2array.GetSize();
  248. m_Chart.SetRowCount(nRowCount);
  249. for (int row = 1; row <= nRowCount; ++row)
  250. {
  251. m_Chart.SetRow(row);
  252. m_Chart.SetRowLabel(m_List2array.ElementAt(row - 1).ElementAt(0));
  253. m_Chart.GetDataGrid().SetData(row, 1, pData[row - 1], 0);
  254. }
  255. m_Chart.Refresh();
  256. delete[]pData;
  257. }
  258. void AreaClient::OnRadio3()
  259. {
  260. // TODO: Add your control notification handler code here
  261. UpdateData();
  262. if (m_radio1 == 0)
  263. {
  264. m_Chart.SetChartType(3);
  265. }
  266. else if (m_radio1 == 1)
  267. {
  268. m_Chart.SetChartType(1);
  269. }
  270. else if (m_radio1 == 2)
  271. {
  272. m_Chart.SetChartType(14);
  273. }
  274. }
  275. void AreaClient::OnRadio4()
  276. {
  277. // TODO: Add your control notification handler code here
  278. OnRadio3();
  279. }
  280. void AreaClient::OnRadio5()
  281. {
  282. // TODO: Add your control notification handler code here
  283. OnRadio3();
  284. }
  285. BEGIN_EVENTSINK_MAP(AreaClient, MyFormView)
  286. //{{AFX_EVENTSINK_MAP(AreaClient)
  287. ON_EVENT(AreaClient, IDC_MSCHART1, -601 /* DblClick */, OnDblClickMschart1, VTS_NONE)
  288. //}}AFX_EVENTSINK_MAP
  289. END_EVENTSINK_MAP()
  290. extern BOOL g_bShowMsChart;
  291. extern HWND g_hShowChartWnd;
  292. void AreaClient::OnDblClickMschart1()
  293. {
  294. // TODO: Add your control notification handler code here
  295. if (g_bShowMsChart)
  296. {
  297. ::SendMessage(g_hShowChartWnd, WM_CLOSE, 0, 0);
  298. return;
  299. }
  300. g_bShowMsChart = 1;
  301. CRect rc;
  302. m_Chart.GetWindowRect(rc);
  303. ScreenToClient(rc);
  304. ShowMschart dlg;
  305. dlg.m_pParent = this;
  306. dlg.m_pChart = &m_Chart;
  307. dlg.DoModal();
  308. m_Chart.MoveWindow(rc);
  309. g_bShowMsChart = 0;
  310. }
  311. // g_sendhead.code[0]=193;