EastDrawView.cpp
上传用户:qiye66671
上传日期:2009-12-10
资源大小:182k
文件大小:63k
源码类别:

绘图程序

开发平台:

C/C++

  1. // EastDrawView.cpp : implementation of the CEastDrawView class
  2. //
  3. #include "stdafx.h"
  4. #include "EastDraw.h"
  5. #include "EastDrawDoc.h"
  6. #include "EastDrawView.h"
  7. #include "ReginSet.h"
  8. #include "EditBox.h"
  9. #ifdef _DEBUG
  10. #define new DEBUG_NEW
  11. #undef THIS_FILE
  12. static char THIS_FILE[] = __FILE__;
  13. #endif
  14. /////////////////////////////////////////////////////////////////////////////
  15. // CEastDrawView
  16. IMPLEMENT_DYNCREATE(CEastDrawView, CScrollView)
  17. BEGIN_MESSAGE_MAP(CEastDrawView, CScrollView)
  18. //{{AFX_MSG_MAP(CEastDrawView)
  19. ON_WM_LBUTTONDOWN()
  20. ON_WM_LBUTTONUP()
  21. ON_WM_MOUSEMOVE()
  22. ON_COMMAND(ID_BUTTON_DLine, OnBUTTONDLine)
  23. ON_COMMAND(ID_BUTTON32774_Move, OnBUTTON32774Move)
  24. ON_COMMAND(ID_BUTTON32775_CircumRotate, OnBUTTON32775CircumRotate)
  25. ON_COMMAND(ID_BUTTON32777_Curve, OnBUTTON32777Curve)
  26. ON_COMMAND(ID_BUTTON32776_Rectangle, OnBUTTON32776Rectangle)
  27. ON_COMMAND(ID_BUTTON32778_RoundRectangle, OnBUTTON32778RoundRectangle)
  28. ON_COMMAND(ID_BUTTON32779_Ellipse, OnBUTTON32779Ellipse)
  29. ON_COMMAND(ID_BUTTON32780_Round, OnBUTTON32780Round)
  30. ON_COMMAND(ID_BUTTON32791_Polygon, OnBUTTON32791Polygon)
  31. ON_WM_LBUTTONDBLCLK()
  32. ON_WM_SETFOCUS()
  33. ON_COMMAND(ID_MENUITEM32794_SetRegin, OnMENUITEM32794SetRegin)
  34. ON_COMMAND(ID_BUTTON_LiEllipse, OnBUTTONLiEllipse)
  35. ON_COMMAND(ID_BUTTON32800_RoundArc, OnBUTTON32800RoundArc)
  36. ON_COMMAND(ID_BUTTON32805_EllipseArc, OnBUTTON32805EllipseArc)
  37. ON_COMMAND(ID_BUTTON32807_PolyBezier, OnBUTTON32807PolyBezier)
  38. ON_COMMAND(ID_BUTTON32809_Text, OnBUTTON32809Text)
  39. ON_COMMAND(ID_CHAR_BOLD, OnCharBold)
  40. ON_COMMAND(ID_CHAR_ITALIC, OnCharItalic)
  41. ON_COMMAND(ID_CHAR_UNDERLINE, OnCharUnderline)
  42. ON_WM_CONTEXTMENU()
  43. ON_COMMAND(ID_MENUITEM_OK, OnMenuitemOk)
  44. ON_WM_SETCURSOR()
  45. ON_COMMAND(ID_CirCu, OnCirCu)
  46. ON_UPDATE_COMMAND_UI(ID_CirCu, OnUpdateCirCu)
  47. ON_WM_KEYUP()
  48. ON_COMMAND(ID_Delete, OnDelete)
  49. ON_COMMAND(ID_BUTTON32830_Lock, OnBUTTON32830Lock)
  50. ON_UPDATE_COMMAND_UI(ID_BUTTON32830_Lock, OnUpdateBUTTON32830Lock)
  51. ON_UPDATE_COMMAND_UI(ID_BUTTON_DLine, OnUpdateBUTTONDLine)
  52. ON_UPDATE_COMMAND_UI(ID_BUTTON32776_Rectangle, OnUpdateBUTTON32776Rectangle)
  53. ON_UPDATE_COMMAND_UI(ID_BUTTON32778_RoundRectangle, OnUpdateBUTTON32778RoundRectangle)
  54. ON_UPDATE_COMMAND_UI(ID_BUTTON32791_Polygon, OnUpdateBUTTON32791Polygon)
  55. ON_UPDATE_COMMAND_UI(ID_BUTTON32779_Ellipse, OnUpdateBUTTON32779Ellipse)
  56. ON_UPDATE_COMMAND_UI(ID_BUTTON32780_Round, OnUpdateBUTTON32780Round)
  57. ON_UPDATE_COMMAND_UI(ID_BUTTON32777_Curve, OnUpdateBUTTON32777Curve)
  58. ON_UPDATE_COMMAND_UI(ID_BUTTON_LiEllipse, OnUpdateBUTTONLiEllipse)
  59. ON_UPDATE_COMMAND_UI(ID_BUTTON32800_RoundArc, OnUpdateBUTTON32800RoundArc)
  60. ON_UPDATE_COMMAND_UI(ID_BUTTON32805_EllipseArc, OnUpdateBUTTON32805EllipseArc)
  61. ON_UPDATE_COMMAND_UI(ID_BUTTON32807_PolyBezier, OnUpdateBUTTON32807PolyBezier)
  62. ON_UPDATE_COMMAND_UI(ID_BUTTON32809_Text, OnUpdateBUTTON32809Text)
  63. ON_UPDATE_COMMAND_UI(ID_BUTTON32774_Move, OnUpdateBUTTON32774Move)
  64. ON_COMMAND(ID_BUTTON32845_Axis, OnBUTTON32845Axis)
  65. ON_UPDATE_COMMAND_UI(ID_BUTTON32845_Axis, OnUpdateBUTTON32845Axis)
  66. ON_COMMAND(ID_BUTTON32850_ReDraw, OnBUTTON32850ReDraw)
  67. ON_COMMAND(ID_BUTTON32856_DONothing, OnBUTTON32856DONothing)
  68. ON_COMMAND(ID_BUTTON32858_OnDo, OnBUTTON32858OnDo)
  69. ON_COMMAND(ID_BUTTON32859_ReDo, OnBUTTON32859ReDo)
  70. ON_UPDATE_COMMAND_UI(ID_BUTTON32858_OnDo, OnUpdateBUTTON32858OnDo)
  71. ON_UPDATE_COMMAND_UI(ID_BUTTON32859_ReDo, OnUpdateBUTTON32859ReDo)
  72. ON_COMMAND(ID_MouseCap_On, OnMouseCapOn)
  73. ON_UPDATE_COMMAND_UI(ID_MouseCap_On, OnUpdateMouseCapOn)
  74. ON_WM_KEYDOWN()
  75. //}}AFX_MSG_MAP
  76. // Standard printing commands
  77. ON_COMMAND(ID_FILE_PRINT, CScrollView::OnFilePrint)
  78. ON_COMMAND(ID_FILE_PRINT_DIRECT, CScrollView::OnFilePrint)
  79. ON_COMMAND(ID_FILE_PRINT_PREVIEW, CScrollView::OnFilePrintPreview)
  80. END_MESSAGE_MAP()
  81. /////////////////////////////////////////////////////////////////////////////
  82. // CEastDrawView construction/destruction
  83. #include "MainFrm.h"
  84. #include "CCurve.h"
  85. #include "CDLine.h"
  86. #include "CRectangle.h"
  87. #include "CRoundRectangle.h"
  88. #include "CEllipse.h"
  89. #include "CRound.h"
  90. #include "CPolygon.h"
  91. #include"CLiEllipse.h"
  92. #include"CRoundArc.h"
  93. #include"CEllipseArc.h"
  94. #include "CPolyBezier.h"
  95. //#include "TextEdit.h"
  96. #include "CText.h"
  97. CEastDrawView::CEastDrawView()
  98. {
  99. // TODO: add construction code here
  100. m_IsLastMove=false;
  101. m_Rtimes=0;
  102. m_Index=0;
  103. m_pCurrentUnit=new CUnit;
  104. m_HaveAxis=true;
  105. m_Bitmap=NULL;
  106. m_IsLocked=false;
  107. CMainFrame*pMainFrame=STATIC_DOWNCAST(CMainFrame, AfxGetMainWnd());
  108. m_DLineProperty=pMainFrame->m_DLineProperty;
  109. m_IsMouseCap=true;
  110. }
  111. CEastDrawView::~CEastDrawView()
  112. {
  113. this->ReMoveTemp();
  114. }
  115. BOOL CEastDrawView::PreCreateWindow(CREATESTRUCT& cs)
  116. {
  117. // TODO: Modify the Window class or styles here by modifying
  118. //  the CREATESTRUCT cs
  119.  
  120. return CScrollView::PreCreateWindow(cs);
  121. }
  122. /////////////////////////////////////////////////////////////////////////////
  123. // CEastDrawView drawing
  124. void CEastDrawView::OnDraw(CDC* pDC)
  125. {
  126. CEastDrawDoc* pDoc = GetDocument();
  127. ASSERT_VALID(pDoc);
  128. pDC->SetWindowOrg(m_CenterPoint);
  129.     this->DrawAll(pDC);
  130. if(this->m_HaveAxis)
  131. this->DrawAxis(pDC);
  132. }
  133. void CEastDrawView::OnInitialUpdate()
  134. {
  135. CScrollView::OnInitialUpdate();
  136.     CEastDrawDoc* pDoc = GetDocument();
  137. ASSERT_VALID(pDoc);
  138. CSize sizeTotal;
  139. // TODO: calculate the total size of this view
  140. sizeTotal.cx = sizeTotal.cy =2000;
  141. SetScrollSizes(MM_TEXT,pDoc->m_TotalSize);
  142.     m_CenterPoint=pDoc->m_CenterPoint; 
  143. //SetScrollSizes(MM_HIENGLISH, sizeTotal);
  144.     m_bHaveFindFirst=FALSE;
  145. m_bHaveFindSecond=false;
  146. m_LBDownTimes=0;
  147.     m_CurrentDrawTool=0;
  148. m_CurrentDrawStatus=0;
  149.     ScrollToPosition(CPoint(900,600));
  150.   
  151. AddTempFile();
  152. AutoSave();
  153.   }
  154. /////////////////////////////////////////////////////////////////////////////
  155. // CEastDrawView printing
  156. void CEastDrawView::OnBeginPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
  157. {
  158. // TODO: add extra initialization before printing
  159. }
  160. void CEastDrawView::OnEndPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
  161. {
  162. // TODO: add cleanup after printing
  163. }
  164. /////////////////////////////////////////////////////////////////////////////
  165. // CEastDrawView diagnostics
  166. #ifdef _DEBUG
  167. void CEastDrawView::AssertValid() const
  168. {
  169. CScrollView::AssertValid();
  170. }
  171. void CEastDrawView::Dump(CDumpContext& dc) const
  172. {
  173. CScrollView::Dump(dc);
  174. }
  175. CEastDrawDoc* CEastDrawView::GetDocument() // non-debug version is inline
  176. {
  177. ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CEastDrawDoc)));
  178. return (CEastDrawDoc*)m_pDocument;
  179. }
  180. #endif //_DEBUG
  181. /////////////////////////////////////////////////////////////////////////////
  182. // CEastDrawView message handlers
  183. //******************************************************************************
  184. //******************************************************************************
  185. //**********void CEastDrawView::OnLButtonDown(UINT nFlags, CPoint point)********************************************************************
  186. //******************************************************************************
  187. //******************************************************************************
  188. void CEastDrawView::OnLButtonDown(UINT nFlags, CPoint point) 
  189. {
  190. // TODO: Add your message handler code here and/or call default
  191.       CEastDrawDoc*pDoc=this->GetDocument();  
  192.   CPoint Devpoint=point;
  193.   CClientDC dc(this);
  194.   this->OnPrepareDC(&dc);
  195.       dc.SetWindowOrg(m_CenterPoint);
  196.   dc.DPtoLP(&point);
  197.       dc.SetROP2(R2_NOTXORPEN);
  198.   this->ComputeMinandMaxPoint(point);
  199.   m_ChangeingPoint=point;
  200.       this->SetMousePosText(point,Devpoint);
  201.   
  202.     
  203. if(this->m_CurrentDrawStatus==Draw_Status)
  204. {
  205.       if(this->m_CurrentDrawTool!=Polygon_Tool&&this->m_CurrentDrawTool!=PolyBezier_Tool)
  206.   {
  207.       if(this->m_CurrentDrawTool==EllipseArc_Tool)
  208.   {
  209.      if(m_LBDownTimes==3)
  210.  {
  211.    this->m_pCurrentUnit->DrawActive(&dc,point);
  212.    this->m_pCurrentUnit->DrawStatic(&dc);
  213.                this->m_LBDownTimes=-1;
  214.    //if(m_DLineProperty->m_Mode->m_bMode)
  215.    //this->m_pCurrentUnit->DrawStatic(&dc);
  216.  }
  217.   
  218.   }
  219.   if(this->m_CurrentDrawTool==Ellipse_Tool||m_CurrentDrawTool==RoundArc_Tool)
  220.  {
  221.       if(m_LBDownTimes==2)
  222. {
  223.        this->ComputeMinandMaxPoint(point);
  224.    this->m_pCurrentUnit->DrawActive(&dc,point);
  225.    this->m_pCurrentUnit->DrawStatic(&dc);
  226.    this->InvalidateMovingRect(m_pCurrentUnit);
  227. m_LBDownTimes=-1;
  228. //if(m_DLineProperty->m_Mode->m_bMode)
  229. //this->m_pCurrentUnit->DrawStatic(&dc);
  230. }
  231.  }
  232.          if(this->m_CurrentDrawTool!=Text_Tool&&this->m_CurrentDrawTool!=Ellipse_Tool&&this->m_CurrentDrawTool!=RoundArc_Tool&&this->m_CurrentDrawTool!=EllipseArc_Tool)
  233.  { 
  234.        if(m_LBDownTimes==1)
  235.    {   
  236.    //this->ComputeMinandMaxPoint(point);
  237.    //this->InvalidateMovingRect(m_pCurrentUnit);
  238.    m_LBDownTimes=-1;
  239.    //if(m_DLineProperty->m_Mode->m_bMode)
  240.    //this->m_pCurrentUnit->DrawStatic(&dc);
  241.    }  
  242.  }//*****if(this->m_CurrentDrawTool!=Ellipse_Tool)
  243.   }//*****if(this->m_CurrentDrawTool!=Polygon_Tool)
  244. }//*******if(this->m_CurrentDrawStatus==Draw_Status)
  245.   if(this->m_CurrentDrawStatus==Select_Status)
  246.    {
  247.      m_LBDownTimes=0;
  248.  this->m_CurrentDrawTool=0;
  249.    }
  250.   
  251. if(m_CurrentDrawStatus==Change_Status||m_CurrentDrawStatus==Drag_Status)
  252.    {   
  253.    
  254.    if((m_CurrentDrawTool==Round_Tool||m_CurrentDrawTool==Ellipse_Tool)&&m_CurrentDrawStatus==Change_Status)
  255.    {
  256.   m_pCurrentUnit->ShowMovingLine(&dc,m_pCurrentUnit->m_CenterPoint,m_pCurrentUnit->m_FoundPoint);
  257.   m_pCurrentUnit->ShowMovingLine(&dc,m_pCurrentUnit->m_CenterPoint,point);
  258.    
  259.    }
  260.   
  261.    m_LBDownTimes=-1;
  262.    m_bHaveFindFirst=false;
  263.    m_CurrentDrawStatus=Select_Status;
  264.    m_pCurrentUnit->ShowSelectPoint(&dc);
  265.    m_pCurrentUnit->ShowMovingLine(&dc,m_pCurrentUnit->m_FoundPoint,point);
  266.    m_pCurrentUnit->DrawOldReferencePoint(&dc,m_pCurrentUnit->m_FoundPoint);
  267.    this->ComputeMinandMaxPoint(point);
  268.    this->InvalidateMovingRect(m_pCurrentUnit);
  269.         if(m_CurrentDrawTool==RoundArc_Tool)
  270. {
  271.   m_pCurrentUnit->DrawActive(&dc,point);
  272.   m_pCurrentUnit->DrawStatic(&dc);
  273. }
  274. }
  275.     
  276.      if(m_LBDownTimes==-1||m_CurrentDrawTool==0||m_CurrentDrawTool==Text_Tool||m_CurrentDrawStatus==Select_Status)
  277.  {
  278.  if(m_IsMouseCap)
  279.  ::ReleaseCapture();
  280.  
  281. }
  282.      if(m_LBDownTimes==-1)
  283.  {
  284.  ExchangeSave(); 
  285.  
  286.  }
  287.       m_LBDownTimes++;
  288.   m_bHaveFindSecond=false;
  289.   m_bHaveFindFirst=false;
  290.   m_LastDownPoint=point;
  291.   L_iPointCount=-1;
  292.       if(m_LBDownTimes==1&&m_CurrentDrawTool!=Text_Tool&&m_CurrentDrawStatus!=Select_Status)
  293.   { 
  294.   m_FirstPoint=point;
  295.   m_SecondPoint=point;
  296.   m_MinPoint=point;
  297.   this->m_MaxPoint=point;
  298.   if(m_IsMouseCap)
  299.   this->SetCapture();
  300.   }
  301.   this->ComputeMinandMaxPoint(point);
  302.   
  303. if(m_DLineProperty->m_DLineDlg2->m_Draw_Status==Select_Color_Status)
  304.   {
  305.     
  306.     m_DLineProperty->m_DLineDlg2->OnChange(dc.GetPixel(point));
  307.     m_CurrentDrawStatus=Select_Color_Status;
  308. m_CurrentDrawTool=0;
  309.   }   
  310.  
  311. //******************************************************************************
  312. //******************************************************************************
  313. dc.SetROP2(R2_NOTXORPEN);
  314. if((m_LBDownTimes==1)&&(m_CurrentDrawStatus==Select_Status))
  315. {  
  316. for(int i=0;!m_bHaveFindSecond&&!m_bHaveFindFirst&&i<pDoc->m_PolyBezierArray.GetSize();i++)
  317. {
  318.  CPolyBezier*L_pPolyBezier=(CPolyBezier*)pDoc->m_PolyBezierArray.GetAt(i);
  319.  L_pPolyBezier->OnLButtonDown(&dc,this,point);
  320. }
  321.     
  322. for(i=0;!m_bHaveFindSecond&&!m_bHaveFindFirst&&i<pDoc->m_TextArray.GetSize();i++)
  323. {
  324.      CText*L_pText=(CText*)pDoc->m_TextArray.GetAt(i);
  325.  L_pText->OnLButtonDown(&dc,this,point);
  326. }
  327.     for(i=0;!m_bHaveFindSecond&&!m_bHaveFindFirst&&i<pDoc->m_EllipseArcArray.GetSize();i++)
  328. {
  329.   CEllipseArc*L_pEllipseArc=(CEllipseArc*)pDoc->m_EllipseArcArray.GetAt(i);
  330.   L_pEllipseArc->OnLButtonDown(&dc,this,point);
  331. }//for(int i=0;!m_bHaveFindSecond&&pDoc->m_EllipseArcArray.GetSize();i++)
  332. for(i=0;!m_bHaveFindSecond&&!m_bHaveFindFirst&&i<pDoc->m_RoundRectangleArray.GetSize();i++)
  333.     { 
  334.      CRoundRectangle*L_pRoundRectangle=(CRoundRectangle*)pDoc->m_RoundRectangleArray.GetAt(i);
  335.      L_pRoundRectangle->OnLButtonDown(&dc,this,point);   
  336. }//******for(int i=0;!l_bHaveFinf&&i<pDoc->m_RoundRectangleArray.GetSize();i++)  
  337.  
  338.    for(i=0;!m_bHaveFindSecond&&!m_bHaveFindFirst&&i<pDoc->m_RoundArcArray.GetSize();i++)
  339.    {
  340.     CRoundArc*L_pRoundArc=(CRoundArc*)pDoc->m_RoundArcArray.GetAt(i);
  341.     L_pRoundArc->OnLButtonDown(&dc,this,point);
  342.    }//******for(i=0;!m_bHaveFindSecond&&i<pDoc->m_RoundArcArray.GetSize();i++)
  343.   
  344.   for(i=0;!m_bHaveFindSecond&&!m_bHaveFindFirst&&i<pDoc->m_LiEllipseArray.GetSize();i++)
  345.   {
  346.    CLiEllipse*L_pLiEllipse=(CLiEllipse*)pDoc->m_LiEllipseArray.GetAt(i);
  347.    L_pLiEllipse->OnLButtonDown(&dc,this,point);
  348.   } //******for(i=0;!l_bHaveFind&&i<pDoc->m_LiEllipseArray.GetSize();i++)
  349.   
  350. for(i=0;!m_bHaveFindSecond&&!m_bHaveFindFirst&&i<pDoc->m_EllipseArray.GetSize();i++)
  351.  {
  352.    CEllipse*L_pEllipse=(CEllipse*)pDoc->m_EllipseArray.GetAt(i);
  353.    L_pEllipse->OnLButtonDown(&dc,this,point);
  354.  }//******for(i=0;!m_bHaveFindFirst&&i<pDoc->m_EllipseArray.GetSize();i++)
  355.   
  356.  for(i=0;!m_bHaveFindSecond&&!m_bHaveFindFirst&&i<pDoc->m_RoundArray.GetSize();i++)
  357.  {
  358.     CRound*L_pRound=(CRound*)pDoc->m_RoundArray.GetAt(i);
  359. L_pRound->OnLButtonDown(&dc,this,point);
  360.  }//******for(i=0;!m_bHaveFindFirst&&i<pDoc->m_RoundArray.GetSize();i++)
  361.  
  362.  for(i=0;!m_bHaveFindSecond&&!m_bHaveFindFirst&&i<pDoc->m_DLineArray.GetSize();i++)
  363.  { 
  364.        CDLine*L_pDLine=(CDLine*)pDoc->m_DLineArray.GetAt(i);
  365.        L_pDLine->OnLButtonDown(&dc,this,point);
  366.  } //******for(int i=0;!m_bHaveFindFirst&&i<pDoc->m_DLineArray.GetSize();i++)
  367.   
  368.  for(i=0;!m_bHaveFindSecond&&!m_bHaveFindFirst&&i<pDoc->m_CurveArray.GetSize();i++)
  369.   {
  370. CCurve*L_pCurve=(CCurve*)pDoc->m_CurveArray.GetAt(i);
  371.  L_pCurve->OnLButtonDown(&dc,this,point);
  372.  }//*****for(i=0;!m_bHaveFindFirst&&i<pDoc->m_CurveArray.GetSize();i++)
  373.  for(i=0;!m_bHaveFindSecond&&!m_bHaveFindFirst&&i<pDoc->m_RectangleArray.GetSize();i++)
  374.  {
  375.     CRectangle *L_pRectangle=(CRectangle*)pDoc->m_RectangleArray.GetAt(i);
  376. L_pRectangle->OnLButtonDown(&dc,this,point);
  377. }//*****for(i=0;!m_bHaveFindFirst&&i<pDoc->m_RectangleArray.GetSize();i++)
  378. for(i=0;!m_bHaveFindSecond&&!m_bHaveFindFirst&&i<pDoc->m_PolygonArray.GetSize();i++)
  379. {
  380.   CPolygon*L_pPolygon=(CPolygon*)pDoc->m_PolygonArray.GetAt(i);
  381.   L_pPolygon->OnLButtonDown(&dc,this,point);
  382. } //******for(i=0;!m_bHaveFindFirst&&i<pDoc->m_PolygonArray.GetSize();i++)
  383. } //******if((m_CurrentDrawStatus==Select_Status))
  384.  //***************************************************************************************
  385.  //***************************************************************************************
  386. if(m_CurrentDrawStatus==Draw_Status)
  387. {    
  388. if(m_CurrentDrawTool==PolyBezier_Tool)
  389.   if(this->m_LBDownTimes==1)
  390.   {   
  391.   m_pCurrentUnit=new CPolyBezier;
  392.       pDoc->m_PolyBezierArray.Add((CPolyBezier*)m_pCurrentUnit);
  393.   }
  394.   this->m_FirstPoint=this->m_SecondPoint=point;
  395.   m_pCurrentUnit->OnLButtonDown(&dc,this,point);
  396. }
  397.     if(m_CurrentDrawTool==Text_Tool)
  398. {
  399.   if(this->m_LBDownTimes==1)
  400.   {   
  401. m_pCurrentUnit=new CText;
  402.     pDoc->m_TextArray.Add((CText*)m_pCurrentUnit);
  403.   }
  404.       m_pCurrentUnit->OnLButtonDown(&dc,this,point);
  405.   }
  406. if(m_CurrentDrawTool==EllipseArc_Tool)
  407. {
  408.       if(this->m_LBDownTimes==1)
  409.   {
  410.   m_pCurrentUnit=new CEllipseArc;
  411.   pDoc->m_EllipseArcArray.Add((CEllipseArc*)m_pCurrentUnit);
  412.   }
  413.  if(this->m_LBDownTimes==2)
  414.  {
  415.    m_pCurrentUnit->ComputSloap(m_pCurrentUnit->m_FirstPoint,point);
  416.        m_pCurrentUnit->m_CenterPoint=CPoint((m_pCurrentUnit->m_FirstPoint.x+point.x)/2,(m_pCurrentUnit->m_FirstPoint.y+point.y)/2);
  417.        m_pCurrentUnit->ComputRadiusY(m_pCurrentUnit->m_CenterPoint,point);
  418.  
  419.  }
  420.  if(this->m_LBDownTimes==3)
  421.  {
  422.      m_pCurrentUnit->m_FourthPoint=point;
  423.  m_pCurrentUnit->m_FifthPoint=point;
  424.  m_pCurrentUnit->ComputeIntersectionPointFirst(point);
  425.  m_pCurrentUnit->ComputeIntersectionPointSecond(point);
  426.  }
  427. }
  428. if(m_CurrentDrawTool==RoundArc_Tool)
  429. {
  430.   if(this->m_LBDownTimes==1)
  431.   {
  432.     m_pCurrentUnit=new CRoundArc;
  433. pDoc->m_RoundArcArray.Add((CRoundArc*)m_pCurrentUnit);
  434.   }
  435.   if(this->m_LBDownTimes==2)
  436.   {
  437.     m_pCurrentUnit->m_SecondPoint=point;
  438.         m_pCurrentUnit->ComputeSloap1(m_pCurrentUnit->m_FirstPoint,m_pCurrentUnit->m_SecondPoint);
  439.     m_pCurrentUnit->m_ThirdPoint=m_pCurrentUnit->m_FirstPoint;
  440.   }
  441. }//******if(m_CurrentDrawTool==RoundArc_Tool)
  442.      
  443. if(m_CurrentDrawTool==Polygon_Tool)
  444.  {
  445.  if(this->m_LBDownTimes==1)
  446.  {
  447.           m_pCurrentUnit=new CPolygon;
  448.           pDoc->m_PolygonArray.Add((CPolygon*)m_pCurrentUnit);
  449.           m_pCurrentUnit->m_PointList->Add(point);
  450.  }
  451.     if(this->m_LBDownTimes!=0&&this->m_LBDownTimes!=1)
  452.  {
  453.        m_pCurrentUnit->m_PointList->Add(point);
  454.      }
  455.  }//******if(m_CurrentDrawTool==Polygon_Tool)
  456.      if(m_CurrentDrawTool==Ellipse_Tool)
  457.  { 
  458.    if(m_LBDownTimes==1)
  459.    {
  460.    m_pCurrentUnit=new CEllipse;
  461.    pDoc->m_EllipseArray.Add((CEllipse*)m_pCurrentUnit);
  462.        }
  463.    if(m_LBDownTimes==2)
  464.    {
  465.    m_pCurrentUnit->ComputSloap(m_pCurrentUnit->m_FirstPoint,point);
  466.        m_pCurrentUnit->m_CenterPoint=CPoint((m_pCurrentUnit->m_FirstPoint.x+point.x)/2,(m_pCurrentUnit->m_FirstPoint.y+point.y)/2);
  467.        m_pCurrentUnit->ComputRadiusX(m_pCurrentUnit->m_CenterPoint,point);
  468.        m_pCurrentUnit->ComputRadiusY(m_pCurrentUnit->m_CenterPoint,point);
  469.        m_pCurrentUnit->ellipseMidpoint(&dc,m_pCurrentUnit->m_CenterPoint.x,m_pCurrentUnit->m_CenterPoint.y,m_pCurrentUnit->m_Xr,m_pCurrentUnit->m_Yr);
  470.        }
  471.    if(this->m_LBDownTimes==0)
  472.    {
  473.     m_pCurrentUnit->ShowMovingLine(&dc,m_pCurrentUnit->m_FirstPoint,m_pCurrentUnit->m_SecondPoint);
  474.    }
  475.        
  476.  }//******if(m_CurrentDrawTool==Ellipse_Tool)
  477.  if(m_CurrentDrawTool==Round_Tool)
  478.  {
  479.   if(m_LBDownTimes==1)
  480.   {
  481.   m_pCurrentUnit=new CRound;
  482.   pDoc->m_RoundArray.Add((CRound*)m_pCurrentUnit);
  483.   m_pCurrentUnit->m_CenterPoint=point;
  484.   }
  485.   if(m_LBDownTimes==0)
  486.   {
  487.   m_pCurrentUnit->ShowMovingLine(&dc,m_pCurrentUnit->m_CenterPoint,point);
  488.       }
  489.  }
  490.   if(m_CurrentDrawTool==RoundRectangle_Tool)
  491. {
  492.  if(m_LBDownTimes==1)
  493.  {
  494.  m_pCurrentUnit=new CRoundRectangle;
  495.      pDoc->m_RoundRectangleArray.Add((CRoundRectangle*)m_pCurrentUnit);
  496.  }
  497.  
  498. }
  499.   if(m_CurrentDrawTool==LiEllipse_Tool)
  500.   {
  501.      if(m_LBDownTimes==1)
  502.  {
  503.   m_pCurrentUnit=new CLiEllipse;
  504.   pDoc->m_LiEllipseArray.Add((CLiEllipse*)m_pCurrentUnit);
  505.  }
  506.   
  507.   }
  508.     if(m_CurrentDrawTool==DLine_Tool)
  509. {
  510. if(m_LBDownTimes==1)
  511. {
  512.      m_pCurrentUnit=new CDLine;
  513.          pDoc->m_DLineArray.Add((CDLine*)m_pCurrentUnit);
  514. }
  515.     if(m_CurrentDrawTool==Curve_Tool)
  516. {  
  517. if(m_LBDownTimes==1)
  518. {
  519.   m_pCurrentUnit=(CCurve*)new CCurve;
  520.   pDoc->m_CurveArray.Add((CCurve*)m_pCurrentUnit);
  521.   m_pCurrentUnit->m_PointList->Add(point);
  522.   m_pCurrentUnit->m_PointList->Add(point);
  523. }
  524. }//******if(m_CurrentDrawTool==Curve_Tool)
  525. if(m_CurrentDrawTool==Rectangle_Tool)
  526. {
  527.  if(m_LBDownTimes==1)
  528.  {
  529.   m_pCurrentUnit=(CRectangle*)new CRectangle;
  530.   pDoc->m_RectangleArray.Add((CRectangle*)m_pCurrentUnit);
  531.      }
  532. }//******if(m_CurrentDrawTool==Rectangle_Tool)
  533.  
  534. }//*****if(m_CurrentDrawStatus==Draw_Status)
  535.  
  536.   if((m_CurrentDrawStatus==Draw_Status&&m_LBDownTimes==1)||(m_bHaveFindSecond&&!m_IsLocked))
  537.   {
  538.   m_DLineProperty->m_DLineDlg1->UpdateData();
  539.       m_pCurrentUnit->m_FirstPoint=m_FirstPoint;
  540.   m_pCurrentUnit->m_SecondPoint=m_SecondPoint;
  541.       m_pCurrentUnit->m_PenStyle=m_DLineProperty->m_DLineDlg1->m_PenStyle;
  542.   m_pCurrentUnit->m_PenWidth=m_DLineProperty->m_DLineDlg1->m_Edit_LineWidth;
  543.   m_pCurrentUnit->m_PenColor=m_DLineProperty->m_DLineDlg2->m_PenColor;
  544.   m_pCurrentUnit->m_BrushColor=m_DLineProperty->m_DLineDlg2->m_BrushColor;
  545.   m_pCurrentUnit->m_BrushHatch=m_DLineProperty->m_DLineDlg1->m_BrushHatch;
  546.   m_pCurrentUnit->m_BrushStyle=m_DLineProperty->m_DLineDlg1->m_BrushStyle;
  547.   m_pCurrentUnit->m_BackgroundColor=m_DLineProperty->m_DLineDlg2->m_BackgroundColor;
  548.   //if(m_DLineProperty->m_Mode->m_bMode)
  549.  
  550.  // m_pCurrentUnit->m_DrawingMode=m_DLineProperty->m_Mode->m_DrawingMode;
  551.       
  552.   //else
  553.   m_pCurrentUnit->m_DrawingMode=dc.GetROP2();
  554.   m_pCurrentUnit->m_BkMode=m_DLineProperty->m_DLineDlg1->m_BKMode;//m_DLineProperty->m_Mode->m_BKMode;
  555.   
  556.   }//**********if(this->m_LBDownTimes==1&&m_bHaveFindFirst)
  557.      
  558.     if(m_bHaveFindSecond&&m_IsLocked)
  559. {
  560.   m_DLineProperty->m_DLineDlg1->UpdateData();
  561.       m_pCurrentUnit->m_FirstPoint=m_FirstPoint;
  562.   m_pCurrentUnit->m_SecondPoint=m_SecondPoint;
  563.       m_DLineProperty->m_DLineDlg1->m_PenStyle=m_pCurrentUnit->m_PenStyle;
  564.   m_DLineProperty->m_DLineDlg1->m_Edit_LineWidth=m_pCurrentUnit->m_PenWidth;
  565.   m_DLineProperty->m_DLineDlg2->m_PenColor=m_pCurrentUnit->m_PenColor;
  566.   m_DLineProperty->m_DLineDlg2->m_BrushColor=m_pCurrentUnit->m_BrushColor;
  567.   m_DLineProperty->m_DLineDlg1->m_BrushHatch=m_pCurrentUnit->m_BrushHatch;
  568.   m_DLineProperty->m_DLineDlg1->m_BrushStyle=m_pCurrentUnit->m_BrushStyle;
  569.   m_DLineProperty->m_DLineDlg2->m_BackgroundColor=m_pCurrentUnit->m_BackgroundColor;
  570.   m_pCurrentUnit->m_DrawingMode=dc.GetROP2();
  571.   m_DLineProperty->m_DLineDlg1->m_BKMode=m_pCurrentUnit->m_BkMode;
  572.   // if(m_DLineProperty->m_Mode->m_bMode)
  573.   //m_DLineProperty->m_Mode->m_DrawingMode=m_pCurrentUnit->m_DrawingMode;
  574.   
  575.   m_DLineProperty->GetActivePage()->UpdateData(false);
  576.   m_DLineProperty->GetActivePage()->Invalidate();
  577.     
  578.  }
  579.   
  580.     if(m_bHaveFindSecond)
  581.  {
  582.   m_pCurrentUnit->DrawStatic(&dc);
  583.  }
  584. if(m_CurrentDrawStatus==Drag_Status)
  585.  {    
  586.   m_FirstPoint=m_pCurrentUnit->m_FoundPoint;
  587.   m_SecondPoint=m_pCurrentUnit->m_FoundPoint;
  588.  }
  589. if(m_CurrentDrawStatus==Change_Status)//&&m_CurrentDrawTool==Ellipse_Tool)
  590. {
  591.       m_FirstPoint=m_pCurrentUnit->m_FoundPoint;
  592.   m_SecondPoint=m_pCurrentUnit->m_FoundPoint;
  593.   
  594.   if(this->m_CurrentDrawTool==Text_Tool)
  595.   {
  596.    m_pCurrentUnit->OnLButtonDown(&dc,this,point);
  597.    
  598.   }
  599. }
  600.   if(m_IsMouseCap&&m_bHaveFindSecond)
  601.   this->SetCapture();
  602. CScrollView::OnLButtonDown(nFlags, point);
  603. }
  604. //***************************************************************************************
  605. //***************************************************************************************
  606. //***************************************************************************************
  607. //***************************************************************************************
  608. void CEastDrawView::OnLButtonUp(UINT nFlags, CPoint point) 
  609. {
  610. // TODO: Add your message handler code here and/or call default
  611.   
  612.   CPoint Devpoint=point;
  613.   CClientDC dc(this);
  614.   this->OnPrepareDC(&dc);
  615.       dc.SetWindowOrg(m_CenterPoint);
  616.   dc.DPtoLP(&point);
  617.       dc.SetROP2(R2_NOTXORPEN);
  618.   this->ComputeMinandMaxPoint(point);
  619.   m_ChangeingPoint=point;
  620.       this->SetMousePosText(point,Devpoint);
  621.  if(m_DLineProperty->m_DLineDlg2->m_Draw_Status==Select_Color_Status)
  622.   {
  623.       m_DLineProperty->m_DLineDlg2->m_Color=dc.GetPixel(point);
  624.   m_DLineProperty->m_DLineDlg2->OnChange(dc.GetPixel(point));
  625.       m_CurrentDrawStatus=0;
  626.       m_DLineProperty->m_DLineDlg2->m_Draw_Status=0;
  627.   m_CurrentDrawTool=0;
  628.  }
  629.  if(m_IsMouseCap&&m_bHaveFindSecond)
  630.   this->SetCapture();
  631.   CScrollView::OnLButtonUp(nFlags, point);
  632. }
  633. //***************************************************************************************
  634. //***************************************************************************************
  635. //***************************************************************************************
  636. //***************************************************************************************
  637. //***************************************************************************************
  638. void CEastDrawView::OnMouseMove(UINT nFlags, CPoint point) 
  639. {
  640. // TODO: Add your message handler code here and/or call default
  641.   CPoint Devpoint=point;
  642.   CClientDC dc(this);
  643.   this->OnPrepareDC(&dc);
  644.       dc.SetWindowOrg(m_CenterPoint);
  645.   dc.DPtoLP(&point);
  646.       dc.SetROP2(R2_NOTXORPEN);
  647.   this->ComputeMinandMaxPoint(point);
  648.   m_ChangeingPoint=point;
  649.       this->SetMousePosText(point,Devpoint);
  650.      
  651.   
  652.  if(m_DLineProperty->m_DLineDlg2->m_Draw_Status==Select_Color_Status)
  653.   {
  654.     
  655.     m_DLineProperty->m_DLineDlg2->OnChange(dc.GetPixel(point));
  656.     m_CurrentDrawStatus=Select_Color_Status;
  657. m_CurrentDrawTool=0;
  658.   }
  659. if((m_LBDownTimes!=0)&&(m_CurrentDrawStatus==Draw_Status||m_CurrentDrawStatus==Change_Status))
  660. {     
  661.     
  662. if(m_CurrentDrawStatus==Change_Status)
  663. {  
  664. m_pCurrentUnit->ShowMovingLine(&dc,m_pCurrentUnit->m_FoundPoint,m_SecondPoint);
  665. }
  666.       
  667. m_pCurrentUnit->OnMouseMove(&dc,this,point);
  668.  if(m_CurrentDrawStatus==Change_Status)
  669.   m_pCurrentUnit->ShowMovingLine(&dc,m_pCurrentUnit->m_FoundPoint,point);
  670. }//*********if(m_IsDrawing&&(m_CurrentDrawStatus==Draw_Status||m_CurrentDrawStatus==Exchange_Status))  
  671.  if(m_CurrentDrawStatus==Drag_Status)
  672.  {     
  673.   m_pCurrentUnit->ShowMovingLine(&dc,m_pCurrentUnit->m_FoundPoint,m_SecondPoint);
  674.   dc.SetROP2(R2_NOTXORPEN);
  675.   
  676.   m_pCurrentUnit->m_DrawingMode=dc.GetROP2();
  677.  if(m_CurrentDrawTool!=EllipseArc_Tool)
  678.   m_pCurrentUnit->DrawActive(&dc,point);
  679.   
  680.   m_FirstPoint=m_SecondPoint;
  681.       m_SecondPoint=point;
  682.      m_pCurrentUnit->OnMouseMove(&dc,this,point);
  683.      m_pCurrentUnit->m_DrawingMode=dc.GetROP2();
  684.     
  685.  if(m_CurrentDrawTool!=EllipseArc_Tool)
  686.  m_pCurrentUnit->DrawActive(&dc,point);
  687.  
  688. m_pCurrentUnit->ShowMovingLine(&dc,m_pCurrentUnit->m_FoundPoint,point);
  689. }
  690.     CScrollView::OnMouseMove(nFlags, point);
  691. }
  692. void CEastDrawView::OnBUTTONDLine() 
  693. {
  694. CClientDC dc(this);
  695. OnPrepareDC(&dc);
  696. dc.SetWindowOrg(m_CenterPoint);
  697. // TODO: Add your command handler code here
  698. if(m_CurrentDrawStatus==Drag_Status||m_CurrentDrawStatus==Change_Status||m_CurrentDrawStatus==Select_Status)
  699.     ResetSelectStatus();
  700.    
  701.     CMainFrame* pMainFrame=(CMainFrame*)AfxGetMainWnd();
  702. if(pMainFrame->m_wndStyleBar.IsWindowVisible())
  703.     { 
  704.  pMainFrame->ShowFontBar(false);
  705.      if(this->m_LBDownTimes==1)
  706.  {
  707.   this->m_LBDownTimes=2;
  708.   this->m_pCurrentUnit->OnLButtonDown(&dc,this,0);
  709.   
  710.  }
  711. }
  712.     m_CurrentDrawTool=DLine_Tool;
  713. m_CurrentDrawStatus=Draw_Status;
  714. this->m_LBDownTimes=0;
  715. }
  716. void CEastDrawView::OnBUTTON32774Move() 
  717. {   
  718. CClientDC dc(this);
  719. OnPrepareDC(&dc);
  720. dc.SetWindowOrg(m_CenterPoint);
  721. // TODO: Add your command handler code here
  722.    
  723. if(m_CurrentDrawStatus==Drag_Status||m_CurrentDrawStatus==Change_Status||m_CurrentDrawStatus==Select_Status)
  724.     ResetSelectStatus();
  725.     
  726.     
  727. CMainFrame* pMainFrame=(CMainFrame*)AfxGetMainWnd();
  728. if(pMainFrame->m_wndStyleBar.IsWindowVisible())
  729.     { 
  730.  pMainFrame->ShowFontBar(false);
  731.      if(this->m_LBDownTimes==1)
  732.  {
  733.   this->m_LBDownTimes=2;
  734.   this->m_pCurrentUnit->OnLButtonDown(&dc,this,0);
  735.   
  736.  }
  737. }
  738. m_CurrentDrawTool=0;
  739. m_CurrentDrawStatus=Select_Status;
  740. m_LBDownTimes=0;
  741. }
  742. void CEastDrawView::OnBUTTON32775CircumRotate() 
  743. {  
  744. CClientDC dc(this);
  745. OnPrepareDC(&dc);
  746. dc.SetWindowOrg(m_CenterPoint);
  747. // TODO: Add your command handler code here
  748.     //m_CurrentDrawStatus=Select_Status; 
  749.  if(m_CurrentDrawStatus==Drag_Status||m_CurrentDrawStatus==Change_Status||m_CurrentDrawStatus==Select_Status)
  750.       ResetSelectStatus();
  751.  CMainFrame* pMainFrame=(CMainFrame*)AfxGetMainWnd();
  752. if(pMainFrame->m_wndStyleBar.IsWindowVisible())
  753.     { 
  754.  pMainFrame->ShowFontBar(false);
  755.      if(this->m_LBDownTimes==1)
  756.  {
  757.   this->m_LBDownTimes=2;
  758.   this->m_pCurrentUnit->OnLButtonDown(&dc,this,0);
  759.   
  760.  }
  761. }
  762.      m_CurrentDrawTool=0;
  763.  m_CurrentDrawStatus=Circumrotate_Status;
  764. }
  765. void CEastDrawView::OnBUTTON32777Curve() 
  766. {  
  767. CClientDC dc(this);
  768. OnPrepareDC(&dc);
  769.     dc.SetWindowOrg(m_CenterPoint);
  770. // TODO: Add your command handler code here
  771.     if(m_CurrentDrawStatus==Drag_Status||m_CurrentDrawStatus==Change_Status||m_CurrentDrawStatus==Select_Status)
  772.     ResetSelectStatus();
  773. CMainFrame* pMainFrame=(CMainFrame*)AfxGetMainWnd();
  774. if(pMainFrame->m_wndStyleBar.IsWindowVisible())
  775.     { 
  776.  pMainFrame->ShowFontBar(false);
  777.      if(this->m_LBDownTimes==1)
  778.  {
  779.   this->m_LBDownTimes=2;
  780.   this->m_pCurrentUnit->OnLButtonDown(&dc,this,0);
  781.   
  782.  }
  783. }
  784.     m_CurrentDrawTool=Curve_Tool;
  785. m_LBDownTimes=0;
  786. m_CurrentDrawStatus=Draw_Status;
  787. }
  788. void CEastDrawView::OnBUTTON32776Rectangle() 
  789. {
  790. CClientDC dc(this);
  791. OnPrepareDC(&dc);
  792. dc.SetWindowOrg(m_CenterPoint);
  793. // TODO: Add your command handler code here
  794. if(m_CurrentDrawStatus==Drag_Status||m_CurrentDrawStatus==Change_Status||m_CurrentDrawStatus==Select_Status)
  795.  ResetSelectStatus();
  796.    
  797. CMainFrame* pMainFrame=(CMainFrame*)AfxGetMainWnd();
  798. if(pMainFrame->m_wndStyleBar.IsWindowVisible())
  799.     { 
  800.  pMainFrame->ShowFontBar(false);
  801.      if(this->m_LBDownTimes==1)
  802.  {
  803.   this->m_LBDownTimes=2;
  804.   this->m_pCurrentUnit->OnLButtonDown(&dc,this,0);
  805.   
  806.  }
  807. }
  808.     m_CurrentDrawTool=Rectangle_Tool;
  809.     m_LBDownTimes=0;
  810. m_CurrentDrawStatus=Draw_Status;
  811. }
  812. void CEastDrawView::OnBUTTON32778RoundRectangle() 
  813. {
  814. CClientDC dc(this);
  815. OnPrepareDC(&dc);
  816. dc.SetWindowOrg(m_CenterPoint);
  817. // TODO: Add your command handler code here
  818. if(m_CurrentDrawStatus==Drag_Status||m_CurrentDrawStatus==Change_Status||m_CurrentDrawStatus==Select_Status)
  819.      ResetSelectStatus();
  820.   CMainFrame* pMainFrame=(CMainFrame*)AfxGetMainWnd();
  821. if(pMainFrame->m_wndStyleBar.IsWindowVisible())
  822.     { 
  823.  pMainFrame->ShowFontBar(false);
  824.      if(this->m_LBDownTimes==1)
  825.  {
  826.   this->m_LBDownTimes=2;
  827.   this->m_pCurrentUnit->OnLButtonDown(&dc,this,0);
  828.   
  829.  }
  830. }
  831.   m_CurrentDrawTool=RoundRectangle_Tool;
  832.   m_CurrentDrawStatus=Draw_Status;
  833.   m_LBDownTimes=0;
  834. }
  835. void CEastDrawView::OnBUTTON32779Ellipse() 
  836. {
  837. CClientDC dc(this);
  838. OnPrepareDC(&dc);
  839. dc.SetWindowOrg(m_CenterPoint);
  840. // TODO: Add your command handler code here
  841.  if(m_CurrentDrawStatus==Drag_Status||m_CurrentDrawStatus==Change_Status||m_CurrentDrawStatus==Select_Status)
  842.  ResetSelectStatus();
  843.    CMainFrame* pMainFrame=(CMainFrame*)AfxGetMainWnd();
  844. if(pMainFrame->m_wndStyleBar.IsWindowVisible())
  845.     { 
  846.  pMainFrame->ShowFontBar(false);
  847.      if(this->m_LBDownTimes==1)
  848.  {
  849.   this->m_LBDownTimes=2;
  850.   this->m_pCurrentUnit->OnLButtonDown(&dc,this,0);
  851.   
  852.  }
  853. m_CurrentDrawTool=Ellipse_Tool;
  854.     m_CurrentDrawStatus=Draw_Status;
  855.     m_LBDownTimes=0;
  856. }
  857. void CEastDrawView::OnBUTTON32780Round() 
  858. {
  859. CClientDC dc(this);
  860. OnPrepareDC(&dc);
  861. dc.SetWindowOrg(m_CenterPoint);
  862. // TODO: Add your command handler code here
  863. if(m_CurrentDrawStatus==Drag_Status||m_CurrentDrawStatus==Change_Status||m_CurrentDrawStatus==Select_Status)
  864.  ResetSelectStatus();
  865.  
  866.   CMainFrame* pMainFrame=(CMainFrame*)AfxGetMainWnd();
  867. if(pMainFrame->m_wndStyleBar.IsWindowVisible())
  868.     { 
  869.  pMainFrame->ShowFontBar(false);
  870.      if(this->m_LBDownTimes==1)
  871.  {
  872.   this->m_LBDownTimes=2;
  873.   this->m_pCurrentUnit->OnLButtonDown(&dc,this,0);
  874.   
  875.  }
  876. }
  877.   m_CurrentDrawTool=Round_Tool;
  878.   m_CurrentDrawStatus=Draw_Status;
  879.   this->m_LBDownTimes=0;
  880. }
  881. void CEastDrawView::OnBUTTON32791Polygon() 
  882. {
  883. CClientDC dc(this);
  884. OnPrepareDC(&dc);
  885. dc.SetWindowOrg(m_CenterPoint);
  886. // TODO: Add your command handler code here
  887.  if(m_CurrentDrawStatus==Drag_Status||m_CurrentDrawStatus==Change_Status||m_CurrentDrawStatus==Select_Status)
  888.  ResetSelectStatus();
  889.  
  890.  
  891.  m_IsPolygonFirst=true;
  892.  CMainFrame* pMainFrame=(CMainFrame*)AfxGetMainWnd();
  893. if(pMainFrame->m_wndStyleBar.IsWindowVisible())
  894.     { 
  895.  pMainFrame->ShowFontBar(false);
  896.      if(this->m_LBDownTimes==1)
  897.  {
  898.   this->m_LBDownTimes=2;
  899.   this->m_pCurrentUnit->OnLButtonDown(&dc,this,0);
  900.   
  901.  }
  902. }
  903. m_CurrentDrawTool=Polygon_Tool;
  904.     m_CurrentDrawStatus=Draw_Status;
  905. this->m_LBDownTimes=0;
  906. }
  907. void CEastDrawView::OnLButtonDblClk(UINT nFlags, CPoint point) 
  908. {
  909. // TODO: Add your message handler code here and/or call default
  910.   
  911.       CPoint Devpoint=point;
  912.   CClientDC dc(this);
  913.   this->OnPrepareDC(&dc);
  914.       dc.SetWindowOrg(m_CenterPoint);
  915.   dc.DPtoLP(&point);
  916.       dc.SetROP2(R2_NOTXORPEN);
  917.   this->ComputeMinandMaxPoint(point);
  918.   m_ChangeingPoint=point;
  919.       this->SetMousePosText(point,Devpoint);
  920.    if(m_CurrentDrawStatus==Draw_Status&&m_CurrentDrawTool==Polygon_Tool)
  921. {
  922. m_pCurrentUnit->DrawEnd(&dc,point);
  923. this->m_LBDownTimes=0;
  924. this->ExchangeSave();
  925.  if(m_IsMouseCap)
  926. ::ReleaseCapture();
  927. }
  928.  
  929. CScrollView::OnLButtonDblClk(nFlags, point);
  930. }
  931. void CEastDrawView::OnSetFocus(CWnd* pOldWnd) 
  932. {
  933. CScrollView::OnSetFocus(pOldWnd);
  934. // TODO: Add your message handler code here
  935.  
  936.  
  937. }
  938. void CEastDrawView::OnMENUITEM32794SetRegin() 
  939. {
  940. // TODO: Add your command handler code here
  941.     CReginSet setReginDlg;
  942. CClientDC dc(this);
  943. setReginDlg.m_Length=this->GetTotalSize().cx;
  944.     setReginDlg.m_Width=this->GetTotalSize().cy;
  945.     
  946. setReginDlg.m_X=m_CenterPoint.x;
  947. setReginDlg.m_Y=m_CenterPoint.y;
  948.     setReginDlg.m_bIsViewReign=true;
  949.    if(setReginDlg.DoModal()==IDOK)
  950. {
  951. CSize sizeTotal;
  952.     sizeTotal.cx=setReginDlg.m_Length;
  953. sizeTotal.cy=setReginDlg.m_Width;
  954. SetScrollSizes(MM_TEXT, sizeTotal);
  955. OnPrepareDC(&dc);
  956. m_CenterPoint.x=setReginDlg.m_X;
  957. m_CenterPoint.y=setReginDlg.m_Y;
  958. dc.SetWindowOrg(m_CenterPoint);
  959. OnBUTTON32850ReDraw();
  960.     CEastDrawDoc* pDoc = GetDocument();
  961. ASSERT_VALID(pDoc);
  962. pDoc->m_CenterPoint=m_CenterPoint;
  963. pDoc->m_TotalSize=sizeTotal;
  964.    }
  965.    
  966.    
  967. }
  968. void CEastDrawView::OnBUTTONLiEllipse() 
  969. {
  970. CClientDC dc(this);
  971. OnPrepareDC(&dc);
  972. dc.SetWindowOrg(m_CenterPoint);
  973. // TODO: Add your command handler code here
  974.  if(m_CurrentDrawStatus==Drag_Status||m_CurrentDrawStatus==Change_Status||m_CurrentDrawStatus==Select_Status)
  975.  ResetSelectStatus();
  976.  
  977. CMainFrame* pMainFrame=(CMainFrame*)AfxGetMainWnd();
  978. if(pMainFrame->m_wndStyleBar.IsWindowVisible())
  979.     { 
  980.  pMainFrame->ShowFontBar(false);
  981.      if(this->m_LBDownTimes==1)
  982.  {
  983.   this->m_LBDownTimes=2;
  984.   this->m_pCurrentUnit->OnLButtonDown(&dc,this,0);
  985.   
  986.  }
  987. }
  988. m_CurrentDrawTool=LiEllipse_Tool;
  989.     m_CurrentDrawStatus=Draw_Status;
  990. this->m_LBDownTimes=0;
  991. }
  992. void CEastDrawView::ResetSelectStatus()
  993. {
  994.     CEastDrawDoc* pDoc = GetDocument();
  995. ASSERT_VALID(pDoc);
  996. CClientDC dc(this);
  997. CClientDC*pDC=&dc;
  998.     OnPrepareDC(pDC);
  999. dc.SetWindowOrg(m_CenterPoint);
  1000. for(int i=0;i<pDoc->m_PolygonArray.GetSize();i++)
  1001. {
  1002.   CPolygon*pPolygon=(CPolygon*)pDoc->m_PolygonArray.GetAt(i);
  1003.   
  1004.   if(pPolygon->m_HaveFindFirst)
  1005.   {
  1006.   pPolygon->ShowSelectPoint(pDC);
  1007.       pPolygon->m_HaveFindFirst=false;
  1008.   }
  1009. }
  1010. for(i=0;i<pDoc->m_TextArray.GetSize();i++)
  1011. {
  1012.   CText*pText=(CText*)pDoc->m_TextArray.GetAt(i);
  1013.   if(pText->m_HaveFindFirst)
  1014.   {
  1015. pText->ShowSelectPoint(pDC);
  1016.     pText->m_HaveFindFirst=false;
  1017.   }
  1018. }
  1019.     for(i=0;i<pDoc->m_EllipseArcArray.GetSize();i++)
  1020. {
  1021.   CEllipseArc*pEllipseArc=(CEllipseArc*)pDoc->m_EllipseArcArray.GetAt(i);
  1022.   if(pEllipseArc->m_HaveFindFirst)
  1023.   {
  1024.    pEllipseArc->ShowSelectPoint(pDC);
  1025.    pEllipseArc->m_HaveFindFirst=false;
  1026.   }
  1027. }
  1028. for(i=0;i<pDoc->m_DLineArray.GetSize();i++)
  1029.    {
  1030. CDLine*pDLine=(CDLine*)pDoc->m_DLineArray.GetAt(i);
  1031.     if(pDLine->m_HaveFindFirst)
  1032. { pDLine->m_HaveFindFirst=false;
  1033. pDLine->ShowSelectPoint(pDC);
  1034. }
  1035. }
  1036. for(i=0;i<pDoc->m_CurveArray.GetSize();i++)
  1037. {
  1038.  CCurve*pCurve=(CCurve*)pDoc->m_CurveArray.GetAt(i);
  1039.  
  1040.  if(pCurve->m_HaveFindFirst)
  1041.  {   pCurve->m_HaveFindFirst=false;
  1042.  pCurve->ShowSelectPoint(pDC);
  1043.      }
  1044. }
  1045. for(i=0;i<pDoc->m_RectangleArray.GetSize();i++)
  1046. {
  1047. CRectangle*pRectangle=(CRectangle*)pDoc->m_RectangleArray.GetAt(i);
  1048. if(pRectangle->m_HaveFindFirst)
  1049. {
  1050. pRectangle->m_HaveFindFirst=false;
  1051. pRectangle->ShowSelectPoint(pDC);
  1052. }
  1053. }
  1054.     for(i=0;i<pDoc->m_RoundRectangleArray.GetSize();i++)
  1055. {
  1056. CRoundRectangle*pRoundRectangle=(CRoundRectangle*)pDoc->m_RoundRectangleArray.GetAt(i);
  1057. if(pRoundRectangle->m_HaveFindFirst)
  1058. {   pRoundRectangle->m_HaveFindFirst=false;
  1059. pRoundRectangle->ShowSelectPoint(pDC);
  1060. }
  1061. }
  1062.     for(i=0;i<pDoc->m_EllipseArray.GetSize();i++)
  1063. {
  1064. CEllipse*pEllipse=(CEllipse*)pDoc->m_EllipseArray.GetAt(i);
  1065. if(pEllipse->m_HaveFindFirst)
  1066. {
  1067. pEllipse->m_HaveFindFirst=false;
  1068. pEllipse->ShowSelectPoint(pDC);
  1069. }
  1070. }
  1071.     for(i=0;i<pDoc->m_RoundArray.GetSize();i++)
  1072. {
  1073. CRound*pRound=(CRound*)pDoc->m_RoundArray.GetAt(i);
  1074. if(pRound->m_HaveFindFirst)
  1075. {   pRound->m_HaveFindFirst=false;
  1076. pRound->ShowSelectPoint(pDC);
  1077. }
  1078. }
  1079.   for(i=0;i<pDoc->m_LiEllipseArray.GetSize();i++)
  1080. {
  1081. CEllipse*pLiEllipse=(CEllipse*)pDoc->m_LiEllipseArray.GetAt(i);
  1082. if(pLiEllipse->m_HaveFindFirst)
  1083. {
  1084. pLiEllipse->m_HaveFindFirst=false;
  1085. pLiEllipse->ShowSelectPoint(pDC);
  1086. }
  1087. }
  1088.   for(i=0;i<pDoc->m_RoundArcArray.GetSize();i++)
  1089.   {
  1090.     CRoundArc*pRoundArc=(CRoundArc*)pDoc->m_RoundArcArray.GetAt(i);
  1091. if(pRoundArc->m_HaveFindFirst)
  1092. {
  1093.   pRoundArc->m_HaveFindFirst=false;
  1094.   pRoundArc->ShowSelectPoint(pDC);
  1095. }
  1096.   }
  1097.  for(i=0;i<pDoc->m_PolyBezierArray.GetSize();i++)
  1098.  {
  1099.   CPolyBezier*pPolyBezier=(CPolyBezier*)pDoc->m_PolyBezierArray.GetAt(i);
  1100.   if(pPolyBezier->m_HaveFindFirst)
  1101.   {
  1102.     pPolyBezier->m_HaveFindFirst=false;
  1103. pPolyBezier->ShowSelectPoint(pDC);
  1104.   }
  1105.  }
  1106. }
  1107. void CEastDrawView::ComputeMinandMaxPoint(CPoint point)
  1108. {
  1109. m_MinPoint.x=min(m_MinPoint.x,point.x);
  1110. m_MinPoint.y=min(m_MinPoint.y,point.y);
  1111. m_MaxPoint.x=max(m_MaxPoint.x,point.x);
  1112. m_MaxPoint.y=max(m_MaxPoint.y,point.y);
  1113. m_InvalidRect.SetRect(m_MinPoint,m_MaxPoint);
  1114. }
  1115. void CEastDrawView::InvalidateMovingRect(CUnit *pMovingUnit)
  1116. {
  1117. /*pMovingUnit->GetBoundingRect(); 
  1118. m_InvalidRect.left=min(m_InvalidRect.left,pMovingUnit->m_BoundingRect.left);
  1119. m_InvalidRect.top=min(m_InvalidRect.top,pMovingUnit->m_BoundingRect.top);
  1120. m_InvalidRect.right=max(m_InvalidRect.right,pMovingUnit->m_BoundingRect.right);
  1121. m_InvalidRect.bottom=max(m_InvalidRect.bottom,pMovingUnit->m_BoundingRect.bottom);
  1122. m_InvalidRect.InflateRect(pMovingUnit->m_PenWidth,pMovingUnit->m_PenWidth);
  1123. //
  1124. CClientDC dc(this);
  1125. dc.Rectangle(m_InvalidRect);*/
  1126. //this->InvalidateRect(m_InvalidRect);
  1127. }
  1128. void CEastDrawView::OnBUTTON32800RoundArc() 
  1129. {
  1130. CClientDC dc(this);
  1131. OnPrepareDC(&dc);
  1132. dc.SetWindowOrg(m_CenterPoint);
  1133. // TODO: Add your command handler code here
  1134. if(m_CurrentDrawStatus==Drag_Status||m_CurrentDrawStatus==Change_Status||m_CurrentDrawStatus==Select_Status)
  1135.  ResetSelectStatus();
  1136.  
  1137.  CMainFrame* pMainFrame=(CMainFrame*)AfxGetMainWnd();
  1138. if(pMainFrame->m_wndStyleBar.IsWindowVisible())
  1139.     { 
  1140.  pMainFrame->ShowFontBar(false);
  1141.      if(this->m_LBDownTimes==1)
  1142.  {
  1143.   this->m_LBDownTimes=2;
  1144.   this->m_pCurrentUnit->OnLButtonDown(&dc,this,0);
  1145.   
  1146.  }
  1147. }
  1148. m_CurrentDrawTool=RoundArc_Tool;
  1149.     m_CurrentDrawStatus=Draw_Status;
  1150. this->m_LBDownTimes=0;
  1151. }
  1152. void CEastDrawView::OnBUTTON32805EllipseArc() 
  1153. {
  1154. CClientDC dc(this);
  1155. OnPrepareDC(&dc);
  1156. dc.SetWindowOrg(m_CenterPoint);
  1157. // TODO: Add your command handler code here
  1158. if(m_CurrentDrawStatus==Drag_Status||m_CurrentDrawStatus==Change_Status||m_CurrentDrawStatus==Select_Status)
  1159.  ResetSelectStatus();
  1160.  
  1161. CMainFrame* pMainFrame=(CMainFrame*)AfxGetMainWnd();
  1162. if(pMainFrame->m_wndStyleBar.IsWindowVisible())
  1163.     { 
  1164.  pMainFrame->ShowFontBar(false);
  1165.      if(this->m_LBDownTimes==1)
  1166.  {
  1167.   this->m_LBDownTimes=2;
  1168.   this->m_pCurrentUnit->OnLButtonDown(&dc,this,0);
  1169.   
  1170.  }
  1171. }
  1172.  m_CurrentDrawTool=EllipseArc_Tool;
  1173.  m_CurrentDrawStatus=Draw_Status;
  1174.  this->m_LBDownTimes=0;
  1175. }
  1176. void CEastDrawView::OnBUTTON32807PolyBezier() 
  1177. {
  1178. CClientDC dc(this);
  1179. OnPrepareDC(&dc);
  1180. dc.SetWindowOrg(m_CenterPoint);
  1181. // TODO: Add your command handler code here
  1182. if(m_CurrentDrawStatus==Drag_Status||m_CurrentDrawStatus==Change_Status||m_CurrentDrawStatus==Select_Status)
  1183.  ResetSelectStatus();
  1184.  
  1185.  CMainFrame* pMainFrame=(CMainFrame*)AfxGetMainWnd();
  1186. if(pMainFrame->m_wndStyleBar.IsWindowVisible())
  1187.     { 
  1188.  pMainFrame->ShowFontBar(false);
  1189.      if(this->m_LBDownTimes==1)
  1190.  {
  1191.   this->m_LBDownTimes=2;
  1192.   this->m_pCurrentUnit->OnLButtonDown(&dc,this,0);
  1193.   
  1194.  }
  1195. }
  1196. m_CurrentDrawTool=PolyBezier_Tool;
  1197.  m_CurrentDrawStatus=Draw_Status;
  1198.  this->m_LBDownTimes=0;
  1199. }
  1200. void CEastDrawView::OnBUTTON32809Text() 
  1201. {
  1202. CClientDC dc(this);
  1203. OnPrepareDC(&dc);
  1204. dc.SetWindowOrg(m_CenterPoint);
  1205. // TODO: Add your command handler code here
  1206. if(m_CurrentDrawStatus==Drag_Status||m_CurrentDrawStatus==Change_Status||m_CurrentDrawStatus==Select_Status)
  1207.  ResetSelectStatus();
  1208.  
  1209.  CMainFrame* pMainFrame=(CMainFrame*)AfxGetMainWnd();
  1210. if(pMainFrame->m_wndStyleBar.IsWindowVisible())
  1211.     { 
  1212.  pMainFrame->ShowFontBar(true);
  1213.      if(this->m_LBDownTimes==1)
  1214.  {
  1215.   this->m_LBDownTimes=2;
  1216.   this->m_pCurrentUnit->OnLButtonDown(&dc,this,0);
  1217.   
  1218.  }
  1219. }
  1220.   if(!pMainFrame->m_wndStyleBar.IsWindowVisible())
  1221.   {
  1222.    pMainFrame->ShowFontBar(true);
  1223.    this->m_LBDownTimes=0;
  1224.   }
  1225.   //m_pTextEdit->ShowWindow(true);
  1226.   m_CurrentDrawTool=Text_Tool;
  1227.  m_CurrentDrawStatus=Draw_Status;
  1228.  this->m_LBDownTimes=0;
  1229. }
  1230. void CEastDrawView::GetFontInfo(LPTSTR pszFaceName, int &nSize)
  1231. {
  1232.    /// CHARFORMAT cf = GetCharFormatSelection ();
  1233.     //::lstrcpy (pszFaceName, cf.dwMask & CFM_FACE ? cf.szFaceName : _T (""));
  1234.    // nSize = cf.dwMask & CFM_SIZE ? cf.yHeight : -1;
  1235. }
  1236. void CEastDrawView::OnCharBold() 
  1237. {
  1238. // TODO: Add your command handler code here
  1239. CMainFrame*pMainFrame=(CMainFrame*)::AfxGetMainWnd();
  1240. pMainFrame->m_wndStyleBar.OnCharBold();
  1241.  
  1242. }
  1243. void CEastDrawView::OnCharItalic() 
  1244. {
  1245. // TODO: Add your command handler code here
  1246. CMainFrame*pMainFrame=(CMainFrame*)::AfxGetMainWnd();
  1247. pMainFrame->m_wndStyleBar.OnCharItalic();
  1248. }
  1249. void CEastDrawView::OnCharUnderline() 
  1250. {
  1251. // TODO: Add your command handler code here
  1252. CMainFrame*pMainFrame=(CMainFrame*)::AfxGetMainWnd();
  1253. pMainFrame->m_wndStyleBar.OnCharUnderline();
  1254. }
  1255. void CEastDrawView::OnContextMenu(CWnd* pWnd, CPoint point) 
  1256. {
  1257.       CClientDC dc(this);
  1258.   this->OnPrepareDC(&dc);
  1259.   dc.SetWindowOrg(m_CenterPoint);
  1260.   //dc.DPtoLP(&point);
  1261. // TODO: Add your message handler code here
  1262.       if(m_CurrentDrawStatus!=Select_Status)
  1263.   m_pCurrentUnit->OnContextMenu(pWnd,point);
  1264.   
  1265.      if(m_CurrentDrawStatus==Select_Status)
  1266.  {
  1267.   CMenu menuTextEdit;
  1268.       menuTextEdit.LoadMenu(IDR_MENU_Delete);
  1269.       
  1270.       menuTextEdit.GetSubMenu(0)->TrackPopupMenu(TPM_LEFTALIGN,point.x,point.y,pWnd);
  1271.  
  1272.  }
  1273. }
  1274. void CEastDrawView::OnMenuitemOk() 
  1275. {
  1276. // TODO: Add your command handler code here
  1277.   CClientDC dc(this);
  1278.   OnPrepareDC(&dc);
  1279.   dc.SetWindowOrg(m_CenterPoint);
  1280.   m_pCurrentUnit->OnMenuitemOk(&dc,this);
  1281. }
  1282. BOOL CEastDrawView::OnSetCursor(CWnd* pWnd, UINT nHitTest, UINT message) 
  1283. {
  1284. // TODO: Add your message handler code here and/or call default
  1285. if(m_CurrentDrawStatus==Draw_Status||m_CurrentDrawStatus==Change_Status||m_CurrentDrawStatus==Select_Color_Status)
  1286.  SetCursor(AfxGetApp()->LoadCursor(ID_Draw));
  1287.     
  1288. if(m_CurrentDrawStatus==Drag_Status||m_CurrentDrawStatus==Select_Status)
  1289.      SetCursor(AfxGetApp()->LoadCursor(ID_Change));
  1290. return true;
  1291. //return CScrollView::OnSetCursor(pWnd, nHitTest, message);
  1292. }
  1293. void CEastDrawView::ShowFontBar(BOOL isShow)
  1294. {
  1295. CMainFrame*pMainFrame=(CMainFrame*)::AfxGetMainWnd();
  1296. pMainFrame->ShowFontBar(isShow);
  1297. }
  1298. void CEastDrawView::OnCirCu() 
  1299. {
  1300. // TODO: Add your command handler code here
  1301.       CClientDC dc(this);
  1302.   this->OnPrepareDC(&dc);
  1303.   dc.SetWindowOrg(m_CenterPoint);
  1304.   this->m_pCurrentUnit->OnMenuitemCirCu(&dc,this);
  1305. }
  1306. void CEastDrawView::OnUpdateCirCu(CCmdUI* pCmdUI) 
  1307. {
  1308. // TODO: Add your command update UI handler code here
  1309.   pCmdUI->SetCheck();
  1310. }
  1311. void CEastDrawView::SetMousePosText(CPoint Logpoint,CPoint Devpoint)
  1312. {
  1313. CMainFrame*pMainFrame=(CMainFrame*)::AfxGetMainWnd();
  1314. pMainFrame->SetMousePosText(Logpoint,Devpoint);
  1315. }
  1316. void CEastDrawView::DrawAxis(CDC*pDC)
  1317. {
  1318.   
  1319. CPen pen;
  1320.     pen.CreatePen(PS_SOLID,1,RGB(255,0,0));
  1321. CPen*OldPen=pDC->SelectObject(&pen);
  1322. int oldRop=pDC->SetROP2(R2_NOTXORPEN);
  1323. pDC->MoveTo(m_CenterPoint.x+2,0);
  1324. pDC->LineTo(GetTotalSize().cx+m_CenterPoint.x-2,0);
  1325. pDC->MoveTo(0,m_CenterPoint.y+2);
  1326. pDC->LineTo(0,GetTotalSize().cy+m_CenterPoint.y-2);
  1327. pDC->SelectObject(OldPen);
  1328. pDC->SetROP2(oldRop);
  1329. }
  1330. BOOL CEastDrawView::SaveDIB(CBitmap*pbitmap, CFile&file)
  1331. {
  1332.     CClientDC dc(this);
  1333. OnPrepareDC(&dc);
  1334. dc.SetWindowOrg(m_CenterPoint);
  1335. CDC*pViewDC=&dc;
  1336.     CEastDrawDoc* pDoc = GetDocument();
  1337. ASSERT_VALID(pDoc);
  1338. CBitmap*Oldmap;
  1339.     CBitmap Bitmap;
  1340. CDC memDC;
  1341.     Bitmap.CreateCompatibleBitmap(pViewDC,this->GetTotalSize().cx,this->GetTotalSize().cy);
  1342.     memDC.CreateCompatibleDC(pViewDC);
  1343.     memDC.SetMapMode(pViewDC->GetMapMode());
  1344. Oldmap=memDC.SelectObject(&Bitmap);
  1345. memDC.SetWindowOrg(m_CenterPoint);
  1346. memDC.PatBlt(m_CenterPoint.x,m_CenterPoint.y,GetTotalSize().cx,GetTotalSize().cy,WHITENESS);
  1347. this->DrawAll(&memDC);
  1348.     if(this->m_HaveAxis)
  1349. this->DrawAxis(&memDC);
  1350. ::GdiFlush();
  1351. memDC.SelectObject(Oldmap);
  1352. memDC.DeleteDC();
  1353. BITMAPFILEHEADER bmfHdr; 
  1354.     bmfHdr.bfType=0x4d42;
  1355. int sizeHdr=sizeof(BITMAPINFOHEADER);
  1356.    
  1357.     LPBITMAPINFOHEADER lpBI=( LPBITMAPINFOHEADER)::GlobalAlloc(LMEM_FIXED,sizeHdr);
  1358.   if(!lpBI)
  1359. {
  1360.   AfxMessageBox("内存申请失败,请稍后再试");
  1361. }
  1362. BYTE *pDib;
  1363. BYTE *pDib2;
  1364.     pDib=(BYTE*)::GlobalAlloc(LMEM_FIXED,GetTotalSize().cx*GetTotalSize().cy*4);
  1365.     if(!pDib)
  1366. {
  1367.   AfxMessageBox("内存申请失败,请稍后再试");
  1368. }
  1369. lpBI->biSize=(LONG)sizeof(BITMAPINFOHEADER);
  1370. lpBI->biWidth=(LONG)this->GetTotalSize().cx;
  1371. lpBI->biHeight=(LONG)this->GetTotalSize().cy;
  1372. lpBI->biPlanes=1;
  1373. lpBI->biBitCount=32;
  1374. lpBI->biCompression=BI_RGB;
  1375. lpBI->biSizeImage=0;
  1376. lpBI->biXPelsPerMeter=0;
  1377. lpBI->biYPelsPerMeter=0;
  1378. lpBI->biClrUsed=0;
  1379. lpBI->biClrImportant=0;
  1380.    
  1381.     Bitmap.GetBitmapBits(GetTotalSize().cx*GetTotalSize().cy*4,pDib);
  1382. pDib2=(BYTE*)::GlobalAlloc(LMEM_FIXED,GetTotalSize().cx*GetTotalSize().cy*4);
  1383.   if(!pDib2)
  1384. {
  1385.   AfxMessageBox("内存申请失败,请稍后再试");
  1386. }
  1387. for(int j=0;j<GetTotalSize().cy;j++)
  1388.  for(int i=0;i<GetTotalSize().cx*4;i++)
  1389.  {
  1390.   pDib2[i+j*GetTotalSize().cx*4]=pDib[GetTotalSize().cx*(GetTotalSize().cy-1-j)*4+i];
  1391. }
  1392.  ::GlobalFree(pDib);
  1393.     bmfHdr.bfSize=(DWORD) (sizeof(BITMAPFILEHEADER) + 
  1394.                  sizeHdr +GetTotalSize().cx*GetTotalSize().cy*4); 
  1395. bmfHdr.bfReserved1=bmfHdr.bfReserved2=0;
  1396. bmfHdr.bfOffBits=sizeof(BITMAPFILEHEADER)+sizeHdr;
  1397.   try
  1398.   {
  1399.  
  1400.      file.Write((LPVOID)&bmfHdr,sizeof(BITMAPFILEHEADER));
  1401.  file.Write((LPVOID)lpBI,sizeHdr);
  1402.  file.WriteHuge((LPVOID)pDib2,GetTotalSize().cx*GetTotalSize().cy*4);
  1403.   }
  1404.   catch(CException*Fe)
  1405.   {
  1406.     Fe->ReportError();
  1407. Fe->Delete();
  1408.    return false;
  1409.   }
  1410.   
  1411.  
  1412.   ::GlobalFree(lpBI);
  1413.   ::GlobalFree(pDib2);
  1414.    return true;  
  1415.   
  1416. }
  1417. void CEastDrawView::DeleteSelect()
  1418. {   
  1419. this->ExchangeSave();
  1420. CClientDC dc(this);
  1421. this->OnPrepareDC(&dc);
  1422. dc.SetWindowOrg(m_CenterPoint);
  1423. CDC*pDC=&dc;
  1424. CEastDrawDoc* pDoc = GetDocument();
  1425. ASSERT_VALID(pDoc);
  1426. int oldrop=pDC->SetROP2(R2_NOTXORPEN);   
  1427. for(int i=0;i<pDoc->m_PolygonArray.GetSize();i++)
  1428. {
  1429.   CPolygon*pPolygon=(CPolygon*)pDoc->m_PolygonArray.GetAt(i);
  1430.   if(pPolygon->m_HaveFindFirst)
  1431.   {
  1432. pPolygon->ShowSelectPoint(pDC);
  1433.     pPolygon->DrawStatic(pDC);
  1434. pDoc->m_PolygonArray.RemoveAt(i);
  1435. delete  pPolygon;
  1436. i--;
  1437.   }
  1438.                 
  1439. }
  1440.     for(i=0;i<pDoc->m_TextArray.GetSize();i++)
  1441. {
  1442.   CText*pText=(CText*)pDoc->m_TextArray.GetAt(i);
  1443.   
  1444.     if(pText->m_HaveFindFirst)
  1445. {
  1446.  pText->ShowSelectPoint(pDC);
  1447.          //pText->DrawStatic(pDC);
  1448.  CPoint point=pText->m_PositionPoint;
  1449.  pDC->LPtoDP(&point);
  1450.  this->InvalidateRect(CRect(point,CPoint(point.x+pText->m_Width,point.y+pText->m_Hight)));
  1451.  pDoc->m_TextArray.RemoveAt(i);
  1452.  delete pText;
  1453.              i--;
  1454. }
  1455. }
  1456. for(i=0;i<pDoc->m_PolyBezierArray.GetSize();i++)
  1457. {
  1458.  CPolyBezier*pPolyBezier=(CPolyBezier*)pDoc->m_PolyBezierArray.GetAt(i);
  1459.  
  1460.   if(pPolyBezier->m_HaveFindFirst)
  1461.   {
  1462.   pPolyBezier->ShowSelectPoint(pDC);
  1463.       pPolyBezier->DrawStatic(pDC);
  1464.   pDoc->m_PolyBezierArray.RemoveAt(i);
  1465.   delete pPolyBezier;
  1466.   i--;
  1467.   }
  1468. }
  1469. for(i=0;i<pDoc->m_DLineArray.GetSize();i++)
  1470.    {
  1471. CDLine*pDLine=(CDLine*)pDoc->m_DLineArray.GetAt(i);
  1472.     if(pDLine->m_HaveFindFirst)
  1473. {   pDLine->ShowSelectPoint(pDC);
  1474.     pDLine->DrawStatic(pDC);
  1475.      pDoc->m_DLineArray.RemoveAt(i);
  1476.  delete pDLine;
  1477.      i--;
  1478. }
  1479. }
  1480. for(i=0;i<pDoc->m_CurveArray.GetSize();i++)
  1481. {
  1482.  CCurve*pCurve=(CCurve*)pDoc->m_CurveArray.GetAt(i);
  1483.  
  1484.  if(pCurve->m_HaveFindFirst)
  1485.  {
  1486.  pCurve->ShowSelectPoint(pDC);
  1487.      pCurve->DrawStatic(pDC);
  1488.  pDoc->m_CurveArray.RemoveAt(i);
  1489.  delete pCurve;
  1490.      i--;
  1491.  }
  1492.  }
  1493. for(i=0;i<pDoc->m_RectangleArray.GetSize();i++)
  1494. {
  1495. CRectangle*pRectangle=(CRectangle*)pDoc->m_RectangleArray.GetAt(i);
  1496. if(pRectangle->m_HaveFindFirst)
  1497. {
  1498. pRectangle->ShowSelectPoint(pDC);
  1499.         pRectangle->DrawStatic(pDC);
  1500. pDoc->m_RectangleArray.RemoveAt(i);
  1501. delete pRectangle;
  1502. i--;
  1503. }
  1504. }
  1505.     for(i=0;i<pDoc->m_RoundRectangleArray.GetSize();i++)
  1506. {
  1507. CRoundRectangle*pRoundRectangle=(CRoundRectangle*)pDoc->m_RoundRectangleArray.GetAt(i);
  1508. if(pRoundRectangle->m_HaveFindFirst)
  1509. {
  1510. pRoundRectangle->ShowSelectPoint(pDC);
  1511.    pRoundRectangle->DrawStatic(pDC);
  1512.     pDoc->m_RoundRectangleArray.RemoveAt(i);
  1513. delete pRoundRectangle;
  1514. i--;
  1515. }
  1516. }
  1517.     for(i=0;i<pDoc->m_EllipseArray.GetSize();i++)
  1518. {
  1519. CEllipse*pEllipse=(CEllipse*)pDoc->m_EllipseArray.GetAt(i);
  1520. if(pEllipse->m_HaveFindFirst)
  1521. {   pEllipse->ShowSelectPoint(pDC);
  1522.     pEllipse->DrawStatic(pDC);
  1523.     pDoc->m_EllipseArray.RemoveAt(i);
  1524. delete pEllipse;
  1525. i--;
  1526. }
  1527. }
  1528.     for(i=0;i<pDoc->m_RoundArray.GetSize();i++)
  1529. {
  1530. CRound*pRound=(CRound*)pDoc->m_RoundArray.GetAt(i);
  1531. if(pRound->m_HaveFindFirst)
  1532. {
  1533. pRound->ShowSelectPoint(pDC);
  1534.     pRound->DrawStatic(pDC);
  1535.     pDoc->m_RoundArray.RemoveAt(i);
  1536. delete pRound;
  1537. i--;
  1538. }
  1539. }
  1540.   for(i=0;i<pDoc->m_LiEllipseArray.GetSize();i++)
  1541. {
  1542. CEllipse*pLiEllipse=(CEllipse*)pDoc->m_LiEllipseArray.GetAt(i);
  1543. if(pLiEllipse->m_HaveFindFirst)
  1544. {
  1545. pLiEllipse->ShowSelectPoint(pDC);
  1546.     pLiEllipse->DrawStatic(pDC);
  1547.     pDoc->m_LiEllipseArray.RemoveAt(i);
  1548. delete pLiEllipse;
  1549. i--;
  1550. }
  1551. }
  1552.   for(i=0;i<pDoc->m_RoundArcArray.GetSize();i++)
  1553.   {
  1554.     CRoundArc*pRoundArc=(CRoundArc*)pDoc->m_RoundArcArray.GetAt(i);
  1555. if(pRoundArc->m_HaveFindFirst)
  1556. {
  1557. pRoundArc->ShowSelectPoint(pDC);
  1558.     pRoundArc->DrawStatic(pDC);
  1559.     pDoc->m_RoundArcArray.RemoveAt(i);
  1560. delete pRoundArc;
  1561. i--;
  1562. }
  1563. }
  1564.     
  1565.   for(i=0;i<pDoc->m_EllipseArcArray.GetSize();i++)
  1566.   {
  1567.    CEllipseArc*pEllipseArc=(CEllipseArc*)pDoc->m_EllipseArcArray.GetAt(i);
  1568.    
  1569.    if(pEllipseArc->m_HaveFindFirst)
  1570.    {   pEllipseArc->ShowSelectPoint(pDC);
  1571.        pEllipseArc->DrawStatic(pDC);
  1572.        pDoc->m_EllipseArcArray.RemoveAt(i);
  1573.    delete pEllipseArc;
  1574.    i--;
  1575.    }
  1576.    }
  1577.   pDC->SetROP2(oldrop);
  1578. }
  1579. void CEastDrawView::OnKeyUp(UINT nChar, UINT nRepCnt, UINT nFlags) 
  1580. {
  1581. // TODO: Add your message handler code here and/or call default
  1582. if(nChar==VK_DELETE)
  1583. this->DeleteSelect();
  1584. CScrollView::OnKeyUp(nChar, nRepCnt, nFlags);
  1585. }
  1586. void CEastDrawView::OnDelete() 
  1587. {
  1588. // TODO: Add your command handler code here
  1589. this->DeleteSelect();
  1590. }
  1591. void CEastDrawView::OnBUTTON32830Lock() 
  1592. {
  1593. // TODO: Add your command handler code here
  1594. m_IsLocked=!m_IsLocked;
  1595. }
  1596. void CEastDrawView::OnUpdateBUTTON32830Lock(CCmdUI* pCmdUI) 
  1597. {
  1598. // TODO: Add your command update UI handler code here
  1599. pCmdUI->SetCheck(m_IsLocked?1:0);
  1600. }
  1601. void CEastDrawView::OnUpdateBUTTONDLine(CCmdUI* pCmdUI) 
  1602. {
  1603. // TODO: Add your command update UI handler code here
  1604. pCmdUI->SetCheck(m_CurrentDrawTool==DLine_Tool?1:0);
  1605. }
  1606. void CEastDrawView::OnUpdateBUTTON32776Rectangle(CCmdUI* pCmdUI) 
  1607. {
  1608. // TODO: Add your command update UI handler code here
  1609.   pCmdUI->SetCheck(m_CurrentDrawTool==Rectangle_Tool?1:0);
  1610. }
  1611. void CEastDrawView::OnUpdateBUTTON32778RoundRectangle(CCmdUI* pCmdUI) 
  1612. {
  1613. // TODO: Add your command update UI handler code here
  1614.  pCmdUI->SetCheck(m_CurrentDrawTool==RoundRectangle_Tool?1:0);
  1615. }
  1616. void CEastDrawView::OnUpdateBUTTON32791Polygon(CCmdUI* pCmdUI) 
  1617. {
  1618. // TODO: Add your command update UI handler code here
  1619.  pCmdUI->SetCheck(m_CurrentDrawTool==Polygon_Tool?1:0);
  1620. }
  1621. void CEastDrawView::OnUpdateBUTTON32779Ellipse(CCmdUI* pCmdUI) 
  1622. {
  1623. // TODO: Add your command update UI handler code here
  1624.  pCmdUI->SetCheck(m_CurrentDrawTool==Ellipse_Tool?1:0);
  1625. }
  1626. void CEastDrawView::OnUpdateBUTTON32780Round(CCmdUI* pCmdUI) 
  1627. {
  1628. // TODO: Add your command update UI handler code here
  1629. pCmdUI->SetCheck(m_CurrentDrawTool==Round_Tool?1:0);
  1630. }
  1631. void CEastDrawView::OnUpdateBUTTON32777Curve(CCmdUI* pCmdUI) 
  1632. {
  1633. // TODO: Add your command update UI handler code here
  1634.  pCmdUI->SetCheck(m_CurrentDrawTool==Curve_Tool?1:0);
  1635. }
  1636. void CEastDrawView::OnUpdateBUTTONLiEllipse(CCmdUI* pCmdUI) 
  1637. {
  1638. // TODO: Add your command update UI handler code here
  1639.  pCmdUI->SetCheck(m_CurrentDrawTool==LiEllipse_Tool?1:0);
  1640. }
  1641. void CEastDrawView::OnUpdateBUTTON32800RoundArc(CCmdUI* pCmdUI) 
  1642. {
  1643. // TODO: Add your command update UI handler code here
  1644. pCmdUI->SetCheck(m_CurrentDrawTool==RoundArc_Tool?1:0);
  1645. }
  1646. void CEastDrawView::OnUpdateBUTTON32805EllipseArc(CCmdUI* pCmdUI) 
  1647. {
  1648. // TODO: Add your command update UI handler code here
  1649.   pCmdUI->SetCheck(m_CurrentDrawTool==EllipseArc_Tool?1:0);
  1650. }
  1651. void CEastDrawView::OnUpdateBUTTON32807PolyBezier(CCmdUI* pCmdUI) 
  1652. {
  1653. // TODO: Add your command update UI handler code here
  1654.   pCmdUI->SetCheck(m_CurrentDrawTool==PolyBezier_Tool?1:0);
  1655. }
  1656. void CEastDrawView::OnUpdateBUTTON32809Text(CCmdUI* pCmdUI) 
  1657. {
  1658. // TODO: Add your command update UI handler code here
  1659.  pCmdUI->SetCheck(m_CurrentDrawTool==Text_Tool?1:0);
  1660. }
  1661. void CEastDrawView::OnUpdateBUTTON32774Move(CCmdUI* pCmdUI) 
  1662. {
  1663. // TODO: Add your command update UI handler code here
  1664. pCmdUI->SetCheck(m_CurrentDrawStatus!=Draw_Status&&m_CurrentDrawStatus!=0?1:0);
  1665. }
  1666. void CEastDrawView::OnBUTTON32845Axis() 
  1667. {
  1668. // TODO: Add your command handler code here
  1669.      CClientDC dc(this);
  1670.  OnPrepareDC(&dc);
  1671.  dc.SetWindowOrg(m_CenterPoint);
  1672.  DrawAxis(&dc);
  1673.  m_HaveAxis=!m_HaveAxis;
  1674. }
  1675. void CEastDrawView::OnUpdateBUTTON32845Axis(CCmdUI* pCmdUI) 
  1676. {
  1677. // TODO: Add your command update UI handler code here
  1678. pCmdUI->SetCheck(m_HaveAxis?1:0);
  1679. }
  1680. void CEastDrawView::OnBUTTON32850ReDraw() 
  1681. {
  1682. // TODO: Add your command handler code here
  1683.     CEastDrawDoc* pDoc = GetDocument();
  1684. ASSERT_VALID(pDoc);
  1685. CClientDC dc(this);
  1686. this->OnPrepareDC(&dc);
  1687. dc.SetWindowOrg(m_CenterPoint);
  1688.     
  1689. CBitmap*Oldmap;
  1690.     CBitmap Bitmap;
  1691. CDC memDC;
  1692.     Bitmap.CreateCompatibleBitmap(&dc,this->GetTotalSize().cx,this->GetTotalSize().cy);
  1693.     memDC.CreateCompatibleDC(&dc);
  1694.     Oldmap=memDC.SelectObject(&Bitmap);
  1695. memDC.SetWindowOrg(m_CenterPoint);
  1696. CRect client;
  1697.     CBrush br(RGB(255,0,255));
  1698. GetClientRect(client);
  1699. dc.DPtoLP(&client);
  1700.     memDC.SetMapMode(dc.GetMapMode());
  1701. memDC.PatBlt(client.left,client.top,client.Width(),client.Height(),WHITENESS);
  1702. this->DrawAll(&memDC);
  1703. if(this->m_HaveAxis)
  1704. this->DrawAxis(&memDC);
  1705. dc.BitBlt(client.left,client.top,client.Width(),client.Height(),&memDC,client.left,client.top,SRCCOPY);
  1706.     memDC.DeleteDC();
  1707.    }
  1708. void CEastDrawView::DrawAll(CDC *pDrawDC)
  1709. {
  1710.     CEastDrawDoc* pDoc = GetDocument();
  1711. ASSERT_VALID(pDoc);
  1712.     CDC*pDC=pDrawDC;
  1713.     
  1714. for(int i=0;i<pDoc->m_PolygonArray.GetSize();i++)
  1715. {
  1716.   CPolygon*pPolygon=(CPolygon*)pDoc->m_PolygonArray.GetAt(i);
  1717.   pPolygon->DrawStatic(pDC);
  1718.   if(pPolygon->m_HaveFindFirst)
  1719.  pPolygon->ShowSelectPoint(pDC);
  1720. }
  1721.     
  1722. for(i=0;i<pDoc->m_PolyBezierArray.GetSize();i++)
  1723. {
  1724.  CPolyBezier*pPolyBezier=(CPolyBezier*)pDoc->m_PolyBezierArray.GetAt(i);
  1725.  pPolyBezier->DrawStatic(pDC);
  1726.   if(pPolyBezier->m_HaveFindFirst)
  1727.   pPolyBezier->ShowSelectPoint(pDC);
  1728. }
  1729. for(i=0;i<pDoc->m_DLineArray.GetSize();i++)
  1730.    {
  1731. CDLine*pDLine=(CDLine*)pDoc->m_DLineArray.GetAt(i);
  1732. pDLine->DrawStatic(pDC);
  1733.     if(pDLine->m_HaveFindFirst)
  1734. pDLine->ShowSelectPoint(pDC);
  1735.    }
  1736. for(i=0;i<pDoc->m_CurveArray.GetSize();i++)
  1737. {
  1738.  CCurve*pCurve=(CCurve*)pDoc->m_CurveArray.GetAt(i);
  1739.  pCurve->DrawStatic(pDC);
  1740.  if(pCurve->m_HaveFindFirst)
  1741.  pCurve->ShowSelectPoint(pDC);
  1742. }
  1743. for(i=0;i<pDoc->m_RectangleArray.GetSize();i++)
  1744. {
  1745. CRectangle*pRectangle=(CRectangle*)pDoc->m_RectangleArray.GetAt(i);
  1746. pRectangle->DrawStatic(pDC);
  1747. if(pRectangle->m_HaveFindFirst)
  1748. pRectangle->ShowSelectPoint(pDC);
  1749. }
  1750.     for(i=0;i<pDoc->m_RoundRectangleArray.GetSize();i++)
  1751. {
  1752. CRoundRectangle*pRoundRectangle=(CRoundRectangle*)pDoc->m_RoundRectangleArray.GetAt(i);
  1753. pRoundRectangle->DrawStatic(pDC);
  1754. if(pRoundRectangle->m_HaveFindFirst)
  1755. pRoundRectangle->ShowSelectPoint(pDC);
  1756. }
  1757.     for(i=0;i<pDoc->m_EllipseArray.GetSize();i++)
  1758. {
  1759. CEllipse*pEllipse=(CEllipse*)pDoc->m_EllipseArray.GetAt(i);
  1760. pEllipse->DrawStatic(pDC);
  1761. if(pEllipse->m_HaveFindFirst)
  1762. pEllipse->ShowSelectPoint(pDC);
  1763. }
  1764.     for(i=0;i<pDoc->m_RoundArray.GetSize();i++)
  1765. {
  1766. CRound*pRound=(CRound*)pDoc->m_RoundArray.GetAt(i);
  1767. pRound->DrawStatic(pDC);
  1768. if(pRound->m_HaveFindFirst)
  1769. pRound->ShowSelectPoint(pDC);
  1770. }
  1771.   for(i=0;i<pDoc->m_LiEllipseArray.GetSize();i++)
  1772. {
  1773. CEllipse*pLiEllipse=(CEllipse*)pDoc->m_LiEllipseArray.GetAt(i);
  1774. pLiEllipse->DrawStatic(pDC);
  1775. if(pLiEllipse->m_HaveFindFirst)
  1776. pLiEllipse->ShowSelectPoint(pDC);
  1777.   }
  1778.   for(i=0;i<pDoc->m_RoundArcArray.GetSize();i++)
  1779.   {
  1780.     CRoundArc*pRoundArc=(CRoundArc*)pDoc->m_RoundArcArray.GetAt(i);
  1781. pRoundArc->DrawStatic(pDC);
  1782. if(pRoundArc->m_HaveFindFirst)
  1783. pRoundArc->ShowSelectPoint(pDC);
  1784.   }
  1785.     
  1786.   for(i=0;i<pDoc->m_EllipseArcArray.GetSize();i++)
  1787.   {
  1788.    CEllipseArc*pEllipseArc=(CEllipseArc*)pDoc->m_EllipseArcArray.GetAt(i);
  1789.    pEllipseArc->DrawStatic(pDC);
  1790.    if(pEllipseArc->m_HaveFindFirst)
  1791.    pEllipseArc->ShowSelectPoint(pDC);
  1792.   }
  1793.   for(i=0;i<pDoc->m_TextArray.GetSize();i++)
  1794.   {
  1795.    CText*pText=(CText*)pDoc->m_TextArray.GetAt(i);
  1796.    pText->DrawStatic(pDC);
  1797.     if(pText->m_HaveFindFirst)
  1798.    pText->ShowSelectPoint(pDC);
  1799.   }
  1800.   
  1801.  // TODO: add draw code for native data here
  1802. }
  1803. void CEastDrawView::OnBUTTON32856DONothing() 
  1804. {
  1805. // TODO: Add your command handler code here
  1806.     CClientDC dc(this);
  1807. OnPrepareDC(&dc);
  1808. dc.SetWindowOrg(m_CenterPoint);
  1809. // TODO: Add your command handler code here
  1810.    
  1811. if(m_CurrentDrawStatus==Drag_Status||m_CurrentDrawStatus==Change_Status||m_CurrentDrawStatus==Select_Status)
  1812.     ResetSelectStatus();
  1813.     
  1814.     
  1815. CMainFrame* pMainFrame=(CMainFrame*)AfxGetMainWnd();
  1816. if(pMainFrame->m_wndStyleBar.IsWindowVisible())
  1817.     { 
  1818.  pMainFrame->ShowFontBar(false);
  1819.      if(this->m_LBDownTimes==1)
  1820.  {
  1821.   this->m_LBDownTimes=2;
  1822.   this->m_pCurrentUnit->OnLButtonDown(&dc,this,0);
  1823.   
  1824.  }
  1825. }
  1826. m_CurrentDrawTool=0;
  1827. m_CurrentDrawStatus=0;
  1828. m_LBDownTimes=0;
  1829. }
  1830. void CEastDrawView::AddTempFile()
  1831. CEastDrawDoc* pDoc = GetDocument();
  1832. ASSERT_VALID(pDoc);
  1833. pDoc->AddTempFile();
  1834. }
  1835. void CEastDrawView::AutoSave()
  1836. {
  1837.     CEastDrawDoc* pDoc = GetDocument();
  1838. ASSERT_VALID(pDoc);
  1839. pDoc->AutoSave();
  1840. }
  1841. void CEastDrawView::ExchangeSave()
  1842. {
  1843.     CEastDrawDoc* pDoc = GetDocument();
  1844. ASSERT_VALID(pDoc);
  1845. pDoc->SetModifiedFlag();
  1846.    if(m_IsLastMove)
  1847. {   
  1848.     pDoc->Requeue(m_Index,m_Rtimes);
  1849. m_IsLastMove=false;
  1850.     m_Index=0;
  1851.    }
  1852.    else
  1853.    {
  1854.   m_Index=0;
  1855.       if(m_Rtimes<6)
  1856.         m_Rtimes++;
  1857.    }
  1858.    pDoc->ExchangeSave(m_Index,m_Rtimes);
  1859.    
  1860.   
  1861.    
  1862. }
  1863. void CEastDrawView::OnBUTTON32858OnDo() 
  1864. {
  1865. // TODO: Add your command handler code here
  1866.     CEastDrawDoc* pDoc = GetDocument();
  1867. ASSERT_VALID(pDoc);
  1868.    if(m_Index<5)
  1869.    {
  1870.    m_Index++;
  1871.  
  1872.         this->m_IsLastMove=true;
  1873. pDoc->OnBUTTON32858OnDo(m_Index);
  1874.         OnBUTTON32850ReDraw();
  1875.    }     
  1876. }
  1877. void CEastDrawView::OnBUTTON32859ReDo() 
  1878. {
  1879. // TODO: Add your command handler code here
  1880.     CEastDrawDoc* pDoc = GetDocument();
  1881. ASSERT_VALID(pDoc);
  1882.          if(m_Index>0)
  1883.  {  
  1884.      m_Index--;
  1885.      pDoc->OnBUTTON32858OnDo(m_Index);
  1886.          m_IsLastMove=true;
  1887.      OnBUTTON32850ReDraw();
  1888.  }
  1889. }
  1890. void CEastDrawView::OnUpdateBUTTON32858OnDo(CCmdUI* pCmdUI) 
  1891. {
  1892. // TODO: Add your command update UI handler code here
  1893. pCmdUI->Enable(m_Index<5&&m_Index<m_Rtimes&&m_Rtimes!=0?true:false);
  1894. }
  1895. void CEastDrawView::OnUpdateBUTTON32859ReDo(CCmdUI* pCmdUI) 
  1896. {
  1897. // TODO: Add your command update UI handler code here
  1898. pCmdUI->Enable(m_Index>0&&m_Rtimes!=0?true:false);
  1899. }
  1900. void CEastDrawView::ReMoveTemp()
  1901. {
  1902.     CEastDrawDoc* pDoc = GetDocument();
  1903. ASSERT_VALID(pDoc);
  1904. pDoc->ReMoveTemp();
  1905. }
  1906. void CEastDrawView::OnPrint(CDC* pDC, CPrintInfo* pInfo) 
  1907. {
  1908. // TODO: Add your specialized code here and/or call the base class
  1909. CClientDC dc(this);
  1910.     int nHorzSC = dc.GetDeviceCaps(LOGPIXELSX);
  1911.     int nHorzPR = pDC->GetDeviceCaps(LOGPIXELSX);
  1912. int PhyToDis=nHorzPR/nHorzSC;
  1913. pDC->SetMapMode(MM_ANISOTROPIC);
  1914.     
  1915. pDC->SetWindowExt(GetTotalSize());
  1916. pDC->SetViewportExt(GetTotalSize().cx*PhyToDis,GetTotalSize().cy*PhyToDis);
  1917.     pDC->SetWindowOrg(m_CenterPoint.x,m_CenterPoint.y);
  1918. this->DrawAll(pDC);
  1919. if(this->m_HaveAxis)
  1920. this->DrawAxis(pDC);
  1921. }
  1922. BOOL CEastDrawView::OnPreparePrinting(CPrintInfo* pInfo) 
  1923. {
  1924. // TODO: call DoPreparePrinting to invoke the Print dialog box
  1925. return DoPreparePrinting(pInfo);
  1926. }
  1927. void CEastDrawView::SetBoxFont()
  1928. {
  1929. CMainFrame*pMainFrame=STATIC_DOWNCAST(CMainFrame, AfxGetMainWnd());
  1930. pMainFrame->m_wndStyleBar.IniFont();
  1931. }
  1932. void CEastDrawView::OnMouseCapOn() 
  1933. {
  1934. // TODO: Add your command handler code here
  1935. m_IsMouseCap=!m_IsMouseCap;
  1936. }
  1937. void CEastDrawView::OnUpdateMouseCapOn(CCmdUI* pCmdUI) 
  1938. {
  1939. // TODO: Add your command update UI handler code here
  1940. pCmdUI->SetCheck(m_IsMouseCap?1:0);
  1941. }
  1942. void CEastDrawView::OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags) 
  1943. {
  1944. // TODO: Add your message handler code here and/or call default
  1945. CSize size=this->GetTotalSize();
  1946. CRect rect;
  1947. this->GetClientRect(&rect);
  1948. switch(nChar)
  1949. {
  1950. case VK_UP:
  1951. if(rect.bottom<size.cy)
  1952. ScrollToPosition(CPoint(GetDeviceScrollPosition().x,GetDeviceScrollPosition().y-rect.Height()/2));
  1953.     break;
  1954. case VK_DOWN:
  1955. if(rect.bottom<size.cy)
  1956. ScrollToPosition(CPoint(GetDeviceScrollPosition().x,GetDeviceScrollPosition().y+rect.Height()/2));
  1957.     break;
  1958. case VK_LEFT:
  1959.       ScrollToPosition(CPoint(GetDeviceScrollPosition().x-rect.Width()/2,GetDeviceScrollPosition().y));
  1960.     break;
  1961.     case VK_RIGHT:
  1962.       ScrollToPosition(CPoint(GetDeviceScrollPosition().x+rect.Width()/2,GetDeviceScrollPosition().y));
  1963.     break;
  1964.     case VK_HOME:
  1965. ScrollToPosition(CPoint(0,0));
  1966.     break;
  1967. }
  1968. CScrollView::OnKeyDown(nChar, nRepCnt, nFlags);
  1969. }