Ejemplo n.º 1
0
 protected override void Show()
 {
     DrawBitmap();
     if (StreamDeckPanelInstance == null)
     {
         throw new Exception("StreamDeckPanelInstance is not set, cannot show image [FaceTypeImage]");
     }
     StreamDeckPanelInstance.StreamDeckBoard.SetKeyBitmap(StreamDeckCommon.ButtonNumber(StreamDeckButtonName) - 1, _keyBitmap);
 }
Ejemplo n.º 2
0
        public void SetImage(EnumStreamDeckButtonNames streamDeckButtonName, BitmapImage bitmapImage)
        {
            if (streamDeckButtonName == EnumStreamDeckButtonNames.BUTTON0_NO_BUTTON)
            {
                return;
            }
            var keyBitmap = KeyBitmap.Create.FromBitmap(BitMapCreator.BitmapImage2Bitmap(bitmapImage));

            lock (_updateStreamDeckOledLockObject)
            {
                _streamDeckBoard.SetKeyBitmap(StreamDeckCommon.ButtonNumber(streamDeckButtonName) - 1, keyBitmap);
            }
        }
Ejemplo n.º 3
0
        public void SetImage(EnumStreamDeckButtonNames streamDeckButtonName, BitmapImage bitmapImage)
        {
            if (streamDeckButtonName == EnumStreamDeckButtonNames.BUTTON0_NO_BUTTON)
            {
                return;
            }
            var keyBitmap = KeyBitmap.Create.FromBitmap(BitMapCreator.BitmapImage2Bitmap(bitmapImage));

            lock (_updateStreamDeckOledLockObject)
            {
                //EventHandlers.NotifyOledImageChange(this, PanelHash, streamDeckButtonName, BitMapCreator.BitmapImage2Bitmap(bitmapImage));
                _streamDeckBoard.SetKeyBitmap(StreamDeckCommon.ButtonNumber(streamDeckButtonName) - 1, keyBitmap);
            }
        }
        public void Execute(CancellationToken threadCancellationToken)
        {
            Common.PlaySoundFile(SoundFile, Volume);

            if (!PluginManager.DisableKeyboardAPI)
            {
                OSKeyPress.Execute(threadCancellationToken);
            }

            if (PluginManager.PlugSupportActivated && PluginManager.HasPlugin())
            {
                PluginManager.DoEvent(
                    DCSFPProfile.SelectedProfile.Description,
                    StreamDeckPanelInstance.HIDInstance,
                    StreamDeckCommon.ConvertEnum(_streamDeckPanel.TypeOfPanel),
                    (int)StreamDeckButtonName,
                    true,
                    OSKeyPress.KeyPressSequence);
            }
        }
        public void DoPress()
        {
            if (ActionForPress == null)
            {
                /*
                 * Must do this here as there are no ActionTypeKey for this button, otherwise Plugin would never get any event.
                 * Otherwise it is sent from ActionTypeKey together with key configs associated with the button.
                 */
                if (PluginManager.PlugSupportActivated && PluginManager.HasPlugin())
                {
                    PluginManager.DoEvent(
                        DCSFPProfile.SelectedProfile.Description,
                        StreamDeckPanelInstance.HIDInstance,
                        StreamDeckCommon.ConvertEnum(_streamDeckPanel.TypeOfPanel),
                        (int)StreamDeckButtonName,
                        true,
                        null);
                }

                return;
            }

            while (ActionForPress.IsRunning())
            {
                _cancellationTokenSource?.Cancel();
            }

            if (ActionForPress.IsRepeatable())
            {
                _cancellationTokenSource = new CancellationTokenSource();
                var threadCancellationToken = _cancellationTokenSource.Token;
                Debug.WriteLine("Creating Key Press Thread for Streamdeck");
                _keyPressedThread = new Thread(() => ThreadedPress(threadCancellationToken));
                _keyPressedThread.Start();
            }
            else
            {
                ActionForPress.Execute(CancellationToken.None);
            }
        }
Ejemplo n.º 6
0
 public static BitmapImage GetButtonImageFromResources(EnumStreamDeckButtonNames streamDeckButtonName, Color color)
 {
     return(new BitmapImage(new Uri(StreamDeckConstants.NUMBER_BUTTON_LOCATION + StreamDeckCommon.ButtonNumber(streamDeckButtonName) + "_" + color.Name.ToLower() + ".png", UriKind.Absolute)));
 }
Ejemplo n.º 7
0
 public void SetImage(int streamDeckButtonNumber, Bitmap bitmap)
 {
     SetImage(StreamDeckCommon.ButtonName(streamDeckButtonNumber), bitmap);
 }
Ejemplo n.º 8
0
        public void Export(string compressedFilenameAndPath, List <ButtonExport> buttonExports)
        {
            var filesToCompressList = new List <string>(); //includes the json file and eventual image files

            StreamDeckCommon.CleanDCSFPTemporaryFolder();

            /*
             * Close because the list changes below. If not then subsequent operations by the user
             * will cause null exceptions since image path is reset.
             */
            var clonedButtonExports = buttonExports.DeepClone();

            foreach (var buttonExport in clonedButtonExports)
            {
                if (buttonExport.Button.Face != null)
                {
                    if (buttonExport.Button.Face.GetType() == typeof(DCSBIOSDecoder))
                    {
                        var decoder = ((DCSBIOSDecoder)buttonExport.Button.Face);

                        foreach (var imageFile in decoder.ImageFiles)
                        {
                            filesToCompressList.Add(imageFile);
                        }

                        /*
                         * We must remove any path imageFilePath.
                         * When importing a path will be added back following whatever folder
                         * the user wants the image files to reside in.
                         */
                        decoder.ResetImageFilePaths();
                    }
                    else if (buttonExport.Button.Face.GetType() == typeof(FaceTypeImage))
                    {
                        var faceTypeImage = ((FaceTypeImage)buttonExport.Button.Face);
                        filesToCompressList.Add(faceTypeImage.ImageFile);
                        faceTypeImage.ImageFile = Path.GetFileName(faceTypeImage.ImageFile);
                    }
                    else if (buttonExport.Button.Face.GetType() == typeof(FaceTypeDCSBIOSOverlay))
                    {
                        var faceTypeDCSBIOSOverlay = ((FaceTypeDCSBIOSOverlay)buttonExport.Button.Face);
                        filesToCompressList.Add(faceTypeDCSBIOSOverlay.BackgroundBitmapPath);
                        faceTypeDCSBIOSOverlay.BackgroundBitmapPath = Path.GetFileName(faceTypeDCSBIOSOverlay.BackgroundBitmapPath);
                    }
                }
            }

            var json  = JsonConvert.SerializeObject(clonedButtonExports, INDENTED_FORMATTING, _jsonSettings);
            var chars = _uniCodeEncoding.GetChars(_uniCodeEncoding.GetBytes(json));

            var filename = StreamDeckCommon.GetDCSFPTemporaryFolder() + "\\" + StreamDeckConstants.BUTTON_EXPORT_FILENAME;

            filesToCompressList.Add(filename);

            using (var streamWriter = File.CreateText(filename))
            {
                streamWriter.Write(chars);
            }

            ZipArchiver.CreateZipFile(compressedFilenameAndPath, filesToCompressList.Distinct().ToList());

            SystemSounds.Asterisk.Play();
        }
Ejemplo n.º 9
0
 protected override void Show()
 {
     DrawBitmap();
     StreamDeckPanel.GetInstance(PanelHash).StreamDeckBoard.SetKeyBitmap(StreamDeckCommon.ButtonNumber(StreamDeckButtonName) - 1, _keyBitmap);
 }