private void Tick() { _cpuLoad.Enqueue(_systemStatusService.GetCpuLoad()); _memoryPercentage.Enqueue((int)(100 - _systemStatusService.GetFreeMemoryMBytes() * 100 / _systemStatusService.GetTotalMemoryMBytes())); var stats = _systemStatusService.GetNetworkStats(); var sent = stats.Sent; var recv = stats.Received; double mbpsSentSpeed = 8 * (sent - _prevSent) / (1024.0 * 1024); double mbpsReceivedSpeed = 8 * (recv - _prevRecv) / (1024.0 * 1024); var bitmap = LayoutContext.CreateBitmap(); if (_prevSent != 0 || _prevRecv != 0) { DefaultDrawingAlgs.DrawTexts(bitmap, GlobalContext.Options.Theme.FontFamily, $"{mbpsReceivedSpeed:F2}\n{mbpsSentSpeed:F2}", "", "888888", GlobalContext.Options.Theme.ForegroundColor); } _prevSent = sent; _prevRecv = recv; DrawLine(_cpuLoad, bitmap, GlobalContext.Options.Theme.ForegroundColor); DrawLine(_memoryPercentage, bitmap, Color.Aquamarine); DrawInvoke(new[] { new LayoutDrawElement(new Location(0, 0), bitmap) }); }
internal static BitmapEx Draw(int?unreadMessageCount, LayoutContext layoutContext) { var bitmap = layoutContext.CreateBitmap(); string countStr; string example = "8888"; string symb; if (unreadMessageCount == 0) { symb = FontAwesomeRes.fa_envelope_o; countStr = ""; } else if (unreadMessageCount == null) { symb = FontAwesomeRes.fa_envelope_o; countStr = "X"; } else { symb = FontAwesomeRes.fa_envelope; countStr = unreadMessageCount.ToString(); } DefaultDrawingAlgs.DrawIconAndText(bitmap, FontService.Instance.AwesomeFontFamily, symb, layoutContext.Options.Theme.FontFamily, countStr, example, layoutContext.Options.Theme.ForegroundColor); return(bitmap); }
protected override void OnEnteredLayout(LayoutContext layoutContext, ILayout previousLayout) { var bitmap = LayoutContext.CreateBitmap(); DefaultDrawingAlgs.DrawText(bitmap, FontService.Instance.AwesomeFontFamily, FontAwesomeRes.fa_arrow_left, GlobalContext.Options.Theme.ForegroundColor); DrawInvoke(new[] { new LayoutDrawElement(new Location(0, 0), bitmap) }); }
private void DrawMarkers() { List <LayoutDrawElement> result = new List <LayoutDrawElement>(); for (byte i = 0; i < TimersCount; i++) { var bmp = LayoutContext.CreateBitmap(); using (var graphics = bmp.CreateGraphics()) using (var brush = new SolidBrush(GlobalContext.Options.Theme.ForegroundColor)) { int r = 10; if (i == _currentPage) { r = 25; } var radius = Math.Min(bmp.Width, bmp.Height) * r / 100; graphics.FillEllipse(brush, (bmp.Width - radius) / 2, (bmp.Width - radius) / 2, radius, radius); } result.Add(new LayoutDrawElement(new Location(i, 2), bmp)); } DrawInvoke(result); }
private BitmapEx DrawKey() { var bitmap = LayoutContext.CreateBitmap(); var fontFamily = GlobalContext.Options.Theme.FontFamily; DefaultDrawingAlgs.DrawText(bitmap, fontFamily, _macroId.ToString(), GlobalContext.Options.Theme.ForegroundColor); return(bitmap); }
private LayoutDrawElement GetHeaderElement(int x, int y, string text, Color color) { var bitmap = _layoutContext.CreateBitmap(); var textFontFamily = _layoutContext.Options.Theme.FontFamily; DefaultDrawingAlgs.DrawText(bitmap, textFontFamily, text, color); return(new LayoutDrawElement(new Location(x, y), bitmap)); }
internal static BitmapEx DrawIcon(WeatherInfo response, string text, LayoutContext layoutContext) { var symbol = WeatherHelpers.GetWeatherSymbol(response.Symbol); var bitmap = layoutContext.CreateBitmap(); DefaultDrawingAlgs.DrawIconAndText(bitmap, WeatherHelpers.WeatherFontFamily, symbol, layoutContext.Options.Theme.FontFamily, text, "22:22", layoutContext.Options.Theme.ForegroundColor); return(bitmap); }
protected override void OnEnteredLayout(LayoutContext layoutContext, ILayout previousLayout) { _individualButtonSize = CalculateIndividualButtonSize(); _buttonShift = CalculateButtonShift(); using (var bitmap = layoutContext.CreateBitmap()) _currentRepresentation = new BitmapRepresentation(bitmap); _layoutToManage.DrawLayout += OnDrawLayout; _layoutToManage.EnterLayout(layoutContext, _previousLayout); }
private void DrawKey() { var bitmap = LayoutContext.CreateBitmap(); var fontFamily = FontService.Instance.AwesomeFontFamily; DefaultDrawingAlgs.DrawText(bitmap, fontFamily, _options.Text, GlobalContext.Options.Theme.ForegroundColor); DrawInvoke(new [] { new LayoutDrawElement(new Location(0, 0), bitmap) }); }
private static BitmapEx DrawText(string l, LayoutContext layoutContext) { var bitmap = layoutContext.CreateBitmap(); var textFontFamily = layoutContext.Options.Theme.FontFamily; DefaultDrawingAlgs.DrawText(bitmap, textFontFamily, l, layoutContext.Options.Theme.ForegroundColor); return(bitmap); }
private BitmapRepresentation GetBitmapRepresentation(byte[] bitmapBytes) { using (var bitmapRepresentation = new BitmapRepresentation(bitmapBytes)) using (var bmpEx = bitmapRepresentation.CreateBitmap()) using (var result = LayoutContext.CreateBitmap()) { BitmapHelpers.ResizeBitmap(bmpEx, result); return(new BitmapRepresentation(result)); } }
internal static BitmapEx DrawTexts(string l1, string l2, LayoutContext layoutContext) { var bitmap = layoutContext.CreateBitmap(); var textFontFamily = layoutContext.Options.Theme.FontFamily; DefaultDrawingAlgs.DrawTexts(bitmap, textFontFamily, l1, l2, "DDD", layoutContext.Options.Theme.ForegroundColor); return(bitmap); }
private static BitmapEx Draw(WeatherInfo weatherInfo, LayoutContext layoutContext) { var temperature = WeatherHelpers.TempToStr(weatherInfo.TemperatureCelsius ?? 0); var symbol = WeatherHelpers.GetWeatherSymbol(weatherInfo.Symbol); var bitmap = layoutContext.CreateBitmap(); DefaultDrawingAlgs.DrawIconAndText(bitmap, WeatherHelpers.WeatherFontFamily, symbol, layoutContext.Options.Theme.FontFamily, temperature, "+88", layoutContext.Options.Theme.ForegroundColor); return(bitmap); }
private static BitmapEx Draw(WeatherStationData weatherInfo, LayoutContext layoutContext) { var indoorDevice = weatherInfo.Devices.First(); var temperature = WeatherHelpers.TempToStr(indoorDevice.Temperature.Value); var co2 = indoorDevice.Co2Measure.Value.ToString(); var bitmap = layoutContext.CreateBitmap(); DefaultDrawingAlgs.DrawTexts(bitmap, layoutContext.Options.Theme.FontFamily, co2, temperature, "+88", layoutContext.Options.Theme.ForegroundColor); return(bitmap); }
private BitmapEx DrawNumber(byte number) { var bitmap = LayoutContext.CreateBitmap(); var fontFamily = GlobalContext.Options.Theme.FontFamily; var str = number.ToString("00"); DefaultDrawingAlgs.DrawText(bitmap, fontFamily, str, GlobalContext.Options.Theme.ForegroundColor); return(bitmap); }
private void DrawCommon() { var bmp1 = LayoutContext.CreateBitmap(); DefaultDrawingAlgs.DrawText(bmp1, FontService.Instance.AwesomeFontFamily, FontAwesomeRes.fa_undo, GlobalContext.Options.Theme.ForegroundColor); var bmp2 = LayoutContext.CreateBitmap(); DefaultDrawingAlgs.DrawText(bmp2, FontService.Instance.AwesomeFontFamily, FontAwesomeRes.fa_hand_grab_o, GlobalContext.Options.Theme.ForegroundColor); DrawInvoke(new[] { new LayoutDrawElement(new Location(3, 0), bmp1), new LayoutDrawElement(new Location(4, 0), bmp2) }); }
private BitmapEx DrawDate(DateTime date) { var bitmap = LayoutContext.CreateBitmap(); var fontFamily = GlobalContext.Options.Theme.FontFamily; var day = CultureInfo.CurrentCulture.DateTimeFormat.AbbreviatedDayNames[(int)date.DayOfWeek]; var dateStr1 = $"{day}, {date.Day}"; var dateStr2 = $"{date.ToString("MM.yy")}"; DefaultDrawingAlgs.DrawText(bitmap, fontFamily, $"{dateStr1}\n{dateStr2}", GlobalContext.Options.Theme.ForegroundColor); return(bitmap); }
private BitmapEx DrawKey() { var bitmap = LayoutContext.CreateBitmap(); var fontFamily = GlobalContext.Options.Theme.FontFamily; string icon = null; if (!_audioSelectLayout._options.Names.TryGetValue(_device.Id, out var combName)) { combName = $"{_device.RealName.Split(' ')[0]}\n{_device.FriendlyName.Split(' ')[0]}"; } else { switch (_device.Type) { case MediaDeviceType.Speakers: icon = FontAwesomeRes.fa_volume_down; break; case MediaDeviceType.Phone: icon = FontAwesomeRes.fa_phone; break; case MediaDeviceType.Digital: icon = FontAwesomeRes.fa_usb; break; case MediaDeviceType.Monitor: icon = FontAwesomeRes.fa_tv; break; } } if (icon != null) { DefaultDrawingAlgs.DrawCaptionedIcon(bitmap, FontService.Instance.AwesomeFontFamily, icon, fontFamily, combName, combName, GlobalContext.Options.Theme.ForegroundColor); } else { DefaultDrawingAlgs.DrawText(bitmap, fontFamily, combName, GlobalContext.Options.Theme.ForegroundColor); } if (_device.Id == _audioSelectLayout._defaultDeviceId) { DefaultDrawingAlgs.SelectElement(bitmap, GlobalContext.Options.Theme); } return(bitmap); }
private BitmapEx DrawKey() { var bitmap = LayoutContext.CreateBitmap(); var fontFamily = GlobalContext.Options.Theme.FontFamily; var combName = $"{_device.RealName.Split(' ')[0]}\n{_device.FriendlyName.Split(' ')[0]}"; DefaultDrawingAlgs.DrawText(bitmap, fontFamily, combName, GlobalContext.Options.Theme.ForegroundColor); if (_device.Mute) { DefaultDrawingAlgs.SelectElement(bitmap, GlobalContext.Options.Theme); } return(bitmap); }
private void Draw() { var bitmap = LayoutContext.CreateBitmap(); var fontFamily = GlobalContext.Options.Theme.FontFamily; DefaultDrawingAlgs.DrawText(bitmap, fontFamily, _action.Text, GlobalContext.Options.Theme.ForegroundColor); if (_action.Active) { DefaultDrawingAlgs.SelectElement(bitmap, GlobalContext.Options.Theme); } DrawInvoke(new [] { new LayoutDrawElement(new Location(0, 0), bitmap) }); }
private async void ProcessDraw() { try { WeatherInfo weather = await _weatherService.GetCurrentWeather(_weatherOptions.Place); var img = Draw(weather, LayoutContext); DrawInvoke(new[] { new LayoutDrawElement(new Location(0, 0), img) }); } catch (Exception) { var bitmap = LayoutContext.CreateBitmap(); DefaultDrawingAlgs.DrawIconAndText(bitmap, GlobalContext.Options.Theme.FontFamily, "...", GlobalContext.Options.Theme.FontFamily, "", "88888", GlobalContext.Options.Theme.ForegroundColor); DrawInvoke(new[] { new LayoutDrawElement(new Location(0, 0), bitmap) }); } }
private static BitmapEx DrawTexts(string l1, string l2, double[] values, LayoutContext layoutContext) { var bitmap = layoutContext.CreateBitmap(); var textFontFamily = layoutContext.Options.Theme.FontFamily; DefaultDrawingAlgs.DrawTexts(bitmap, textFontFamily, l1 + Environment.NewLine + l2, "", "DDDD", layoutContext.Options.Theme.ForegroundColor); var startIndex = 0; if (values.Length > bitmap.Width) { startIndex = values.Length - bitmap.Width; } DefaultDrawingAlgs.DrawPlot(bitmap, layoutContext.Options.Theme.ForegroundColor, values, bitmap.Height / 2, bitmap.Height, startIndex); return(bitmap); }
private void SetValue(byte value) { if (_currentIndex == 2 && value > 5) { return; } _values[_currentIndex] = value; var bmp = LayoutContext.CreateBitmap(); DefaultDrawingAlgs.DrawText(bmp, GlobalContext.Options.Theme.FontFamily, value.ToString(), GlobalContext.Options.Theme.ForegroundColor); DrawInvoke(new[] { new LayoutDrawElement(new Location((byte)(3 + _currentIndex % 2), (byte)(_currentIndex / 2)), bmp) }); _currentIndex++; if (_currentIndex == _values.Length) { LayoutContext.SetPreviousLayout(); } }
public static IEnumerable <LayoutDrawElement> ExtractLayoutDrawElements(BitmapEx source, DeviceSize deviceSize, byte left, byte top, LayoutContext layoutContext, TransitionInfo transitionInfo = default(TransitionInfo)) { var itemWidth = source.Width / deviceSize.Width; var itemHeight = source.Height / deviceSize.Height; for (byte x = 0; x < deviceSize.Width; x++) { for (byte y = 0; y < deviceSize.Height; y++) { var part = layoutContext.CreateBitmap(); using (Graphics grD = part.CreateGraphics()) { grD.DrawImage(source.GetInternal(), new Rectangle(0, 0, itemWidth, itemHeight), new Rectangle(x * itemWidth, y * itemHeight, itemWidth, itemHeight), GraphicsUnit.Pixel); } yield return(new LayoutDrawElement(new Location(left + x, top + y), part, transitionInfo)); } } }
private BitmapEx Draw(AppointmentInfo nextAppointment, byte opacity, LayoutContext layoutContext) { var bitmap = layoutContext.CreateBitmap(); if (opacity != 0) { using (var graphics = bitmap.CreateGraphics()) using (var brush = new SolidBrush(Color.FromArgb(opacity, _options.UpcomingMeetingColor))) { graphics.FillRectangle(brush, 0, 0, bitmap.Width, bitmap.Height); } } string result; result = nextAppointment != null ? $"{nextAppointment.FromDateTime:t}\n{nextAppointment.Location?.Split('(')[0].Trim()}" : "X"; DefaultDrawingAlgs.DrawText(bitmap, layoutContext.Options.Theme.FontFamily, result, layoutContext.Options.Theme.ForegroundColor); return(bitmap); }
private void Draw() { List <LayoutDrawElement> result = new List <LayoutDrawElement>(); for (byte i = 0; i < LayoutContext.ButtonCount.Width; i++) { for (byte j = 0; j < LayoutContext.ButtonCount.Height; j++) { var bmp = LayoutContext.CreateBitmap(); using (var grahics = bmp.CreateGraphics()) using (var brush = new SolidBrush(Color.FromArgb(_random.Next(0, 255), _random.Next(0, 255), _random.Next(0, 255), _random.Next(0, 255)))) { grahics.FillRectangle(brush, 0, 0, bmp.Width, bmp.Height); } result.Add(new LayoutDrawElement(new Location(i, j), bmp, new TransitionInfo(TransitionType.ElementUpdate, _frameDuration))); } } DrawInvoke(result); }
private BitmapEx DrawKey() { var bitmap = LayoutContext.CreateBitmap(); var path = _session.SessionIdentifier.Split('|')[1]; path = path.Substring(0, path.Length - 40); path = DevicePathMapper.FromDevicePath(path); var process = Process.GetProcesses().FirstOrDefault(p => p.Id == _session.ProcessId); if (path == null && process != null) { try { path = process.MainModule.FileName; } catch { } } if (path != null) { var iconRepresentation = _audioSelectLayout._bitmapDownloadService.GetBitmapForExecutable(path).GetAwaiter().GetResult(); using (var iconBmpEx = iconRepresentation.CreateBitmap()) { BitmapHelpers.ResizeBitmap(iconBmpEx, bitmap); } } if (_session.Mute) { DefaultDrawingAlgs.SelectElement(bitmap, GlobalContext.Options.Theme); } return(bitmap); }
protected override void OnEnteredLayout(LayoutContext layoutContext, ILayout previousLayout) { string symbol = ""; switch (GetAction()) { case PowerAction.PowerOff: symbol = FontAwesomeRes.fa_power_off; break; case PowerAction.LogOff: symbol = FontAwesomeRes.fa_user; break; case PowerAction.Reboot: symbol = FontAwesomeRes.fa_undo; break; } var bitmap = LayoutContext.CreateBitmap(); DefaultDrawingAlgs.DrawText(bitmap, FontService.Instance.AwesomeFontFamily, symbol, GlobalContext.Options.Theme.ForegroundColor); DrawInvoke(new[] { new LayoutDrawElement(new Location(0, 0), bitmap) }); }
private void PerformDraw(PlayingInfo playingInfo) { if (_previousRepresentation != playingInfo?.BitmapRepresentation || _prevPlaying != playingInfo?.IsPlaying) { _previousRepresentation = playingInfo?.BitmapRepresentation; _prevPlaying = playingInfo?.IsPlaying ?? false; var bitmap = LayoutContext.CreateBitmap(); if (playingInfo?.BitmapRepresentation != null) { using (var coverBitmap = playingInfo.BitmapRepresentation.CreateBitmap()) { BitmapHelpers.ResizeBitmap(coverBitmap, bitmap, _prevPlaying ? null : BitmapHelpers.GrayColorMatrix); } } else { DefaultDrawingAlgs.DrawText(bitmap, FontService.Instance.AwesomeFontFamily, FontAwesomeRes.fa_headphones, LayoutContext.Options.Theme.ForegroundColor); } DrawInvoke(new[] { new LayoutDrawElement(new Location(0, 0), bitmap, new TransitionInfo(TransitionType.ElementUpdate, TimeSpan.FromSeconds(1))) }); } }
private BitmapEx Draw() { var bitmap = LayoutContext.CreateBitmap(); if (!string.IsNullOrEmpty(_options.Symbol)) { var fontFamily = FontService.Instance.AwesomeFontFamily; DefaultDrawingAlgs.DrawText(bitmap, fontFamily, _options.Symbol, GlobalContext.Options.Theme.ForegroundColor); } else { using (var iconRepresentation = _bitmapDownloadService.GetBitmapForExecutable(_options.Executable).Result) using (var iconBmpEx = iconRepresentation.CreateBitmap()) { BitmapHelpers.ResizeBitmap(iconBmpEx, bitmap); if (_selected) { DefaultDrawingAlgs.SelectElement(bitmap, GlobalContext.Options.Theme); } } } return(bitmap); }