示例#1
0
 internal void ApplyStyleOnPart(IDrawingStyleBase chartPart, ExcelChartStyleEntry section, bool applyChartEx = false)
 {
     if ((applyChartEx == false && _isChartEx) || section == null)
     {
         return;
     }
     _styleManager.ApplyStyle(chartPart, section);
 }
 private void ApplyStyleFill(IDrawingStyleBase chartPart, ExcelChartStyleEntry section, int indexForColor, int numberOfItems)
 {
     if (section.HasFill)  //Has inner fill section
     {
         chartPart.Fill.SetFromXml(section.Fill);
     }
     else if (section.FillReference.Index > 0)//From theme
     {
         var theme = GetTheme();
         if (theme.FormatScheme.FillStyle.Count > section.FillReference.Index - 1)
         {
             var fill = theme.FormatScheme.FillStyle[section.FillReference.Index - 1];
             chartPart.Fill.SetFromXml(fill);
         }
     }
     TransformColorFill(chartPart.Fill, section.FillReference.Color, indexForColor, numberOfItems);
 }
 internal void ApplyStyle(IDrawingStyleBase chartPart, ExcelChartStyleEntry section, int indexForColor = 0, int numberOfItems = 0, bool applyFill = true)
 {
     if (chartPart is IStyleMandatoryProperties setMandatoryProperties)
     {
         setMandatoryProperties.SetMandatoryProperties();
     }
     chartPart.CreatespPr();
     if (applyFill)
     {
         ApplyStyleFill(chartPart, section, indexForColor, numberOfItems);
     }
     ApplyStyleBorder(chartPart.Border, section, indexForColor, numberOfItems);
     ApplyStyleEffect(chartPart.Effect, section, indexForColor, numberOfItems);
     ApplyStyle3D(chartPart, section, indexForColor, numberOfItems);
     if (chartPart is IDrawingStyle chartPartWithFont)
     {
         ApplyStyleFont(section, indexForColor, chartPartWithFont, numberOfItems);
     }
 }
        private void ApplyStyle3D(IDrawingStyleBase chartThreeD, ExcelChartStyleEntry section, int indexForColor, int numberOfItems)
        {
            bool tranformColor = false;

            if (section.HasThreeD)
            {
                chartThreeD.ThreeD.SetFromXml(section.ThreeD.Scene3DElement, section.ThreeD.Sp3DElement);
                tranformColor = true;
            }
            else if (section.EffectReference.Index > 0) //From theme
            {
                var theme = GetTheme();
                if (theme.FormatScheme.EffectStyle.Count > section.EffectReference.Index - 1)
                {
                    var effect = theme.FormatScheme.EffectStyle[section.EffectReference.Index - 1];
                    chartThreeD.ThreeD.SetFromXml(effect.ThreeD.Scene3DElement, effect.ThreeD.Sp3DElement);
                    tranformColor = (effect.ThreeD.Sp3DElement != null);
                }
            }
            if (tranformColor)
            {
                TransformColorThreeD(chartThreeD.ThreeD, section.EffectReference.Color, indexForColor, numberOfItems);
            }
        }