/
EugenyCh7
/
VividUI.Net
Обзор
Документация
Войти
/
EugenyCh7
/
VividUI.Net
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
Безопасность
develop
VividUI.Net.Demo/Program.cs
200 строк
7 KB
Eugeny Chekmarev
Switch fix
02 дек 2024, 18:03
02 дек 2024, 18:03
eadd2fc
Код
Авторство
О чём код?
using SFML.Window; using SkiaSharp; using VividUI.Net.Brushes; using VividUI.Net.Containers; using VividUI.Net.TextOperations; using VividUI.Net.Widgets; namespace VividUI.Net.Demo { internal class Program { private static float Scale => VideoMode.DesktopMode.Height / 1080.0f; private static float BorderThickness => 2; private static void Main(string[] args) { Size windowSize = new Size(800, 600) * Scale; UIWindow window = new UIWindow(windowSize, "VividUI.Net.Demo") { WindowColor = SKColors.DarkSlateBlue, BackgroundBrush = new SolidColorBrush(SKColors.SteelBlue), BorderColor = SKColors.Black, BorderThickness = BorderThickness, Margin = new Thickness(32), ShowRenderFrequency = true }; window.SetRadius(32); Unary unary = new Unary { Stretching = Stretching.Max, Padding = new Thickness(32), BorderColor = SKColors.Black, BorderThickness = BorderThickness, BackgroundBrush = new SweepGradientBrush { Center = new SKPoint(0.5f, 0.5f), Colors = [SKColors.Blue, SKColors.Red, SKColors.Green, SKColors.Blue], Positions = [0, 0.333f, 0.666f, 1], TileMode = SKShaderTileMode.Clamp, StartAngle = 0, EndAngle = 360 } }; unary.SetRadius(32); unary.Margin = new Thickness(32); Unary subUnary = new Unary { SizeRequest = new Size(240, 80) * Scale, Padding = new Thickness(32), BorderColor = SKColors.LightGray, BackgroundBrush = new BitmapBrush { Bitmap = SKBitmap.Decode("texture.jpg"), ScaleX = 0.333f, ScaleY = 0.333f, TileModeX = SKShaderTileMode.Repeat, TileModeY = SKShaderTileMode.Repeat }, BorderThickness = 4 }; subUnary.SetRadius(32); FontDescription fontDescription = new FontDescription { TextColor = SKColors.White, FontSize = 16 * Scale, FontFamily = "Cascadia Code", ShadowColor = SKColors.Black, ShadowEnabled = true, ShadowX = 2, ShadowY = 2 }; Label label = new Label { Text = "Hello, world!!!", BackgroundBrush = new SolidColorBrush(SKColors.DarkSlateBlue), BorderColor = SKColors.SlateBlue, BorderThickness = BorderThickness, Padding = new Thickness(16), FontDescription = fontDescription }; label.SetRadius(16); Box box = new Box(Orientation.Vertical) { Stretching = Stretching.Max, ContentAlign = 0.5f, BorderColor = SKColors.Black, BackgroundBrush = new SolidColorBrush(SKColors.White.WithAlpha(128)), BorderThickness = BorderThickness, Padding = new Thickness(32), Spacing = 32 }; box.SetRadius(32); Overlay overlay = [ new OvalWidget { SizeRequest = new Size(64, 64), BackgroundBrush = new SolidColorBrush(SKColors.DarkSlateBlue), BorderColor = SKColors.SlateBlue, BorderThickness = BorderThickness }, new Label { Text = "73", FontDescription = fontDescription } ]; ProgressBar progressBar = new ProgressBar { SizeRequest = new Size(240, 32), BorderThickness = BorderThickness, BorderColor = SKColors.SlateBlue, BarBrush = new LinearGradientBrush { Start = new SKPoint(0, 0), End = new SKPoint(1, 0), Colors = [SKColors.DarkSlateBlue, SKColors.SlateBlue], Positions = [0.0f, 1.0f] }, BackgroundBrush = new RadialGradientBrush { Center = new SKPoint(0.5f, 0.5f), Radius = 1, Colors = [SKColors.White, SKColors.Gray], Positions = [0.0f, 1.0f] } }; progressBar.SetRadius(16); Button button = new Button("Press me!", fontDescription) { BackgroundBrush = new SolidColorBrush(SKColors.DarkSlateBlue), Padding = new Thickness(32) }; button.SetRadius(16); SvgPicture image = new SvgPicture(Resources.GetSvgIcon("System/add-box-fill"), new SvgPictureInitialization { ReplacementColor = SKColors.White, Size = new Size(48, 48), Shader = SKShader.CreateLinearGradient( new SKPoint(0, 0), new SKPoint(48, 48), [SKColors.Yellow, SKColors.Orange], [0, 1], SKShaderTileMode.Clamp) }) { ImageSize = new Size(48, 48) }; Switch switchWidget = new Switch { SizeRequest = new Size(64, 28), ActiveBackgroundBrush = new SolidColorBrush(SKColors.SlateBlue), InactiveBackgroundBrush = new SolidColorBrush(SKColors.LightGray), SliderBrush = new SolidColorBrush(SKColors.White), SliderBorderRadius = 12, SliderBorderThickness = 2, ActiveSliderBorderColor = SKColors.SlateBlue, InactiveSliderBorderColor = SKColors.LightGray, ActiveBorderColor = SKColors.SlateBlue, InactiveBorderColor = SKColors.LightGray, BorderThickness = 2, Padding = new Thickness(2) }; switchWidget.SetRadius(14); switchWidget.MouseButtonPressed += delegate { switchWidget.IsActive = !switchWidget.IsActive; }; box.Add(progressBar); box.Add(button); box.Add(image); box.Add(switchWidget); unary.Child = box; window.Child = unary; DateTime start = DateTime.Now; System.Timers.Timer timer = new System.Timers.Timer(10); timer.Elapsed += delegate { progressBar.BarValue = ((float)(DateTime.Now - start).TotalSeconds % 5.0f) / 5.0f; }; timer.Start(); object result = window.Open(); Console.WriteLine(result); } } }