csharpc-sharpdotnetxamlavaloniauicross-platformcross-platform-xamlavaloniaguimulti-platformuser-interfacedotnetcore
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
78 lines
2.7 KiB
78 lines
2.7 KiB
using System;
|
|
using System.Collections;
|
|
using Avalonia;
|
|
using Avalonia.Controls;
|
|
using Avalonia.Markup.Xaml;
|
|
using Avalonia.Markup.Xaml.MarkupExtensions;
|
|
using Avalonia.Markup.Xaml.Styling;
|
|
using Avalonia.Markup.Xaml.XamlIl;
|
|
using Avalonia.Platform;
|
|
using ControlCatalog.Pages;
|
|
|
|
namespace ControlCatalog
|
|
{
|
|
public class MainView : UserControl
|
|
{
|
|
public MainView()
|
|
{
|
|
AvaloniaXamlLoader.Load(this);
|
|
if (AvaloniaLocator.Current.GetService<IRuntimePlatform>().GetRuntimeInfo().IsDesktop)
|
|
{
|
|
IList tabItems = ((IList)this.FindControl<TabControl>("Sidebar").Items);
|
|
tabItems.Add(new TabItem()
|
|
{
|
|
Header = "Dialogs",
|
|
Content = new DialogsPage()
|
|
});
|
|
tabItems.Add(new TabItem()
|
|
{
|
|
Header = "Screens",
|
|
Content = new ScreenPage()
|
|
});
|
|
|
|
}
|
|
|
|
var themes = this.Find<ComboBox>("Themes");
|
|
themes.SelectionChanged += (sender, e) =>
|
|
{
|
|
switch (themes.SelectedIndex)
|
|
{
|
|
case 0:
|
|
Application.Current.Styles[0] = App.FluentDark;
|
|
break;
|
|
case 1:
|
|
Application.Current.Styles[0] = App.FluentLight;
|
|
break;
|
|
case 2:
|
|
Application.Current.Styles[0] = App.DefaultLight;
|
|
break;
|
|
case 3:
|
|
Application.Current.Styles[0] = App.DefaultDark;
|
|
break;
|
|
}
|
|
};
|
|
|
|
var decorations = this.Find<ComboBox>("Decorations");
|
|
decorations.SelectionChanged += (sender, e) =>
|
|
{
|
|
if (VisualRoot is Window window)
|
|
window.SystemDecorations = (SystemDecorations)decorations.SelectedIndex;
|
|
};
|
|
|
|
var transparencyLevels = this.Find<ComboBox>("TransparencyLevels");
|
|
transparencyLevels.SelectionChanged += (sender, e) =>
|
|
{
|
|
if (VisualRoot is Window window)
|
|
window.TransparencyLevelHint = (WindowTransparencyLevel)transparencyLevels.SelectedIndex;
|
|
};
|
|
}
|
|
|
|
protected override void OnAttachedToVisualTree(VisualTreeAttachmentEventArgs e)
|
|
{
|
|
base.OnAttachedToVisualTree(e);
|
|
var decorations = this.Find<ComboBox>("Decorations");
|
|
if (VisualRoot is Window window)
|
|
decorations.SelectedIndex = (int)window.SystemDecorations;
|
|
}
|
|
}
|
|
}
|
|
|