private void SetStyles() { var graphStyles = new GraphStyles(); var fontSize = Convert.ToInt32(txtVerticesSizeFont.Text); graphStyles.VerticeNameFont = chbVerticesBold.Checked ? new Font("Times New Roman", fontSize, FontStyle.Bold) : new Font("Times New Roman", fontSize, FontStyle.Regular); graphStyles.VerticePointBrush = new SolidBrush(pbVerticesColor.BackColor); graphStyles.VerticeNameBrush = new SolidBrush(pbVerticesName.BackColor); graphStyles.EdgePen = new Pen(pbEdgesColor.BackColor, 1); fontSize = Convert.ToInt32(txtWeightsSizeFont.Text); graphStyles.WeightFont = chbWeightsBold.Checked ? new Font("Times New Roman", fontSize, FontStyle.Bold) : new Font("Times New Roman", fontSize, FontStyle.Regular); graphStyles.WeightBrush = new SolidBrush(pbWeightsColor.BackColor); fontSize = Convert.ToInt32(txtVerticesWeightsSizeFont.Text); graphStyles.VerticeWeightFont = chbVerticesWeightsBold.Checked ? new Font("Times New Roman", fontSize, FontStyle.Bold) : new Font("Times New Roman", fontSize, FontStyle.Regular); graphStyles.VerticeWeightBrush = new SolidBrush(pbVerticesWeightsColor.BackColor); graphStyles.EdgePenList = new List <Pen>(); if (pbEdgeColor1.BackColor != Color.Transparent) { graphStyles.EdgePenList.Add(new Pen(pbEdgeColor1.BackColor, 1)); } if (pbEdgeColor2.BackColor != Color.Transparent) { graphStyles.EdgePenList.Add(new Pen(pbEdgeColor2.BackColor, 1)); } if (pbEdgeColor3.BackColor != Color.Transparent) { graphStyles.EdgePenList.Add(new Pen(pbEdgeColor3.BackColor, 1)); } if (pbEdgeColor4.BackColor != Color.Transparent) { graphStyles.EdgePenList.Add(new Pen(pbEdgeColor4.BackColor, 1)); } if (pbEdgeColor5.BackColor != Color.Transparent) { graphStyles.EdgePenList.Add(new Pen(pbEdgeColor5.BackColor, 1)); } if (pbEdgeColor6.BackColor != Color.Transparent) { graphStyles.EdgePenList.Add(new Pen(pbEdgeColor6.BackColor, 1)); } _graph.SetCustomStyles(graphStyles); }
public void ArrangeGraph(GraphStyles Style) { if (Style == GraphStyles.TopDown) { // set 'PlaceStyle' var placeStyleCell = this._window.Application.ActivePage.PageSheet.get_CellsSRC( (short)Visio.VisSectionIndices.visSectionObject, (short)Visio.VisRowIndices.visRowPageLayout, (short)Visio.VisCellIndices.visPLOPlaceStyle).ResultIU = 1; // set 'RouteStyle' var routeStyleCell = this._window.Application.ActivePage.PageSheet.get_CellsSRC( (short)Visio.VisSectionIndices.visSectionObject, (short)Visio.VisRowIndices.visRowPageLayout, (short)Visio.VisCellIndices.visPLORouteStyle).ResultIU = 5; // set 'PageShapeSplit' var pageShapeSplitCell = this._window.Application.ActivePage.PageSheet.get_CellsSRC( (short)Visio.VisSectionIndices.visSectionObject, (short)Visio.VisRowIndices.visRowPageLayout, (short)Visio.VisCellIndices.visPLOSplit).ResultIU = 1; } else if (Style == GraphStyles.LeftRight) { // set 'PlaceStyle' var placeStyleCell = this._window.Application.ActivePage.PageSheet.get_CellsSRC( (short)Visio.VisSectionIndices.visSectionObject, (short)Visio.VisRowIndices.visRowPageLayout, (short)Visio.VisCellIndices.visPLOPlaceStyle).ResultIU = 2; // set 'RouteStyle' var routeStyleCell = this._window.Application.ActivePage.PageSheet.get_CellsSRC( (short)Visio.VisSectionIndices.visSectionObject, (short)Visio.VisRowIndices.visRowPageLayout, (short)Visio.VisCellIndices.visPLORouteStyle).ResultIU = 6; // set 'PageShapeSplit' var pageShapeSplitCell = this._window.Application.ActivePage.PageSheet.get_CellsSRC( (short)Visio.VisSectionIndices.visSectionObject, (short)Visio.VisRowIndices.visRowPageLayout, (short)Visio.VisCellIndices.visPLOSplit).ResultIU = 1; } else { throw new NotImplementedException("GraphStyle " + Style.ToString() + " is not supported"); } this._window.Application.ActivePage.Layout(); }