/// <summary> /// Overriden to create the elliptical grid template in the specified document /// </summary> /// <param name="document">document in which to create the template</param> protected override void CreateTemplate(NDrawingDocument document) { int i; NShape node; NShape edge = null; NPoint pt; NList <NShape> nodes = new NList <NShape>(); NPage page = document.Content.ActivePage; // create the ellipse nodes double curAngle = 0; double stepAngle = NMath.PI2 / m_nRimNodesCount; NPoint center = new NPoint(m_Origin.X + m_dRadiusX + m_VerticesSize.Width / 2, m_Origin.Y + m_dRadiusY + m_VerticesSize.Height / 2); for (i = 0; i < m_nRimNodesCount; i++) { pt = new NPoint(center.X + m_dRadiusX * (double)Math.Cos(curAngle) - m_VerticesSize.Width / 2, center.Y + m_dRadiusY * (double)Math.Sin(curAngle) - m_VerticesSize.Height / 2); node = CreateVertex(m_VerticesShape); node.SetBounds(new NRectangle(pt, m_VerticesSize)); page.Items.AddChild(node); nodes.Add(node); curAngle += stepAngle; } // connect the ellipse nodes if (m_bConnectGrid) { for (i = 0; i < m_nRimNodesCount; i++) { edge = CreateEdge(ENConnectorShape.Line); page.Items.AddChild(edge); edge.GlueBeginToGeometryIntersection(nodes[i]); edge.GlueEndToGeometryIntersection(nodes[(i + 1) % m_nRimNodesCount]); } } if (m_bHasCenter == false) { return; } // create the center node = CreateVertex(m_VerticesShape); pt = new NPoint(center.X - m_VerticesSize.Width / 2, center.Y - m_VerticesSize.Height / 2); node.SetBounds(new NRectangle(pt, m_VerticesSize)); page.Items.AddChild(node); // connect the ellipse nodes with the center if (m_bConnectGrid) { for (i = 0; i < m_nRimNodesCount; i++) { edge = CreateEdge(ENConnectorShape.Line); page.Items.AddChild(edge); edge.GlueBeginToGeometryIntersection(node); edge.GlueEndToGeometryIntersection(nodes[i]); } } }