Setting Source URI on PictureElement not working

313
0
02-17-2023 06:59 AM
Labels (1)
marco_vertigis
New Contributor III

Hi there,

Today I was trying to programatically set the source uri (local filepath) of a ArcGIS.Desktop.Layouts.PictureElement with the provided SetSourcePath() SDK method. Unfortunately this seems to have no effect at all. The PictureElement on the layout remains empty without any feedback.

After I looked at the implementation of the SetSourcePath() Method, I could implement it by myself.

private void SetPictureSource(string uri)
{
    // SDK call '_pictureElement.SetSourcePath(uri)' not working
    _pictureElement.SetSourcePath(uri);

    // manually setting source url over cim definition working
    QueuedTask.Run(() =>
    {
        var definition = _pictureElement.GetDefinition();
        if (definition is CIMGraphicElement graphicElement &&
            graphicElement.Graphic is CIMPictureGraphic pictureGraphic)
        {
            pictureGraphic.SourceURL = uri;
            graphicElement.Graphic = pictureGraphic;
            _pictureElement.SetDefinition(graphicElement);
        }
    });
}

 

The SDK implementation almost looks the same but its setting PictureURL instead of SourceURL.

// SDK Implementation
public void SetSourcePath(string URI)
{
    LayoutUtil.EnsureWorkerThread();
    string fullPath = Path.GetFullPath(URI);
    if (!File.Exists(fullPath))
    {
        throw new Exception("Invalid Picture path");
    }

    ElementUtil.UpdateElement(_container, base.Name, Resources.OperationUpdatePictures, delegate (CIMElement cimElement)
    {
        CIMPictureGraphic cIMPictureGraphic = (cimElement as 
        CIMGraphicElement).Graphic as CIMPictureGraphic;
        if (cIMPictureGraphic != null)
        {
             cIMPictureGraphic.PictureURL = fullPath;
        }
    });
}

 

Is this a SDK Bug or do I use the method the wrong way? Would appreciate any response.

0 Kudos
0 Replies