/// <summary> /// Sets the color of the series using a solidcolor brush /// If a null brush is supplied any color is removed so the color will be automatic /// </summary> /// <param name="series">The series.</param> /// <param name="brush">The brush.</param> /// <exception cref="ArgumentNullException">series</exception> public static void UpdateSeriesMarkerBrush(this OpenXmlCompositeElement series, Brush brush) { if (series == null) { throw new ArgumentNullException("series"); } var marker = series.Descendants <Marker>().FirstOrDefault(); if (marker == null) { return; } var scb = brush as SolidColorBrush; if (scb == null) { return; } // clear down and start again marker.RemoveAllChildren(); var chartShapeProperties = new ChartShapeProperties(); SolidFill solidFill = new SolidFill(); StringBuilder hexString = new StringBuilder(); hexString.Append(scb.Color.R.ToString("X")); hexString.Append(scb.Color.G.ToString("X")); hexString.Append(scb.Color.B.ToString("X")); RgbColorModelHex hexColour = new RgbColorModelHex() { Val = hexString.ToString() }; var outlineNoFill = new Outline(); outlineNoFill.Append(new NoFill()); solidFill.Append(hexColour); chartShapeProperties.Append(solidFill); chartShapeProperties.Append(outlineNoFill); marker.Append(chartShapeProperties); }
/// <summary> /// Updates a supplied <see cref="SolidFill" /> with a <see cref="SolidColorBrush" /> colour. /// </summary> /// <param name="solidFill">The <see cref="SolidFill" /></param> /// <param name="brush">The <see cref="SolidColorBrush" /> which contains the colour which needs to be set</param> private static void UpdateSolidFill(this SolidFill solidFill, SolidColorBrush brush) { solidFill.RemoveAllChildren(); var scb = (SolidColorBrush)brush; StringBuilder hexString = new StringBuilder(); hexString.Append(brush.Color.R.ToString("X")); hexString.Append(brush.Color.G.ToString("X")); hexString.Append(brush.Color.B.ToString("X")); RgbColorModelHex hexColour = new RgbColorModelHex() { Val = hexString.ToString() }; solidFill.Append(hexColour); }
/// <summary> /// Design settings for Y axis. /// </summary> public ValueAxis SetGanttValueAxis(PlotArea plotArea, TimeSpan minSpan, TimeSpan maxSpan) { MajorGridlines majorGridlines1 = new MajorGridlines(); ChartShapeProperties chartShapeProperties2 = new ChartShapeProperties(); Outline outline2 = new Outline(); SolidFill solidFill2 = new SolidFill(); SchemeColor schemeColor2 = new SchemeColor() { Val = SchemeColorValues.Accent1 }; Alpha alpha1 = new Alpha() { Val = 10000 }; schemeColor2.Append(alpha1); solidFill2.Append(schemeColor2); outline2.Append(solidFill2); chartShapeProperties2.Append(outline2); majorGridlines1.Append(chartShapeProperties2); return(plotArea.AppendChild <ValueAxis>(new ValueAxis(new AxisId() { Val = new UInt32Value(48672768u) }, new Scaling(new Orientation() { Val = new EnumValue <DocumentFormat.OpenXml.Drawing.Charts.OrientationValues>( DocumentFormat.OpenXml.Drawing.Charts.OrientationValues.MinMax) }, new MinAxisValue() { Val = 0 }, new MaxAxisValue() { Val = 0.99 }), new Delete() { Val = false }, new AxisPosition() { Val = new EnumValue <AxisPositionValues>(AxisPositionValues.Left) }, majorGridlines1, new MajorTickMark() { Val = TickMarkValues.None }, new MinorTickMark() { Val = TickMarkValues.None }, new MajorUnit() { Val = 4.1666666666666713E-2D }, new DocumentFormat.OpenXml.Drawing.Charts.NumberingFormat() { FormatCode = "h:mm;@", SourceLinked = false }, new TickLabelPosition() { Val = new EnumValue <TickLabelPositionValues> (TickLabelPositionValues.NextTo) }, new CrossingAxis() { Val = new UInt32Value(48650112U) }, new Crosses() { Val = new EnumValue <CrossesValues>(CrossesValues.AutoZero) }, new CrossBetween() { Val = new EnumValue <CrossBetweenValues>(CrossBetweenValues.Between) }))); }
public Paragraph CreateStyledParagraph(string text, int fontsize, bool bold, bool italic, Color color) { var run = new Drawing.Run(); var run2 = new Drawing.Run(); var textBody = new Drawing.Text(); var textBody2 = new Drawing.Text(); var newParagraph = new Paragraph(); string[] newStringa = text.Split(new string[] { "<", ">" }, StringSplitOptions.RemoveEmptyEntries); for (int i = 0; i < newStringa.Count(); i++) { if (newStringa[i].Contains('(')) { var runProperties2 = new RunProperties(); //set basic styles for paragraph Run ru11 = new Run(); runProperties2.Bold = bold; runProperties2.Italic = italic; runProperties2.FontSize = fontsize; runProperties2.Dirty = false; string rem = newStringa[i].Substring(1); Color col = ColorTranslator.FromHtml("#007AC9"); var hexColor = col.R.ToString("X2") + col.G.ToString("X2") + col.B.ToString("X2");//convert color to hex //convert color to hex var solidFill = new SolidFill(); var rgbColorModelHex = new RgbColorModelHex() { Val = hexColor }; var rgbColorModelHex1 = new LatinFont() { Typeface = "Arial Narrow" }; solidFill.Append(rgbColorModelHex1); solidFill.Append(rgbColorModelHex); runProperties2.Append(solidFill); textBody2 = new Drawing.Text(); textBody2.Text = rem; //assign text run2 = new Drawing.Run(); run2.Append(runProperties2); //append styles run2.Append(textBody2); newParagraph.Append(run2); } else { var runProperties = new RunProperties(); //set basic styles for paragraph runProperties.Bold = false; runProperties.Italic = false; runProperties.FontSize = fontsize; runProperties.Dirty = false; var hexColor = color.R.ToString("X2") + color.G.ToString("X2") + color.B.ToString("X2");//convert color to hex var solidFill = new SolidFill(); var rgbColorModelHex = new RgbColorModelHex() { Val = hexColor }; solidFill.Append(rgbColorModelHex); runProperties.Append(solidFill); textBody = new Drawing.Text(); textBody.Text = newStringa[i]; //assign text run = new Drawing.Run(); run.Append(runProperties); //append styles run.Append(textBody); newParagraph.Append(run); } } return(newParagraph); //append text //append run to paragraph }
/// <summary> /// Design settings for Y axis. /// </summary> public virtual ValueAxis SetValueAxis(PlotArea plotArea) { // Postavljanje Gridline-a. MajorGridlines majorGridlines = new MajorGridlines(); ChartShapeProperties chartShapeProperties = new ChartShapeProperties(); Outline outline = new Outline(); SolidFill solidFill = new SolidFill(); SchemeColor schemeColor = new SchemeColor() { Val = SchemeColorValues.Accent1 }; Alpha alpha = new Alpha() { Val = 10000 }; schemeColor.Append(alpha); solidFill.Append(schemeColor); outline.Append(solidFill); chartShapeProperties.Append(outline); majorGridlines.Append(chartShapeProperties); var valueAxis = plotArea.AppendChild <ValueAxis>(new ValueAxis( new AxisId() { Val = new UInt32Value(48672768u) }, new Scaling(new Orientation() { Val = new EnumValue <DocumentFormat.OpenXml.Drawing.Charts.OrientationValues>( DocumentFormat.OpenXml.Drawing.Charts.OrientationValues.MinMax) }), new Delete() { Val = !ChartProperties.AxisY }, new AxisPosition() { Val = new EnumValue <AxisPositionValues>(AxisPositionValues.Left) }, majorGridlines, SetTitle(ChartProperties.AxisYTitle), new NumberingFormat() { FormatCode = ChartProperties.AxisYFormatCode, SourceLinked = new BooleanValue(true) }, new MajorTickMark() { Val = TickMarkValues.None }, new MinorTickMark() { Val = TickMarkValues.None }, new TickLabelPosition() { Val = new EnumValue <TickLabelPositionValues> (TickLabelPositionValues.NextTo) }, new CrossingAxis() { Val = new UInt32Value(48650112U) }, new Crosses() { Val = new EnumValue <CrossesValues>(CrossesValues.AutoZero) }, new CrossBetween() { Val = new EnumValue <CrossBetweenValues>(CrossBetweenValues.Between) })); if (ChartProperties.AxisYFormatCategory == "Time") { valueAxis.Append(new MajorUnit() { Val = getMajorUnitFromSeconds((int)yAxisValue) }); } return(valueAxis); }