/// <summary> /// Try to modify the chart title settings. /// </summary> /// <param name="title">Reference to title settings to apply</param> /// <returns> /// <para> /// A <see cref="BooleanResult"/> reference that contains the result of the operation, to check if the operation is correct, the <b>Success</b> /// property will be <b>true</b> and the <b>Value</b> property will contain the value; Otherwise, the the <b>Success</b> property /// will be false and the <b>Errors</b> property will contain the errors associated with the operation, if they have been filled in. /// </para> /// <para> /// The type of the return value is <see cref="BooleanResult"/>, which contains the operation result /// </para> /// </returns> public IResult SetTitle(XlsxChartTitle title) { if (title == null) { return BooleanResult.CreateErroResult("title can not be null"); } if (title.Show == YesNo.No) { return BooleanResult.SuccessResult; } try { var chartTitle = Chart.Title; chartTitle.Text = title.Text; chartTitle.Font.SetFromFont(title.Font.ToFont()); chartTitle.Font.Color = title.Font.GetColor(); chartTitle.Rotation = title.Orientation.ToAngle(); chartTitle.TextVertical = title.Orientation == TextOrientation.Vertical ? eTextVerticalType.WordArtVertical : eTextVerticalType.Horizontal; return BooleanResult.SuccessResult; } catch (Exception e) { return BooleanResult.FromException(e); } }
/// <summary> /// Try to modify the chart border settings. /// </summary> /// <param name="border">Reference to border settings to apply</param> /// <returns> /// <para> /// A <see cref="BooleanResult"/> reference that contains the result of the operation, to check if the operation is correct, the <b>Success</b> /// property will be <b>true</b> and the <b>Value</b> property will contain the value; Otherwise, the the <b>Success</b> property /// will be false and the <b>Errors</b> property will contain the errors associated with the operation, if they have been filled in. /// </para> /// <para> /// The type of the return value is <see cref="BooleanResult"/>, which contains the operation result /// </para> /// </returns> public IResult SetBorder(XlsxBorder border) { if (border == null) { return BooleanResult.CreateErroResult("border can not be null"); } if (border.Show == YesNo.No) { return BooleanResult.SuccessResult; } try { var chartBorder = Chart.Border; chartBorder.Fill.Style = eFillStyle.SolidFill; chartBorder.Fill.Color = border.GetColor(); chartBorder.Fill.Transparancy = border.Transparency; chartBorder.LineStyle = border.Style.ToEppLineStyle(); chartBorder.Width = border.Width; return BooleanResult.SuccessResult; } catch (Exception e) { return BooleanResult.FromException(e); } }
/// <summary> /// Try to modify the chart plots settings. /// </summary> /// <param name="plots">Reference to chart plots settings to apply</param> /// <returns> /// <para> /// A <see cref="BooleanResult"/> reference that contains the result of the operation, to check if the operation is correct, the <b>Success</b> /// property will be <b>true</b> and the <b>Value</b> property will contain the value; Otherwise, the the <b>Success</b> property /// will be false and the <b>Errors</b> property will contain the errors associated with the operation, if they have been filled in. /// </para> /// <para> /// The type of the return value is <see cref="BooleanResult"/>, which contains the operation result /// </para> /// </returns> public IResult SetPlotArea(XlsxChartPlotsCollection plots) { if (plots == null) { return BooleanResult.CreateErroResult("legend can not be null"); } try { var chartPlots = Chart.PlotArea; chartPlots.Fill.Color = plots.Parent.GetBackColor(); chartPlots.Border.SetBorder(plots.Border); var series = plots.SelectMany(plot => plot.Series); foreach (var serie in series) { AddColorToSerie(serie); } return BooleanResult.SuccessResult; } catch (Exception e) { return BooleanResult.FromException(e); } }
/// <summary> /// Try to modify the chart legend settings. /// </summary> /// <param name="legend">Reference to legend settings to apply</param> /// <returns> /// <para> /// A <see cref="BooleanResult"/> reference that contains the result of the operation, to check if the operation is correct, the <b>Success</b> /// property will be <b>true</b> and the <b>Value</b> property will contain the value; Otherwise, the the <b>Success</b> property /// will be false and the <b>Errors</b> property will contain the errors associated with the operation, if they have been filled in. /// </para> /// <para> /// The type of the return value is <see cref="BooleanResult"/>, which contains the operation result /// </para> /// </returns> public IResult SetLegend(XlsxChartLegend legend) { if (legend == null) { return BooleanResult.CreateErroResult("legend can not be null"); } if (legend.Show == YesNo.No) { return BooleanResult.SuccessResult; } try { var chartLegend = Chart.Legend; chartLegend.Font.SetFromFont(legend.Font.ToFont()); chartLegend.Font.Color = legend.Font.GetColor(); chartLegend.Position = legend.Location.AsEnumType<eLegendPosition>(); chartLegend.Border.SetBorder(legend.Border); return BooleanResult.SuccessResult; } catch (Exception e) { return BooleanResult.FromException(e); } }
/// <summary> /// Try to modify the picture content settings. /// </summary> /// <param name="content">Reference to picture content settings to apply</param> /// <returns> /// <para> /// A <see cref="BooleanResult"/> reference that contains the result of the operation, to check if the operation is correct, the <b>Success</b> /// property will be <b>true</b> and the <b>Value</b> property will contain the value; Otherwise, the the <b>Success</b> property /// will be false and the <b>Errors</b> property will contain the errors associated with the operation, if they have been filled in. /// </para> /// <para> /// The type of the return value is <see cref="BooleanResult"/>, which contains the operation result /// </para> /// </returns> public IResult SetContent(XlsxPictureContent content) { if (content == null) { return(BooleanResult.CreateErroResult("border can not be null")); } if (content.Show == YesNo.No) { return(BooleanResult.SuccessResult); } try { var element = Picture.Fill; element.Style = eFillStyle.SolidFill; element.Color = content.GetColor(); //element.Transparancy = content.Transparency; return(BooleanResult.SuccessResult); } catch (Exception e) { return(BooleanResult.FromException(e)); } }
/// <summary> /// Try to modify the shape content settings. /// </summary> /// <param name="content">Reference to picture content settings to apply</param> /// <returns> /// <para> /// A <see cref="BooleanResult"/> reference that contains the result of the operation, to check if the operation is correct, the <b>Success</b> /// property will be <b>true</b> and the <b>Value</b> property will contain the value; Otherwise, the the <b>Success</b> property /// will be false and the <b>Errors</b> property will contain the errors associated with the operation, if they have been filled in. /// </para> /// <para> /// The type of the return value is <see cref="BooleanResult"/>, which contains the operation result /// </para> /// </returns> public IResult SetContent(XlsxShapeContent content) { if (content == null) { return(BooleanResult.CreateErroResult("border can not be null")); } if (content.Show == YesNo.No) { return(BooleanResult.SuccessResult); } try { var element = Shape.Fill; element.Style = eFillStyle.SolidFill; element.Color = content.GetColor(); //element.Transparancy = content.Transparency; Shape.TextAlignment = content.Alignment.Horizontal.ToEppTextHorizontalAlignment(); return(BooleanResult.SuccessResult); } catch (Exception e) { return(BooleanResult.FromException(e)); } }
/// <summary> /// Try to modify the picture size settings. /// </summary> /// <param name="size">Reference to picture size settings to apply</param> /// <returns> /// <para> /// A <see cref="BooleanResult"/> reference that contains the result of the operation, to check if the operation is correct, the <b>Success</b> /// property will be <b>true</b> and the <b>Value</b> property will contain the value; Otherwise, the the <b>Success</b> property /// will be false and the <b>Errors</b> property will contain the errors associated with the operation, if they have been filled in. /// </para> /// <para> /// The type of the return value is <see cref="BooleanResult"/>, which contains the operation result /// </para> /// </returns> public IResult SetSize(XlsxBaseSize size) { if (size == null) { return(BooleanResult.CreateErroResult("size can not be null")); } try { switch (size.Type) { case KnownSizeType.Percent: Picture.SetSize((int)((XlsxPercentSize)size).Value); break; case KnownSizeType.NullableSize: var nullableSize = (XlsxNullableSize)size; var hasWidth = nullableSize.Width.HasValue; var hasHeight = nullableSize.Height.HasValue; if (!hasWidth && hasHeight) { Picture.SetSize(Picture.Image.Width, nullableSize.Height.Value); } else if (hasWidth && !hasHeight) { Picture.SetSize(nullableSize.Width.Value, Picture.Image.Height); } else if (hasWidth && hasHeight) { Picture.SetSize(nullableSize.Width.Value, nullableSize.Height.Value); } break; default: case KnownSizeType.Size: Picture.SetSize(((XlsxSize)size).Width, ((XlsxSize)size).Height); break; } return(BooleanResult.SuccessResult); } catch (Exception e) { return(BooleanResult.FromException(e)); } }
/// <summary> /// Try to modify the chart size settings. /// </summary> /// <param name="size">Reference to chart size settings to apply</param> /// <returns> /// <para> /// A <see cref="BooleanResult"/> reference that contains the result of the operation, to check if the operation is correct, the <b>Success</b> /// property will be <b>true</b> and the <b>Value</b> property will contain the value; Otherwise, the the <b>Success</b> property /// will be false and the <b>Errors</b> property will contain the errors associated with the operation, if they have been filled in. /// </para> /// <para> /// The type of the return value is <see cref="BooleanResult"/>, which contains the operation result /// </para> /// </returns> public IResult SetSize(XlsxSize size) { if (size == null) { return BooleanResult.CreateErroResult("size can not be null"); } try { Chart.SetSize(size.Width, size.Height); return BooleanResult.SuccessResult; } catch (Exception e) { return BooleanResult.FromException(e); } }
/// <summary> /// Try to modify the shape font settings. /// </summary> /// <param name="font">Reference to shape font settings to apply</param> /// <returns> /// <para> /// A <see cref="BooleanResult"/> reference that contains the result of the operation, to check if the operation is correct, the <b>Success</b> /// property will be <b>true</b> and the <b>Value</b> property will contain the value; Otherwise, the the <b>Success</b> property /// will be false and the <b>Errors</b> property will contain the errors associated with the operation, if they have been filled in. /// </para> /// <para> /// The type of the return value is <see cref="BooleanResult"/>, which contains the operation result /// </para> /// </returns> public IResult SetFont(FontModel font) { if (font == null) { return(BooleanResult.CreateErroResult("border can not be null")); } try { Shape.Font.SetFromFont(font.ToFont()); return(BooleanResult.SuccessResult); } catch (Exception e) { return(BooleanResult.FromException(e)); } }
/// <summary> /// Try to modify the chart location settings. /// </summary> /// <param name="range">Reference to range location settings to apply</param> /// <returns> /// <para> /// A <see cref="BooleanResult"/> reference that contains the result of the operation, to check if the operation is correct, the <b>Success</b> /// property will be <b>true</b> and the <b>Value</b> property will contain the value; Otherwise, the the <b>Success</b> property /// will be false and the <b>Errors</b> property will contain the errors associated with the operation, if they have been filled in. /// </para> /// <para> /// The type of the return value is <see cref="BooleanResult"/>, which contains the operation result /// </para> /// </returns> public IResult SetPosition(XlsxBaseRange range) { if (range == null) { return BooleanResult.CreateErroResult("border can not be null"); } try { ExcelAddressBase locationAddress = range.ToEppExcelAddress(); Chart.SetPosition(locationAddress.Start.Row - 1, 0, locationAddress.Start.Column - 1, 0); return BooleanResult.SuccessResult; } catch (Exception e) { return BooleanResult.FromException(e); } }
/// <summary> /// Try to modify the shape effects settings. /// </summary> /// <param name="effects">Reference to chart shape effects settings to apply</param> /// <returns> /// <para> /// A <see cref="BooleanResult"/> reference that contains the result of the operation, to check if the operation is correct, the <b>Success</b> /// property will be <b>true</b> and the <b>Value</b> property will contain the value; Otherwise, the the <b>Success</b> property /// will be false and the <b>Errors</b> property will contain the errors associated with the operation, if they have been filled in. /// </para> /// <para> /// The type of the return value is <see cref="BooleanResult"/>, which contains the operation result /// </para> /// </returns> public IResult SetShapeEffects(XlsxShapeEffects effects) { if (effects == null) { return BooleanResult.CreateErroResult("size can not be null"); } try { SetIlluminationEffect(effects.Illumination); SetShadowEffect(effects.Shadow); SetReflectionEffect(effects.Reflection); SetSoftEdgeEffect(effects.SoftEdge); return BooleanResult.SuccessResult; } catch (Exception e) { return BooleanResult.FromException(e); } }
/// <summary> /// Try to modify the chart axes settings. /// </summary> /// <param name="axes">Reference to axes settings to apply</param> /// <returns> /// <para> /// A <see cref="BooleanResult"/> reference that contains the result of the operation, to check if the operation is correct, the <b>Success</b> /// property will be <b>true</b> and the <b>Value</b> property will contain the value; Otherwise, the the <b>Success</b> property /// will be false and the <b>Errors</b> property will contain the errors associated with the operation, if they have been filled in. /// </para> /// <para> /// The type of the return value is <see cref="BooleanResult"/>, which contains the operation result /// </para> /// </returns> public IResult SetAxes(XlsxChartAxes axes) { if (axes == null) { return BooleanResult.CreateErroResult("axes can not be null"); } var chartAxes = Chart.Axis; var axesList = chartAxes.ToList(); var hasAnyAxes = axesList.Any(); if (!hasAnyAxes) { return BooleanResult.SuccessResult; } try { var axesListAsXml = GetXmlAxis().ToList(); // Primary axis axesList[0].SetAxis(axesListAsXml[0], axes.Primary.Category, XmlWriter); axesList[1].SetAxis(axesListAsXml[1], axes.Primary.Values, XmlWriter); // Secondary axis if (axesList.Count <= 2) { return BooleanResult.SuccessResult; } axesList[2].SetAxis(axesListAsXml[2], axes.Secondary.Category, XmlWriter); axesList[3].SetAxis(axesListAsXml[3], axes.Secondary.Values, XmlWriter); return BooleanResult.SuccessResult; } catch (Exception e) { return BooleanResult.FromException(e); } }
/// <summary> /// Process all the commands in the collection asynchronously. /// </summary> public async Task ProcessAsync() { var resultTable = new Dictionary <ICommand, IResult>(); _index = -1; OnNotifyFeatureCommandsCollectionStart(new NotifyFeatureCommandsCollectionStartEventArgs(this)); foreach (ICommand command in this) { if (!(command is FeatureCommand featureCommand)) { continue; } featureCommand.NotifyFeatureCommandExecuted += NotifyFeatureCommandExecuted; featureCommand.NotifyFeatureCommandExecuting += NotifyFeatureCommandExecuting; resultTable.Add(featureCommand, await command.ExecuteAsync()); } OnNotifyFeatureCommandsCollectionFinish(new NotifyFeatureCommandsCollectionFinishEventArgs(resultTable.Values.All(t => t.Success) ? BooleanResult.SuccessResult : BooleanResult.CreateErroResult(""))); }