Наследование: IApplet
Пример #1
0
        public void Open(Applet applet, DeviceType type)
        {
            if (Opened)
            {
                throw new Exception("Already opened.");
            }
            if (!applet.Connected)
            {
                throw new Exception("Applet must be connected to LCDMon.");
            }
            if (type != DeviceType.Monochrome && type != DeviceType.Qvga)
            {
                throw new InvalidEnumArgumentException();
            }
            if ((type == DeviceType.Monochrome && applet.CapabilitiesSupported != AppletCapabilities.Monochrome) ||
                (type == DeviceType.Qvga && applet.CapabilitiesSupported != AppletCapabilities.Qvga))
            {
                throw new Exception("The applet does not support the device type \"" + type.ToString() + "\".");
            }
            if (type != DeviceType.Monochrome && type != DeviceType.Qvga)
            {
                throw new InvalidEnumArgumentException();
            }
            Type = type;
            if (type == DeviceType.Monochrome)
            {
                _bitmapFormat = LgLcd.BitmapFormat.Monochrome;
                BitmapWidth   = (int)LgLcd.BwBmp.Width;
                BitmapHeight  = (int)LgLcd.BwBmp.Height;
                BitmapBpp     = (int)LgLcd.BwBmp.Bpp;
            }
            else if (type == DeviceType.Qvga)
            {
                _bitmapFormat = LgLcd.BitmapFormat.QVGAx32;
                BitmapWidth   = (int)LgLcd.QvgaBmp.Width;
                BitmapHeight  = (int)LgLcd.QvgaBmp.Height;
                BitmapBpp     = (int)LgLcd.QvgaBmp.Bpp;
                _pixelFormat  = PixelFormat.Format32bppArgb;
            }
            var ctx = new LgLcd.OpenByTypeContext {
                Connection           = applet.Handle,
                DeviceType           = (LgLcd.DeviceType)Type,
                OnSoftbuttonsChanged = new LgLcd.SoftbuttonsChangedContext {
                    Context = IntPtr.Zero,
                    OnSoftbuttonsChanged = _softButtonsDelegate,
                }
            };

            LgLcd.ReturnValue error = LgLcd.OpenByType(ref ctx);
            if (error != LgLcd.ReturnValue.ErrorSuccess)
            {
                if (error == LgLcd.ReturnValue.ErrorAlreadyExists)
                {
                    throw new Exception("The specified device has already been opened in the given applet.");
                }
                throw new Win32Exception((int)error);
            }
            _handle = ctx.Device;
        }
Пример #2
0
        protected void InitializeApplet()
        {
            _applet = new AppletProxy(this);
            Connect(AppletName, true, AppletCapabilities.Qvga);

            Device = new Device();
            Device.Open(_applet, DeviceType.Qvga);
        }
Пример #3
0
        protected WinFormsApplet()
        {
            // we don't want the designer to really call this constructor
            if (LicenseManager.UsageMode == LicenseUsageMode.Designtime) return;

            _bm = new Bitmap(320, 240, PixelFormat.Format32bppArgb);
            _gfx = Graphics.FromImage(_bm);
            UpdateLcdScreen += WinFormsApplet_UpdateLcdScreen;

            _applet = new AppletProxy(this);
            Connect(AppletName, true, AppletCapabilities.Qvga);

            Device = new Device();
            Device.Open(_applet, DeviceType.Qvga);
        }
Пример #4
0
        protected void InitializeApplet()
        {
            _applet = new AppletProxy(this);
            Connect(AppletName, true, AppletCapabilities.Qvga);

            Device = new Device();
            Device.Open(_applet, DeviceType.Qvga);
        }
Пример #5
0
 public void Open(Applet applet, DeviceType type)
 {
     if (Opened) {
         throw new Exception("Already opened.");
     }
     if (!applet.Connected) {
         throw new Exception("Applet must be connected to LCDMon.");
     }
     if (type != DeviceType.Monochrome && type != DeviceType.Qvga) {
         throw new InvalidEnumArgumentException();
     }
     if ((type == DeviceType.Monochrome && applet.CapabilitiesSupported != AppletCapabilities.Monochrome)
         || (type == DeviceType.Qvga && applet.CapabilitiesSupported != AppletCapabilities.Qvga)) {
         throw new Exception("The applet does not support the device type \"" + type.ToString() + "\".");
     }
     if (type != DeviceType.Monochrome && type != DeviceType.Qvga) {
         throw new InvalidEnumArgumentException();
     }
     Type = type;
     if (type == DeviceType.Monochrome) {
         _bitmapFormat = LgLcd.BitmapFormat.Monochrome;
         BitmapWidth = (int)LgLcd.BwBmp.Width;
         BitmapHeight = (int)LgLcd.BwBmp.Height;
         BitmapBpp = (int)LgLcd.BwBmp.Bpp;
     }
     else if (type == DeviceType.Qvga) {
         _bitmapFormat = LgLcd.BitmapFormat.QVGAx32;
         BitmapWidth = (int)LgLcd.QvgaBmp.Width;
         BitmapHeight = (int)LgLcd.QvgaBmp.Height;
         BitmapBpp = (int)LgLcd.QvgaBmp.Bpp;
         _pixelFormat = PixelFormat.Format32bppArgb;
     }
     var ctx = new LgLcd.OpenByTypeContext {
         Connection = applet.Handle,
         DeviceType = (LgLcd.DeviceType)Type,
         OnSoftbuttonsChanged = new LgLcd.SoftbuttonsChangedContext {
             Context = IntPtr.Zero,
             OnSoftbuttonsChanged = _softButtonsDelegate,
         }
     };
     LgLcd.ReturnValue error = LgLcd.OpenByType(ref ctx);
     if (error != LgLcd.ReturnValue.ErrorSuccess) {
         if (error == LgLcd.ReturnValue.ErrorAlreadyExists) {
             throw new Exception("The specified device has already been opened in the given applet.");
         }
         throw new Win32Exception((int)error);
     }
     _handle = ctx.Device;
 }