Example #1
0
        public void Connect(string friendlyName, bool autostartable, AppletCapabilities appletCaps)
        {
            if (Connected)
            {
                throw new Exception("Already connected.");
            }
            FriendlyName          = friendlyName;
            Autostartable         = autostartable;
            CapabilitiesSupported = appletCaps;
            var ctx = new LgLcd.ConnectContextEx {
                AppFriendlyName             = friendlyName,
                AppletCapabilitiesSupported = (LgLcd.AppletCapabilities)appletCaps,
                IsAutostartable             = autostartable,
                IsPersistent = true,                 // deprecated and ignored as of 3.00
                OnConfigure  = new LgLcd.ConfigureContext {
                    Context     = IntPtr.Zero,
                    OnConfigure = _configurationDelegate,
                },
                OnNotify = new LgLcd.NotificationContext {
                    Context        = IntPtr.Zero,
                    OnNotification = _notificationDelegate,
                },
                Reserved1 = 0,
            };
            var error = LgLcd.ConnectEx(ref ctx);

            if (error != LgLcd.ReturnValue.ErrorSuccess)
            {
                if (error == LgLcd.ReturnValue.ErrorInvalidParameter)
                {
                    throw new ArgumentException("FriendlyName must not be null.");
                }
                if (error == LgLcd.ReturnValue.ErrorFileNotFound)
                {
                    throw new Exception("LCDMon is not running on the system.");
                }
                if (error == LgLcd.ReturnValue.ErrorAlreadyExists)
                {
                    throw new Exception("The same client is already connected.");
                }
                if (error == LgLcd.ReturnValue.RcpXWrongPipeVersion)
                {
                    throw new Exception("LCDMon does not understand the protocol.");
                }
                throw new Win32Exception((int)error);
            }
            _handle = ctx.Connection;
        }
Example #2
0
 public void Connect(string friendlyName, bool autostartable, AppletCapabilities appletCaps)
 {
     if (Connected) {
         throw new Exception("Already connected.");
     }
     FriendlyName = friendlyName;
     Autostartable = autostartable;
     CapabilitiesSupported = appletCaps;
     var ctx = new LgLcd.ConnectContextEx {
         AppFriendlyName = friendlyName,
         AppletCapabilitiesSupported = (LgLcd.AppletCapabilities)appletCaps,
         IsAutostartable = autostartable,
         IsPersistent = true, // deprecated and ignored as of 3.00
         OnConfigure = new LgLcd.ConfigureContext {
             Context = IntPtr.Zero,
             OnConfigure = _configurationDelegate,
         },
         OnNotify = new LgLcd.NotificationContext {
             Context = IntPtr.Zero,
             OnNotification = _notificationDelegate,
         },
         Reserved1 = 0,
     };
     var error = LgLcd.ConnectEx(ref ctx);
     if (error != LgLcd.ReturnValue.ErrorSuccess) {
         if (error == LgLcd.ReturnValue.ErrorInvalidParameter) {
             throw new ArgumentException("FriendlyName must not be null.");
         }
         if (error == LgLcd.ReturnValue.ErrorFileNotFound) {
             throw new Exception("LCDMon is not running on the system.");
         }
         if (error == LgLcd.ReturnValue.ErrorAlreadyExists) {
             throw new Exception("The same client is already connected.");
         }
         if (error == LgLcd.ReturnValue.RcpXWrongPipeVersion) {
             throw new Exception("LCDMon does not understand the protocol.");
         }
         throw new Win32Exception((int)error);
     }
     _handle = ctx.Connection;
 }