Using SVGs in IconSet

Posted by: kbj on 31 January 2021, 5:54 am EST

  • Posted 31 January 2021, 5:54 am EST

    Some svgs render perfectly in a RibbonButton icon set and some do not. In the included example, both svg resources render properly in InkScape, but only the svgSnapshot works in an IconSet.

    -Kingman

    RibbonIconSetProblem.zip

  • Posted 31 January 2021, 6:11 pm EST

    Hi,

    We have escalated this issue to the developers and will let you know when we have an update. [Internal Tracking Id: 24279]

    In the meantime, you can use the modified SVG attached.

    blank-page.svg.zip

    Regards,

    Prabhat Sharma.

  • Posted 1 February 2021, 2:11 am EST

    Hi Prabhat,

    I have hundreds of svg icons which I convert to images used to create C1BitmapIcon objects which are then added into the RibbonButtons.IconSet. This is not ideal since monochrome C1PathIcons automatically change color based on the C1Theme selected which is a GREAT feature. Is there a way to have C1BitmapIcons automatically change color? I have tried drawing them with Color.Transparent, but that doesn’t work.

    Also, could you find out what theme color is used to repaint C1PathIcons for RibbonButtons on a ribbon menu based on the theme? I use “C1Ribbon365\Form\Buttons\Default\GlyphColor” but I don’t think that is exactly right.

    I tried the following code to simplify the svg data (based on your changes to the blank-page.svg), and it worked for some but not all cases.

        Private Function kludgeFixSvg(resource As String) As String
            'strip out elements and properties that confuse the C1 icon renderer
            Dim xdocResource = XDocument.Parse(resource)
            Dim ns = xdocResource.Root.GetDefaultNamespace
            Dim xeIn = xdocResource.Element(ns + "svg")
            Dim xeOut = New XElement("svg")
            xeOut.Add(xeIn.Attribute("height"))
            xeOut.Add(xeIn.Attribute("width"))
            xeOut.Add(xeIn.Attribute("viewBox"))
            For Each xeInG In xeIn.Elements(ns + "g")
                Dim xeInPaths = xeInG.Elements(ns + "path")
                If xeInPaths.Count > 0 Then
                    Dim xeOutG = New XElement("g")
                    For Each xeInPath In xeInPaths
                        xeOutG.Add(New XElement("path", xeInPath.Attributes("d")))
                    Next
                    xeOut.Add(xeOutG)
                End If
            Next
            Dim resourceOut As String = xeOut.ToString
            Return resourceOut
        End Function
    

    Here is an example of a simple svg file that will not render:svgNew.zip

  • Posted 2 February 2021, 7:54 pm EST

    Hi,

    You cannot automatically change the color of BitmapIcon but you can use the SVGs as C1PathIcon with a Color set as Color.Transparent which works fine at our end, please refer to the sample attached.

    >> I tried the following code to simplify the svg data (based on your changes to the blank-page.svg), and it worked for some but not all cases.

    We have escalated this issue as mentioned in the previous reply and adding this information for the developers. We will let you know when we have an update. Till then you can try to validate your SVG files online for errors and try after removing the errors.

    >>This is not ideal since monochrome C1PathIcons automatically change color based on the C1Theme selected which is a GREAT feature. Is there a way to have C1BitmapIcons automatically change color? Also, could you find out what theme color is used to repaint C1PathIcons for RibbonButtons on a ribbon menu based on the theme? I use “C1Ribbon365\Form\Buttons\Default\GlyphColor” but I don’t think that is exactly right.

    We are discussing this with the developers and will let you know once we get an update on this.[ Internal Tracking Id: 24315]

    Regards,

    Prabhat Sharma.

    RibbonIconSetProblem.zip

  • Posted 3 February 2021, 2:38 am EST

    re “validate your SVG files online”.

    Where can I validate my svg files online?

    The files that don’t render as C1PathIcons render fine in Inkscape and any browser I send them to (eg. svgNew.svg in my last post. It would be helpful to know what elements or properties cause your renderer to fail.

    -Kingman

  • Posted 3 February 2021, 9:47 pm EST

    Hi Kingman,

    It seems to be internal reason that some svg files are not working properly.

    You can use some third party link to validate the file, like we have used the given link:

    https://validator.w3.org/check

    By checking your initial file blank-page.svg with this link, it is giving error but svgNew.svg is not giving any error so I request you to please wait untill we get any update from the developers side.

    Regards,

    Prabhat Sharma.

  • Posted 21 February 2021, 2:01 pm EST

    Hello,

    As per the developers: “C1PathIcon it’s not an SVG icon, it’s one Path icon. This icon can work with the content of “d” attribute from Path tag only.”

    If you want several paths in one icon you can use CompositeIcon, like this sample: https://www.grapecity.com/samples/c1icondemo

    Then please let us know, we will raise an enhancement request for this.

    Regards,

    Prabhat Sharma.

  • Posted 22 February 2021, 12:51 am EST

    Hi Prabhat,

    Please do request that the developers create the C1SVGIcon that would create an icon from a svg file. This would be very helpful as programmers will often obtain their icons from sources like FlatIcon.com. Since these images are vector based, resizing them is very simple. And since variable screen dpi settings are now the norm, icons in the ribbon do vary accordingly.

    The developers can find an excellent Git Hub entry https://github.com/svg-net/SVG that I use to translate svg files on the fly.

    The main utility I am looking for is how a themed ribbon automatically (and very quickly) recolors c1PathIcons when a theme changes (which is very cool).

    -Kingman

  • Posted 22 February 2021, 6:11 pm EST

    Hello Kingman,

    We have forwarded your request to the developers and will let you know as soon as we get the update from the developers’ end.

    [Internal Tracking Id: 24441]

    Regards,

    Prabhat Sharma.

Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels