Beispiel #1
0
        /// <summary>
        /// This function is used to read the value of MHL feature functions of String type.
        /// </summary>
        /// <param name="name">Name of the requested feature</param>
        /// <exception cref="System.ArgumentException">If exceptions are enabled, on failure exception is thrown with valid error message.</exception>
        /// <returns>String value for requested feature. Empty string on failure, if exceptions are not enabled.</returns>
        /// <remarks>On failure, use GetLastError() ot GetLastErrorMessage() for more information.</remarks>
        public string GetString(string name)
        {
            int length = MHLSRV._MHL_GetStringLen(loadedDrvHandle, name) + 1;

            if (throwsException && this.GetLastError() != 0)
            {
                throw new System.ArgumentException("Get STRING Failed " + name, "Error " + this.GetLastError().ToString() + "; " + this.GetLastErrorMessage());
            }
            if (length == 0)
            {
                return("");
            }

            string str = new string(' ', length);

            MHLSRV._MHL_GetString(loadedDrvHandle, name, str, length);
            if (throwsException && this.GetLastError() != 0)
            {
                throw new System.ArgumentException("Get STRING Failed " + name, "Error " + this.GetLastError().ToString() + "; " + this.GetLastErrorMessage());
            }

            // Remove NULL character, if present
            if (str[str.Length - 1] == '\0')
            {
                return(str.Remove(str.Length - 1, 1));
            }
            return(str);
        }
Beispiel #2
0
        /// <summary>
        /// This function is used to read the value of MHL feature functions of BINARY type.
        /// </summary>
        /// <param name="name">Name of the requested feature</param>
        /// <exception cref="System.ArgumentException">If exceptions are enabled, on failure exception is thrown with valid error message.</exception>
        /// <returns>Binary array value for requested feature. Null on failure, if exceptions are not enabled.</returns>
        /// <remarks>On failure, use GetLastError() ot GetLastErrorMessage() for more information.</remarks>
        public byte[] GetBin(string name)
        {
            int  retLen;
            uint len = MHLSRV._MHL_GetBinLength(loadedDrvHandle, name);

            if (this.GetLastError() != 0)
            {
                if (throwsException)
                {
                    throw new System.ArgumentException("Get BIN Failed " + name, "Error " + this.GetLastError().ToString() + "; " + this.GetLastErrorMessage());
                }
                return(null);
            }

            byte[] buf = new byte[len];

            retLen = (int)MHLSRV._MHL_GetBin(loadedDrvHandle, name, buf, (int)len);
            if (this.GetLastError() != 0)
            {
                if (throwsException)
                {
                    throw new System.ArgumentException("Get BIN Failed " + name, "Error " + this.GetLastError().ToString() + "; " + this.GetLastErrorMessage());
                }
                return(null);
            }

            buf = (byte[])ResizeArray(buf, retLen);

            return(buf);
        }
Beispiel #3
0
        /// <summary>
        /// This function is used to read the value of MHL feature functions of BOOL type.
        /// </summary>
        /// <param name="name">Name of the requested feature</param>
        /// <exception cref="System.ArgumentException">If exceptions are enabled, on failure exception is thrown with valid error message.</exception>
        /// <returns>BOOL value for requested feature. Returns false on failure, use GetLastError() to verify errors if exceptions are not enabled.</returns>
        /// <remarks>On failure, use GetLastError() ot GetLastErrorMessage() for more information.</remarks>
        public bool GetBool(string name)
        {
            bool ret = MHLSRV._MHL_GetBool(loadedDrvHandle, name) == 1;

            if (throwsException && this.GetLastError() != 0)
            {
                throw new System.ArgumentException("Get BOOL Failed " + name, "Error " + this.GetLastError().ToString() + "; " + this.GetLastErrorMessage());
            }
            return(ret);
        }
Beispiel #4
0
        /// <summary>
        /// This function is used to read the value of MHL feature functions of INT type. MHL Integers are 32 bit signed values.
        /// </summary>
        /// <param name="name">Name of the requested feature</param>
        /// <exception cref="System.ArgumentException">If exceptions are enabled, on failure exception is thrown with valid error message.</exception>
        /// <returns>INT value for requested feature. -1 on failure, if exceptions are not enabled.</returns>
        /// <remarks>On failure, use GetLastError() ot GetLastErrorMessage() for more information.</remarks>
        public int GetInt(string name)
        {
            int ret = MHLSRV._MHL_GetInt(loadedDrvHandle, name);

            if (throwsException && this.GetLastError() != 0)
            {
                throw new System.ArgumentException("Get INT Failed " + name, "Error " + this.GetLastError().ToString() + "; " + this.GetLastErrorMessage());
            }
            return(ret);
        }
Beispiel #5
0
        /// <summary>PROVIDED ONLY FOR BACKWARD COMPATIBILITY. Please use new HotkeyHelper class.</summary>
        /// <remarks>PROVIDED ONLY FOR BACKWARD COMPATIBILITY. Please use new MHLDriver class.</remarks>
        public byte[] GetBin(int handle, String name, int length)
        {
            int retLen;

            byte[] buf = new byte[length];

            retLen = (int)MHLSRV._MHL_GetBin(handle, name, buf, (int)length);
            buf    = (byte[])ResizeArray(buf, retLen);

            return(buf);
        }
Beispiel #6
0
 /// <summary>
 /// This function is used to write binary data to MHL features that are of binary type.
 /// </summary>
 /// <param name="name">Name of the feature to set</param>
 /// <param name="val">Byte array to write</param>
 /// <exception cref="System.ArgumentException">If exceptions are enabled, on failure exception is thrown with valid error message.</exception>
 /// <returns>true on success, false on failure.</returns>
 /// <remarks>On failure, use GetLastError() ot GetLastErrorMessage() for more information.</remarks>
 public bool SetBin(string name, byte[] val)
 {
     if (MHLSRV._MHL_SetBin(loadedDrvHandle, name, val, val.Length) == 0)
     {
         if (throwsException)
         {
             throw new System.ArgumentException("Cannot set BIN " + name, "Error " + this.GetLastError().ToString() + "; " + this.GetLastErrorMessage());
         }
         return(false);
     }
     return(true);
 }
Beispiel #7
0
 /// <summary>
 /// This function is used to write a double value to MHL features that are of double type.
 /// The double data type is defined as a 32 bit unsigned integer in MHL.
 /// </summary>
 /// <param name="name">Name of the feature to set</param>
 /// <param name="val">double value to set</param>
 /// <exception cref="System.ArgumentException">If exceptions are enabled, on failure exception is thrown with valid error message.</exception>
 /// <returns>true on success, false on failure.</returns>
 /// <remarks>On failure, use GetLastError() ot GetLastErrorMessage() for more information.</remarks>
 public bool SetDouble(string name, double val)
 {
     if (MHLSRV._MHL_SetDouble(loadedDrvHandle, name, ref val) == 0)
     {
         if (throwsException)
         {
             throw new System.ArgumentException("Cannot set double " + name, "Error " + this.GetLastError().ToString() + "; " + this.GetLastErrorMessage());
         }
         return(false);
     }
     return(true);
 }
Beispiel #8
0
 /// <summary>
 /// This function is used for MHL feature functions that are of the Executable type.
 /// They typically trigger some kind of process or function in hardware.
 /// Internally this call is the same as calling the same function with SetBool with a true parameter.
 /// </summary>
 /// <param name="name">Name of the feature to set</param>
 /// <exception cref="System.ArgumentException">If exceptions are enabled, on failure exception is thrown with valid error message.</exception>
 /// <returns>true on success, false on failure.</returns>
 /// <remarks>On failure, use GetLastError() ot GetLastErrorMessage() for more information.</remarks>
 public bool Execute(string name)
 {
     if (MHLSRV._MHL_Execute(loadedDrvHandle, name) == 0)
     {
         if (throwsException)
         {
             throw new System.ArgumentException("Cannot EXECUTE " + name, "Error " + this.GetLastError().ToString() + "; " + this.GetLastErrorMessage());
         }
         return(false);
     }
     return(true);
 }
Beispiel #9
0
        /// <summary>
        /// This function is used to read the value of MHL feature functions of double type. MHL doubles are 64 bit floating point values.
        /// </summary>
        /// <param name="name">Name of the requested feature</param>
        /// <exception cref="System.ArgumentException">If exceptions are enabled, on failure exception is thrown with valid error message.</exception>
        /// <returns>double value for requested feature. NaN constant on failure (0xFFFFFFFF in hexadecimal), if exceptions are not enabled.</returns>
        /// <remarks>On failure, use GetLastError() ot GetLastErrorMessage() for more information.</remarks>
        public double GetDouble(string name)
        {
            double ret = 0;

            MHLSRV._MHL_GetDouble(loadedDrvHandle, name, ref ret);

            if (throwsException && this.GetLastError() != 0)
            {
                throw new System.ArgumentException("Get double Failed " + name, "Error " + this.GetLastError().ToString() + "; " + this.GetLastErrorMessage());
            }
            return(ret);
        }
Beispiel #10
0
 /// <summary>
 /// When you are done with a feature and driver you must call this function to free up resources.
 /// If your application is likely to be run exclusively on the unit, it is recommendable that you open and close an MHL feature handle only once during the lifetime of the application.
 /// Do not make code that opens and closes the feature rapidly and very often, it is extremely inefficient.
 /// </summary>
 /// <exception cref="System.ArgumentException">If exceptions are enabled, on failure exception is thrown with valid error message.</exception>
 /// <returns>true on success, false on failure.</returns>
 /// <remarks>On failure, use GetLastError() ot GetLastErrorMessage() for more information.</remarks>
 public bool Close()
 {
     if (IsOpen())
     {
         if (MHLSRV._MHL_CloseDrv(loadedDrvHandle) == 0)
         {
             if (throwsException)
             {
                 throw new System.ArgumentException("Cannot close driver " + loadedDrvName, "Error " + this.GetLastError().ToString() + "; " + this.GetLastErrorMessage());
             }
         }
         loadedDrvHandle = -1;
         loadedDrvName   = "";
         return(true);
     }
     return(false);
 }
Beispiel #11
0
        /// <summary>
        /// This function opens an MHL feature driver for use.
        /// Call this function to select which MHL driver you wish the object instance to use, if you have not already done so in the constructor.
        /// Once a MHL feature driver has been opened you can call the Get/Set functions to communicate / command the driver.
        /// See the specific drivers documentation for information about available functionality.
        ///
        /// If this instance of object have already open MHL driver, it will be internally closed first.
        /// </summary>
        /// <param name="name">Name of the MHL driver to open.</param>
        /// <exception cref="System.ArgumentException">If exceptions are enabled, on failure exception is thrown with valid error message.</exception>
        /// <returns>true on success, false on failure.</returns>
        /// <remarks>On failure, use GetLastError() ot GetLastErrorMessage() for more information.</remarks>
        public bool Open(string name)
        {
            if (this.IsOpen())
            {
                this.Close();
            }
            loadedDrvHandle = MHLSRV._MHL_OpenDrv(name);

            if (throwsException && loadedDrvHandle == WIN32.INVALID_HANDLE_VALUE)
            {
                throw new System.ArgumentException("Cannot open driver " + name, "Error " + this.GetLastError().ToString() + "; " + this.GetLastErrorMessage());
            }

            if (this.IsOpen())
            {
                loadedDrvName = name;
                return(true);
            }
            return(false);
        }
Beispiel #12
0
        /// <summary>PROVIDED ONLY FOR BACKWARD COMPATIBILITY. Please use new HotkeyHelper class.</summary>
        /// <remarks>PROVIDED ONLY FOR BACKWARD COMPATIBILITY. Please use new MHLDriver class.</remarks>
        public String GetString(int handle, String name)
        {
            int length = MHLSRV._MHL_GetStringLen(handle, name) + 1;

            if (length == 0)
            {
                return("");
            }

            String str = new String(' ', length);

            MHLSRV._MHL_GetString(handle, name, str, length);

            // Remove NULL character, if present
            if (str[str.Length - 1] == '\0')
            {
                return(str.Remove(str.Length - 1, 1));
            }
            return(str);
        }
Beispiel #13
0
        ///////////////////////////////////
        // Get Functions

        /// <summary>PROVIDED ONLY FOR BACKWARD COMPATIBILITY. Please use new HotkeyHelper class.</summary>
        /// <remarks>PROVIDED ONLY FOR BACKWARD COMPATIBILITY. Please use new MHLDriver class.</remarks>
        public uint GetDword(int handle, String name)
        {
            return(MHLSRV._MHL_GetDword(handle, name));
        }
Beispiel #14
0
 /// <summary>PROVIDED ONLY FOR BACKWARD COMPATIBILITY. Please use new HotkeyHelper class.</summary>
 /// <remarks>PROVIDED ONLY FOR BACKWARD COMPATIBILITY. Please use new MHLDriver class.</remarks>
 public int SetBool(int handle, String name, bool val)
 {
     return(MHLSRV._MHL_SetBool(handle, name, (val == true) ? 1 : 0));
 }
Beispiel #15
0
 /// <summary>PROVIDED ONLY FOR BACKWARD COMPATIBILITY. Please use new HotkeyHelper class.</summary>
 /// <remarks>PROVIDED ONLY FOR BACKWARD COMPATIBILITY. Please use new MHLDriver class.</remarks>
 public int SetInt(int handle, String name, int val)
 {
     return(MHLSRV._MHL_SetInt(handle, name, val));
 }
Beispiel #16
0
        ///////////////////////////////////
        // Set Functions

        /// <summary>PROVIDED ONLY FOR BACKWARD COMPATIBILITY. Please use new HotkeyHelper class.</summary>
        /// <remarks>PROVIDED ONLY FOR BACKWARD COMPATIBILITY. Please use new MHLDriver class.</remarks>
        public int SetDword(int handle, String name, uint val)
        {
            return(MHLSRV._MHL_SetDword(handle, name, val));
        }
Beispiel #17
0
 /// <summary>PROVIDED ONLY FOR BACKWARD COMPATIBILITY. Please use new HotkeyHelper class.</summary>
 /// <remarks>PROVIDED ONLY FOR BACKWARD COMPATIBILITY. Please use new MHLDriver class.</remarks>
 public int SaveProfile(int handle, String name)
 {
     return(MHLSRV._MHL_SaveProfile(handle, name));
 }
Beispiel #18
0
 /// <summary>PROVIDED ONLY FOR BACKWARD COMPATIBILITY. Please use new HotkeyHelper class.</summary>
 /// <remarks>PROVIDED ONLY FOR BACKWARD COMPATIBILITY. Please use new MHLDriver class.</remarks>
 public int LoadProfile(int handle, String name)
 {
     return(MHLSRV._MHL_LoadProfile(handle, name));
 }
Beispiel #19
0
 /// <summary>PROVIDED ONLY FOR BACKWARD COMPATIBILITY. Please use new HotkeyHelper class.</summary>
 /// <remarks>PROVIDED ONLY FOR BACKWARD COMPATIBILITY. Please use new MHLDriver class.</remarks>
 public int CloseDrv(int handle)
 {
     return(MHLSRV._MHL_CloseDrv(handle));
 }
Beispiel #20
0
 /// <summary>PROVIDED ONLY FOR BACKWARD COMPATIBILITY. Please use new HotkeyHelper class.</summary>
 /// <remarks>PROVIDED ONLY FOR BACKWARD COMPATIBILITY. Please use new MHLDriver class.</remarks>
 public bool GetBool(int handle, String name)
 {
     return((MHLSRV._MHL_GetBool(handle, name) == 1) ? true : false);
 }
Beispiel #21
0
 /// <summary>PROVIDED ONLY FOR BACKWARD COMPATIBILITY. Please use new HotkeyHelper class.</summary>
 /// <remarks>PROVIDED ONLY FOR BACKWARD COMPATIBILITY. Please use new MHLDriver class.</remarks>
 public int Execute(int handle, String name)
 {
     return(MHLSRV._MHL_Execute(handle, name));
 }
Beispiel #22
0
 /// <summary>PROVIDED ONLY FOR BACKWARD COMPATIBILITY. Please use new HotkeyHelper class.</summary>
 /// <remarks>PROVIDED ONLY FOR BACKWARD COMPATIBILITY. Please use new MHLDriver class.</remarks>
 public int SetString(int handle, String name, String val)
 {
     return(MHLSRV._MHL_SetString(handle, name, val));
 }
Beispiel #23
0
 /// <summary>PROVIDED ONLY FOR BACKWARD COMPATIBILITY. Please use new HotkeyHelper class.</summary>
 /// <remarks>PROVIDED ONLY FOR BACKWARD COMPATIBILITY. Please use new MHLDriver class.</remarks>
 public int OpenDrv(String name)
 {
     return(MHLSRV._MHL_OpenDrv(name));
 }
Beispiel #24
0
 /// <summary>PROVIDED ONLY FOR BACKWARD COMPATIBILITY. Please use new HotkeyHelper class.</summary>
 /// <remarks>PROVIDED ONLY FOR BACKWARD COMPATIBILITY. Please use new MHLDriver class.</remarks>
 public int SetBin(int handle, String name, byte[] val)
 {
     return(MHLSRV._MHL_SetBin(handle, name, val, val.Length));
 }
Beispiel #25
0
 /// <summary>PROVIDED ONLY FOR BACKWARD COMPATIBILITY. Please use new HotkeyHelper class.</summary>
 /// <remarks>PROVIDED ONLY FOR BACKWARD COMPATIBILITY. Please use new MHLDriver class.</remarks>
 public int GetInt(int handle, String name)
 {
     return(MHLSRV._MHL_GetInt(handle, name));
 }