public void SetBitmaps(IEnumerable <LayoutDrawElement> elements) { foreach (var element in elements) { _device?.SetKeyBitmap(element.Location.X + element.Location.Y * ButtonCount.Width, FromBitmapRepresentation(element.BitmapRepresentation)); } }
/// <summary> /// Draw a given image as fullscreen (spanning over all keys) /// </summary> /// <param name="board"></param> /// <param name="b"></param> public static void DrawFullScreenBitmap(this IMacroBoard board, Bitmap b) { if (board is null) { throw new ArgumentNullException(nameof(board)); } if (b is null) { throw new ArgumentNullException(nameof(b)); } byte[] imgData = null; using (var resizedImage = ResizeToFullStreamDeckImage(b, board.Keys.Area.Size)) { imgData = GetRgbArray(resizedImage); } for (var i = 0; i < board.Keys.Count; i++) { var img = GetKeyImageFromFull(board.Keys[i], imgData, board.Keys.Area.Size); board.SetKeyBitmap(i, img); } }
/// <summary> /// Sets a background image for all keys /// </summary> /// <param name="board"></param> /// <param name="bitmap"></param> public static void SetKeyBitmap(this IMacroBoard board, KeyBitmap bitmap) { for (int i = 0; i < board.Keys.Count; i++) { board.SetKeyBitmap(i, bitmap); } }
private static void StartGame(IMacroBoard deck) { //suffle memory cards openCard[0] = -1; openCard[1] = -1; mode = 0; SuffleArray(gameState, rnd); for (int i = 0; i < cardVisible.Length; i++) { cardVisible[i] = false; } //Clear all tiles (except restart key) for (int i = 0; i < deck.Keys.Count; i++) { if (i != restartKey) { deck.ClearKey(i); } } //(Re-)Draw restart key image deck.SetKeyBitmap(restartKey, restartIcon); }
/// <summary> /// Sets background to black for a given key /// </summary> /// <param name="board"></param> /// <param name="keyId"></param> public static void ClearKey(this IMacroBoard board, int keyId) { if (board is null) { throw new System.ArgumentNullException(nameof(board)); } board.SetKeyBitmap(keyId, KeyBitmap.Black); }
private static void RefreshKeyIcon(IMacroBoard deck, int cardId) { var keyId = cardId >= restartKey ? cardId + 1 : cardId; if (cardVisible[cardId]) { if ((openCard[0] == cardId || openCard[1] == cardId)) { deck.SetKeyBitmap(keyId, iconsInactive[gameState[cardId]]); } else { deck.SetKeyBitmap(keyId, iconsActive[gameState[cardId]]); } } else { deck.SetKeyBitmap(keyId, KeyBitmap.Black); } }
/// <summary> /// Sets a background image for all keys /// </summary> /// <param name="board"></param> /// <param name="bitmap"></param> public static void SetKeyBitmap(this IMacroBoard board, KeyBitmap bitmap) { if (board is null) { throw new System.ArgumentNullException(nameof(board)); } for (var i = 0; i < board.Keys.Count; i++) { board.SetKeyBitmap(i, bitmap); } }
/// <summary> /// Draw a given image as fullscreen (spanning over all keys) /// </summary> /// <param name="board"></param> /// <param name="b"></param> public static void DrawFullScreenBitmap(this IMacroBoard board, Bitmap b) { byte[] imgData = null; using (var resizedImage = ResizeToFullStreamDeckImage(b, board.Keys.Area.Size)) { imgData = GetRgbArray(resizedImage); } for (int i = 0; i < board.Keys.Count; i++) { var img = GetKeyImageFromFull(board.Keys[i], imgData, board.Keys.Area.Size); board.SetKeyBitmap(i, img); } }
//process video frames for animation public static void StartAnimation() { while (true) { //create instance of video reader and open video file VideoFileReader vidReader = new VideoFileReader(); string vidFile = SharedSettings.animationImgDir + SettingsSDMonitor.animName + ".mp4"; vidReader.Open(vidFile); int frameCount = Convert.ToInt32(vidReader.FrameCount); int adjustedCount; if (frameCount >= SettingsSDMonitor.framesToProcess) { adjustedCount = SettingsSDMonitor.framesToProcess; } else { adjustedCount = frameCount; } for (int i = 0; i < adjustedCount; i++) { using (var vidStream = new MemoryStream()) { //resize and save frames to MemoryStream Bitmap videoFrame = new Bitmap(vidReader.ReadVideoFrame(), new Size(dimensHeight, dimensHeight)); videoFrame.Save(vidStream, ImageFormat.Png); //dispose the video frame videoFrame.Dispose(); //display animation from stream vidStream.Seek(0, SeekOrigin.Begin); var animStream = KeyBitmap.Create.FromStream(vidStream); ShowAnim(animStream); vidStream.Close(); } } vidReader.Close(); //display animation void ShowAnim(KeyBitmap animStream) { foreach (var button in SettingsSDMonitor.BgButtonList()) { if (exitflag) { break; } deck.SetKeyBitmap(button, animStream); } //frametime delay int frametime = SettingsSDMonitor.FrametimeValue(); System.Threading.Thread.Sleep(frametime); } } }
/// <inheritdoc/> public virtual void SetKeyBitmap(int keyId, KeyBitmap bitmapData) { macroBoard.SetKeyBitmap(keyId, bitmapData); }
/// <summary> /// Sets background to black for all given keys /// </summary> /// <param name="board"></param> public static void ClearKeys(this IMacroBoard board) { board.SetKeyBitmap(KeyBitmap.Black); }
/// <summary> /// Sets background to black for a given key /// </summary> /// <param name="board"></param> /// <param name="keyId"></param> public static void ClearKey(this IMacroBoard board, int keyId) { board.SetKeyBitmap(keyId, KeyBitmap.Black); }