Пример #1
0
        public IActionResult RenderLayerIcon(string deviceId, string layerId, int keyId)
        {
            Bitmap icon;

            try
            {
                DeviceModel device = _deviceManager.GetDevice(deviceId);
                KeyMap      keyMap = device.Layers.GetLayerById(layerId).Keys;


                if (keyMap.ContainsKey(keyId))
                {
                    KeyModel key = keyMap[keyId];
                    icon = _deviceManager.GenerateKeyIcon(key, deviceId);
                }
                else
                {
                    icon = IconHelpers.DrawBlankKeyIcon(244, 244);
                }
            }
            catch (Exception e)
            {
                icon = IconHelpers.DrawBlankKeyIcon(244, 244);
            }

            return(File(icon.ToMemoryStream(), "image/png", "key.png"));
        }
Пример #2
0
        public IActionResult RenderLiveStateIcon(string deviceId, int keyId)
        {
            Bitmap icon;

            try
            {
                KeyModel keyInput = null;
                if (_deviceManager.GetDevice(deviceId).KeyStates.IsKeyMapped(keyId))
                {
                    keyInput = _deviceManager.GetDevice(deviceId).KeyStates[keyId];
                }
                icon = _deviceManager.GenerateKeyIcon(keyInput, deviceId);
            }
            catch (Exception e)
            {
                icon = IconHelpers.DrawBlankKeyIcon(244, 244);
            }
            return(File(icon.ToMemoryStream(), "image/png", "key.png"));
        }