Ejemplo n.º 1
0
        internal static Brush GetRichTextFill(List <TextParagraph> richText, Workbook workbook)
        {
            TextRun       firstRun       = GetFirstRun(richText);
            TextParagraph firstParagraph = GetFirstParagraph(richText);
            Brush         brush          = null;
            IFillFormat   fillFormat     = null;

            if (firstRun != null)
            {
                fillFormat = firstRun.FillFormat;
            }
            if ((fillFormat == null) && (firstParagraph != null))
            {
                fillFormat = firstParagraph.FillFormat;
            }
            if (fillFormat != null)
            {
                object fill = ExcelChartExtension.GetFill(fillFormat, workbook);
                SpreadDrawingColorSettings spreadDrawingColorSettings = ExcelChartExtension.GetSpreadDrawingColorSettings(fillFormat);
                if (fill is string)
                {
                    if (workbook != null)
                    {
                        Windows.UI.Color color = Dt.Cells.Data.ColorHelper.UpdateColor(workbook.GetThemeColor((string)(fill as string)), spreadDrawingColorSettings, false);
                        return(new SolidColorBrush(color));
                    }
                    return(brush);
                }
                if (fill is Brush)
                {
                    brush = fill as Brush;
                }
            }
            return(brush);
        }
Ejemplo n.º 2
0
 internal static Windows.UI.Color UpdateColor(Color color, SpreadDrawingColorSettings drawingColorSettings, bool updateTint)
 {
     if (drawingColorSettings != null)
     {
         double?alpha = drawingColorSettings.alpha;
         if (alpha.HasValue)
         {
             color = Windows.UI.Color.FromArgb((byte)((alpha.Value / 100000.0) * 255.0), color.R, color.G, color.B);
         }
         double?shade = drawingColorSettings.shade;
         if (shade.HasValue)
         {
             float num = ((float)shade.Value) / 100000f;
             byte  r   = (byte)(num * color.R);
             byte  g   = (byte)(num * color.G);
             byte  b   = (byte)(num * color.B);
             color = Windows.UI.Color.FromArgb(color.A, r, g, b);
         }
         if (updateTint)
         {
             double?tint = drawingColorSettings.tint;
             if (tint.HasValue)
             {
                 float num5 = ((float)tint.Value) / 100000f;
                 byte  num6 = (byte)((num5 * color.R) + ((1f - num5) * 255f));
                 byte  num7 = (byte)((num5 * color.G) + ((1f - num5) * 255f));
                 byte  num8 = (byte)((num5 * color.B) + ((1f - num5) * 255f));
                 color = Windows.UI.Color.FromArgb(color.A, num6, num7, num8);
             }
         }
         double?hue    = drawingColorSettings.hue;
         double?hueOff = drawingColorSettings.hueOff;
         double?hueMod = drawingColorSettings.hueMod;
         double?sat    = drawingColorSettings.sat;
         double?satOff = drawingColorSettings.satOff;
         double?satMod = drawingColorSettings.satMod;
         double?lum    = drawingColorSettings.lum;
         double?lumOff = drawingColorSettings.lumOff;
         double?lumMod = drawingColorSettings.lumMod;
         if (((!hue.HasValue && !hueOff.HasValue) && (!hueMod.HasValue && !sat.HasValue)) && ((!satOff.HasValue && !satMod.HasValue) && ((!lum.HasValue && !lumOff.HasValue) && !lumMod.HasValue)))
         {
             return(color);
         }
         HLSColor color2     = new HLSColor(color);
         int      num9       = color2.Hue;
         int      saturation = color2.Saturation;
         int      luminosity = color2.Luminosity;
         int      num12      = 0xff;
         if (hue.HasValue)
         {
             num9 = (int)((hue.Value * num12) / 36000000.0);
         }
         if (hueMod.HasValue)
         {
             num9 = (int)((num9 * hueMod.Value) / 100000.0);
             if (num9 > num12)
             {
                 num9 = num12;
             }
         }
         if (hueOff.HasValue)
         {
             num9 += (int)((hueOff.Value * num12) / 21600000.0);
             if (num9 > num12)
             {
                 num9 = num12;
             }
             else if (num9 < 0)
             {
                 num9 = 0;
             }
         }
         if (sat.HasValue)
         {
             saturation = (int)((sat.Value * num12) / 1000000.0);
         }
         if (satMod.HasValue)
         {
             saturation = (int)((saturation * satMod.Value) / 100000.0);
             if (saturation > num12)
             {
                 saturation = num12;
             }
         }
         if (satOff.HasValue)
         {
             saturation += (int)((satOff.Value * num12) / 100000.0);
             if (saturation > num12)
             {
                 saturation = num12;
             }
             else if (saturation < 0)
             {
                 saturation = 0;
             }
         }
         if (lum.HasValue)
         {
             luminosity = (int)((lum.Value * num12) / 1000000.0);
         }
         if (lumMod.HasValue)
         {
             luminosity = (int)((luminosity * lumMod.Value) / 100000.0);
             if (luminosity > num12)
             {
                 luminosity = num12;
             }
         }
         if (lumOff.HasValue)
         {
             luminosity += (int)((lumOff.Value * num12) / 100000.0);
             if (luminosity > num12)
             {
                 luminosity = num12;
             }
             else if (luminosity < 0)
             {
                 luminosity = 0;
             }
         }
         color = ColorFromHLS(num9, luminosity, saturation);
     }
     return(color);
 }