public override void RenderOverlay(RenderFrame frame, bool keyboardOnly) { if ((MainManager.DeviceManager.ActiveKeyboard == null) || (VolumeDisplay == null) || (VolumeDisplay.Ttl < 1)) return; using (var g = Graphics.FromImage(frame.KeyboardBitmap)) { VolumeDisplay.Draw(g); } }
// Called after every update /// <summary> /// Renders the currently active profile /// </summary> /// <param name="frame"></param> /// <param name="keyboardOnly"></param> public virtual void Render(RenderFrame frame, bool keyboardOnly) { if (Profile == null || DataModel == null || MainManager.DeviceManager.ActiveKeyboard == null) return; lock (DataModel) { // Get all enabled layers who's conditions are met var renderLayers = GetRenderLayers(keyboardOnly); // Render the keyboard layer-by-layer var keyboardRect = MainManager.DeviceManager.ActiveKeyboard.KeyboardRectangle(KeyboardScale); using (var g = Graphics.FromImage(frame.KeyboardBitmap)) { Profile?.DrawLayers(g, renderLayers.Where(rl => rl.LayerType.DrawType == DrawType.Keyboard), DataModel, keyboardRect, false, true); } // Render mice layer-by-layer var devRec = new Rect(0, 0, 40, 40); using (var g = Graphics.FromImage(frame.MouseBitmap)) { Profile?.DrawLayers(g, renderLayers.Where(rl => rl.LayerType.DrawType == DrawType.Mouse), DataModel, devRec, false, true); } // Render headsets layer-by-layer using (var g = Graphics.FromImage(frame.HeadsetBitmap)) { Profile?.DrawLayers(g, renderLayers.Where(rl => rl.LayerType.DrawType == DrawType.Headset), DataModel, devRec, false, true); } // Render generic devices layer-by-layer using (var g = Graphics.FromImage(frame.GenericBitmap)) { Profile?.DrawLayers(g, renderLayers.Where(rl => rl.LayerType.DrawType == DrawType.Generic), DataModel, devRec, false, true); } // Render mousemats layer-by-layer using (var g = Graphics.FromImage(frame.MousematBitmap)) { Profile?.DrawLayers(g, renderLayers.Where(rl => rl.LayerType.DrawType == DrawType.Mousemat), DataModel, devRec, false, true); } // Trace debugging if (DateTime.Now.AddSeconds(-2) <= LastTrace) return; LastTrace = DateTime.Now; MainManager.Logger.Trace("Effect datamodel as JSON: \r\n{0}", JsonConvert.SerializeObject(DataModel, Formatting.Indented)); MainManager.Logger.Trace("Effect {0} has to render {1} layers", Name, renderLayers.Count); foreach (var renderLayer in renderLayers) MainManager.Logger.Trace("- Layer name: {0}, layer type: {1}", renderLayer.Name, renderLayer.LayerType); } }
public override void Render(RenderFrame frame, bool keyboardOnly) { if (Profile == null || DataModel == null || MainManager.DeviceManager.ActiveKeyboard == null) return; lock (DataModel) { // Get all enabled layers who's conditions are met var renderLayers = GetRenderLayers(keyboardOnly); // Render the keyboard layer-by-layer var keyboardRect = MainManager.DeviceManager.ActiveKeyboard.KeyboardRectangle(KeyboardScale); using (var g = Graphics.FromImage(frame.KeyboardBitmap)) { Profile.DrawLayers(g, renderLayers.Where(rl => rl.LayerType.DrawType == DrawType.Keyboard), DataModel, keyboardRect, true, true); } // Render mice layer-by-layer var devRec = new Rect(0, 0, 40, 40); using (var g = Graphics.FromImage(frame.MouseBitmap)) { Profile?.DrawLayers(g, renderLayers.Where(rl => rl.LayerType.DrawType == DrawType.Mouse), DataModel, devRec, true, true); } // Render headsets layer-by-layer using (var g = Graphics.FromImage(frame.HeadsetBitmap)) { Profile?.DrawLayers(g, renderLayers.Where(rl => rl.LayerType.DrawType == DrawType.Headset), DataModel, devRec, true, true); } // Render generic devices layer-by-layer using (var g = Graphics.FromImage(frame.GenericBitmap)) { Profile?.DrawLayers(g, renderLayers.Where(rl => rl.LayerType.DrawType == DrawType.Generic), DataModel, devRec, true, true); } // Render mousemats layer-by-layer using (var g = Graphics.FromImage(frame.MousematBitmap)) { Profile?.DrawLayers(g, renderLayers.Where(rl => rl.LayerType.DrawType == DrawType.Mousemat), DataModel, devRec, true, true); } } }
private void Render(object sender, ElapsedEventArgs e) { if (!Running || _deviceManager.ChangingKeyboard) return; // Stop if no active effect if (_effectManager.ActiveEffect == null) { _logger.Debug("No active effect, stopping"); Stop(); return; } var renderEffect = _effectManager.ActiveEffect; // Stop if no active keyboard if (_deviceManager.ActiveKeyboard == null) { _logger.Debug("No active keyboard, stopping"); Stop(); return; } lock (_deviceManager.ActiveKeyboard) { // Skip frame if effect is still initializing if (renderEffect.Initialized == false) return; // ApplyProperties the current effect if (renderEffect.Initialized) renderEffect.Update(); // Get the devices that must be rendered to var mice = _deviceManager.MiceProviders.Where(m => m.CanUse).ToList(); var headsets = _deviceManager.HeadsetProviders.Where(m => m.CanUse).ToList(); var generics = _deviceManager.GenericProviders.Where(m => m.CanUse).ToList(); var mousemats = _deviceManager.MousematProviders.Where(m => m.CanUse).ToList(); var keyboardOnly = !mice.Any() && !headsets.Any() && !generics.Any() && !mousemats.Any(); // Setup the frame for this tick using (var frame = new RenderFrame(_deviceManager.ActiveKeyboard)) { if (renderEffect.Initialized) renderEffect.Render(frame, keyboardOnly); // Draw enabled overlays on top of the renderEffect foreach (var overlayModel in _effectManager.EnabledOverlays) { overlayModel.Update(); overlayModel.RenderOverlay(frame, keyboardOnly); } // Update the keyboard _deviceManager.ActiveKeyboard?.DrawBitmap(frame.KeyboardBitmap); // Update the other devices foreach (var mouse in mice) mouse.UpdateDevice(frame.MouseBitmap); foreach (var headset in headsets) headset.UpdateDevice(frame.HeadsetBitmap); foreach (var generic in generics) generic.UpdateDevice(frame.GenericBitmap); foreach (var mousemat in mousemats) mousemat.UpdateDevice(frame.MousematBitmap); } } }
public override void Render(RenderFrame frame, bool keyboardOnly) { using (var g = Graphics.FromImage(frame.KeyboardBitmap)) { foreach (var bubble in _bubbles) bubble.Draw(g); } }
public abstract void RenderOverlay(RenderFrame frame, bool keyboardOnly);