-
Notifications
You must be signed in to change notification settings - Fork 81
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #587 from irihitech/splash
Add Splash Window
- Loading branch information
Showing
13 changed files
with
345 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
<u:SplashWindow xmlns="/~https://github.com/avaloniaui" | ||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | ||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" | ||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" | ||
xmlns:u="https://irihi.tech/ursa" | ||
mc:Ignorable="d" d:DesignWidth="800" | ||
d:DesignHeight="450" | ||
CountDown="0:0:2" | ||
x:Class="Sandbox.Views.MainSplashWindow" | ||
Title="MainSplashWindow"> | ||
Welcome to Avalonia Splash Window! | ||
</u:SplashWindow> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
using System; | ||
using System.Threading.Tasks; | ||
using System.Timers; | ||
using Avalonia; | ||
using Avalonia.Controls; | ||
using Avalonia.Markup.Xaml; | ||
using Avalonia.Threading; | ||
using Sandbox.ViewModels; | ||
using Ursa.Controls; | ||
|
||
namespace Sandbox.Views; | ||
|
||
public partial class MainSplashWindow : SplashWindow | ||
{ | ||
public MainSplashWindow() | ||
{ | ||
InitializeComponent(); | ||
} | ||
|
||
protected override async Task<Window> CreateNextWindow() | ||
{ | ||
return new MainWindow() | ||
{ | ||
DataContext = new MainWindowViewModel() | ||
}; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
using System; | ||
using Avalonia.Threading; | ||
using CommunityToolkit.Mvvm.ComponentModel; | ||
using Irihi.Avalonia.Shared.Contracts; | ||
|
||
namespace Ursa.Demo.ViewModels; | ||
|
||
public partial class SplashViewModel: ObservableObject, IDialogContext | ||
{ | ||
[ObservableProperty] private double _progress; | ||
private Random _r = new(); | ||
|
||
public SplashViewModel() | ||
{ | ||
DispatcherTimer.Run(OnUpdate, TimeSpan.FromMilliseconds(20), DispatcherPriority.Default); | ||
} | ||
|
||
private bool OnUpdate() | ||
{ | ||
Progress += 10 * _r.NextDouble(); | ||
if (Progress <= 100) | ||
{ | ||
return true; | ||
} | ||
else | ||
{ | ||
RequestClose?.Invoke(this, true); | ||
return false; | ||
} | ||
} | ||
|
||
public void Close() | ||
{ | ||
RequestClose?.Invoke(this, false); | ||
} | ||
|
||
public event EventHandler<object?>? RequestClose; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
<u:SplashWindow | ||
x:Class="Ursa.Demo.Views.MainSplashWindow" | ||
xmlns="/~https://github.com/avaloniaui" | ||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | ||
xmlns:iri="https://irihi.tech/shared" | ||
xmlns:u="https://irihi.tech/ursa" | ||
Title="MainSplashWindow" | ||
Width="400" | ||
Height="400"> | ||
<Grid | ||
HorizontalAlignment="Center" | ||
VerticalAlignment="Center" | ||
ColumnDefinitions="Auto, Auto" | ||
RowDefinitions="Auto, Auto"> | ||
<iri:IrihiLogo | ||
Grid.Row="0" | ||
Grid.Column="0" | ||
Width="64" | ||
Margin="0,0,16,0" | ||
Fill="{DynamicResource SemiColorText2}" /> | ||
<StackPanel Grid.Row="0" Grid.Column="1"> | ||
<TextBlock | ||
Classes="H2" | ||
Text="铱泓科技" | ||
Theme="{DynamicResource TitleTextBlock}" /> | ||
<TextBlock FontWeight="Bold" Text="IRIHI Technology" /> | ||
</StackPanel> | ||
<StackPanel | ||
Grid.Row="1" | ||
Grid.Column="0" | ||
Grid.ColumnSpan="2"> | ||
<TextBlock | ||
Margin="0,12,0,0" | ||
HorizontalAlignment="Center" | ||
FontSize="14" | ||
Text="聚焦生产力的美学进化" /> | ||
<TextBlock | ||
HorizontalAlignment="Center" | ||
FontSize="14" | ||
Text="Aesthetic Evolution of Productivity" /> | ||
</StackPanel> | ||
</Grid> | ||
</u:SplashWindow> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
using System.Threading.Tasks; | ||
using Avalonia; | ||
using Avalonia.Controls; | ||
using Avalonia.Markup.Xaml; | ||
using Ursa.Controls; | ||
using Ursa.Demo.ViewModels; | ||
|
||
namespace Ursa.Demo.Views; | ||
|
||
public partial class MainSplashWindow : SplashWindow | ||
{ | ||
public MainSplashWindow() | ||
{ | ||
InitializeComponent(); | ||
} | ||
|
||
protected override async Task<Window?> CreateNextWindow() | ||
{ | ||
return new MainWindow() | ||
{ | ||
DataContext = new MainViewViewModel() | ||
}; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
<u:SplashWindow | ||
x:Class="Ursa.Demo.Views.MvvmSplashWindow" | ||
xmlns="/~https://github.com/avaloniaui" | ||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | ||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" | ||
xmlns:iri="https://irihi.tech/shared" | ||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" | ||
xmlns:u="https://irihi.tech/ursa" | ||
xmlns:viewModels="clr-namespace:Ursa.Demo.ViewModels" | ||
Title="MvvmSplashWindow" | ||
Width="400" | ||
Height="400" | ||
x:DataType="viewModels:SplashViewModel" | ||
CountDown="{x:Null}" | ||
mc:Ignorable="d"> | ||
<Grid | ||
HorizontalAlignment="Center" | ||
VerticalAlignment="Center" | ||
ColumnDefinitions="Auto, Auto" | ||
RowDefinitions="Auto, Auto, Auto"> | ||
<iri:IrihiLogo | ||
Grid.Row="0" | ||
Grid.Column="0" | ||
Width="64" | ||
Margin="0,0,16,0" | ||
Fill="{DynamicResource SemiColorText2}" /> | ||
<StackPanel Grid.Row="0" Grid.Column="1"> | ||
<TextBlock | ||
Classes="H2" | ||
Text="铱泓科技" | ||
Theme="{DynamicResource TitleTextBlock}" /> | ||
<TextBlock FontWeight="Bold" Text="IRIHI Technology" /> | ||
</StackPanel> | ||
<ProgressBar | ||
Grid.Row="1" | ||
Grid.Column="0" | ||
Grid.ColumnSpan="2" | ||
Margin="0,16,0,0" | ||
Value="{Binding Progress}" /> | ||
<StackPanel | ||
Grid.Row="2" | ||
Grid.Column="0" | ||
Grid.ColumnSpan="2"> | ||
<TextBlock | ||
Margin="0,12,0,0" | ||
HorizontalAlignment="Center" | ||
FontSize="14" | ||
Text="聚焦生产力的美学进化" /> | ||
<TextBlock | ||
HorizontalAlignment="Center" | ||
FontSize="14" | ||
Text="Aesthetic Evolution of Productivity" /> | ||
</StackPanel> | ||
</Grid> | ||
</u:SplashWindow> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
using System.Threading.Tasks; | ||
using Avalonia; | ||
using Avalonia.Controls; | ||
using Avalonia.Markup.Xaml; | ||
using Ursa.Controls; | ||
using Ursa.Demo.ViewModels; | ||
|
||
namespace Ursa.Demo.Views; | ||
|
||
public partial class MvvmSplashWindow : SplashWindow | ||
{ | ||
public MvvmSplashWindow() | ||
{ | ||
InitializeComponent(); | ||
} | ||
|
||
protected override async Task<Window?> CreateNextWindow() | ||
{ | ||
if (this.DialogResult is true) | ||
{ | ||
return new MainWindow() | ||
{ | ||
DataContext = new MainViewViewModel() | ||
}; | ||
} | ||
return null; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
<ResourceDictionary | ||
xmlns="/~https://github.com/avaloniaui" | ||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | ||
xmlns:u="https://irihi.tech/ursa"> | ||
<ControlTheme x:Key="{x:Type u:SplashWindow}" TargetType="u:SplashWindow"> | ||
<Setter Property="Background" Value="{DynamicResource WindowDefaultBackground}" /> | ||
<Setter Property="TransparencyBackgroundFallback" Value="{DynamicResource WindowDefaultBackground}" /> | ||
<Setter Property="Foreground" Value="{DynamicResource WindowDefaultForeground}" /> | ||
<Setter Property="FontSize" Value="{DynamicResource DefaultFontSize}" /> | ||
<Setter Property="FontFamily" Value="{DynamicResource DefaultFontFamily}" /> | ||
<Setter Property="ExtendClientAreaChromeHints" Value="NoChrome" /> | ||
<Setter Property="ExtendClientAreaTitleBarHeightHint" Value="0" /> | ||
<Setter Property="ExtendClientAreaToDecorationsHint" Value="True" /> | ||
<Setter Property="WindowStartupLocation" Value="CenterScreen" /> | ||
<Setter Property="SystemDecorations"> | ||
<OnPlatform> | ||
<On Options="Default, Windows, macOS"> | ||
<SystemDecorations>Full</SystemDecorations> | ||
</On> | ||
<On Options="Linux"> | ||
<SystemDecorations>None</SystemDecorations> | ||
</On> | ||
</OnPlatform> | ||
</Setter> | ||
</ControlTheme> | ||
</ResourceDictionary> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.