Window Size
* Preserve window size when swapping Fluent and Simple themes. * Simplify test batch files. * Trim output. * Different output type depending on the configuration.
This commit is contained in:
parent
cd2a9d72aa
commit
dcc47c332f
@ -2,23 +2,29 @@
|
|||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<!-- if you want to check exceptions, change this to "Exe" and start your app from the console -->
|
<!-- if you want to check exceptions, change this to "Exe" and start your app from the console -->
|
||||||
<OutputType>WinExe</OutputType>
|
<OutputType Condition="'$(Configuration.toUpper())' != 'DEBUG'">WinExe</OutputType>
|
||||||
|
<OutputType Condition="'$(Configuration.toUpper())' == 'DEBUG'">Exe</OutputType>
|
||||||
<TargetFramework>net7.0</TargetFramework>
|
<TargetFramework>net7.0</TargetFramework>
|
||||||
<Platforms>x64</Platforms>
|
|
||||||
<ApplicationIcon>Assets/app.ico</ApplicationIcon>
|
<ApplicationIcon>Assets/app.ico</ApplicationIcon>
|
||||||
<InvariantGlobalization>true</InvariantGlobalization>
|
<InvariantGlobalization>true</InvariantGlobalization>
|
||||||
<PublishAot>true</PublishAot>
|
|
||||||
<Nullable>enable</Nullable>
|
<Nullable>enable</Nullable>
|
||||||
|
<PublishAot>true</PublishAot>
|
||||||
|
<PublishTrimmed>true</PublishTrimmed>
|
||||||
|
<SelfContained>true</SelfContained>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<PropertyGroup>
|
||||||
<IsWindows Condition="$([MSBuild]::IsOSPlatform('Windows'))">true</IsWindows>
|
<IsWindows Condition="$([MSBuild]::IsOSPlatform('Windows'))">true</IsWindows>
|
||||||
<IsLinux Condition="$([MSBuild]::IsOSPlatform('Linux'))">true</IsLinux>
|
<IsLinux Condition="$([MSBuild]::IsOSPlatform('Linux'))">true</IsLinux>
|
||||||
<IsOSX Condition="$([MSBuild]::IsOSPlatform('OSX'))">true</IsOSX>
|
<IsOSX Condition="$([MSBuild]::IsOSPlatform('OSX'))">true</IsOSX>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<!--Tthese can help when debugging weird exceptions especially when reflection is involved. See https://github.com/dotnet/corert/blob/master/Documentation/using-corert/optimizing-corert.md -->
|
<TrimMode>link</TrimMode>
|
||||||
|
<!--These can help when debugging weird exceptions especially when reflection is involved. See https://github.com/dotnet/corert/blob/master/Documentation/using-corert/optimizing-corert.md -->
|
||||||
<!--RootAllApplicationAssemblies: False -> TrimMode:link See https://github.com/dotnet/runtimelab/issues/597 and https://github.com/dotnet/runtimelab/blob/feature/NativeAOT/docs/using-nativeaot/optimizing.md -->
|
<!--RootAllApplicationAssemblies: False -> TrimMode:link See https://github.com/dotnet/runtimelab/issues/597 and https://github.com/dotnet/runtimelab/blob/feature/NativeAOT/docs/using-nativeaot/optimizing.md -->
|
||||||
<IlcGenerateCompleteTypeMetadata>false</IlcGenerateCompleteTypeMetadata>
|
<IlcGenerateCompleteTypeMetadata>false</IlcGenerateCompleteTypeMetadata>
|
||||||
<IlcGenerateStackTraceData>false</IlcGenerateStackTraceData>
|
<IlcGenerateStackTraceData Condition="'$(Configuration.toUpper())' != 'DEBUG'">false</IlcGenerateStackTraceData>
|
||||||
<IlcDisableUnhandledExceptionExperience>true</IlcDisableUnhandledExceptionExperience>
|
<IlcDisableUnhandledExceptionExperience>true</IlcDisableUnhandledExceptionExperience>
|
||||||
<StripSymbols>true</StripSymbols>
|
<StripSymbols>true</StripSymbols>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
@ -37,6 +43,7 @@
|
|||||||
<CopyToPublishDirectory>PreserveNewest</CopyToPublishDirectory>
|
<CopyToPublishDirectory>PreserveNewest</CopyToPublishDirectory>
|
||||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||||
</None>
|
</None>
|
||||||
|
<RuntimeHostConfigurationOption Include="Switch.System.Reflection.Assembly.SimulatedCallingAssembly" Value="true" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
@ -49,7 +56,7 @@
|
|||||||
<!--Condition below is needed to remove Avalonia.Diagnostics package from build output in Release configuration.-->
|
<!--Condition below is needed to remove Avalonia.Diagnostics package from build output in Release configuration.-->
|
||||||
<PackageReference Condition="'$(Configuration)' == 'Debug'" Include="Avalonia.Diagnostics" Version="11.0.0-*" />
|
<PackageReference Condition="'$(Configuration)' == 'Debug'" Include="Avalonia.Diagnostics" Version="11.0.0-*" />
|
||||||
<!--Condition below is needed to generate macOS App only.-->
|
<!--Condition below is needed to generate macOS App only.-->
|
||||||
<PackageReference Include="Dotnet.Bundle" Version="*" Condition="$(RuntimeIdentifier.StartsWith('osx'))" />
|
<PackageReference Include="Dotnet.Bundle" Version="0.9.13" Condition="$(RuntimeIdentifier.StartsWith('osx'))" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<!-- Information for Dotnet.Bundle to Generate macOS app-->
|
<!-- Information for Dotnet.Bundle to Generate macOS app-->
|
||||||
|
@ -18,10 +18,9 @@ namespace AvaloniaCoreRTDemo.Controls
|
|||||||
this.DataContext = new MainControlViewModel();
|
this.DataContext = new MainControlViewModel();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Reload(IMainWindowState? model)
|
public void Reload(IMainWindowState model)
|
||||||
{
|
{
|
||||||
if (model is not null)
|
this.DataContext = new MainControlViewModel(model);
|
||||||
this.DataContext = new MainControlViewModel(model);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,8 +1,15 @@
|
|||||||
namespace AvaloniaCoreRTDemo.Interfaces
|
using Avalonia;
|
||||||
|
using Avalonia.Controls;
|
||||||
|
|
||||||
|
namespace AvaloniaCoreRTDemo.Interfaces
|
||||||
{
|
{
|
||||||
public interface IMainWindow
|
public interface IMainWindow
|
||||||
{
|
{
|
||||||
IThemeSwitch ThemeSwitch { get; }
|
IThemeSwitch ThemeSwitch { get; }
|
||||||
IMainWindowState Model { get; }
|
IMainWindowState Model { get; }
|
||||||
|
PixelPoint Position { get; }
|
||||||
|
Size ClientSize { get; }
|
||||||
|
Size? FrameSize { get; }
|
||||||
|
WindowState State { get; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -10,20 +10,23 @@ namespace AvaloniaCoreRTDemo.Windows
|
|||||||
{
|
{
|
||||||
public sealed partial class AboutWindow : Window
|
public sealed partial class AboutWindow : Window
|
||||||
{
|
{
|
||||||
|
private readonly Boolean _darkTheme;
|
||||||
|
|
||||||
public AboutWindow() : this(false) { }
|
public AboutWindow() : this(false) { }
|
||||||
|
|
||||||
public AboutWindow(Boolean darkTheme)
|
public AboutWindow(Boolean darkTheme)
|
||||||
{
|
{
|
||||||
this.InitializeComponent(darkTheme);
|
this._darkTheme = darkTheme;
|
||||||
|
this.InitializeComponent();
|
||||||
#if DEBUG
|
#if DEBUG
|
||||||
this.AttachDevTools();
|
this.AttachDevTools();
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
private void InitializeComponent(Boolean darkTheme = default)
|
private void InitializeComponent()
|
||||||
{
|
{
|
||||||
AvaloniaXamlLoader.Load(this);
|
AvaloniaXamlLoader.Load(this);
|
||||||
this.DataContext = new AboutViewModel(darkTheme);
|
this.DataContext = new AboutViewModel(this._darkTheme);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
x:DataType="viewModels1:ApplicationModelBase">
|
x:DataType="viewModels1:ApplicationModelBase">
|
||||||
<DockPanel>
|
<DockPanel>
|
||||||
<NativeMenuBar DockPanel.Dock="Top" />
|
<NativeMenuBar DockPanel.Dock="Top" />
|
||||||
<controls:MainControl Name="mainControl"/>
|
<controls:MainControl Name="MainControl"/>
|
||||||
</DockPanel>
|
</DockPanel>
|
||||||
<NativeMenu.Menu>
|
<NativeMenu.Menu>
|
||||||
<NativeMenu>
|
<NativeMenu>
|
||||||
|
@ -12,6 +12,8 @@ namespace AvaloniaCoreRTDemo.Windows
|
|||||||
{
|
{
|
||||||
private readonly Application? _app = App.Current;
|
private readonly Application? _app = App.Current;
|
||||||
|
|
||||||
|
private MainControl MainControl => this.GetControl<MainControl>("MainControl");
|
||||||
|
|
||||||
public MainWindow() : this(default) { }
|
public MainWindow() : this(default) { }
|
||||||
public MainWindow(IMainWindow? window)
|
public MainWindow(IMainWindow? window)
|
||||||
{
|
{
|
||||||
@ -21,14 +23,25 @@ namespace AvaloniaCoreRTDemo.Windows
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
IThemeSwitch IMainWindow.ThemeSwitch => (this._app as IThemeSwitch)!;
|
IThemeSwitch IMainWindow.ThemeSwitch => (IThemeSwitch)this._app!;
|
||||||
IMainWindowState IMainWindow.Model => (this.GetControl<MainControl>("mainControl")!.DataContext as IMainWindowState)!;
|
IMainWindowState IMainWindow.Model => (IMainWindowState)this.MainControl.DataContext!;
|
||||||
|
PixelPoint IMainWindow.Position => this.Position;
|
||||||
|
Size IMainWindow.ClientSize => this.ClientSize;
|
||||||
|
Size? IMainWindow.FrameSize => this.FrameSize;
|
||||||
|
WindowState IMainWindow.State => this.WindowState;
|
||||||
|
|
||||||
private void InitializeComponent(IMainWindow? window)
|
private void InitializeComponent(IMainWindow? window)
|
||||||
{
|
{
|
||||||
AvaloniaXamlLoader.Load(this);
|
AvaloniaXamlLoader.Load(this);
|
||||||
this.DataContext = new MainViewModel<MainWindow>(this);
|
this.DataContext = new MainViewModel<MainWindow>(this);
|
||||||
this.GetControl<MainControl>("mainControl").Reload(window?.Model);
|
if(window is not null)
|
||||||
|
{
|
||||||
|
this.MainControl.Reload(window.Model);
|
||||||
|
this.WindowState = window.State;
|
||||||
|
this.Position = window.Position;
|
||||||
|
this.FrameSize = window.FrameSize;
|
||||||
|
this.ClientSize = window.ClientSize;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
2
test.cmd
2
test.cmd
@ -1,2 +1,2 @@
|
|||||||
del src\packages.lock.json
|
del src\packages.lock.json
|
||||||
dotnet publish -r win-x64 -c release /p:RestoreLockedMode=true /p:TrimLink=true --self-contained
|
dotnet publish -r win-x64 -c Release /p:RestoreLockedMode=true
|
@ -4,7 +4,7 @@ if [ -d "$dir" ]; then
|
|||||||
cd "$dir"
|
cd "$dir"
|
||||||
fi
|
fi
|
||||||
rm -f src/packages.lock.json
|
rm -f src/packages.lock.json
|
||||||
dotnet publish -r osx-x64 -c release /p:RestoreLockedMode=true -t:BundleApp /p:TrimLink=true --self-contained
|
dotnet publish -r osx-x64 -c Release /p:RestoreLockedMode=true -t:BundleApp
|
||||||
rm -rf src/bin/x64/Release/net7.0/osx-x64/publish/Assets/
|
rm -rf src/bin/x64/Release/net7.0/osx-x64/publish/Assets/
|
||||||
rm -rf src/bin/x64/Release/net7.0/osx-x64/publish/AvaloniaCoreRTDemo.app/Contents/MacOS/Assets/
|
rm -rf src/bin/x64/Release/net7.0/osx-x64/publish/AvaloniaCoreRTDemo.app/Contents/MacOS/Assets/
|
||||||
rm src/bin/x64/Release/net7.0/osx-x64/publish/AvaloniaCoreRTDemo.app/Contents/MacOS/AvaloniaCoreRTDemo.dwarf
|
rm src/bin/x64/Release/net7.0/osx-x64/publish/AvaloniaCoreRTDemo.app/Contents/MacOS/AvaloniaCoreRTDemo.dwarf
|
2
test.sh
2
test.sh
@ -1,6 +1,6 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
rm -f src/packages.lock.json
|
rm -f src/packages.lock.json
|
||||||
dotnet publish -r linux-x64 -c release /p:RestoreLockedMode=true /p:TrimLink=true --self-contained
|
dotnet publish -r linux-x64 -c Release /p:RestoreLockedMode=true
|
||||||
cd src/bin/x64/Release/net7.0/linux-x64/publish
|
cd src/bin/x64/Release/net7.0/linux-x64/publish
|
||||||
cp AvaloniaCoreRTDemo AvaloniaCoreRTDemo.bin
|
cp AvaloniaCoreRTDemo AvaloniaCoreRTDemo.bin
|
||||||
strip AvaloniaCoreRTDemo.bin
|
strip AvaloniaCoreRTDemo.bin
|
||||||
|
Loading…
x
Reference in New Issue
Block a user