Graphics

 View Only
  • 1.  Xpression API vs. C# compatibility

    Posted 02-13-2013 14:59
    Hello,

    I'm currently in the process of converting my old VB6 applications that I have been using to control my Xpression-projects into C#.

    As I'm still trying to wrestle myself into the new C#-syntax I did come across some strange behaviour.

    It seems I can't reference a textfield as being an XpTextObject. I can reference it as an xpBaseObject but I don't want that because I can't access the Text-property and change the textfield.

    Even when I look in the Intellisense it wants me to declare the object as an xpBaseObject

    bool.IxpScene.getObjectByName(string Name, out xpBaseObject BaseObject)

    So what am I doing something wrong?

    *** EDIT ***

    Are there actually any C# examples available somewhere? I have the feeling that I'm going to have some other issues in the future as well

    Best regards,

    Kenneth


  • 2.  RE: Xpression API vs. C# compatibility

    Posted 02-13-2013 15:21
    In VB.net, I do a ctype to convert the xpbaseobject to a xptextobject...

    #XPression


  • 3.  RE: Xpression API vs. C# compatibility

    Posted 02-14-2013 02:40
    Hi Kenneth,

    C# does not let you pass a subclass like xpTextObject to a function requiring an xpBaseObject. VB.Net DOES allow you to do this.. It's just a language thing.. You can however typecast from one to the other..

    Here is a code snippet:



    public void SetTextObject(xpScene Scene, String textobj, String value)

    {

    xpBaseObject xpBase;

    xpTextObject xpText;

    if (Scene == null) return;

    if (Scene.ObjectExistsByName(textobj) && Scene.GetObjectByName(textobj, out xpBase))

    {

    xpText = (xpTextObject)xpBase;

    xpText.Text = value;

    }

    }



    #XPression


  • 4.  RE: Xpression API vs. C# compatibility

    Posted 02-14-2013 17:43
    Thanks Brian for your help!

    #XPression