private async Task UpdateImage()
        {
            var currentStatus = status;

            if (currentStatus != null)
            {
                switch (action)
                {
                case "tech.flighttracker.streamdeck.master.activate":
                    await SetImageAsync(imageLogic.GetImage("AP", currentStatus.IsAutopilotOn));

                    break;

                case "tech.flighttracker.streamdeck.heading.activate":
                    await SetImageAsync(imageLogic.GetImage("HDG", currentStatus.IsApHdgOn, currentStatus.ApHeading.ToString()));

                    break;

                case "tech.flighttracker.streamdeck.nav.activate":
                    await SetImageAsync(imageLogic.GetImage("NAV", currentStatus.IsApNavOn));

                    break;

                case "tech.flighttracker.streamdeck.approach.activate":
                    await SetImageAsync(imageLogic.GetImage("APR", currentStatus.IsApAprOn));

                    break;

                case "tech.flighttracker.streamdeck.altitude.activate":
                    await SetImageAsync(imageLogic.GetImage("ALT", currentStatus.IsApAltOn, currentStatus.ApAltitude.ToString()));

                    break;
                }
            }
        }
 private async Task UpdateImage()
 {
     if (settings != null)
     {
         await SetImageAsync(imageLogic.GetImage(settings.Header, currentStatus, currentValue, settings.ImageOn, settings.ImageOff));
     }
 }
Example #3
0
        public async Task <ActionResult> GetImage(Guid imageUid)
        {
            var validationResult = _imageValidation.ValidateGetImage(imageUid);

            if (!validationResult.ValidationResult)
            {
                return(BadRequest(validationResult.ValidationMessage));
            }
            var content = await _imageLogic.GetImage(imageUid);

            return(File(content, "image/jpeg"));
        }
        private async Task UpdateImage()
        {
            var currentStatus = status;

            if (currentStatus != null)
            {
                switch (settings.Type)
                {
                case PresetFunction.Avionics:
                    await SetImageAsync(imageLogic.GetImage(settings.HideHeader ? "" : "AV", currentStatus.IsAvMasterOn, customActiveBackground: settings.ImageOn, customBackground: settings.ImageOff));

                    break;

                case PresetFunction.ApMaster:
                    await SetImageAsync(imageLogic.GetImage(settings.HideHeader ? "" : "AP", currentStatus.IsAutopilotOn, customActiveBackground: settings.ImageOn, customBackground: settings.ImageOff));

                    break;

                case PresetFunction.Heading:
                    await SetImageAsync(imageLogic.GetImage(settings.HideHeader ? "" : "HDG", currentStatus.IsApHdgOn, currentStatus.ApHeading.ToString(), customActiveBackground: settings.ImageOn, customBackground: settings.ImageOff));

                    break;

                case PresetFunction.Nav:
                    await SetImageAsync(imageLogic.GetImage(settings.HideHeader ? "" : "NAV", currentStatus.IsApNavOn, customActiveBackground: settings.ImageOn, customBackground: settings.ImageOff));

                    break;

                case PresetFunction.Altitude:
                    await SetImageAsync(imageLogic.GetImage(settings.HideHeader ? "" : "ALT", currentStatus.IsApAltOn, currentStatus.ApAltitude.ToString(), customActiveBackground: settings.ImageOn, customBackground: settings.ImageOff));

                    break;

                case PresetFunction.VerticalSpeed:
                    await SetImageAsync(imageLogic.GetImage(settings.HideHeader ? "" : "VS", currentStatus.IsApVsOn, currentStatus.ApVs.ToString(), customActiveBackground: settings.ImageOn, customBackground: settings.ImageOff));

                    break;

                case PresetFunction.FLC:
                    await SetImageAsync(imageLogic.GetImage(settings.HideHeader ? "" : "FLC", currentStatus.IsApFlcOn, customActiveBackground: settings.ImageOn, customBackground: settings.ImageOff, value: currentStatus.IsApFlcOn ? currentStatus.ApAirspeed.ToString() : null));

                    break;

                case PresetFunction.Approach:
                    await SetImageAsync(imageLogic.GetImage(settings.HideHeader ? "" : "APR", currentStatus.IsApAprOn, customActiveBackground: settings.ImageOn, customBackground: settings.ImageOff));

                    break;
                }
            }
        }
        private async Task UpdateImage()
        {
            var currentStatus = status;

            if (currentStatus != null && settings != null)
            {
                byte[]? imageOnBytes = settings.ImageOn_base64 != null?Convert.FromBase64String(settings.ImageOn_base64) : null;

                byte[]? imageOffBytes = settings.ImageOff_base64 != null?Convert.FromBase64String(settings.ImageOff_base64) : null;

                var image = settings.Type switch
                {
                    PresetFunction.Avionics => imageLogic.GetImage(
                        settings.HideHeader ? "" : "AV", currentStatus.IsAvMasterOn,
                        imageOnFilePath: settings.ImageOn, imageOnBytes: imageOnBytes,
                        imageOffFilePath: settings.ImageOff, imageOffBytes: imageOffBytes),

                    PresetFunction.ApMaster => imageLogic.GetImage(
                        settings.HideHeader ? "" : "AP", currentStatus.IsAutopilotOn,
                        imageOnFilePath: settings.ImageOn, imageOnBytes: imageOnBytes,
                        imageOffFilePath: settings.ImageOff, imageOffBytes: imageOffBytes),

                    PresetFunction.Heading => imageLogic.GetImage(
                        settings.HideHeader ? "" : "HDG", currentStatus.IsApHdgOn, currentStatus.ApHeading.ToString(),
                        imageOnFilePath: settings.ImageOn, imageOnBytes: imageOnBytes,
                        imageOffFilePath: settings.ImageOff, imageOffBytes: imageOffBytes),

                    PresetFunction.Nav => imageLogic.GetImage(
                        settings.HideHeader ? "" : "NAV", currentStatus.IsApNavOn,
                        imageOnFilePath: settings.ImageOn, imageOnBytes: imageOnBytes,
                        imageOffFilePath: settings.ImageOff, imageOffBytes: imageOffBytes),

                    PresetFunction.Altitude => imageLogic.GetImage(
                        settings.HideHeader ? "" : "ALT", currentStatus.IsApAltOn, currentStatus.ApAltitude1.ToString(),
                        imageOnFilePath: settings.ImageOn, imageOnBytes: imageOnBytes,
                        imageOffFilePath: settings.ImageOff, imageOffBytes: imageOffBytes),

                    PresetFunction.VerticalSpeed => imageLogic.GetImage(
                        settings.HideHeader ? "" : "VS", currentStatus.IsApVsOn, currentStatus.ApVs.ToString(),
                        imageOnFilePath: settings.ImageOn, imageOnBytes: imageOnBytes,
                        imageOffFilePath: settings.ImageOff, imageOffBytes: imageOffBytes),

                    PresetFunction.FLC => imageLogic.GetImage(
                        settings.HideHeader ? "" : "FLC", currentStatus.IsApFlcOn,
                        value: currentStatus.IsApFlcOn ? currentStatus.ApAirspeed.ToString() : null,
                        imageOnFilePath: settings.ImageOn, imageOnBytes: imageOnBytes,
                        imageOffFilePath: settings.ImageOff, imageOffBytes: imageOffBytes),

                    PresetFunction.Approach => imageLogic.GetImage(
                        settings.HideHeader ? "" : "APR", currentStatus.IsApAprOn,
                        imageOnFilePath: settings.ImageOn, imageOnBytes: imageOnBytes,
                        imageOffFilePath: settings.ImageOff, imageOffBytes: imageOffBytes),

                    _ => null,
                };

                if (image != null)
                {
                    await SetImageSafeAsync(image);
                }
            }
        }
 private async Task UpdateImage()
 {
     await SetImageAsync(imageLogic.GetImage(header, currentStatus, legacyDisplayImage, currentValue));
 }