first commit -push

This commit is contained in:
dungtt
2025-10-15 15:15:53 +07:00
parent 674ae395be
commit a9577c5756
885 changed files with 74595 additions and 0 deletions

View File

@@ -0,0 +1,11 @@
using System.Text.Json.Serialization;
namespace RobotNet.WebApp.Charts.Enums;
[JsonConverter(typeof(LowerCaseEnumConverter<AxisDirection>))]
public enum AxisDirection
{
X,
Y,
XY
}

View File

@@ -0,0 +1,7 @@
namespace RobotNet.WebApp.Charts.Enums;
public enum BorderAlign
{
Center,
Inner
}

View File

@@ -0,0 +1,12 @@
using System.Text.Json.Serialization;
namespace RobotNet.WebApp.Charts.Enums;
[JsonConverter(typeof(LowerCaseEnumConverter<BorderJoinStyle>))]
public enum BorderJoinStyle
{
Round,
Bevel,
Miter
}

View File

@@ -0,0 +1,17 @@
using System.Text.Json.Serialization;
namespace RobotNet.WebApp.Charts.Enums;
[JsonConverter(typeof(LowerCaseEnumConverter<BorderSkipped>))]
public enum BorderSkipped
{
Start,
End,
Middle,
Bottom,
Left,
Top,
Right,
False,
True
}

View File

@@ -0,0 +1,13 @@
using System.Text.Json.Serialization;
namespace RobotNet.WebApp.Charts.Enums;
[JsonConverter(typeof(LowerCaseEnumConverter<ChartAxesType>))]
public enum ChartAxesType
{
Linear,
Logarithmic,
Category,
Time,
Timeseries,
}

View File

@@ -0,0 +1,17 @@
using System.Text.Json.Serialization;
namespace RobotNet.WebApp.Charts.Enums;
[JsonConverter(typeof(CamelCaseEnumConverter<ChartType>))]
public enum ChartType
{
Line,
Bar,
Pie,
Doughnut,
PolarArea,
Radar,
Scatter,
Bubble
}

View File

@@ -0,0 +1,16 @@
using System.Text.Json.Serialization;
namespace RobotNet.WebApp.Charts.Enums;
[JsonConverter(typeof(LowerCaseEnumConverter<DataLabelsAlignment>))]
public enum DataLabelsAlignment
{
Center,
Start,
End,
Right,
Bottom,
Left,
Top,
None
}

View File

@@ -0,0 +1,12 @@
using System.Text.Json.Serialization;
namespace RobotNet.WebApp.Charts.Enums;
[JsonConverter(typeof(LowerCaseEnumConverter<DataLabelsAnchoring>))]
public enum DataLabelsAnchoring
{
Center,
Start,
End,
None,
}

View File

@@ -0,0 +1,10 @@
using System.Text.Json.Serialization;
namespace RobotNet.WebApp.Charts.Enums;
[JsonConverter(typeof(LowerCaseEnumConverter<DatasetType>))]
public enum DatasetType
{
Bar,
Line,
}

View File

@@ -0,0 +1,40 @@
using System.Text.Json.Serialization;
namespace RobotNet.WebApp.Charts.Enums;
[JsonConverter(typeof(LowerCaseEnumConverter<Easing>))]
public enum Easing
{
Linear,
EaseInQuad,
EaseOutQuad,
EaseInOutQuad,
EaseInCubic,
EaseOutCubic,
EaseInOutCubic,
EaseInQuart,
EaseOutQuart,
EaseInOutQuart,
EaseInQuint,
EaseOutQuint,
EaseInOutQuint,
EaseInSine,
EaseOutSine,
EaseInOutSine,
EaseInExpo,
EaseOutExpo,
EaseInOutExpo,
EaseInCirc,
EaseOutCirc,
EaseInOutCirc,
EaseInElastic,
EaseOutElastic,
EaseInOutElastic,
EaseInBack,
EaseOutBack,
EaseInOutBack,
EaseInBounce,
EaseOutBounce,
EaseInOutBounce,
}

View File

@@ -0,0 +1,38 @@
namespace RobotNet.WebApp.Charts.Enums;
public static class EnumExtensions
{
public static string? ToChartDatasetDataLabelAlignmentString(this DataLabelsAlignment alignment) =>
alignment switch
{
DataLabelsAlignment.Start => "start",
DataLabelsAlignment.Center or DataLabelsAlignment.None => "center", // default
DataLabelsAlignment.End => "end",
_ => null
};
public static string? ToChartDatasetDataLabelAnchorString(this DataLabelsAnchoring anchor) =>
anchor switch
{
DataLabelsAnchoring.Start => "start",
DataLabelsAnchoring.Center or DataLabelsAnchoring.None => "center", // default
DataLabelsAnchoring.End => "end",
_ => null
};
public static string ToCssString(this Unit unit) =>
unit switch
{
Unit.Em => "em",
Unit.Percentage => "%",
Unit.Pt => "pt",
Unit.Px => "px",
Unit.Rem => "rem",
Unit.Vh => "vh",
Unit.VMax => "vmax",
Unit.VMin => "vmin",
Unit.Vw => "vw",
_ => string.Empty
};
}

View File

@@ -0,0 +1,10 @@
using System.Text.Json.Serialization;
namespace RobotNet.WebApp.Charts.Enums;
[JsonConverter(typeof(LowerCaseEnumConverter<IndexAxis>))]
public enum IndexAxis
{
X,
Y,
}

View File

@@ -0,0 +1,37 @@
using System.Text.Json.Serialization;
namespace RobotNet.WebApp.Charts.Enums;
[JsonConverter(typeof(LowerCaseEnumConverter<InteractionMode>))]
public enum InteractionMode
{
/// <summary>
/// Finds items in the same dataset.
/// </summary>
Dataset,
/// <summary>
/// Finds item at the same index.
/// </summary>
Index,
/// <summary>
/// Gets the items that are at the nearest distance to the point.
/// </summary>
Nearest,
/// <summary>
/// Finds all of the items that intersect the point
/// </summary>
Point,
/// <summary>
/// Returns all items that would intersect based on the X coordinate of the position only. Would be useful for a vertical cursor implementation. Note that this only applies to cartesian charts.
/// </summary>
X,
/// <summary>
/// Returns all items that would intersect based on the Y coordinate of the position. This would be useful for a horizontal cursor implementation. Note that this only applies to cartesian charts.
/// </summary>
Y
}

View File

@@ -0,0 +1,11 @@
using System.Text.Json.Serialization;
namespace RobotNet.WebApp.Charts.Enums;
[JsonConverter(typeof(LowerCaseEnumConverter<LegendAlignment>))]
public enum LegendAlignment
{
Start,
Center,
End
}

View File

@@ -0,0 +1,16 @@
using System.Text.Json.Serialization;
namespace RobotNet.WebApp.Charts.Enums;
[JsonConverter(typeof(LowerCaseEnumConverter<LegendPosition>))]
public enum LegendPosition
{
Top,
Left,
Bottom,
Right,
/// <summary>
/// Using the 'chartArea' option the legend position is at the moment not configurable, it will always be on the left side of the chart in the middle.
/// </summary>
ChartArea,
}

View File

@@ -0,0 +1,52 @@
using System.Text.Json;
using System.Text.Json.Serialization;
namespace RobotNet.WebApp.Charts.Enums;
public class LowerCaseEnumConverter<T> : JsonConverter<T> where T : struct, Enum
{
public override T Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
{
var value = reader.GetString();
if (Enum.TryParse(value, true, out T result))
{
return result;
}
throw new JsonException($"Unable to convert \"{value}\" to enum {typeof(T)}.");
}
public override void Write(Utf8JsonWriter writer, T value, JsonSerializerOptions options)
{
writer.WriteStringValue(value.ToString().ToLower());
}
}
public class CamelCaseEnumConverter<T> : JsonConverter<T> where T : struct, Enum
{
public override T Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
{
string value = reader.GetString() ?? throw new JsonException();
foreach (T enumValue in Enum.GetValues<T>())
{
if (string.Equals(CamelCaseEnumConverter<T>.ToCamelCase(enumValue.ToString()), value, StringComparison.OrdinalIgnoreCase))
{
return enumValue;
}
}
throw new JsonException($"Unable to convert \"{value}\" to {typeof(T)}.");
}
public override void Write(Utf8JsonWriter writer, T value, JsonSerializerOptions options)
{
string enumString = CamelCaseEnumConverter<T>.ToCamelCase(value.ToString());
writer.WriteStringValue(enumString);
}
private static string ToCamelCase(string input)
{
if (string.IsNullOrEmpty(input) || char.IsLower(input[0]))
return input;
return char.ToLower(input[0]) + input[1..];
}
}

View File

@@ -0,0 +1,18 @@
using System.Text.Json.Serialization;
namespace RobotNet.WebApp.Charts.Enums;
[JsonConverter(typeof(LowerCaseEnumConverter<PointStyle>))]
public enum PointStyle
{
Circle,
Cross,
CrossRot,
Dash,
Line,
Rect,
RectRounded,
RectRot,
Star,
Triangle,
}

View File

@@ -0,0 +1,11 @@
using System.Text.Json.Serialization;
namespace RobotNet.WebApp.Charts.Enums;
[JsonConverter(typeof(LowerCaseEnumConverter<TicksAlignment>))]
public enum TicksAlignment
{
Center,
Start,
End
}

View File

@@ -0,0 +1,11 @@
using System.Text.Json.Serialization;
namespace RobotNet.WebApp.Charts.Enums;
[JsonConverter(typeof(LowerCaseEnumConverter<TitleAlignment>))]
public enum TitleAlignment
{
Start,
Center,
End
}

View File

@@ -0,0 +1,12 @@
using System.Text.Json.Serialization;
namespace RobotNet.WebApp.Charts.Enums;
[JsonConverter(typeof(LowerCaseEnumConverter<TitlePosition>))]
public enum TitlePosition
{
Top,
Left,
Bottom,
Right,
}

View File

@@ -0,0 +1,19 @@
using System.Text.Json.Serialization;
namespace RobotNet.WebApp.Charts.Enums;
[JsonConverter(typeof(LowerCaseEnumConverter<TooltipXAlignment>))]
public enum TooltipXAlignment
{
Left,
Center,
Right,
}
[JsonConverter(typeof(LowerCaseEnumConverter<TooltipYAlignment>))]
public enum TooltipYAlignment
{
Top,
Center,
Bottom,
}

View File

@@ -0,0 +1,11 @@
using System.Text.Json.Serialization;
namespace RobotNet.WebApp.Charts.Enums;
[JsonConverter(typeof(LowerCaseEnumConverter<TooltipPosition>))]
public enum TooltipPosition
{
Average,
Nearest
}

View File

@@ -0,0 +1,57 @@
using System.Text.Json.Serialization;
namespace RobotNet.WebApp.Charts.Enums;
[JsonConverter(typeof(LowerCaseEnumConverter<Unit>))]
public enum Unit
{
/// <summary>
/// No unit.
/// </summary>
None,
/// <summary>
/// Ems.
/// </summary>
Em,
/// <summary>
/// Percent.
/// </summary>
Percentage,
/// <summary>
/// Points.
/// </summary>
Pt,
/// <summary>
/// Pixels.
/// </summary>
Px,
/// <summary>
/// Root ems.
/// </summary>
Rem,
/// <summary>
/// Viewport height.
/// </summary>
Vh,
/// <summary>
/// Viewport maximum height.
/// </summary>
VMax,
/// <summary>
/// Viewport minimum height.
/// </summary>
VMin,
/// <summary>
/// Viewport width.
/// </summary>
Vw
}