Exemple #1
0
        public static xdr.ShapeProperties SetSolidFill(this xdr.ShapeProperties shapeProperties, sysDr.Color fillColor, float alpha = 1f)
        {
            if (shapeProperties == null)
            {
                return(null);
            }
            shapeProperties.RemoveAllChildren <a.NoFill>();
            shapeProperties.RemoveAllChildren <a.GradientFill>();
            shapeProperties.RemoveAllChildren <a.BlipFill>();
            shapeProperties.RemoveAllChildren <a.GroupFill>();
            shapeProperties.RemoveAllChildren <a.SolidFill>();
            var solidFill = new a.SolidFill();

            shapeProperties.Insert(solidFill).AfterOneOf(typeof(a.PresetGeometry));
            var fillColorModel = new a.RgbColorModelHex();

            fillColorModel.Val = fillColor.ToHex();
            solidFill.Append(fillColorModel);
            var colorAlpha = new a.Alpha()
            {
                Val = (int)(alpha * 100000)
            };                                                              // FillAlpha - def = val / 1000

            fillColorModel.Append(colorAlpha);
            return(shapeProperties);
        }
        public static xdr.ShapeProperties RemoveFill(this xdr.ShapeProperties shapeProperties)
        {
            if (shapeProperties == null)
            {
                return(null);
            }
            shapeProperties.RemoveAllChildren <a.SolidFill>();
            shapeProperties.RemoveAllChildren <a.GradientFill>();
            shapeProperties.RemoveAllChildren <a.BlipFill>();
            shapeProperties.RemoveAllChildren <a.GroupFill>();
            var noFillProp = shapeProperties.GetFirstChild <a.NoFill>();

            if (noFillProp == null)
            {
                noFillProp = new a.NoFill();
                shapeProperties.Insert(noFillProp).AfterOneOf(typeof(a.PresetGeometry));
            }
            return(shapeProperties);
        }