Ejemplo n.º 1
0
        /*
         * 名称:添加顶点信息
         * 摘要:
         *   1、向正在绘制的图形添加一个顶点;
         *   2、若顶点数量达到图形所允许的最大值,则自动完成绘制
         */
        public eCustomGraphStatus AddVertex(int _x, int _y)
        {
            lock (mLockObject)
            {
                if (eCustomGraphStatus.BeDrawing == m_status)
                {
                    if (!m_bModifyInfo)
                    {
                        m_graphVertex.Add(new strCustomPoint(_x, _y));
                        int vertexCount = m_graphVertex.Count;
                        switch (m_drawType)
                        {
                        case eCustomGraphDrawType.Line:
                        case eCustomGraphDrawType.DirectLine:
                            if (2 == vertexCount)
                            {
                                m_status = eCustomGraphStatus.BeComplete;
                            }
                            break;

                        case eCustomGraphDrawType.Rectangle:
                            if (2 == vertexCount)
                            {
                                int x = m_graphVertex[0].X <= m_graphVertex[1].X ? m_graphVertex[0].X : m_graphVertex[1].X;
                                int y = m_graphVertex[0].Y <= m_graphVertex[1].Y ? m_graphVertex[0].Y : m_graphVertex[1].Y;
                                int w = m_graphVertex[0].X + m_graphVertex[1].X - 2 * x;
                                int h = m_graphVertex[0].Y + m_graphVertex[1].Y - 2 * y;
                                m_graphVertex[0] = new strCustomPoint(x, y);
                                m_graphVertex[1] = new strCustomPoint(w, h);
                                m_status         = eCustomGraphStatus.BeComplete;
                            }
                            break;

                        case eCustomGraphDrawType.DoubleLine:
                        case eCustomGraphDrawType.Quadrangle:
                            if (4 == vertexCount)
                            {
                                m_status = eCustomGraphStatus.BeComplete;
                            }
                            break;

                        case eCustomGraphDrawType.Polygon:
                            if (CustomGraphMacro.MaxVertexNum == vertexCount)
                            {
                                m_status = eCustomGraphStatus.BeComplete;
                            }
                            break;

                        default:
                            break;
                        }
                        if (eCustomGraphStatus.BeComplete == m_status)
                        {
                            calculateGraphBorder();
                        }
                    }
                }
                return(m_status);
            }
        }
Ejemplo n.º 2
0
 /*
  * 名称:移动图形
  * 摘要:
  *   1、该函数对所有图形有效;
  *   2、请注意矩形的存储格式(x,y)(w,h),只需移动(x,y)即可;
  */
 private bool moveGraph(Int32 _xInfo, Int32 _yInfo)
 {
     if (eCustomGraphDrawType.Rectangle == m_drawType)
     {
         m_graphVertex[0] = new strCustomPoint(m_graphVertex[0].X + _xInfo, m_graphVertex[0].Y + _yInfo);
     }
     else
     {
         int vertexNum = m_graphVertex.Count;
         for (int i = 0; i < vertexNum; i++)
         {
             m_graphVertex[i] = new strCustomPoint(m_graphVertex[i].X + _xInfo, m_graphVertex[i].Y + _yInfo);
         }
     }
     return(true);
 }
Ejemplo n.º 3
0
        /*
         * 名称:修改图形指定顶点坐标
         * 摘要:
         *   1、该函数对所有类型的图形有效;
         *   2、修改矩形顶点时,请注意矩形存储的格式(x,y)(w,h)
         */
        private bool modifyGraphVertex(Int32 _xInfo, Int32 _yInfo)
        {
            if (eCustomGraphDrawType.Rectangle == m_drawType)
            {
                int[] xAng = new int[4];
                int[] yAng = new int[4];
                xAng[0] = m_graphVertex[0].X;
                yAng[0] = m_graphVertex[0].Y;
                xAng[1] = m_graphVertex[0].X + m_graphVertex[1].X;
                yAng[1] = m_graphVertex[0].Y;
                xAng[2] = m_graphVertex[0].X + m_graphVertex[1].X;
                yAng[2] = m_graphVertex[0].Y + m_graphVertex[1].Y;
                xAng[3] = m_graphVertex[0].X;
                yAng[3] = m_graphVertex[0].Y + m_graphVertex[1].Y;

                int orgId = m_modifyId + 2;
                if (orgId >= 4)
                {
                    orgId -= 4;
                }
                int orgX = xAng[orgId];
                int orgY = yAng[orgId];
                int x    = orgX <= _xInfo ? orgX : _xInfo;
                int y    = orgY <= _yInfo ? orgY : _yInfo;
                int w    = orgX + _xInfo - 2 * x;
                int h    = orgY + _yInfo - 2 * y;
                m_graphVertex[0] = new strCustomPoint(x, y);
                m_graphVertex[1] = new strCustomPoint(w, h);
                return(true);
            }
            else
            {
                if (m_modifyId >= 0 && m_modifyId < m_graphVertex.Count)
                {
                    m_graphVertex[m_modifyId] = new strCustomPoint(_xInfo, _yInfo);
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
        }