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 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); }
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); }
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 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 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 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 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 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 void DrawLine(Queue <int> queue, BitmapEx bitmap, Color color) { while (queue.Count > bitmap.Width) { queue.Dequeue(); } if (queue.Count > 1) { var array = queue.ToArray(); DefaultDrawingAlgs.DrawPlot(bitmap, color, array, 0, bitmap.Height, minValue: 0, maxValue: 100); } }
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 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 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 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 async void ProcessDraw() { try { var from = DateTime.Now.Subtract(_options.ExpiredMeetingTolerance); var to = from.AddDays(2).Date; _appointments = _calendarServices.SelectMany(c => c.GetCalendar(from, to)).OrderBy(c => c.FromDateTime).ToArray(); var rows = _layoutContext.ButtonCount.Height; var columns = _layoutContext.ButtonCount.Width; LayoutDrawElement[] result = new LayoutDrawElement[columns * rows]; for (byte i = 0; i < Math.Min(_layoutContext.ButtonCount.Height, _appointments.Length); i++) { result[i * columns] = new LayoutDrawElement(new Location(0, i), DrawText(FormatDateTime(_appointments[i].FromDateTime, _appointments[i].ToDateTime), _layoutContext)); result[i * columns + 1] = new LayoutDrawElement(new Location(2, i), DrawText(_appointments[i].Location, _layoutContext)); result[i * columns + 2] = new LayoutDrawElement(new Location(1, i), DrawText(_appointments[i].Organiser, _layoutContext)); byte firstNameIndex = 3; byte textButtonCount = (byte)(columns - firstNameIndex); if (textButtonCount > 0) { using (var bitmap = new BitmapEx(_layoutContext.IconSize.Width * textButtonCount, _layoutContext.IconSize.Height)) { bitmap.MakeTransparent(); DefaultDrawingAlgs.DrawText(bitmap, _layoutContext.Options.Theme.FontFamily, _appointments[i].Subject, _layoutContext.Options.Theme.ForegroundColor); var elements = BitmapHelpers.ExtractLayoutDrawElements(bitmap, new DeviceSize(textButtonCount, 1), firstNameIndex, i, _layoutContext); int j = firstNameIndex; foreach (var e in elements) { result[i * columns + j] = e; j++; } } } } DrawLayout?.Invoke(this, new DrawEventArgs(result)); } catch (Exception ex) { Debug.WriteLine($"Exception during weather station layout drawing: {ex}"); } }
private async void ProcessDraw() { try { List <LayoutDrawElement> result = new List <LayoutDrawElement>(14); var weather = await _weatherStationService.GetHistorical(); var values = weather.Union(new[] { await _weatherStationService.GetData() }).Select(m => _element.GetFunc(m)).ToArray(); var currentValue = values.Last(); var minValue = values.Min(); var maxValue = values.Max(); var avgValue = values.Average(); var color = _layoutContext.Options.Theme.ForegroundColor; result.Add(GetHeaderElement(0, 0, "Min", color)); result.Add(GetHeaderElement(1, 0, "Avg", color)); result.Add(GetHeaderElement(2, 0, "Max", color)); result.Add(GetHeaderElement(3, 0, "Cur", color)); result.Add(GetHeaderElement(0, 1, _element.TransformFunc(minValue), color)); result.Add(GetHeaderElement(1, 1, _element.TransformFunc(avgValue), color)); result.Add(GetHeaderElement(2, 1, _element.TransformFunc(maxValue), color)); result.Add(GetHeaderElement(3, 1, _element.TransformFunc(currentValue), color)); result.Add(GetHeaderElement(4, 1, _element.Suffix, color)); var deviceWidth = _layoutContext.ButtonCount.Width; using (var bitmap = new BitmapEx(_layoutContext.IconSize.Width * deviceWidth, _layoutContext.IconSize.Height)) { bitmap.MakeTransparent(); DefaultDrawingAlgs.DrawPlot(bitmap, color, values, 0, bitmap.Height); result.AddRange(BitmapHelpers.ExtractLayoutDrawElements(bitmap, new DeviceSize(deviceWidth, 1), 0, 2, _layoutContext)); } DrawLayout?.Invoke(this, new DrawEventArgs(result.ToArray())); } catch (Exception ex) { Debug.WriteLine($"Exception during weather station layout drawing: {ex}"); } }
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(); } }
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 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 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); }
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 void PerformDraw(PlayingInfo playingInfo) { byte imageSize = 2; byte textSize = 3; var result = new List <LayoutDrawElement>(); if (playingInfo.IsPlaying != _isPlaying) { _isPlaying = playingInfo.IsPlaying; _playPauseButton.ReplaceText(_isPlaying.Value?FontAwesomeRes.fa_pause:FontAwesomeRes.fa_play); } if (_previousRepresentation != playingInfo?.BitmapRepresentation) { _previousRepresentation = playingInfo?.BitmapRepresentation; using (var bitmap = new BitmapEx(LayoutContext.IconSize.Width * imageSize, LayoutContext.IconSize.Height * imageSize)) { bitmap.MakeTransparent(); if (playingInfo?.BitmapRepresentation != null) { using (BitmapEx coverBitmap = playingInfo.BitmapRepresentation.CreateBitmap()) { BitmapHelpers.ResizeBitmap(coverBitmap, bitmap); } } result.AddRange(BitmapHelpers.ExtractLayoutDrawElements(bitmap, new DeviceSize(imageSize, imageSize), 0, 0, LayoutContext)); } } using (var bitmap = new BitmapEx(LayoutContext.IconSize.Width * textSize, LayoutContext.IconSize.Height)) { var lineWidth = 0.05; bitmap.MakeTransparent(); var title = playingInfo?.Title; DefaultDrawingAlgs.DrawText(bitmap, GlobalContext.Options.Theme.FontFamily, title, LayoutContext.Options.Theme.ForegroundColor); if (playingInfo != null) { using (var graphics = bitmap.CreateGraphics()) using (var brush = new SolidBrush(GlobalContext.Options.Theme.ForegroundColor)) { var rect = new Rectangle(0, (int)(bitmap.Height * (1 - lineWidth)), (int)(bitmap.Width * playingInfo.CurrentPosition.TotalMilliseconds / playingInfo.DurationSpan.TotalMilliseconds), (int)(bitmap.Height * lineWidth)); graphics.FillRectangle(brush, rect); } } result.AddRange(BitmapHelpers.ExtractLayoutDrawElements(bitmap, new DeviceSize(textSize, 1), imageSize, 0, LayoutContext)); } using (var bitmap = new BitmapEx(LayoutContext.IconSize.Width * textSize, LayoutContext.IconSize.Height)) { bitmap.MakeTransparent(); var artist = playingInfo?.Artist ?? string.Empty; var album = playingInfo?.Album ?? string.Empty; var text = $"{artist}\n{album}"; DefaultDrawingAlgs.DrawText(bitmap, GlobalContext.Options.Theme.FontFamily, text, GlobalContext.Options.Theme.ForegroundColor); result.AddRange(BitmapHelpers.ExtractLayoutDrawElements(bitmap, new DeviceSize(textSize, 1), imageSize, 1, LayoutContext)); } DrawInvoke(result); }