/// <summary>
 /// Creates a new
 /// <see cref="HtmlBackgroundImage"/>
 /// instance.
 /// </summary>
 /// <param name="xObject">
 /// background-image property.
 /// <see cref="iText.Kernel.Pdf.Xobject.PdfImageXObject"/>
 /// instance.
 /// </param>
 /// <param name="repeat">
 /// background-repeat property.
 /// <see cref="iText.Layout.Properties.BackgroundRepeat"/>
 /// instance.
 /// </param>
 /// <param name="position">
 /// background-position property.
 /// <see cref="iText.Layout.Properties.BackgroundPosition"/>
 /// instance.
 /// </param>
 /// <param name="blendMode">
 /// background-blend-mode property.
 /// <see cref="iText.Layout.Properties.BlendMode"/>
 /// instance.
 /// </param>
 /// <param name="clip">
 /// background-clip property.
 /// <see cref="iText.Layout.Properties.BackgroundBox"/>
 /// instance.
 /// </param>
 /// <param name="origin">
 /// background-origin property.
 /// <see cref="iText.Layout.Properties.BackgroundBox"/>
 /// instance.
 /// </param>
 public HtmlBackgroundImage(PdfImageXObject xObject, BackgroundRepeat repeat, BackgroundPosition position,
                            BlendMode blendMode, BackgroundBox clip, BackgroundBox origin)
     : base(new BackgroundImage.Builder().SetImage(xObject).SetBackgroundRepeat(repeat).SetBackgroundPosition(position
                                                                                                              ).SetBackgroundBlendMode(blendMode).SetBackgroundClip(clip).SetBackgroundOrigin(origin).Build())
 {
     dimensionMultiplier = PX_TO_PT_MULTIPLIER;
 }
Пример #2
0
        void ReleaseDesignerOutlets()
        {
            if (BoxFour != null)
            {
                BoxFour.Dispose();
                BoxFour = null;
            }

            if (BoxOne != null)
            {
                BoxOne.Dispose();
                BoxOne = null;
            }

            if (BoxThree != null)
            {
                BoxThree.Dispose();
                BoxThree = null;
            }

            if (BoxTwo != null)
            {
                BoxTwo.Dispose();
                BoxTwo = null;
            }

            if (BackgroundBox != null)
            {
                BackgroundBox.Dispose();
                BackgroundBox = null;
            }
        }
Пример #3
0
        public void ClearSongControls()
        {
            UniqueIdBox.Text = "(No song selected)";
            TitleBox.Clear();
            SubtitleBox.Clear();

            BackgroundBox.Clear();

            ComposerBox.Clear();
            ArrangerBox.Clear();
            CopyrightBox.Clear();
            LicenseBox.Clear();
            MadeFamousByBox.Clear();

            DifficultyBox.Value = 0;
            RatingBox.Value     = 0;

            FingerHintBox.Clear();
            HandsBox.Clear();

            TagBox.Clear();
            TagList.Items.Clear();

            BookmarkMeasureBox.Value = 1;
            BookmarkDescriptionBox.Clear();
            BookmarkList.Items.Clear();

            PropertiesGroup.Enabled = false;
        }
        void ReleaseDesignerOutlets()
        {
            if (BackgroundBox != null)
            {
                BackgroundBox.Dispose();
                BackgroundBox = null;
            }

            if (BeatCodeScroller != null)
            {
                BeatCodeScroller.Dispose();
                BeatCodeScroller = null;
            }

            if (SoundSourceSelector != null)
            {
                SoundSourceSelector.Dispose();
                SoundSourceSelector = null;
            }

            if (BeatCodeInput != null)
            {
                BeatCodeInput.Dispose();
                BeatCodeInput = null;
            }
        }
        public virtual void BackgroundConstructorWithClipTest()
        {
            DeviceRgb     deviceRgbColor = new DeviceRgb();
            float         opacity        = 10f;
            BackgroundBox backgroundClip = BackgroundBox.BORDER_BOX;
            Background    background     = new Background(deviceRgbColor, opacity, backgroundClip);

            NUnit.Framework.Assert.AreEqual(deviceRgbColor, background.GetColor());
            NUnit.Framework.Assert.AreEqual(opacity, background.GetOpacity(), EPS);
            NUnit.Framework.Assert.AreEqual(backgroundClip, background.GetBackgroundClip());
        }
 private static bool ApplyLinearGradient(String image, IList <BackgroundImage> backgroundImagesList, BlendMode
                                         blendMode, BackgroundPosition position, float em, float rem, BackgroundRepeat repeat, BackgroundBox clip
                                         , BackgroundBox origin)
 {
     try {
         StrategyBasedLinearGradientBuilder gradientBuilder = CssGradientUtil.ParseCssLinearGradient(image, em, rem
                                                                                                     );
         if (gradientBuilder != null)
         {
             backgroundImagesList.Add(new BackgroundImage.Builder().SetLinearGradientBuilder(gradientBuilder).SetBackgroundBlendMode
                                          (blendMode).SetBackgroundPosition(position).SetBackgroundRepeat(repeat).SetBackgroundClip(clip).SetBackgroundOrigin
                                          (origin).Build());
             return(true);
         }
     }
     catch (StyledXMLParserException) {
         LOGGER.Warn(MessageFormatUtil.Format(iText.Html2pdf.LogMessageConstant.INVALID_GRADIENT_DECLARATION, image
                                              ));
     }
     return(false);
 }
Пример #7
0
 /// <summary>
 /// Creates a new
 /// <see cref="BackgroundImage"/>
 /// instance.
 /// </summary>
 /// <param name="image">
 /// background-image property.
 /// <see cref="iText.Kernel.Pdf.Xobject.PdfXObject"/>
 /// instance.
 /// </param>
 /// <param name="repeat">
 /// background-repeat property.
 /// <see cref="BackgroundRepeat"/>
 /// instance.
 /// </param>
 /// <param name="position">
 /// background-position property.
 /// <see cref="BackgroundPosition"/>
 /// instance.
 /// </param>
 /// <param name="backgroundSize">
 /// background-size property.
 /// <see cref="BackgroundSize"/>
 /// instance.
 /// </param>
 /// <param name="linearGradientBuilder">
 /// background-image property.
 /// <see cref="iText.Kernel.Colors.Gradients.AbstractLinearGradientBuilder"/>
 /// instance.
 /// </param>
 /// <param name="blendMode">
 /// the image's blend mode.
 /// <see cref="BlendMode"/>
 /// instance.
 /// </param>
 /// <param name="clip">
 /// background-clip property.
 /// <see cref="BackgroundBox"/>
 /// instance.
 /// </param>
 /// <param name="origin">
 /// background-origin property.
 /// <see cref="BackgroundBox"/>
 /// instance.
 /// </param>
 private BackgroundImage(PdfXObject image, BackgroundRepeat repeat, BackgroundPosition position, BackgroundSize
                         backgroundSize, AbstractLinearGradientBuilder linearGradientBuilder, BlendMode blendMode, BackgroundBox
                         clip, BackgroundBox origin)
 {
     this.image = image;
     if (repeat != null)
     {
         this.repeatX = !repeat.IsNoRepeatOnXAxis();
         this.repeatY = !repeat.IsNoRepeatOnYAxis();
     }
     this.repeat                = repeat;
     this.position              = position;
     this.backgroundSize        = backgroundSize;
     this.linearGradientBuilder = linearGradientBuilder;
     if (blendMode != null)
     {
         this.blendMode = blendMode;
     }
     this.backgroundClip   = clip;
     this.backgroundOrigin = origin;
 }
        private static IList <BackgroundImage> GetBackgroundImagesList(IList <String> backgroundImagesArray, ProcessorContext
                                                                       context, float em, float rem, IList <String> backgroundPositionXArray, IList <String> backgroundPositionYArray
                                                                       , IList <IList <String> > backgroundSizeArray, IList <String> backgroundBlendModeArray, IList <String> backgroundRepeatArray
                                                                       , IList <String> backgroundClipArray, IList <String> backgroundOriginArray)
        {
            IList <BackgroundImage> backgroundImagesList = new List <BackgroundImage>();

            for (int i = 0; i < backgroundImagesArray.Count; ++i)
            {
                String backgroundImage = backgroundImagesArray[i];
                if (backgroundImage == null || CssConstants.NONE.Equals(backgroundImage))
                {
                    continue;
                }
                BackgroundPosition position = ApplyBackgroundPosition(backgroundPositionXArray, backgroundPositionYArray,
                                                                      i, em, rem);
                BlendMode        blendMode    = ApplyBackgroundBlendMode(backgroundBlendModeArray, i);
                bool             imageApplied = false;
                BackgroundRepeat repeat       = ApplyBackgroundRepeat(backgroundRepeatArray, i);
                BackgroundBox    clip         = GetBackgroundBoxProperty(backgroundClipArray, i, BackgroundBox.BORDER_BOX);
                BackgroundBox    origin       = GetBackgroundBoxProperty(backgroundOriginArray, i, BackgroundBox.PADDING_BOX);
                if (CssGradientUtil.IsCssLinearGradientValue(backgroundImage))
                {
                    imageApplied = ApplyLinearGradient(backgroundImage, backgroundImagesList, blendMode, position, em, rem, repeat
                                                       , clip, origin);
                }
                else
                {
                    PdfXObject image = context.GetResourceResolver().RetrieveImageExtended(CssUtils.ExtractUrl(backgroundImage
                                                                                                               ));
                    imageApplied = ApplyBackgroundImage(image, backgroundImagesList, repeat, blendMode, position, clip, origin
                                                        );
                }
                if (imageApplied)
                {
                    ApplyBackgroundSize(backgroundSizeArray, em, rem, i, backgroundImagesList[backgroundImagesList.Count - 1]);
                }
            }
            return(backgroundImagesList);
        }
        /// <summary>Applies background to an element.</summary>
        /// <param name="cssProps">the CSS properties</param>
        /// <param name="context">the processor context</param>
        /// <param name="element">the element</param>
        public static void ApplyBackground(IDictionary <String, String> cssProps, ProcessorContext context, IPropertyContainer
                                           element)
        {
            String                  backgroundColorStr     = cssProps.Get(CssConstants.BACKGROUND_COLOR);
            String                  backgroundImagesStr    = cssProps.Get(CssConstants.BACKGROUND_IMAGE);
            String                  backgroundRepeatStr    = cssProps.Get(CssConstants.BACKGROUND_REPEAT);
            String                  backgroundSizeStr      = cssProps.Get(CssConstants.BACKGROUND_SIZE);
            String                  backgroundPositionXStr = cssProps.Get(CssConstants.BACKGROUND_POSITION_X);
            String                  backgroundPositionYStr = cssProps.Get(CssConstants.BACKGROUND_POSITION_Y);
            String                  backgroundBlendModeStr = cssProps.Get(CssConstants.BACKGROUND_BLEND_MODE);
            String                  backgroundClipStr      = cssProps.Get(CssConstants.BACKGROUND_CLIP);
            String                  backgroundOriginStr    = cssProps.Get(CssConstants.BACKGROUND_ORIGIN);
            IList <String>          backgroundImagesArray  = CssUtils.SplitStringWithComma(backgroundImagesStr);
            IList <String>          backgroundRepeatArray  = CssUtils.SplitStringWithComma(backgroundRepeatStr);
            IList <IList <String> > backgroundSizeArray    = backgroundSizeStr == null ? null : CssUtils.ExtractShorthandProperties
                                                                 (backgroundSizeStr);
            IList <String> backgroundPositionXArray = CssUtils.SplitStringWithComma(backgroundPositionXStr);
            IList <String> backgroundPositionYArray = CssUtils.SplitStringWithComma(backgroundPositionYStr);
            IList <String> backgroundBlendModeArray = CssUtils.SplitStringWithComma(backgroundBlendModeStr);
            String         fontSize              = cssProps.Get(CssConstants.FONT_SIZE);
            float          em                    = fontSize == null ? 0 : CssDimensionParsingUtils.ParseAbsoluteLength(fontSize);
            float          rem                   = context.GetCssContext().GetRootFontSize();
            IList <String> backgroundClipArray   = CssUtils.SplitStringWithComma(backgroundClipStr);
            IList <String> backgroundOriginArray = CssUtils.SplitStringWithComma(backgroundOriginStr);
            BackgroundBox  clipForColor          = GetBackgroundBoxProperty(backgroundClipArray, backgroundImagesArray.IsEmpty()
                 ? 0 : (backgroundImagesArray.Count - 1), BackgroundBox.BORDER_BOX);

            ApplyBackgroundColor(backgroundColorStr, element, clipForColor);
            IList <BackgroundImage> backgroundImagesList = GetBackgroundImagesList(backgroundImagesArray, context, em,
                                                                                   rem, backgroundPositionXArray, backgroundPositionYArray, backgroundSizeArray, backgroundBlendModeArray
                                                                                   , backgroundRepeatArray, backgroundClipArray, backgroundOriginArray);

            if (!backgroundImagesList.IsEmpty())
            {
                element.SetProperty(Property.BACKGROUND_IMAGE, backgroundImagesList);
            }
        }
 /// <summary>
 /// Creates a new
 /// <see cref="HtmlBackgroundImage"/>
 /// instance.
 /// </summary>
 /// <param name="xObject">
 /// background-image property.
 /// <see cref="iText.Kernel.Pdf.Xobject.PdfFormXObject"/>
 /// instance.
 /// </param>
 /// <param name="repeat">
 /// background-repeat property.
 /// <see cref="iText.Layout.Properties.BackgroundRepeat"/>
 /// instance.
 /// </param>
 /// <param name="position">
 /// background-position property.
 /// <see cref="iText.Layout.Properties.BackgroundPosition"/>
 /// instance.
 /// </param>
 /// <param name="blendMode">
 /// background-blend-mode property.
 /// <see cref="iText.Layout.Properties.BlendMode"/>
 /// instance.
 /// </param>
 /// <param name="clip">
 /// background-clip property.
 /// <see cref="iText.Layout.Properties.BackgroundBox"/>
 /// instance.
 /// </param>
 /// <param name="origin">
 /// background-origin property.
 /// <see cref="iText.Layout.Properties.BackgroundBox"/>
 /// instance.
 /// </param>
 public HtmlBackgroundImage(PdfFormXObject xObject, BackgroundRepeat repeat, BackgroundPosition position, BlendMode
                            blendMode, BackgroundBox clip, BackgroundBox origin)
     : base(new BackgroundImage.Builder().SetImage(xObject).SetBackgroundRepeat(repeat).SetBackgroundPosition(position
                                                                                                              ).SetBackgroundBlendMode(blendMode).SetBackgroundClip(clip).SetBackgroundOrigin(origin).Build())
 {
 }
 private static bool ApplyBackgroundImage(PdfXObject image, IList <BackgroundImage> backgroundImagesList, BackgroundRepeat
                                          repeat, BlendMode backgroundBlendMode, BackgroundPosition position, BackgroundBox clip, BackgroundBox
                                          origin)
 {
     if (image == null)
     {
         return(false);
     }
     if (image is PdfImageXObject)
     {
         backgroundImagesList.Add(new BackgroundApplierUtil.HtmlBackgroundImage((PdfImageXObject)image, repeat, position
                                                                                , backgroundBlendMode, clip, origin));
         return(true);
     }
     else
     {
         if (image is PdfFormXObject)
         {
             backgroundImagesList.Add(new BackgroundApplierUtil.HtmlBackgroundImage((PdfFormXObject)image, repeat, position
                                                                                    , backgroundBlendMode, clip, origin));
             return(true);
         }
         else
         {
             throw new InvalidOperationException();
         }
     }
 }
 private static void ApplyBackgroundColor(String backgroundColorStr, IPropertyContainer element, BackgroundBox
                                          clip)
 {
     if (backgroundColorStr != null && !CssConstants.TRANSPARENT.Equals(backgroundColorStr))
     {
         float[]    rgbaColor       = CssDimensionParsingUtils.ParseRgbaColor(backgroundColorStr);
         Color      color           = new DeviceRgb(rgbaColor[0], rgbaColor[1], rgbaColor[2]);
         float      opacity         = rgbaColor[3];
         Background backgroundColor = new Background(color, opacity, clip);
         element.SetProperty(Property.BACKGROUND, backgroundColor);
     }
 }
        void ReleaseDesignerOutlets()
        {
            if (AddTagButton != null)
            {
                AddTagButton.Dispose();
                AddTagButton = null;
            }

            if (ArrangerBox != null)
            {
                ArrangerBox.Dispose();
                ArrangerBox = null;
            }

            if (BackgroundBox != null)
            {
                BackgroundBox.Dispose();
                BackgroundBox = null;
            }

            if (BookmarkLabelBox != null)
            {
                BookmarkLabelBox.Dispose();
                BookmarkLabelBox = null;
            }

            if (BookmarkList != null)
            {
                BookmarkList.Dispose();
                BookmarkList = null;
            }

            if (BookmarkMeasureBox != null)
            {
                BookmarkMeasureBox.Dispose();
                BookmarkMeasureBox = null;
            }

            if (ComposerBox != null)
            {
                ComposerBox.Dispose();
                ComposerBox = null;
            }

            if (CopyrightBox != null)
            {
                CopyrightBox.Dispose();
                CopyrightBox = null;
            }

            if (DifficultyBox != null)
            {
                DifficultyBox.Dispose();
                DifficultyBox = null;
            }

            if (FingerHintBox != null)
            {
                FingerHintBox.Dispose();
                FingerHintBox = null;
            }

            if (HandsBox != null)
            {
                HandsBox.Dispose();
                HandsBox = null;
            }

            if (LicenseBox != null)
            {
                LicenseBox.Dispose();
                LicenseBox = null;
            }

            if (MadeFamousByBox != null)
            {
                MadeFamousByBox.Dispose();
                MadeFamousByBox = null;
            }

            if (PartsBox != null)
            {
                PartsBox.Dispose();
                PartsBox = null;
            }

            if (PropertiesGroup != null)
            {
                PropertiesGroup.Dispose();
                PropertiesGroup = null;
            }

            if (RatingBox != null)
            {
                RatingBox.Dispose();
                RatingBox = null;
            }

            if (RemoveBookmarkButton != null)
            {
                RemoveBookmarkButton.Dispose();
                RemoveBookmarkButton = null;
            }

            if (RemoveTagButton != null)
            {
                RemoveTagButton.Dispose();
                RemoveTagButton = null;
            }

            if (RetargetButton != null)
            {
                RetargetButton.Dispose();
                RetargetButton = null;
            }

            if (SongList != null)
            {
                SongList.Dispose();
                SongList = null;
            }

            if (SubtitleBox != null)
            {
                SubtitleBox.Dispose();
                SubtitleBox = null;
            }

            if (TagBox != null)
            {
                TagBox.Dispose();
                TagBox = null;
            }

            if (TagList != null)
            {
                TagList.Dispose();
                TagList = null;
            }

            if (TitleBox != null)
            {
                TitleBox.Dispose();
                TitleBox = null;
            }

            if (UniqueIdBox != null)
            {
                UniqueIdBox.Dispose();
                UniqueIdBox = null;
            }
        }
Пример #14
0
 /// <summary>Sets background-origin.</summary>
 /// <param name="origin">
 ///
 /// <see cref="BackgroundBox"/>
 /// to be set.
 /// </param>
 /// <returns>
 /// this
 /// <see cref="Builder"/>.
 /// </returns>
 public virtual BackgroundImage.Builder SetBackgroundOrigin(BackgroundBox origin)
 {
     this.origin = origin;
     return(this);
 }
Пример #15
0
 /// <summary>Sets background-clip.</summary>
 /// <param name="clip">
 ///
 /// <see cref="BackgroundBox"/>
 /// to be set.
 /// </param>
 /// <returns>
 /// this
 /// <see cref="Builder"/>.
 /// </returns>
 public virtual BackgroundImage.Builder SetBackgroundClip(BackgroundBox clip)
 {
     this.clip = clip;
     return(this);
 }
        private static BackgroundBox GetBackgroundBoxProperty(IList <String> propertyArray, int iteration, BackgroundBox
                                                              defaultValue)
        {
            int index = GetBackgroundSidePropertyIndex(propertyArray.Count, iteration);

            if (index == -1)
            {
                return(defaultValue);
            }
            else
            {
                return(GetBackgroundBoxPropertyByString(propertyArray[index]));
            }
        }
Пример #17
0
 protected override Drawable CreateBackground() => background = new BackgroundBox();
Пример #18
0
 /// <summary>Creates a background with a specified color, opacity and clip value.</summary>
 /// <param name="color">the background color</param>
 /// <param name="opacity">
 /// the opacity of the background color; a float between 0 and 1, where 1 stands for fully opaque
 /// color and 0 - for fully transparent
 /// </param>
 /// <param name="clip">the value to clip the background color</param>
 public Background(Color color, float opacity, BackgroundBox clip)
     : this(color, opacity)
 {
     this.backgroundClip = clip;
 }