-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
36c19d4
commit ddb8e32
Showing
2 changed files
with
53 additions
and
2 deletions.
There are no files selected for viewing
29 changes: 27 additions & 2 deletions
29
src/RxTelegram.Bot/Interface/ChatBackground/BackgroundTypeWallpaper.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,31 @@ | ||
using RxTelegram.Bot.Interface.BaseTypes; | ||
|
||
namespace RxTelegram.Bot.Interface.ChatBackground; | ||
|
||
public class BackgroundTypeWallpaper | ||
public class BackgroundTypeWallpaper : BackgroundType | ||
{ | ||
|
||
/// <summary> | ||
/// Type of the background, always “wallpaper” | ||
/// </summary> | ||
public override string Type { get; } = "wallpaper"; | ||
|
||
/// <summary> | ||
/// Document with the wallpaper | ||
/// </summary> | ||
public Document Document { get; set; } | ||
|
||
/// <summary> | ||
/// Dimming of the background in dark themes, as a percentage; 0-100 | ||
/// </summary> | ||
public int DarkThemeDimming { get; set; } | ||
|
||
/// <summary> | ||
/// Optional. True, if the wallpaper is downscaled to fit in a 450x450 square and then box-blurred with radius 12 | ||
/// </summary> | ||
public bool IsBlurred { get; set; } | ||
|
||
/// <summary> | ||
/// Optional. True, if the background moves slightly when the device is tilted | ||
/// </summary> | ||
public bool IsMoving { get; set; } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
using System; | ||
using System.Globalization; | ||
|
||
namespace RxTelegram.Bot.Utils; | ||
|
||
public class HexToRgb24 | ||
{ | ||
public int Convert(string hexColor) => int.Parse(FormatHexString(hexColor), NumberStyles.HexNumber); | ||
|
||
public bool TryConvert(string hexColor, out int result) => int.TryParse(FormatHexString(hexColor), NumberStyles.HexNumber, null, out result); | ||
|
||
private static string FormatHexString(string hexColor) | ||
{ | ||
hexColor = hexColor.TrimStart('#'); | ||
if (hexColor.Length == 3) | ||
{ | ||
hexColor = string.Concat(hexColor[0], hexColor[0], hexColor[1], hexColor[1], hexColor[2], hexColor[2]); | ||
} | ||
else if (hexColor.Length != 6) | ||
{ | ||
throw new ArgumentException("Hex color must be 3 or 6 characters long."); | ||
} | ||
|
||
return hexColor; | ||
} | ||
} |