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); }
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 async void ProcessDraw() { var weather = await GetData(); var rows = _layoutContext.ButtonCount.Height; LayoutDrawElement[] result = new LayoutDrawElement[_layoutContext.ButtonCount.Width * rows]; for (byte i = 0; i < Math.Min(_layoutContext.ButtonCount.Width, weather.Length); i++) { result[i * rows] = new LayoutDrawElement(new Location(i, 0), DrawIcon(weather[i], GetDescription(weather[i]), _layoutContext)); result[i * rows + 1] = new LayoutDrawElement(new Location(i, 1), DrawTexts(WeatherHelpers.TempToStr(weather[i].TemperatureMaxCelsius ?? 0), WeatherHelpers.TempToStr(weather[i].TemperatureMinCelsius ?? 0), _layoutContext)); if (_layoutContext.ButtonCount.Height > 2) { result[i * rows + 2] = new LayoutDrawElement(new Location(i, 2), DrawTexts(((int)(weather[i].PressureMPa ?? 0)).ToString(), weather[i].Humidity.ToString() + "%", _layoutContext)); } if (_layoutContext.ButtonCount.Height > 3) { result[i * rows + 3] = new LayoutDrawElement(new Location(i, 3), DrawTexts(((int)(weather[i].Rain ?? 0)).ToString(), weather[i].Wind, _layoutContext)); } } DrawLayout?.Invoke(this, new DrawEventArgs(result)); }