Menu

Getting started

2010-11-21
2013-05-14
  • Benjamin Postiff

    I am not a seasoned programmer and wondered if someone could explain very very briefly how to implement this api wrapper in a VS project. 

     
  • Montellese

    Montellese - 2010-11-21

    Hey

    thanks for your interest in iMON Display API Wrapper#. Here is a simple code snippet to get started (I have not tested this exact code I just copy/pasted the import parts here):

    iMonWrapperApi imon = new iMonWrapperApi();
    imon.StateChanged += wrapperApi_StateChanged;
    imon.Error += wrapperApi_Error;
    imon.Log += wrapperApi_Log;
    imon.LogError += wrapperApi_LogError;
    imon.Initialize();
    // do something until you get the StateChanged event
    // do something with the display
    imon.Uninitialize();
    

    This was the setup. It is important to remember that Initialize() and Uninitialize() do not return whether the display has been initialized or not because that happens asynchronously. You'll have to wait for the StateChanged event which will tell you if the display has been initialized or not. The Error event will let you know about any errors that occur (during any call to the wrapper). The Log and LogError are simply for debug purposes if you get an error and would like to know more about it.

    Your event handlers would look something like this:

     private void wrapperApi_StateChanged(object sender, iMonStateChangedEventArgs e)
    {
        if (e.IsInitialized)
        {
            // now you can use the display but check iMonWrapperApi.DisplayType to see what display type you have available
        }
        else 
        {
            // now the display is uninitialized and you can't use it anymore
        }
    }
    private void wrapperApi_Error(object sender, iMonErrorEventArgs e)
    {
        // check e.Type to find out what kind of error occured
    }
    

    If you want to see more you can look into the code of my project "XBMC on iMON Display" here on sourceforge as well.

    I'm happy to answer further questions.

     
  • Benjamin Postiff

    Thanks so much for helping!  What using statement do I need to add in my class? ex(using iMonDisplayApiSharp or iMonDisplayApiWrapperSharp)  I am not sure which dll I need to reference.

     
  • Montellese

    Montellese - 2010-11-21

    You should reference the iMonDisplayApiSharp and iMonDisplayApiWrapperSharp dlls in your Visual Studio project.
    The only using statement you need should be

    using iMon.DisplayApi;
    
     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.