NewDialogTrigon.cpp
资源名称:CAD2006.rar [点击查看]
上传用户:ckg1000
上传日期:2013-01-26
资源大小:630k
文件大小:7k
源码类别:
CAD
开发平台:
Visual C++
- // NewDialogTrigon.cpp : implementation file
- //
- #include "stdafx.h"
- #include "CAD2006.h"
- #include "NewDialogTrigon.h"
- #include "Polygon.h"
- #include "line1.h"
- #ifdef _DEBUG
- #define new DEBUG_NEW
- #undef THIS_FILE
- static char THIS_FILE[] = __FILE__;
- #endif
- #include "NewDialogBar.h"
- #include "MainFrm.h"
- #include "CAD2006Doc.h"
- extern enum SHAPE;
- /////////////////////////////////////////////////////////////////////////////
- // NewDialogTrigon dialog
- NewDialogTrigon::NewDialogTrigon(CWnd* pParent /*=NULL*/)
- {
- //{{AFX_DATA_INIT(NewDialogTrigon)
- m_anglevalue = _T("");
- //}}AFX_DATA_INIT
- }
- void NewDialogTrigon::DoDataExchange(CDataExchange* pDX)
- {
- CDialogBar::DoDataExchange(pDX);
- DDX_Control(pDX, IDC_COMBO_SHAPE, m_ComShape);
- DDX_Control(pDX, IDC_COMBO_MODE, m_ComMode);
- DDX_Control(pDX, IDC_COMBO_SIZE, m_ComSize);
- DDX_Control(pDX, IDC_COMBO_COLOR, m_ComCol);
- //{{AFX_DATA_MAP(NewDialogTrigon)
- DDX_Text(pDX, IDC_EDIT_ANGLE, m_anglevalue);
- //}}AFX_DATA_MAP
- }
- BEGIN_MESSAGE_MAP(NewDialogTrigon, CDialogBar)
- //{{AFX_MSG_MAP(NewDialogTrigon)
- ON_CBN_SELCHANGE(IDC_COMBO_SHAPE, OnSelchangeComboShape)
- ON_CBN_SELCHANGE(IDC_COMBO_MODE, OnSelchangeComboMode)
- ON_CBN_SELCHANGE(IDC_COMBO_SIZE, OnSelchangeComboSize)
- ON_CBN_SELCHANGE(IDC_COMBO_COLOR, OnSelchangeComboColor)
- ON_EN_CHANGE(IDC_EDIT_ANGLE, OnChangeEditAngle)
- //}}AFX_MSG_MAP
- END_MESSAGE_MAP()
- /////////////////////////////////////////////////////////////////////////////
- // NewDialogTrigon message handlers
- void NewDialogTrigon::InitDialogBar()
- {
- UpdateData(false);
- m_ComShape.AddString("直线");
- m_ComShape.AddString("折线");
- m_ComShape.AddString("角度线");
- m_ComShape.SetCurSel(2);
- m_ComMode.AddString("虚线");
- m_ComMode.AddString("实线");
- m_ComMode.AddString("点线");
- m_ComMode.AddString("交互线");
- m_ComMode.SetCurSel(2);
- CString strTemp;
- for( int i = 1; i < 8; i++ )
- {
- strTemp.Format("%d",i);
- m_ComSize.AddString(strTemp);
- }
- m_ComSize.SetCurSel(0);
- m_ComCol.AddString("黑色");
- m_ComCol.AddString("红色");
- m_ComCol.AddString("黄色");
- m_ComCol.AddString("自定义颜色");
- m_ComCol.SetCurSel(0);
- }
- void NewDialogTrigon::OnSelchangeComboShape() //m_ComShape selected
- {
- // TODO: Add your control notification handler code here
- CButton *m_angle = (CButton *)GetDlgItem(IDC_EDIT_ANGLE);
- CMainFrame* MainFrame = (CMainFrame *)::AfxGetApp()->m_pMainWnd;
- CCAD2006Doc* pDoc = ( CCAD2006Doc* )MainFrame->GetActiveDocument();
- CString m_tool;
- m_ComShape.GetLBText(m_ComShape.GetCurSel(),m_tool);
- if( m_tool == "直线" )
- {
- pDoc->m_shape = line;
- m_angle->EnableWindow(false);
- }
- if( m_tool == "折线" )
- {
- pDoc->m_shape = linedown;
- m_angle->EnableWindow(false);
- }
- if( m_tool == "角度线" )
- {
- pDoc->m_shape = lineangle;
- m_angle->EnableWindow(true);
- }
- if( m_tool == "三角形" )
- {
- pDoc->m_shape = trigon;
- m_angle->EnableWindow(false);
- }
- if( m_tool == "圆" )
- {
- pDoc->m_shape = circle;
- m_angle->EnableWindow(false);
- }
- if( m_tool == "椭圆" )
- {
- pDoc->m_shape = ellipse;
- m_angle->EnableWindow(false);
- }
- if( m_tool == "圆弧" )
- {
- pDoc->m_shape = circlemater;
- m_angle->EnableWindow(false);
- }
- if( m_tool == "正方形" )
- {
- pDoc->m_shape = rect;
- m_angle->EnableWindow(false);
- }
- if( m_tool == "多边形" )
- {
- pDoc->m_shape = polygon;
- m_angle->EnableWindow(true);
- }
- if( m_tool == "字体" )
- {
- pDoc->m_shape = font;
- m_angle->EnableWindow(false);
- }
- }
- void NewDialogTrigon::OnSelchangeComboMode() //m_ComMode selected
- {
- // TODO: Add your control notification handler code here
- CMainFrame* MainFrame = (CMainFrame *)::AfxGetApp()->m_pMainWnd;
- CCAD2006Doc* pDoc = ( CCAD2006Doc* )MainFrame->GetActiveDocument();
- CString m_style;
- m_ComMode.GetLBText(m_ComMode.GetCurSel(),m_style);
- if( m_style == "实线" )
- {
- MainFrame->m_style = realline;
- m_shape.SetBorderStyle(PS_SOLID);
- }
- if( m_style == "虚线" )
- {
- MainFrame->m_style = brokenline;
- m_shape.SetBorderStyle(PS_DASH);
- }
- if( m_style == "点线" )
- {
- MainFrame->m_style = dotline;
- m_shape.SetBorderStyle(PS_DOT);
- }
- if( m_style == "交互线" )
- {
- MainFrame->m_style = twoline;
- m_shape.SetBorderStyle(PS_DASHDOT);
- }
- }
- void NewDialogTrigon::OnSelchangeComboSize() //m_ComSize selected
- {
- // TODO: Add your control notification handler code here
- CMainFrame* MainFrame = (CMainFrame *)::AfxGetApp()->m_pMainWnd;
- CString m_size;
- m_ComSize.GetLBText(m_ComSize.GetCurSel(),m_size);
- if( m_size == "1" )
- {
- MainFrame->m_linewidth = one;
- }
- if( m_size == "2" )
- {
- MainFrame->m_linewidth = two;
- }
- if( m_size == "3" )
- {
- MainFrame->m_linewidth = three;
- }
- if( m_size == "4" )
- {
- MainFrame->m_linewidth = four;
- }
- if( m_size == "5" )
- {
- MainFrame->m_linewidth = five;
- }
- if( m_size == "6" )
- {
- MainFrame->m_linewidth = six;
- }
- if( m_size == "7" )
- {
- MainFrame->m_linewidth = seven;
- }
- m_shape.SetBorderWidth(atoi(m_size.operator LPCTSTR()));
- }
- void NewDialogTrigon::OnSelchangeComboColor() //m_ComColor selected
- {
- // TODO: Add your control notification handler code here
- CMainFrame* MainFrame = (CMainFrame *)::AfxGetApp()->m_pMainWnd;
- CLabelControl *m_forcol = (CLabelControl *)MainFrame->m_wndDialogBar.GetDlgItem(IDC_LABEL_FORBK);
- switch( m_ComCol.GetCurSel() )
- {
- case 0:
- {
- m_forcol->SetBackColor(RGB(0,0,0));
- break;
- }
- case 1:
- {
- m_forcol->SetBackColor(RGB(255,0,0));
- break;
- }
- case 2:
- {
- m_forcol->SetBackColor(RGB(255,255,0));
- break;
- }
- case 3:
- {
- CColorDialog m_fordlg;
- if( m_fordlg.DoModal() == IDOK )
- {
- m_forcol->SetBackColor(m_fordlg.GetColor());
- }
- break;
- }
- }
- }
- void NewDialogTrigon::OnChangeEditAngle()
- {
- CMainFrame* MainFrame = (CMainFrame *)::AfxGetApp()->m_pMainWnd;
- CCAD2006Doc* pDoc = ( CCAD2006Doc* )MainFrame->GetActiveDocument();
- UpdateData(true);
- int temp = atoi(m_anglevalue.operator LPCTSTR());
- /* switch( pDoc->m_shape )
- {
- case polygon:
- {
- CPolygon polygon;
- polygon.SetSide(temp);
- break;
- }
- }*/
- if( pDoc->m_shape == polygon && pDoc->m_tool == tool )
- {
- CPolygon polygon;
- polygon.SetSide(temp);
- }
- if( pDoc->m_tool == eddy )
- {
- switch( pDoc->m_shape )
- {
- case polygon:
- {
- CPolygon polygon;
- polygon.SetAngle(temp);
- break;
- }
- case trigon:
- {
- CTrigon trigon;
- trigon.SetAngle(temp);
- break;
- }
- case line:
- {
- CLine line;
- line.SetAngle(temp);
- break;
- }
- }
- }
- // TODO: Add your control notification handler code here
- }