Exemplo n.º 1
0
 /// <summary>
 ///     Releases the unmanaged resources used by the <see cref="T:LogiFrame.LCDControl" /> and optionally releases the
 ///     managed resources.
 /// </summary>
 /// <param name="disposing">
 ///     true to release both managed and unmanaged resources; false to release only unmanaged
 ///     resources.
 /// </param>
 protected override void Dispose(bool disposing)
 {
     LgLcd.Close(_device);
     base.Dispose(disposing);
     _closeCancellationTokenSource.Cancel();
     _buttonPressCancellationTokenSource?.Cancel();
 }
Exemplo n.º 2
0
        /// <summary>
        ///     Pushes the specified bitmap to the LCD.
        /// </summary>
        /// <param name="bitmap">The bitmap.</param>
        private void Push(MonochromeBitmap bitmap)
        {
            if (bitmap == null)
            {
                throw new ArgumentNullException(nameof(bitmap));
            }

            var render   = new MonochromeBitmap(bitmap, (int)LgLcd.BitmapWidth, (int)LgLcd.BitmapHeight);
            var lgBitmap = new LgLcd.Bitmap160X43X1
            {
                Header = { Format = LgLcd.BitmapFormat160X43X1 },
                Pixels = render.Pixels
            };

            LgLcd.UpdateBitmap(_device, ref lgBitmap, (uint)UpdatePriority);
            OnRendered(new RenderedEventArgs(render));
        }
Exemplo n.º 3
0
        /// <summary>
        ///     Initializes a new instance of the <see cref="LCDApp" /> class.
        /// </summary>
        /// <param name="name">The name.</param>
        /// <param name="canAutoStart">if set to <c>true</c> the app can automatic start.</param>
        /// <param name="isPersistent">if set to <c>true</c> the app is persistent.</param>
        /// <param name="allowConfiguration">
        ///     if set to <c>true</c> the user is allowed to access the configuration menu from the
        ///     GamePanel software.
        /// </param>
        /// <exception cref="ConnectionException"></exception>
        public LCDApp(string name, bool canAutoStart, bool isPersistent, bool allowConfiguration)
        {
            UpdatePriority = UpdatePriority.Normal;

            _connection.AppFriendlyName = name;
            _connection.IsAutostartable = canAutoStart;
            _connection.IsPersistent    = isPersistent;

            if (allowConfiguration)
            {
                _connection.OnConfigure.ConfigCallback = (connection, pContext) =>
                {
                    OnConfigure();
                    return(1);
                }
            }
            ;

            UnmanagedLibrariesLoader.Load();
            LgLcd.Init();

            var connectionResponse = LgLcd.Connect(ref _connection);

            if (connectionResponse != 0)
            {
                throw new ConnectionException(connectionResponse);
            }

            _openContext = new LgLcd.OpenContext
            {
                Connection           = _connection.Connection,
                Index                = 0,
                OnSoftButtonsChanged =
                {
                    Callback                     = (device, buttons, context) =>
                    {
                        var oldOldButtons        = _oldButtons;
                        _oldButtons              = buttons;
                        for (var button          = 0; button < 4; button++)
                        {
                            var buttonIdentifier = 1 << button;
                            if ((buttons & buttonIdentifier) > (oldOldButtons & buttonIdentifier))
                            {
                                HandleButtonDown(button);
                            }
                            else if ((buttons & buttonIdentifier) < (oldOldButtons & buttonIdentifier))
                            {
                                HandleButtonUp(button);
                            }
                        }
                        return(1);
                    }
                }
            };

            LgLcd.Open(ref _openContext);
            _device = _openContext.Device;

            SetBounds(0, 0, DefaultSize.Width, DefaultSize.Height);
            InitLayout();
        }
Exemplo n.º 4
0
        /// <summary>
        ///     Pushes the app to the background.
        /// </summary>
        public void PushToBackground()
        {
            ThrowIfDisposed();

            LgLcd.SetAsLCDForegroundApp(_device, 0);
        }