Skip to content

Commit

Permalink
feat: add tray demo, change icon.
Browse files Browse the repository at this point in the history
  • Loading branch information
rabbitism committed Jan 11, 2025
1 parent 8955c83 commit 1602e7d
Show file tree
Hide file tree
Showing 8 changed files with 40 additions and 3 deletions.
1 change: 1 addition & 0 deletions demo/Semi.Avalonia.Demo.Web/Semi.Avalonia.Demo.Web.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

<ItemGroup>
<AvaloniaResource Include="Assets\**"/>
<AvaloniaResource Include="wwwroot\irihi.ico" />
</ItemGroup>

<ItemGroup>
Expand Down
Binary file modified demo/Semi.Avalonia.Demo.Web/wwwroot/favicon.ico
Binary file not shown.
19 changes: 17 additions & 2 deletions demo/Semi.Avalonia.Demo/App.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@
x:Class="Semi.Avalonia.Demo.App"
xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:semi="https://irihi.tech/semi">
x:CompileBindings="True"
x:DataType="viewModels:ApplicationViewModel"
xmlns:semi="https://irihi.tech/semi"
xmlns:viewModels="clr-namespace:Semi.Avalonia.Demo.ViewModels">
<Application.Styles>
<!-- You can still reference in old way. -->
<!-- <StyleInclude Source="avares://Semi.Avalonia/Index.axaml" /> -->
Expand All @@ -14,8 +17,20 @@
<Application.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceInclude Source="Themes/_index.axaml" />
<ResourceInclude
Source="Themes/_index.axaml" />
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</Application.Resources>
<TrayIcon.Icons>
<TrayIcons>
<TrayIcon Icon="/Assets/irihi.ico" MacOSProperties.IsTemplateIcon="true" ToolTipText="Semi Avalonia Demo">
<TrayIcon.Menu>
<NativeMenu>
<NativeMenuItem Header="Exit" Command="{Binding ExitCommand}" />
</NativeMenu>
</TrayIcon.Menu>
</TrayIcon>
</TrayIcons>
</TrayIcon.Icons>
</Application>
2 changes: 2 additions & 0 deletions demo/Semi.Avalonia.Demo/App.axaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using Avalonia.Controls.ApplicationLifetimes;
using Avalonia.Data.Core.Plugins;
using Avalonia.Markup.Xaml;
using Semi.Avalonia.Demo.ViewModels;
using Semi.Avalonia.Demo.Views;

namespace Semi.Avalonia.Demo;
Expand All @@ -11,6 +12,7 @@ public partial class App : Application
public override void Initialize()
{
AvaloniaXamlLoader.Load(this);
this.DataContext = new ApplicationViewModel();
}

public override void OnFrameworkInitializationCompleted()
Expand Down
Binary file removed demo/Semi.Avalonia.Demo/Assets/avalonia-logo.ico
Binary file not shown.
Binary file added demo/Semi.Avalonia.Demo/Assets/irihi.ico
Binary file not shown.
19 changes: 19 additions & 0 deletions demo/Semi.Avalonia.Demo/ViewModels/ApplicationViewModel.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
using Avalonia;
using Avalonia.Controls.ApplicationLifetimes;
using CommunityToolkit.Mvvm.ComponentModel;
using CommunityToolkit.Mvvm.Input;
using Semi.Avalonia.Demo.Views;

namespace Semi.Avalonia.Demo.ViewModels;

public partial class ApplicationViewModel: ObservableObject
{
[RelayCommand]
private void Exit()
{
if (Application.Current?.ApplicationLifetime is IClassicDesktopStyleApplicationLifetime desktop)
{
desktop.Shutdown();
}
}
}
2 changes: 1 addition & 1 deletion demo/Semi.Avalonia.Demo/Views/MainWindow.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
Title="Semi.Avalonia.Demo"
d:DesignHeight="450"
d:DesignWidth="800"
Icon="/Assets/avalonia-logo.ico"
Icon="/Assets/irihi.ico"
mc:Ignorable="d">
<views:MainView />
</Window>

0 comments on commit 1602e7d

Please sign in to comment.