static NCalendarExample() { NCalendarExampleSchema = NSchema.Create(typeof(NCalendarExample), NExampleBase.NExampleBaseSchema); // Fill the list of cultures string[] cultureNames = new string[] { "en-US", "en-GB", "fr-FR", "de-DE", "es-ES", "ru-RU", "zh-CN", "ja-JP", "it-IT", "hi-IN", "ar-AE", "he-IL", "id-ID", "ko-KR", "pt-BR", "sv-SE", "tr-TR", "pt-BR", "bg-BG", "ro-RO", "pl-PL", "nl-NL", "cs-CZ" }; Cultures = new NList <CultureInfo>(); for (int i = 0, count = cultureNames.Length; i < count; i++) { CultureInfo cultureInfo; try { cultureInfo = new CultureInfo(cultureNames[i]); } catch { cultureInfo = null; } if (cultureInfo != null && Cultures.Contains(cultureInfo) == false) { Cultures.Add(cultureInfo); } } // Sort the cultures by their English name Cultures.Sort(new NCultureNameComparer()); }
/// <summary> /// Overriden to create a random graph template in the specified document. /// </summary> /// <param name="document">The document to create a graph in.</param> protected override void CreateTemplate(NDrawingDocument document) { if (m_nEdgeCount < m_nVertexCount - 1) { throw new Exception("##The number of edges must be greater than or equal to the (number of vertices - 1) in order to generate a connected graph"); } if (m_nEdgeCount > MaxEdgeCount(m_nVertexCount)) { throw new Exception("##Too many edges wanted for the graph"); } int i; Random random = new Random(); NPage activePage = document.Content.ActivePage; NShape[] vertices = new NShape[m_nVertexCount]; NList <NPointI> edges = GetRandomMST(m_nVertexCount); NPointI edgeInfo; NSizeI minSize = m_MinVerticesSize.Round(); NSizeI maxSize = m_MaxVerticesSize.Round(); maxSize.Width++; maxSize.Height++; // Create the vertices for (i = 0; i < m_nVertexCount; i++) { vertices[i] = CreateVertex(m_VerticesShape); double width = random.Next(minSize.Width, maxSize.Width); double height = random.Next(minSize.Height, maxSize.Height); vertices[i].SetBounds(new NRectangle(0, 0, width, height)); activePage.Items.AddChild(vertices[i]); } // Generate the edges for (i = m_nVertexCount - 1; i < m_nEdgeCount; i++) { do { // Generate a new edge edgeInfo = new NPointI(random.Next(m_nVertexCount), random.Next(m_nVertexCount)); }while (edgeInfo.X == edgeInfo.Y || edges.Contains(edgeInfo) || edges.Contains(new NPointI(edgeInfo.Y, edgeInfo.X))); edges.Add(edgeInfo); } // Create the edges for (i = 0; i < m_nEdgeCount; i++) { edgeInfo = edges[i]; NShape edge = CreateEdge(ENConnectorShape.RoutableConnector); activePage.Items.AddChild(edge); edge.GlueBeginToGeometryIntersection(vertices[edgeInfo.X]); edge.GlueEndToShape(vertices[edgeInfo.Y]); } // Apply a table layout to the generated graph NTableFlowLayout tableLayout = new NTableFlowLayout(); tableLayout.MaxOrdinal = (int)Math.Sqrt(m_nVertexCount) + 1; tableLayout.HorizontalSpacing = m_VerticesSize.Width / 5; tableLayout.VerticalSpacing = m_VerticesSize.Width / 5; NDrawingLayoutContext context = new NDrawingLayoutContext(document, activePage); tableLayout.Arrange(new NList <object>(NArrayHelpers <NShape> .CastAll <object>(vertices)), context); }