mirror of
https://gitcode.com/gh_mirrors/se/Semi.Avalonia
synced 2026-04-26 03:07:54 +08:00
feat: simplify menu.
This commit is contained in:
@@ -47,21 +47,6 @@
|
|||||||
</Style>
|
</Style>
|
||||||
</StackPanel.Styles>
|
</StackPanel.Styles>
|
||||||
|
|
||||||
<Button>
|
|
||||||
<PathIcon Data="{StaticResource SemiIconLanguage}" />
|
|
||||||
<Button.Flyout>
|
|
||||||
<MenuFlyout Placement="Bottom" ItemsSource="{Binding LocaleItems}" />
|
|
||||||
</Button.Flyout>
|
|
||||||
<Button.Styles>
|
|
||||||
<Style Selector="MenuItem" x:DataType="views:MenuItemViewModel">
|
|
||||||
<Setter Property="Header" Value="{Binding Header}" />
|
|
||||||
<Setter Property="ItemsSource" Value="{Binding Items}" />
|
|
||||||
<Setter Property="Command" Value="{Binding Command}" />
|
|
||||||
<Setter Property="CommandParameter" Value="{Binding CommandParameter}" />
|
|
||||||
</Style>
|
|
||||||
</Button.Styles>
|
|
||||||
</Button>
|
|
||||||
|
|
||||||
<Button Command="{Binding OpenUrlCommand}" CommandParameter="{Binding DocumentationUrl}">
|
<Button Command="{Binding OpenUrlCommand}" CommandParameter="{Binding DocumentationUrl}">
|
||||||
<PathIcon Data="{StaticResource SemiIconGlobe}" />
|
<PathIcon Data="{StaticResource SemiIconGlobe}" />
|
||||||
</Button>
|
</Button>
|
||||||
|
|||||||
@@ -26,75 +26,84 @@ public partial class MainViewModel : ObservableObject
|
|||||||
public string RepoUrl => "https://github.com/irihitech/Semi.Avalonia";
|
public string RepoUrl => "https://github.com/irihitech/Semi.Avalonia";
|
||||||
public IReadOnlyList<MenuItemViewModel> MenuItems { get; }
|
public IReadOnlyList<MenuItemViewModel> MenuItems { get; }
|
||||||
|
|
||||||
public IReadOnlyList<MenuItemViewModel> LocaleItems { get; }
|
|
||||||
|
|
||||||
public MainViewModel()
|
public MainViewModel()
|
||||||
{
|
{
|
||||||
MenuItems =
|
MenuItems =
|
||||||
[
|
[
|
||||||
new MenuItemViewModel
|
new MenuItemViewModel
|
||||||
{
|
{
|
||||||
Header = "Aquatic",
|
Header = "High Contrast Theme",
|
||||||
Command = SelectThemeCommand,
|
Items =
|
||||||
CommandParameter = SemiTheme.Aquatic
|
[
|
||||||
|
new MenuItemViewModel
|
||||||
|
{
|
||||||
|
Header = "Aquatic",
|
||||||
|
Command = SelectThemeCommand,
|
||||||
|
CommandParameter = SemiTheme.Aquatic
|
||||||
|
},
|
||||||
|
new MenuItemViewModel
|
||||||
|
{
|
||||||
|
Header = "Desert",
|
||||||
|
Command = SelectThemeCommand,
|
||||||
|
CommandParameter = SemiTheme.Desert
|
||||||
|
},
|
||||||
|
new MenuItemViewModel
|
||||||
|
{
|
||||||
|
Header = "Dusk",
|
||||||
|
Command = SelectThemeCommand,
|
||||||
|
CommandParameter = SemiTheme.Dusk
|
||||||
|
},
|
||||||
|
new MenuItemViewModel
|
||||||
|
{
|
||||||
|
Header = "NightSky",
|
||||||
|
Command = SelectThemeCommand,
|
||||||
|
CommandParameter = SemiTheme.NightSky
|
||||||
|
},
|
||||||
|
]
|
||||||
},
|
},
|
||||||
new MenuItemViewModel
|
new MenuItemViewModel()
|
||||||
{
|
{
|
||||||
Header = "Desert",
|
Header = "Locale",
|
||||||
Command = SelectThemeCommand,
|
Items=
|
||||||
CommandParameter = SemiTheme.Desert
|
[
|
||||||
},
|
new MenuItemViewModel
|
||||||
new MenuItemViewModel
|
{
|
||||||
{
|
Header = "简体中文",
|
||||||
Header = "Dusk",
|
Command = SelectLocaleCommand,
|
||||||
Command = SelectThemeCommand,
|
CommandParameter = new System.Globalization.CultureInfo("zh-cn")
|
||||||
CommandParameter = SemiTheme.Dusk
|
},
|
||||||
},
|
new MenuItemViewModel
|
||||||
new MenuItemViewModel
|
{
|
||||||
{
|
Header = "English",
|
||||||
Header = "NightSky",
|
Command = SelectLocaleCommand,
|
||||||
Command = SelectThemeCommand,
|
CommandParameter = new System.Globalization.CultureInfo("en-us")
|
||||||
CommandParameter = SemiTheme.NightSky
|
},
|
||||||
},
|
new MenuItemViewModel
|
||||||
];
|
{
|
||||||
LocaleItems =
|
Header = "日本語",
|
||||||
[
|
Command = SelectLocaleCommand,
|
||||||
new MenuItemViewModel
|
CommandParameter = new System.Globalization.CultureInfo("ja-jp")
|
||||||
{
|
},
|
||||||
Header = "简体中文",
|
new MenuItemViewModel
|
||||||
Command = SelectLocaleCommand,
|
{
|
||||||
CommandParameter = new System.Globalization.CultureInfo("zh-cn")
|
Header = "Українська",
|
||||||
},
|
Command = SelectLocaleCommand,
|
||||||
new MenuItemViewModel
|
CommandParameter = new System.Globalization.CultureInfo("uk-ua")
|
||||||
{
|
},
|
||||||
Header = "English",
|
new MenuItemViewModel
|
||||||
Command = SelectLocaleCommand,
|
{
|
||||||
CommandParameter = new System.Globalization.CultureInfo("en-us")
|
Header = "Русский",
|
||||||
},
|
Command = SelectLocaleCommand,
|
||||||
new MenuItemViewModel
|
CommandParameter = new System.Globalization.CultureInfo("ru-ru")
|
||||||
{
|
},
|
||||||
Header = "日本語",
|
new MenuItemViewModel
|
||||||
Command = SelectLocaleCommand,
|
{
|
||||||
CommandParameter = new System.Globalization.CultureInfo("ja-jp")
|
Header = "繁體中文",
|
||||||
},
|
Command = SelectLocaleCommand,
|
||||||
new MenuItemViewModel
|
CommandParameter = new System.Globalization.CultureInfo("zh-tw")
|
||||||
{
|
},
|
||||||
Header = "Українська",
|
]
|
||||||
Command = SelectLocaleCommand,
|
}
|
||||||
CommandParameter = new System.Globalization.CultureInfo("uk-ua")
|
|
||||||
},
|
|
||||||
new MenuItemViewModel
|
|
||||||
{
|
|
||||||
Header = "Русский",
|
|
||||||
Command = SelectLocaleCommand,
|
|
||||||
CommandParameter = new System.Globalization.CultureInfo("ru-ru")
|
|
||||||
},
|
|
||||||
new MenuItemViewModel
|
|
||||||
{
|
|
||||||
Header = "繁體中文",
|
|
||||||
Command = SelectLocaleCommand,
|
|
||||||
CommandParameter = new System.Globalization.CultureInfo("zh-tw")
|
|
||||||
},
|
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user