/// <summary> /// Get all profiles matching the provided game /// </summary> /// <param name="game">The game to match</param> /// <param name="keyboard">The keyboard to match</param> /// <returns>All profiles matching the provided game</returns> public static List<ProfileModel> GetAll(EffectModel game, KeyboardProvider keyboard) { if (game == null) throw new ArgumentNullException(nameof(game)); if (keyboard == null) throw new ArgumentNullException(nameof(keyboard)); return GetAll().Where(g => g.GameName.Equals(game.Name) && g.KeyboardSlug.Equals(keyboard.Slug)).ToList(); }
/// <summary> /// Represents a Rectangle on the keyboard which can be drawn to a Bitmap. /// By default, a rectangle is the entire keyboard's size. /// </summary> /// <param name="keyboard">The keyboard this rectangle will be used for</param> /// <param name="x"></param> /// <param name="y"></param> /// <param name="colors">An array of colors the ColorBlend will use</param> /// <param name="gradientMode"></param> public KeyboardRectangle(KeyboardProvider keyboard, int x, int y, List<Color> colors, LinearGradientMode gradientMode) { _keyboard = keyboard; _rotationProgress = 0; _blinkWorker.DoWork += BlinkWorker_DoWork; Scale = 4; X = x; Y = y; Width = keyboard.Width*Scale; Height = keyboard.Height*Scale; Visible = true; Opacity = 255; ContainedBrush = true; GradientMode = gradientMode; Rotate = false; LoopSpeed = 1; Colors = colors; }
public RenderFrame(KeyboardProvider keyboard) { KeyboardBitmap = keyboard.KeyboardBitmap(4); KeyboardBitmap.SetResolution(96, 96); MouseBitmap = new Bitmap(40, 40); MouseBitmap.SetResolution(96, 96); HeadsetBitmap = new Bitmap(40, 40); HeadsetBitmap.SetResolution(96, 96); GenericBitmap = new Bitmap(40, 40); GenericBitmap.SetResolution(96, 96); MousematBitmap = new Bitmap(40, 40); MousematBitmap.SetResolution(96, 96); using (var g = Graphics.FromImage(KeyboardBitmap)) g.Clear(Color.Black); using (var g = Graphics.FromImage(MouseBitmap)) g.Clear(Color.Black); using (var g = Graphics.FromImage(HeadsetBitmap)) g.Clear(Color.Black); using (var g = Graphics.FromImage(GenericBitmap)) g.Clear(Color.Black); using (var g = Graphics.FromImage(MousematBitmap)) g.Clear(Color.Black); }
public KeyboardChangedEventArgs(KeyboardProvider oldKeyboard, KeyboardProvider newKeyboard) { OldKeyboard = oldKeyboard; NewKeyboard = newKeyboard; }
/// <summary> /// Enables the given keyboard /// </summary> /// <param name="keyboardProvider"></param> public async void EnableKeyboard(KeyboardProvider keyboardProvider) { if (keyboardProvider == null) throw new ArgumentNullException(nameof(keyboardProvider)); if (ChangingKeyboard || (ActiveKeyboard?.Name == keyboardProvider.Name)) return; _logger.Debug("Trying to enable keyboard: {0}", keyboardProvider.Name); ChangingKeyboard = true; // Store the old keyboard so it can be used in the event we're raising later var oldKeyboard = ActiveKeyboard; // Release the current keyboard ReleaseActiveKeyboard(); // Create a dialog to let the user know Artemis hasn't frozen ProgressDialogController dialog = null; if (DialogService.GetActiveWindow() != null) { dialog = await DialogService.ShowProgressDialog("Enabling keyboard", $"Checking if keyboard '{keyboardProvider.Name}' can be enabled...", true); // May seem a bit cheesy, but it's tidier to have the animation finish await Task.Delay(500); } dialog?.SetIndeterminate(); var canEnable = await keyboardProvider.CanEnableAsync(dialog); if (!canEnable) { if (dialog != null) await dialog.CloseAsync(); DialogService.ShowErrorMessageBox(keyboardProvider.CantEnableText); ActiveKeyboard = null; _generalSettings.LastKeyboard = null; _generalSettings.Save(); _logger.Warn("Failed enabling keyboard: {0}", keyboardProvider.Name); ChangingKeyboard = false; return; } dialog?.SetMessage($"Enabling keyboard: {keyboardProvider.Name}..."); // Setup the new keyboard ActiveKeyboard = keyboardProvider; await ActiveKeyboard.EnableAsync(dialog); EnableUsableDevices(); _generalSettings.LastKeyboard = ActiveKeyboard.Name; _generalSettings.Save(); RaiseKeyboardChangedEvent(new KeyboardChangedEventArgs(oldKeyboard, ActiveKeyboard)); _logger.Debug("Enabled keyboard: {0}", keyboardProvider.Name); if (dialog != null) await dialog.CloseAsync(); ChangingKeyboard = false; }
/// <summary> /// Resizes layers that are shown in the editor and match exactly the full keyboard widht and height /// </summary> /// <param name="target">The new keyboard to adjust the layers for</param> public void ResizeLayers(KeyboardProvider target) { foreach (var layer in GetLayers()) { if (!layer.LayerType.ShowInEdtor || !(Math.Abs(layer.Properties.Width - Width) < 0.01) || !(Math.Abs(layer.Properties.Height - Height) < 0.01)) continue; layer.Properties.Width = target.Width; layer.Properties.Height = target.Height; } }