コード例 #1
0
        public void Color_GetterReturnsColor_OfSlidePlaceholder()
        {
            // Arrange
            IAutoShape   placeholderCase1 = (IAutoShape)_fixture.Pre001.Slides[2].Shapes.First(sp => sp.Id == 4);
            IAutoShape   placeholderCase2 = (IAutoShape)_fixture.Pre001.Slides[4].Shapes.First(sp => sp.Id == 5);
            IAutoShape   placeholderCase3 = (IAutoShape)_fixture.Pre014.Slides[0].Shapes.First(sp => sp.Id == 61);
            IAutoShape   placeholderCase4 = (IAutoShape)_fixture.Pre014.Slides[5].Shapes.First(sp => sp.Id == 52);
            IAutoShape   placeholderCase5 = (IAutoShape)_fixture.Pre032.Slides[0].Shapes.First(sp => sp.Id == 10242);
            IAutoShape   titlePhCase6     = (IAutoShape)_fixture.Pre034.Slides[0].Shapes.First(sp => sp.Id == 2);
            IAutoShape   titlePhCase7     = (IAutoShape)_fixture.Pre035.Slides[0].Shapes.First(sp => sp.Id == 9);
            IAutoShape   bodyPhCase8      = (IAutoShape)_fixture.Pre036.Slides[0].Shapes.First(sp => sp.Id == 6146);
            IAutoShape   bodyPhCase9      = (IAutoShape)_fixture.Pre037.Slides[0].Shapes.First(sp => sp.Id == 7);
            IColorFormat colorFormatC1    = placeholderCase1.TextBox.Paragraphs[0].Portions[0].Font.ColorFormat;
            IColorFormat colorFormatC2    = placeholderCase2.TextBox.Paragraphs[0].Portions[0].Font.ColorFormat;
            IColorFormat colorFormatC3    = placeholderCase3.TextBox.Paragraphs[0].Portions[0].Font.ColorFormat;
            IColorFormat colorFormatC4    = placeholderCase4.TextBox.Paragraphs[0].Portions[0].Font.ColorFormat;
            IColorFormat colorFormatC5    = placeholderCase5.TextBox.Paragraphs[0].Portions[0].Font.ColorFormat;
            IColorFormat colorFormatC6    = titlePhCase6.TextBox.Paragraphs[0].Portions[0].Font.ColorFormat;
            IColorFormat colorFormatC7    = titlePhCase7.TextBox.Paragraphs[0].Portions[0].Font.ColorFormat;
            IColorFormat colorFormatC8    = bodyPhCase8.TextBox.Paragraphs[0].Portions[0].Font.ColorFormat;
            IColorFormat colorFormatC9    = bodyPhCase9.TextBox.Paragraphs[0].Portions[0].Font.ColorFormat;

            // Act-Assert
            colorFormatC1.Color.Should().Be(ColorTranslator.FromHtml("#000000"));
            colorFormatC2.Color.Should().Be(ColorTranslator.FromHtml("#000000"));
            colorFormatC3.Color.Should().Be(ColorTranslator.FromHtml("#595959"));
            colorFormatC4.Color.Should().Be(ColorTranslator.FromHtml("#FFFFFF"));
            colorFormatC5.Color.Should().Be(ColorTranslator.FromHtml("#0070C0"));
            colorFormatC6.Color.Should().Be(ColorTranslator.FromHtml("#000000"));
            colorFormatC7.Color.Should().Be(ColorTranslator.FromHtml("#000000"));
            colorFormatC8.Color.Should().Be(ColorTranslator.FromHtml("#404040"));
            colorFormatC9.Color.Should().Be(ColorTranslator.FromHtml("#1A1A1A"));
        }
コード例 #2
0
        public void Color_GetterReturnsColor()
        {
            // Arrange
            IAutoShape   nonPhAutoShapeCase1 = (IAutoShape)_fixture.Pre020.Slides[0].Shapes.First(sp => sp.Id == 2);
            IAutoShape   nonPhAutoShapeCase2 = (IAutoShape)_fixture.Pre020.Slides[0].Shapes.First(sp => sp.Id == 3);
            IAutoShape   nonPhAutoShapeCase3 = (IAutoShape)_fixture.Pre020.Slides[2].Shapes.First(sp => sp.Id == 8);
            IAutoShape   nonPhAutoShapeCase4 = (IAutoShape)_fixture.Pre001.Slides[0].Shapes.First(sp => sp.Id == 4);
            IAutoShape   nonPhAutoShapeCase5 = (IAutoShape)_fixture.Pre002.Slides[1].Shapes.First(sp => sp.Id == 3);
            IAutoShape   nonPhAutoShapeCase6 = (IAutoShape)_fixture.Pre026.Slides[0].Shapes.First(sp => sp.Id == 128);
            IAutoShape   nonPhAutoShapeCase7 = (IAutoShape)_fixture.Pre030.Slides[0].Shapes.First(sp => sp.Id == 5);
            IAutoShape   nonPhAutoShapeCase8 = (IAutoShape)_fixture.Pre031.Slides[0].Shapes.First(sp => sp.Id == 44);
            IAutoShape   nonPhAutoShapeCase9 = (IAutoShape)_fixture.Pre033.Slides[0].Shapes.First(sp => sp.Id == 3);
            IColorFormat colorFormatC1       = nonPhAutoShapeCase1.TextBox.Paragraphs[0].Portions[0].Font.ColorFormat;
            IColorFormat colorFormatC2       = nonPhAutoShapeCase2.TextBox.Paragraphs[0].Portions[0].Font.ColorFormat;
            IColorFormat colorFormatC3       = nonPhAutoShapeCase3.TextBox.Paragraphs[1].Portions[0].Font.ColorFormat;
            IColorFormat colorFormatC4       = nonPhAutoShapeCase4.TextBox.Paragraphs[0].Portions[0].Font.ColorFormat;
            IColorFormat colorFormatC5       = nonPhAutoShapeCase5.TextBox.Paragraphs[0].Portions[0].Font.ColorFormat;
            IColorFormat colorFormatC6       = nonPhAutoShapeCase6.TextBox.Paragraphs[0].Portions[0].Font.ColorFormat;
            IColorFormat colorFormatC7       = nonPhAutoShapeCase7.TextBox.Paragraphs[0].Portions[0].Font.ColorFormat;
            IColorFormat colorFormatC8       = nonPhAutoShapeCase8.TextBox.Paragraphs[0].Portions[0].Font.ColorFormat;
            IColorFormat colorFormatC9       = nonPhAutoShapeCase9.TextBox.Paragraphs[0].Portions[0].Font.ColorFormat;

            // Act-Assert
            colorFormatC1.Color.Should().Be(ColorTranslator.FromHtml("#000000"));
            colorFormatC2.Color.Should().Be(ColorTranslator.FromHtml("#000000"));
            colorFormatC3.Color.Should().Be(ColorTranslator.FromHtml("#FFFF00"));
            colorFormatC4.Color.Should().Be(ColorTranslator.FromHtml("#000000"));
            colorFormatC5.Color.Should().Be(ColorTranslator.FromHtml("#000000"));
            colorFormatC6.Color.Should().Be(ColorTranslator.FromHtml("#000000"));
            colorFormatC7.Color.Should().Be(ColorTranslator.FromHtml("#000000"));
            colorFormatC8.Color.Should().Be(ColorTranslator.FromHtml("#000000"));
            colorFormatC9.Color.Should().Be(ColorTranslator.FromHtml("#000000"));
        }
コード例 #3
0
        public void Color_GetterReturnsColor_OfSlideLayoutPlaceholder()
        {
            // Arrange
            IAutoShape   titlePh     = (IAutoShape)_fixture.Pre001.Slides[0].ParentSlideLayout.Shapes.First(sp => sp.Id == 2);
            IColorFormat colorFormat = titlePh.TextBox.Paragraphs[0].Portions[0].Font.ColorFormat;

            // Act-Assert
            colorFormat.Color.Should().Be(ColorTranslator.FromHtml("#000000"));
        }
コード例 #4
0
        public void Color_GetterReturnsWhiteColor_WhenFontHasPredefinedWhiteColor()
        {
            // Arrange
            IAutoShape   nonPhAutoShapeCase = (IAutoShape)_fixture.Pre020.Slides[0].Shapes.First(sp => sp.Id == 4);
            IColorFormat colorFormat        = nonPhAutoShapeCase.TextBox.Paragraphs[0].Portions[0].Font.ColorFormat;

            // Act-Assert
            colorFormat.Color.Should().Be(Color.White);
        }
コード例 #5
0
        public void Color_GetterReturnsColor_OfTableCellOnSlide()
        {
            // Arrange
            Color        redColor    = ColorTranslator.FromHtml("#FF0000");
            ITable       table       = (ITable)_fixture.Pre001.Slides[1].Shapes.First(sp => sp.Id == 4);
            IColorFormat colorFormat = table.Rows[0].Cells[0].TextBox.Paragraphs[0].Portions[0].Font.ColorFormat;

            // Act-Assert
            colorFormat.Color.Should().Be(redColor);
        }
コード例 #6
0
        public void Color_GetterReturnsColor_OfTitlePlaceholderOnSlideMaster()
        {
            // Arrange
            Color        blackColor       = ColorTranslator.FromHtml("#000000");
            IAutoShape   titlePlaceholder = (IAutoShape)_fixture.Pre001.SlideMasters[0].Shapes.First(sp => sp.Id == 2);
            IColorFormat colorFormat      = titlePlaceholder.TextBox.Paragraphs[0].Portions[0].Font.ColorFormat;

            // Act-Assert
            colorFormat.Color.Should().Be(blackColor);
        }
コード例 #7
0
        public void Color_GetterReturnsColor_OfSlideMasterNonPlaceholder()
        {
            // Arrange
            Color        whiteColor     = ColorTranslator.FromHtml("#FFFFFF");
            IAutoShape   nonPlaceholder = (IAutoShape)_fixture.Pre001.SlideMasters[0].Shapes.First(sp => sp.Id == 8);
            IColorFormat colorFormat    = nonPlaceholder.TextBox.Paragraphs[0].Portions[0].Font.ColorFormat;

            // Act-Assert
            colorFormat.Color.Should().Be(whiteColor);
        }
コード例 #8
0
        public void ColorType_ReturnsSchemeColorType_WhenFontColorIsSetAsRGB()
        {
            // Arrange
            IAutoShape   placeholder = (IAutoShape)_fixture.Pre014.Slides[5].Shapes.First(sp => sp.Id == 52);
            IColorFormat colorFormat = placeholder.TextBox.Paragraphs[0].Portions[0].Font.ColorFormat;

            // Act
            SCColorType colorType = colorFormat.ColorType;

            // Assert
            colorType.Should().Be(SCColorType.RGB);
        }
コード例 #9
0
        public void ColorType_ReturnsSchemeColorType_WhenFontColorIsTakenFromThemeScheme()
        {
            // Arrange
            IAutoShape   nonPhAutoShape = (IAutoShape)_fixture.Pre020.Slides[0].Shapes.First(sp => sp.Id == 2);
            IColorFormat colorFormat    = nonPhAutoShape.TextBox.Paragraphs[0].Portions[0].Font.ColorFormat;

            // Act
            SCColorType colorType = colorFormat.ColorType;

            // Assert
            colorType.Should().Be(SCColorType.Scheme);
        }
コード例 #10
0
        private static string GetDestinationColor(IShape shape, IColorFormat colorFormat)
        {
            var cloneShape = shape.Slide.Shapes.AddClone(shape);

            cloneShape.FillFormat.FillType = FillType.Solid;
            cloneShape.FillFormat.SolidFillColor.CopyFrom(colorFormat);

            Color effectiveColor = cloneShape.FillFormat.GetEffective().SolidFillColor;

            shape.Slide.Shapes.Remove(cloneShape);

            return("rgb(" + effectiveColor.R + "," + effectiveColor.G + "," + effectiveColor.B + ")");
        }
コード例 #11
0
        public void Color_SetterSetsGreenColorForFont_WhenGreenIsSpecified(SCPresentation presentation, SlideElementQuery portionQuery)
        {
            // Arrange
            Color        greenColor  = ColorTranslator.FromHtml("#008000");
            MemoryStream mStream     = new ();
            IColorFormat colorFormat = TestHelper.GetParagraphPortion(presentation, portionQuery).Font.ColorFormat;

            // Act
            colorFormat.Color = greenColor;

            // Assert
            colorFormat.Color.Should().Be(greenColor);

            presentation.SaveAs(mStream);
            presentation = SCPresentation.Open(mStream, false);
            colorFormat  = TestHelper.GetParagraphPortion(presentation, portionQuery).Font.ColorFormat;
            colorFormat.Color.Should().Be(greenColor);
        }
コード例 #12
0
        /// <summary>
        /// Reads a sequence of bytes that represents the image pixel data
        /// </summary>
        /// <param name="format">The format of the image data</param>
        /// <param name="width">The image width</param>
        /// <param name="height">The image height</param>
        /// <returns></returns>
        protected uint[] ReadImageData(ImageFormat format, int width, int height, BinaryReader reader)
        {
            if (!_colorFormats.ContainsKey(format))
            {
                throw new InvalidOperationException($"{format} is currently not supported");
            }
            IColorFormat colorFormat = _colorFormats[format];

            if (format == ImageFormat.RGB332)
            {
                // The data is stored as bytes
                return(reader.ReadBytes(width * height)
                       .Select(pixel => colorFormat.ToRGBA((ushort)pixel))
                       .ToArray());
            }
            else
            {
                // The data is stored as UInt16 values
                return(reader.ReadAsUInt16Array(width * height)
                       .Select(pixel => colorFormat.ToRGBA(pixel))
                       .ToArray());
            }
        }
コード例 #13
0
        private static int FillSequenceEffectCollection(ISequence sequence, Dictionary <IShape, Tuple <string, string, float, float, string, string, int> > shapeEffectsCollection, int onclickIndex)
        {
            float prevDelay       = 0;
            float maxPrevDuration = 0;

            foreach (var effect in sequence)
            {
                var shape       = effect.TargetShape;
                var classType   = effect.PresetClassType;
                var type        = effect.Type;
                var subType     = effect.Subtype;
                var triggerType = effect.Timing.TriggerType;

                var delay = effect.Timing.TriggerDelayTime;

                string targetShapeId = "";

                IColorFormat toColor  = null;
                string       extra    = null;
                float        duration = 0;
                foreach (var behavior in effect.Behaviors)
                {
                    if (behavior.GetType() == typeof(ColorEffect))
                    {
                        toColor = ((ColorEffect)behavior).To;
                    }

                    if (behavior.GetType() == typeof(SetEffect) && ((SetEffect)behavior).To is IColorFormat)
                    {
                        toColor  = (IColorFormat)((SetEffect)behavior).To;
                        duration = behavior.Timing.Duration;
                        break;
                    }

                    if (type == EffectType.Wave && behavior.GetType() == typeof(MotionEffect))
                    {
                        extra = ((MotionEffect)behavior).RotationCenter.ToString();
                    }

                    if (type == EffectType.Transparency && behavior.GetType() == typeof(SetEffect))
                    {
                        extra = ((SetEffect)behavior).To.ToString();
                    }

                    if (type == EffectType.Spin && behavior.GetType() == typeof(RotationEffect))
                    {
                        extra = ((RotationEffect)behavior).By.ToString();
                    }

                    if (type == EffectType.GrowShrink && behavior.GetType() == typeof(ScaleEffect))
                    {
                        extra = ((ScaleEffect)behavior).By.ToString();
                    }

                    if (behavior.GetType() == typeof(PropertyEffect) ||
                        behavior.GetType() == typeof(FilterEffect) ||
                        behavior.GetType() == typeof(RotationEffect) ||
                        behavior.GetType() == typeof(ScaleEffect) ||
                        behavior.GetType() == typeof(ColorEffect))
                    {
                        if (type == EffectType.CenterRevolve || type == EffectType.Bounce || type == EffectType.Teeter || type == EffectType.Flicker || type == EffectType.Wave) // a crutch...
                        {
                            duration += behavior.Timing.Duration;
                        }
                        else
                        {
                            duration = behavior.Timing.Duration;
                            break;
                        }
                    }
                }

                if (float.IsInfinity(duration))
                {
                    duration = 0.5f;
                }

                if (type == EffectType.CenterRevolve || type == EffectType.Bounce) // a crutch...
                {
                    duration /= 2;
                }

                if (triggerType == EffectTriggerType.AfterPrevious)
                {
                    prevDelay      += maxPrevDuration;
                    maxPrevDuration = delay + duration;
                }
                else if (triggerType == EffectTriggerType.WithPrevious)
                {
                    maxPrevDuration = Math.Max(maxPrevDuration, delay + duration);
                }
                else // OnClick
                {
                    onclickIndex++;
                    prevDelay       = 0;
                    maxPrevDuration = delay + duration;
                }

                if (sequence.TriggerShape != null)
                {
                    targetShapeId = "slide-" + sequence.TriggerShape.Slide.SlideId + "-shape-" + sequence.TriggerShape.UniqueId;
                }
                else
                {
                    targetShapeId = "slide";
                }

                float totalDelay = delay + prevDelay;

                if (toColor != null && toColor.ColorType != ColorType.NotDefined)
                {
                    extra = GetDestinationColor(shape, toColor);
                }

                if (!shapeEffectsCollection.ContainsKey(shape))
                {
                    shapeEffectsCollection.Add(shape, new Tuple <string, string, float, float, string, string, int>(classType.ToString() + type.ToString(), subType.ToString(), duration, totalDelay, targetShapeId, extra, onclickIndex));
                }
            }

            return(onclickIndex);
        }