void modifyTextApplication(Visio.Characters chars, CfgApplication application) { appendEndOfLine(chars); chars.Begin = chars.End; new Parser.Parser().parseText(Settings.ApplicationText, new Parser.ApplicationTextVisitor(application, chars)); }
/// <summary> /// Draw an "Entity" Rectangle /// </summary> /// <param name="page">The Page on which to draw</param> /// <param name="entityName">The name of the entity</param> /// <param name="ownership">The ownership type of the entity</param> /// <returns>The newly drawn rectangle</returns> private VisioApi.Shape DrawEntityRectangle(VisioApi.Page page, string entityName, OwnershipTypes ownership) { VisioApi.Shape rect = page.DrawRectangle(X_POS1, Y_POS1, X_POS2, Y_POS2); rect.Name = entityName; rect.Text = entityName + " "; // Determine the shape fill color based on entity ownership. string fillColor; // Update the style of the entity name VisioApi.Characters characters = rect.Characters; characters.Begin = 0; characters.End = entityName.Length; characters.set_CharProps((short)VisioApi.VisCellIndices.visCharacterStyle, (short)VisioApi.VisCellVals.visBold); characters.set_CharProps((short)VisioApi.VisCellIndices.visCharacterSize, NAME_CHARACTER_SIZE); //set the font family of the text to segoe for the visio 2013. if (VersionName == "15.0") { characters.set_CharProps((short)VisioApi.VisCellIndices.visCharacterFont, (short)FONT_STYLE); } switch (ownership) { case OwnershipTypes.BusinessOwned: fillColor = "RGB(255,140,0)"; // orange characters.set_CharProps((short)VisioApi.VisCellIndices.visCharacterColor, (short)VisioApi.VisDefaultColors.visBlack); // set the font color of the text break; case OwnershipTypes.OrganizationOwned: fillColor = "RGB(127, 186, 0)"; // green characters.set_CharProps((short)VisioApi.VisCellIndices.visCharacterColor, (short)VisioApi.VisDefaultColors.visBlack); // set the font color of the text break; case OwnershipTypes.UserOwned: fillColor = "RGB(0,24,143)"; // blue characters.set_CharProps((short)VisioApi.VisCellIndices.visCharacterColor, (short)VisioApi.VisDefaultColors.visWhite); // set the font color of the text break; default: fillColor = "RGB(255,255,255)"; // White characters.set_CharProps((short)VisioApi.VisCellIndices.visCharacterColor, (short)VisioApi.VisDefaultColors.visDarkBlue); // set the font color of the text break; } // Set the fill color, placement properties, and line weight of the shape. rect.get_CellsSRC(VISIO_SECTION_OJBECT_INDEX, (short)VisioApi.VisRowIndices.visRowMisc, (short)VisioApi.VisCellIndices.visLOFlags).FormulaU = ((int)VisioApi.VisCellVals.visLOFlagsPlacable).ToString(); rect.get_CellsSRC(VISIO_SECTION_OJBECT_INDEX, (short)VisioApi.VisRowIndices.visRowFill, (short)VisioApi.VisCellIndices.visFillForegnd).FormulaU = fillColor; return(rect); }
/// <summary> /// Draw an "Entity" Rectangle /// </summary> /// <param name="page">The Page on which to draw</param> /// <param name="entityName">The name of the entity</param> /// <param name="ownership">The ownership type of the entity</param> /// <returns>The newly drawn rectangle</returns> private VisioApi.Shape DrawEntityRectangle(VisioApi.Page page, string entityName, string displayName, OwnershipTypes ownership) { VisioApi.Shape rect = page.DrawRectangle(X_POS1, Y_POS1, X_POS2, Y_POS2); rect.Name = entityName; rect.Text = displayName + " "; // Determine the shape fill color based on entity ownership. string fillColor; switch (ownership) { case OwnershipTypes.BusinessOwned: fillColor = "RGB(255,202,176)"; // Light orange break; case OwnershipTypes.OrganizationOwned: fillColor = "RGB(255,255,176)"; // Light yellow break; case OwnershipTypes.UserOwned: fillColor = "RGB(204,255,204)"; // Light green break; default: fillColor = "RGB(255,255,255)"; // White break; } // Set the fill color, placement properties, and line weight of the shape. rect.get_CellsSRC(VISIO_SECTION_OJBECT_INDEX, (short)VisioApi.VisRowIndices.visRowMisc, (short)VisioApi.VisCellIndices.visLOFlags).FormulaU = ((int)VisioApi.VisCellVals.visLOFlagsPlacable).ToString(); rect.get_CellsSRC(VISIO_SECTION_OJBECT_INDEX, (short)VisioApi.VisRowIndices.visRowFill, (short)VisioApi.VisCellIndices.visFillForegnd).FormulaU = fillColor; // Update the style of the entity name VisioApi.Characters characters = rect.Characters; characters.Begin = 0; characters.End = displayName.Length; characters.set_CharProps((short)VisioApi.VisCellIndices.visCharacterStyle, (short)VisioApi.VisCellVals.visBold); characters.set_CharProps((short)VisioApi.VisCellIndices.visCharacterColor, (short)VisioApi.VisDefaultColors.visDarkBlue); characters.set_CharProps((short)VisioApi.VisCellIndices.visCharacterSize, NAME_CHARACTER_SIZE); return(rect); }
void modifyShapeText(Visio.Shape shape, CfgHost host) { shape.Name = host.Name; Visio.Characters chars = shape.Characters; chars.set_ParaProps(6, 0); // Left alignment if (Settings.WriteHost) { modifyTextHost(chars, host); } if (Settings.WriteApplicationList) { foreach (CfgServer server in host.Servers) { CfgApplication app = server.Application; chars.Begin = chars.End; modifyTextApplication(chars, app); } } }
/// <param name="chars"> /// Visio Characters object. Its contents will be substituted by this Visitor. /// </param> public CharsVisitor(Visio.Characters chars) { this.chars = chars; chars.Text = ""; // Now: chars.Begin == chars.End }
/// <summary> /// Draw an "Entity" Rectangle /// </summary> /// <param name="page">The Page on which to draw</param> /// <param name="entity">The entity to draw</param> /// <returns>The newly drawn rectangle</returns> private VisioApi.Shape DrawEntityRectangle(VisioApi.Page page, EntityMetadata entity) { VisioApi.Shape rect = page.DrawRectangle(X_POS1, Y_POS1, X_POS2, Y_POS2); rect.Name = entity.LogicalName; if (dbp.entityLabelDisplay == 1) { rect.Text = entity.DisplayName.UserLocalizedLabel.Label + " "; } else if (dbp.entityLabelDisplay == 2) { rect.Text = entity.DisplayName.UserLocalizedLabel.Label + " [" + entity.LogicalName + "] "; } else { rect.Text = entity.LogicalName + " "; } // Determine the shape fill color based on entity ownership. string fillColor; switch (entity.OwnershipType.Value) { case OwnershipTypes.BusinessOwned: fillColor = "RGB(255,202,176)"; // Light orange break; case OwnershipTypes.OrganizationOwned: fillColor = "RGB(255,255,176)"; // Light yellow break; case OwnershipTypes.UserOwned: fillColor = "RGB(204,255,204)"; // Light green break; default: fillColor = "RGB(255,255,255)"; // White break; } // Set the fill color, placement properties, and line weight of the shape. rect.get_CellsSRC(VISIO_SECTION_OJBECT_INDEX, (short)VisioApi.VisRowIndices.visRowMisc, (short)VisioApi.VisCellIndices.visLOFlags).Formula = ((int)VisioApi.VisCellVals.visLOFlagsPlacable).ToString(); if (dbp.showOwnership) { rect.get_CellsSRC(VISIO_SECTION_OJBECT_INDEX, (short)VisioApi.VisRowIndices.visRowFill, (short)VisioApi.VisCellIndices.visFillForegnd).FormulaU = fillColor; } // Update the style of the entity name VisioApi.Characters characters = rect.Characters; characters.Begin = 0; characters.End = entity.LogicalName.Length; characters.set_CharProps((short)VisioApi.VisCellIndices.visCharacterStyle, (short)VisioApi.VisCellVals.visBold); characters.set_CharProps((short)VisioApi.VisCellIndices.visCharacterColor, (short)VisioApi.VisDefaultColors.visDarkBlue); characters.set_CharProps((short)VisioApi.VisCellIndices.visCharacterSize, NAME_CHARACTER_SIZE); //set the font family of the text to segoe for the visio 2013. if (VersionName == "15.0") { characters.set_CharProps((short)VisioApi.VisCellIndices.visCharacterFont, (short)FONT_STYLE); } _processedEntities.Add(new ProcessedEntity { entityName = entity.LogicalName, attributes = new List <string> { entity.PrimaryIdAttribute } }); //Add Primary Key attribute if (dbp.showPrimaryKeys) { rect.get_CellsSRC(VISIO_SECTION_OJBECT_INDEX, (short)VisioApi.VisRowIndices.visRowXFormOut, (short)VisioApi.VisCellIndices.visXFormHeight).ResultIU += HEIGHT; AttributeMetadata attribute = GetAttributeMetadata(entity, entity.PrimaryIdAttribute); rect.Text += getAttributeValue(attribute) + " [PK]"; } return(rect); }
/// <summary> /// Draw on a Visio page the entity relationships defined in the passed-in relationship collection. /// </summary> /// <param name="entity">Core entity</param> /// <param name="rect">Shape representing the core entity</param> /// <param name="relationshipCollection">Collection of entity relationships to draw</param> /// <param name="areReferencingRelationships">Whether or not the core entity is the referencing entity in the relationship</param> private void DrawRelationships(EntityMetadata entity, VisioApi.Shape rect, RelationshipMetadataBase[] relationshipCollection, bool areReferencingRelationships) { ManyToManyRelationshipMetadata currentManyToManyRelationship = null; OneToManyRelationshipMetadata currentOneToManyRelationship = null; EntityMetadata entity2 = null; AttributeMetadata attribute2 = null; AttributeMetadata attribute = null; Guid metadataID = Guid.NewGuid(); bool isManyToMany = false; // Draw each relationship in the relationship collection. foreach (RelationshipMetadataBase entityRelationship in relationshipCollection) { entity2 = null; if (entityRelationship is ManyToManyRelationshipMetadata) { isManyToMany = true; currentManyToManyRelationship = entityRelationship as ManyToManyRelationshipMetadata; // The entity passed in is not necessarily the originator of this relationship. if (String.Compare(entity.LogicalName, currentManyToManyRelationship.Entity1LogicalName, true) != 0) { entity2 = GetEntityMetadata(currentManyToManyRelationship.Entity1LogicalName); } else { entity2 = GetEntityMetadata(currentManyToManyRelationship.Entity2LogicalName); } attribute2 = GetAttributeMetadata(entity2, entity2.PrimaryIdAttribute); attribute = GetAttributeMetadata(entity, entity.PrimaryIdAttribute); metadataID = currentManyToManyRelationship.MetadataId.Value; } else if (entityRelationship is OneToManyRelationshipMetadata) { isManyToMany = false; currentOneToManyRelationship = entityRelationship as OneToManyRelationshipMetadata; entity2 = GetEntityMetadata(areReferencingRelationships ? currentOneToManyRelationship.ReferencingEntity : currentOneToManyRelationship.ReferencedEntity); attribute2 = GetAttributeMetadata(entity2, areReferencingRelationships ? currentOneToManyRelationship.ReferencingAttribute : currentOneToManyRelationship.ReferencedAttribute); attribute = GetAttributeMetadata(entity, areReferencingRelationships ? currentOneToManyRelationship.ReferencedAttribute : currentOneToManyRelationship.ReferencingAttribute); metadataID = currentOneToManyRelationship.MetadataId.Value; } // Verify relationship is either ManyToManyMetadata or OneToManyMetadata if (entity2 != null) { if (_processedRelationships.Contains(metadataID)) { // Skip relationships we have already drawn continue; } else { // Record we are drawing this relationship _processedRelationships.Add(metadataID); // Define convenience variables based upon the direction of referencing with respect to the core entity. VisioApi.Shape rect2; // Do not draw relationships involving the entity itself, SystemUser, BusinessUnit, // or those that are intentionally excluded. if (String.Compare(entity2.LogicalName, "systemuser", true) != 0 && String.Compare(entity2.LogicalName, "businessunit", true) != 0 && String.Compare(entity2.LogicalName, rect.Name, true) != 0 && String.Compare(entity.LogicalName, "systemuser", true) != 0 && String.Compare(entity.LogicalName, "businessunit", true) != 0 && !_excludedRelationsTable.ContainsKey(attribute.LogicalName.GetHashCode())) { // Either find or create a shape that represents this secondary entity, and add the name of // the involved attribute to the shape's text. try { rect2 = rect.ContainingPage.Shapes.get_ItemU(entity2.SchemaName); if (rect2.Text.IndexOf(attribute2.SchemaName) == -1) { rect2.get_CellsSRC(VISIO_SECTION_OJBECT_INDEX, (short)VisioApi.VisRowIndices.visRowXFormOut, (short)VisioApi.VisCellIndices.visXFormHeight).ResultIU += 0.25; rect2.Text += "\n" + attribute2.SchemaName; // If the attribute is a primary key for the entity, append a [PK] label to the attribute name to indicate this. if (String.Compare(entity2.PrimaryIdAttribute, attribute2.LogicalName) == 0) { rect2.Text += " [PK]"; } } } catch (System.Runtime.InteropServices.COMException) { rect2 = DrawEntityRectangle(rect.ContainingPage, entity2.SchemaName, entity2.OwnershipType.Value); rect2.Text += "\n" + attribute2.SchemaName; // If the attribute is a primary key for the entity, append a [PK] label to the attribute name to indicate so. if (String.Compare(entity2.PrimaryIdAttribute, attribute2.LogicalName) == 0) { rect2.Text += " [PK]"; } } // Add the name of the involved attribute to the core entity's text, if not already present. if (rect.Text.IndexOf(attribute.SchemaName) == -1) { rect.get_CellsSRC(VISIO_SECTION_OJBECT_INDEX, (short)VisioApi.VisRowIndices.visRowXFormOut, (short)VisioApi.VisCellIndices.visXFormHeight).ResultIU += HEIGHT; rect.Text += "\n" + attribute.SchemaName; // If the attribute is a primary key for the entity, append a [PK] label to the attribute name to indicate so. if (String.Compare(entity.PrimaryIdAttribute, attribute.LogicalName) == 0) { rect.Text += " [PK]"; } } // Update the style of the entity name VisioApi.Characters characters = rect.Characters; VisioApi.Characters characters2 = rect2.Characters; //set the font family of the text to segoe for the visio 2013. if (VersionName == "15.0") { characters.set_CharProps((short)VisioApi.VisCellIndices.visCharacterFont, (short)FONT_STYLE); characters2.set_CharProps((short)VisioApi.VisCellIndices.visCharacterFont, (short)FONT_STYLE); } switch (entity2.OwnershipType) { case OwnershipTypes.BusinessOwned: // set the font color of the text characters.set_CharProps((short)VisioApi.VisCellIndices.visCharacterColor, (short)VisioApi.VisDefaultColors.visBlack); characters2.set_CharProps((short)VisioApi.VisCellIndices.visCharacterColor, (short)VisioApi.VisDefaultColors.visBlack); break; case OwnershipTypes.OrganizationOwned: // set the font color of the text characters.set_CharProps((short)VisioApi.VisCellIndices.visCharacterColor, (short)VisioApi.VisDefaultColors.visBlack); characters2.set_CharProps((short)VisioApi.VisCellIndices.visCharacterColor, (short)VisioApi.VisDefaultColors.visBlack); break; case OwnershipTypes.UserOwned: // set the font color of the text characters.set_CharProps((short)VisioApi.VisCellIndices.visCharacterColor, (short)VisioApi.VisDefaultColors.visWhite); characters2.set_CharProps((short)VisioApi.VisCellIndices.visCharacterColor, (short)VisioApi.VisDefaultColors.visWhite); break; default: break; } // Draw the directional, dynamic connector between the two entity shapes. if (areReferencingRelationships) { DrawDirectionalDynamicConnector(rect, rect2, isManyToMany); } else { DrawDirectionalDynamicConnector(rect2, rect, isManyToMany); } } else { Debug.WriteLine(String.Format("<{0} - {1}> not drawn.", rect.Name, entity2.LogicalName), "Relationship"); } } } } }
void appendEndOfLine(Visio.Characters chars) { chars.Begin = chars.End; chars.Text = "\n"; }
void modifyTextHost(Visio.Characters chars, CfgHost host) { new Parser.Parser().parseText(Settings.HostText, new Parser.HostTextVisitor(host, chars)); }
public ApplicationTextVisitor(CfgApplication application, Visio.Characters chars) : base(chars) { this.application = application; }
public HostTextVisitor(CfgHost host, Visio.Characters chars) : base(chars) { this.host = host; }