static void Main(string[] args) { using (var deck = StreamDeck.OpenDevice()) { PlayVideoAForgeFFMPEG(deck, @"C:\testvideo.mp4"); } }
static void Main(string[] args) { using (var deck = StreamDeck.OpenDevice()) { deck.ClearKeys(); var map = new Map(); var player = new Player(); var screenManager = new ScreenManager(deck); var titleScreen = new TitleScreen(screenManager); var powerScreen = new PowersScreen(screenManager, player); var mapScreen = new MapScreen(screenManager, map, player); titleScreen.NextScreen = powerScreen; powerScreen.NextScreen = mapScreen; titleScreen.Activate(); while (true) { Task.Delay(1000).GetAwaiter().GetResult(); } } }
private void InitJoystick() { lock (lockObj) { // Verify the vJoy driver is enabled. if (!VirtualJoystick.vJoyEnabled()) { throw new VJoyNotEnabledException("vJoy is not enabled! Please install and enable vJoy!"); } // Get the state of the requested device. VjdStat Status = VirtualJoystick.GetVJDStatus(JoystickID); switch (Status) { case VjdStat.VJD_STAT_OWN: case VjdStat.VJD_STAT_FREE: break; case VjdStat.VJD_STAT_BUSY: case VjdStat.VJD_STAT_MISS: default: throw new VJoyAccessException("Cannot access vJoy! Code: " + Status.ToString()); } ; // Acquire the target joystick. if (!VirtualJoystick.AcquireVJD(JoystickID)) { throw new VJoyAcquisitionException("Could not acquire vJoy with ID: " + JoystickID.ToString()); } // Open the Stream Deck device. try { Deck = StreamDeck.OpenDevice(); } catch (Exception ex) { //Catch the internal StreamDeck error and handle it our way. Deck = null; #if DEBUG Console.WriteLine(ex.ToString()); #endif } if (Deck == null || !Deck.IsConnected) { throw new StreamDeckAccessException("Stream Deck could not be opened!"); } // Set the brightness of the keys. Deck.SetBrightness(100); // Register the key pressed event handler. Deck.KeyStateChanged += StreamDeckKeyPressed; } ReloadButtonImages(); }
private void Current_Exit(object sender, ExitEventArgs e) { var deck = StreamDeck.OpenDevice(); deck.SetBrightness(50); deck.ShowLogo(); _notifyIcon?.Icon?.Dispose(); _notifyIcon?.Dispose(); }
static void Main(string[] args) { using (var deck = StreamDeck.OpenDevice()) using (var bmp = (Bitmap)Image.FromFile(@"C:\testimage.png")) { deck.DrawFullScreenBitmap(bmp); Console.ReadKey(); } }
static void Main(string[] args) { initializeIconBitmaps(); using (var s = StreamDeck.OpenDevice()) { s.KeyStateChanged += StreamDeckKeyHandler; startGame(s); Console.WriteLine("Press any key (on the keyboard) to exit Stream Deck demo."); Console.ReadKey(); } }
static void Main(string[] args) { //Open the Stream Deck device using (var deck = StreamDeck.OpenDevice()) { ConsoleWriteAndWait("Press any key to run System.Drawing example"); ExampleWithSystemDrawing(deck); ConsoleWriteAndWait("Press any key to run WPF FrameworkElement example"); ExampleWithWpfElement(deck); ConsoleWriteAndWait("Press any key to exit"); } }
static void Main(string[] args) { Console.CancelKeyPress += Console_CancelKeyPress; using (var deck = StreamDeck.OpenDevice()) { deck.SetBrightness(100); Console.WriteLine("Connected. Now press some keys on the Stream Deck."); deck.ClearKeys(); deck.KeyStateChanged += Deck_KeyPressed; Console.WriteLine("To close the console app press Ctrl + C"); exitSignal.WaitOne(); } }
public static void Main(string[] args) { Console.CancelKeyPress += (sender, eArgs) => { _quitEvent.Set(); eArgs.Cancel = true; }; var deck = StreamDeck.OpenDevice(); InitDeck(deck); deck.ConnectionStateChanged += Deck_ConnectionStateChanged; deck.KeyStateChanged += Deck_KeyStateChanged; _quitEvent.WaitOne(); deck.SetBrightness(50); deck.ShowLogo(); }
static void Main(string[] args) { //Create some color we use later to draw the flag of austria var red = KeyBitmap.FromRGBColor(237, 41, 57); var white = KeyBitmap.FromRGBColor(255, 255, 255); var rowColors = new KeyBitmap[] { red, white, red }; //Open the Stream Deck device using (var deck = StreamDeck.OpenDevice()) { deck.SetBrightness(100); //Send the bitmap informaton to the device for (int i = 0; i < deck.KeyCount; i++) { deck.SetKeyBitmap(i, rowColors[i / 5]); } Console.ReadKey(); } }
public static void DrawText(string text, int sdPos) { using (var deck = StreamDeck.OpenDevice()) { var key = KeyBitmap.FromGraphics(g => { g.SmoothingMode = SmoothingMode.AntiAlias; g.InterpolationMode = InterpolationMode.HighQualityBicubic; g.PixelOffsetMode = PixelOffsetMode.HighQuality; g.TextRenderingHint = TextRenderingHint.AntiAliasGridFit; //Fill background black g.FillRectangle(Brushes.Black, 0, 0, deck.IconSize, deck.IconSize); //Write text to graphics var f = new Font("Arial", 24); g.DrawString(text, f, Brushes.White, new PointF(12, 20)); }); deck.SetKeyBitmap(sdPos, key); Thread.Sleep(500); } }
private void ClipboardChanged(object sender, EventArgs e) { if (_shouldCaptureImage) { var imageFromClipboard = Clipboard.GetImage(); if (imageFromClipboard != null) { var resizedImage = new TransformedBitmap(imageFromClipboard, new ScaleTransform(BUTTON_WIDTH / imageFromClipboard.PixelWidth, BUTTON_HEIGHT / imageFromClipboard.PixelHeight)); var bitmapEncoder = new PngBitmapEncoder(); bitmapEncoder.Frames.Add(BitmapFrame.Create(resizedImage)); var imageStream = new MemoryStream(); bitmapEncoder.Save(imageStream); var keybitmap = KeyBitmap.FromStream(imageStream); var clipboardItem = new ClipboardItem() { Bitmap = imageFromClipboard, KeyBitmap = keybitmap }; _clipboardItems.Enqueue(clipboardItem); while (_clipboardItems.Count > 5) { if (_clipboardItems.TryDequeue(out ClipboardItem item)) { } } var deck = StreamDeck.OpenDevice(); int i = 9; foreach (var clipItem in _clipboardItems) { deck.SetKeyBitmap(i--, clipItem.KeyBitmap); } } _shouldCaptureImage = false; } }
//===================================== // Epilepsiewarning! Flicking images //===================================== static void Main(string[] args) { //default (startup) value //press buttons on streamdeck to change method GetKeyBitmap = ReferenceImageFactory.GetChangingFilledImage; Console.CancelKeyPress += Console_CancelKeyPress; var availableFunctions = new Func <int, KeyBitmap>[] { GetBlank, ReferenceImageFactory.GetStableFilledImage, ReferenceImageFactory.GetChangingFilledImage, ReferenceImageFactory.GetStableLineImage, ReferenceImageFactory.GetChangingLineImage }; using (var deck = StreamDeck.OpenDevice()) { //setup StreamDeck button mapping keyFunctions = new Func <int, KeyBitmap> [deck.KeyCount]; for (int i = 0; i < deck.KeyCount; i++) { keyFunctions[i] = availableFunctions[i % availableFunctions.Length]; } deck.KeyStateChanged += Deck_KeyStateChanged; while (mode == 0) { for (int i = 0; i < deck.KeyCount; i++) { deck.SetKeyBitmap(i, GetKeyBitmap(i)); } } } }
public async Task <bool> Connect() { bool result = false; try { this.deck = StreamDeck.OpenDevice(); await this.ConnectionWrapper((deck) => { deck.ConnectionStateChanged -= Deck_ConnectionStateChanged; deck.KeyStateChanged -= Deck_KeyStateChanged; deck.ShowLogo(); deck.ConnectionStateChanged += Deck_ConnectionStateChanged; deck.KeyStateChanged += Deck_KeyStateChanged; result = true; return(Task.FromResult(0)); }); } catch (Exception ex) { Logger.Log(ex); } return(result); }
private void Window_Loaded(object sender, RoutedEventArgs e) { var deck = StreamDeck.OpenDevice(); InitDeck(deck); deck.ConnectionStateChanged += Deck_ConnectionStateChanged; deck.KeyStateChanged += Deck_KeyStateChanged; Application.Current.Exit += Current_Exit; _notifyIcon = new System.Windows.Forms.NotifyIcon { Icon = System.Drawing.SystemIcons.Application, Visible = true }; ShowInTaskbar = false; _notifyIcon.MouseDoubleClick += _notifyIcon_MouseDoubleClick; var windowClipboardManager = new ClipboardManager(this); windowClipboardManager.ClipboardChanged += ClipboardChanged; }
static void Main(string[] args) { using (var deck = StreamDeck.OpenDevice()) { var sw = Stopwatch.StartNew(); //Create random noise image var rnd = new Random(); var raw = new byte[72 * 72 * 3]; rnd.NextBytes(raw); var rndImage = KeyBitmap.FromRawBitmap(raw); deck.ClearKeys(); //Run a few million SetKeyBitmaps long cnt = 5_000_000; long i = cnt; while (--i > 0) { deck.SetKeyBitmap(7, rndImage); } var t = sw.Elapsed.TotalSeconds; var setKeyTime = t / cnt; //about 0.5µs on my machine Console.WriteLine((setKeyTime * 1000000.0) + " µs"); //Make sure that the test takes a least 3 seconds on your machine // -> change cnt! Console.WriteLine("Total Test time: " + t + " s"); Console.ReadKey(); } }
// Main program, which handles joystick initialization. static void Main(string[] args) { // Verify the vJoy driver is enabled. if (!VirtualJoystick.vJoyEnabled()) { return; } // Get the state of the requested device. VjdStat Status = VirtualJoystick.GetVJDStatus(Id); switch (Status) { case VjdStat.VJD_STAT_OWN: case VjdStat.VJD_STAT_FREE: break; case VjdStat.VJD_STAT_BUSY: case VjdStat.VJD_STAT_MISS: default: return; } ; // Acquire the target joystick. if ((Status == VjdStat.VJD_STAT_OWN) || ((Status == VjdStat.VJD_STAT_FREE) && (!VirtualJoystick.AcquireVJD(Id)))) { return; } // Open the Stream Deck device. var Deck = StreamDeck.OpenDevice(); // Set the brightness of the keys. Deck.SetBrightness(100); // Register the key pressed event handler. Deck.KeyStateChanged += StreamDeckKeyPressed; // Send the bitmap information to the device. Bitmap FullImage = new Bitmap(@"StreamDeckImage.png"); for (int i = 0; i < Deck.Keys.Count; i++) { int Left = (i % 5) * (72 + 16); int Top = (int)Math.Floor((double)i / 5) * (72 + 16); Rectangle CropArea = new Rectangle(Left, Top, 72, 72); buttonBitmaps.Add(FullImage.Clone(CropArea, FullImage.PixelFormat)); } // Infinitely loop, that way we can constantly receive key presses. while (true) { // TODO: Send OSC heartbeat message here. byte i = 0; foreach (Bitmap bitmap in buttonBitmaps) { Deck.SetKeyBitmap(i, KeyBitmap.Create.FromBitmap(bitmap)); i++; } Thread.Sleep(1000); } }