m8
m8
CC#
Created by brakence on 5/21/2025 in #help
How would I make automatic font size scaling with a custom control?
double minFontSize = 4.0; double maxFontSize = 32.0; double bestSize = minFontSize; for (double size = maxFontSize; size >= minFontSize; size -= 0.5) { var formattedText = new FormattedText( yourText, CultureInfo.CurrentCulture, FlowDirection.LeftToRight, new Typeface(yourFontFamily, yourFontStyle, yourFontWeight, FontStretches.Normal), size, Brushes.Black, new NumberSubstitution(), 1.0); formattedText.MaxTextWidth = ActualWidth; formattedText.MaxTextHeight = ActualHeight; if (formattedText.Width <= ActualWidth && formattedText.Height <= ActualHeight) { bestSize = size; break; // We found a size that fits! } } // Apply the best font size _FormattedText.SetFontSize(bestSize);
2 replies
CC#
Created by Elsevar on 5/21/2025 in #help
✅ Query Parameter Filtering Library
GET /api/items?search=book&sortBy=name&descending=true&page=2&pageSize=10 Something like this
8 replies
CC#
Created by Sweet_Spark on 5/16/2025 in #help
LibVLC in WinForms missing package components
Will check on my end
17 replies
CC#
Created by Sweet_Spark on 5/16/2025 in #help
LibVLC in WinForms missing package components
Or course, if you don't mind.
17 replies
CC#
Created by Sweet_Spark on 5/16/2025 in #help
LibVLC in WinForms missing package components
Can you share project? Or I can connect your pc via anydesk, will debug on there.
17 replies
CC#
Created by Sweet_Spark on 5/16/2025 in #help
LibVLC in WinForms missing package components
You don't use Visual Studio?
17 replies
CC#
Created by Sweet_Spark on 5/16/2025 in #help
LibVLC in WinForms missing package components
Can you share .csproj file?
17 replies
CC#
Created by Sweet_Spark on 5/16/2025 in #help
LibVLC in WinForms missing package components
using LibVLCSharp; // For MediaListPlayer using LibVLCSharp.Shared; // For LibVLC, MediaPlayer, MediaList
17 replies
CC#
Created by Zylvian on 5/16/2025 in #help
✅ Is there a good way to add example input values to your OpenAPI spec?
Register it in Program.cs: builder.Services.AddSwaggerGen(c => { c.SchemaFilter<ExampleSchemaFilter>(); });
5 replies
CC#
Created by Zylvian on 5/16/2025 in #help
✅ Is there a good way to add example input values to your OpenAPI spec?
2. Using ISchemaFilter for richer control Create a custom schema filter to inject examples at runtime: using Microsoft.OpenApi.Any; using Microsoft.OpenApi.Models; using Swashbuckle.AspNetCore.SwaggerGen; public class ExampleSchemaFilter : ISchemaFilter { public void Apply(OpenApiSchema schema, SchemaFilterContext context) { if (context.Type == typeof(DateTime)) { schema.Example = new OpenApiString("2025-01-01T00:00:00Z"); } } }
5 replies
CC#
Created by Zylvian on 5/16/2025 in #help
✅ Is there a good way to add example input values to your OpenAPI spec?
Yes, in .NET 9 (or even .NET 6/7/8), you can add example values to your OpenAPI spec so that tools like Scalar Playground, Swagger UI, or Postman prefill example data like a UTC datetime — saving you from typing it manually each time. 1. Using [SwaggerSchema] or [Example] attributes (recommended in .NET 7+) For a model class: using Swashbuckle.AspNetCore.Annotations; public class MyRequest { [SwaggerSchema(Description = "Date in UTC", Format = "date-time", Example = "2025-01-01T00:00:00Z")] public DateTime Timestamp { get; set; } }
5 replies