Implement menubar items for common window sizes.
This commit is contained in:
parent
3bea3ea077
commit
6c5f105ec1
4 changed files with 47 additions and 9 deletions
|
@ -30,6 +30,10 @@
|
||||||
"MenuBarToolsManageFileTypes": "Manage file types",
|
"MenuBarToolsManageFileTypes": "Manage file types",
|
||||||
"MenuBarToolsInstallFileTypes": "Install file types",
|
"MenuBarToolsInstallFileTypes": "Install file types",
|
||||||
"MenuBarToolsUninstallFileTypes": "Uninstall file types",
|
"MenuBarToolsUninstallFileTypes": "Uninstall file types",
|
||||||
|
"MenuBarView": "_View",
|
||||||
|
"MenuBarViewWindow": "Window Size",
|
||||||
|
"MenuBarViewWindow720": "720p",
|
||||||
|
"MenuBarViewWindow1080": "1080p",
|
||||||
"MenuBarHelp": "_Help",
|
"MenuBarHelp": "_Help",
|
||||||
"MenuBarHelpCheckForUpdates": "Check for Updates",
|
"MenuBarHelpCheckForUpdates": "Check for Updates",
|
||||||
"MenuBarHelpAbout": "About",
|
"MenuBarHelpAbout": "About",
|
||||||
|
|
|
@ -186,6 +186,12 @@
|
||||||
<MenuItem Header="{locale:Locale MenuBarToolsUninstallFileTypes}" Click="UninstallFileTypes_Click"/>
|
<MenuItem Header="{locale:Locale MenuBarToolsUninstallFileTypes}" Click="UninstallFileTypes_Click"/>
|
||||||
</MenuItem>
|
</MenuItem>
|
||||||
</MenuItem>
|
</MenuItem>
|
||||||
|
<MenuItem VerticalAlignment="Center" Header="{locale:Locale MenuBarView}">
|
||||||
|
<MenuItem VerticalAlignment="Center" Header="{locale:Locale MenuBarViewWindow}">
|
||||||
|
<MenuItem Header="{locale:Locale MenuBarViewWindow720}" Tag="720" Click="ChangeWindowSize_Click" />
|
||||||
|
<MenuItem Header="{locale:Locale MenuBarViewWindow1080}" Tag="1080" Click="ChangeWindowSize_Click" />
|
||||||
|
</MenuItem>
|
||||||
|
</MenuItem>
|
||||||
<MenuItem VerticalAlignment="Center" Header="{locale:Locale MenuBarHelp}">
|
<MenuItem VerticalAlignment="Center" Header="{locale:Locale MenuBarHelp}">
|
||||||
<MenuItem
|
<MenuItem
|
||||||
Name="UpdateMenuItem"
|
Name="UpdateMenuItem"
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
using Avalonia;
|
using Avalonia;
|
||||||
using Avalonia.Controls;
|
using Avalonia.Controls;
|
||||||
using Avalonia.Interactivity;
|
using Avalonia.Interactivity;
|
||||||
|
using Avalonia.Threading;
|
||||||
using LibHac.Ncm;
|
using LibHac.Ncm;
|
||||||
using LibHac.Tools.FsSystem.NcaUtils;
|
using LibHac.Tools.FsSystem.NcaUtils;
|
||||||
using Ryujinx.Ava.Common.Locale;
|
using Ryujinx.Ava.Common.Locale;
|
||||||
|
@ -211,6 +212,37 @@ namespace Ryujinx.Ava.UI.Views.Main
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private async void ChangeWindowSize_Click(object sender, RoutedEventArgs e)
|
||||||
|
{
|
||||||
|
if (sender is MenuItem item)
|
||||||
|
{
|
||||||
|
int height;
|
||||||
|
int width;
|
||||||
|
|
||||||
|
switch (item.Tag)
|
||||||
|
{
|
||||||
|
case "720":
|
||||||
|
height = 720;
|
||||||
|
width = 1280;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case "1080":
|
||||||
|
height = 1080;
|
||||||
|
width = 1920;
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
throw new ArgumentNullException(nameof(item.Tag));
|
||||||
|
}
|
||||||
|
|
||||||
|
await Dispatcher.UIThread.InvokeAsync(() =>
|
||||||
|
{
|
||||||
|
ViewModel.WindowHeight = height + Window.StatusBarHeight + Window.MenuBarHeight;
|
||||||
|
ViewModel.WindowWidth = width;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public async void CheckForUpdates(object sender, RoutedEventArgs e)
|
public async void CheckForUpdates(object sender, RoutedEventArgs e)
|
||||||
{
|
{
|
||||||
if (Updater.CanUpdate(true))
|
if (Updater.CanUpdate(true))
|
||||||
|
|
|
@ -67,11 +67,11 @@ namespace Ryujinx.Ava.UI.Windows
|
||||||
|
|
||||||
DataContext = ViewModel;
|
DataContext = ViewModel;
|
||||||
|
|
||||||
SetWindowSizePosition();
|
|
||||||
|
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
Load();
|
Load();
|
||||||
|
|
||||||
|
SetWindowSizePosition();
|
||||||
|
|
||||||
UiHandler = new AvaHostUIHandler(this);
|
UiHandler = new AvaHostUIHandler(this);
|
||||||
|
|
||||||
ViewModel.Title = $"Ryujinx {Program.Version}";
|
ViewModel.Title = $"Ryujinx {Program.Version}";
|
||||||
|
@ -324,17 +324,13 @@ namespace Ryujinx.Ava.UI.Windows
|
||||||
|
|
||||||
private void SetWindowSizePosition()
|
private void SetWindowSizePosition()
|
||||||
{
|
{
|
||||||
// WindowStartupLocation is unable to be used after the MainWindow is created.
|
|
||||||
// To center a window manually we need the raw display dimensions.
|
|
||||||
PixelPoint windowCenter = new(Screens.Primary.Bounds.Width / 4, Screens.Primary.Bounds.Height / 4);
|
|
||||||
|
|
||||||
if (!ConfigurationState.Instance.RememberWindowState)
|
if (!ConfigurationState.Instance.RememberWindowState)
|
||||||
{
|
{
|
||||||
ViewModel.WindowHeight = 777 * Program.WindowScaleFactor;
|
ViewModel.WindowHeight = 777 * Program.WindowScaleFactor;
|
||||||
ViewModel.WindowWidth = 1280 * Program.WindowScaleFactor;
|
ViewModel.WindowWidth = 1280 * Program.WindowScaleFactor;
|
||||||
WindowState = WindowState.Normal;
|
|
||||||
|
|
||||||
Position = windowCenter;
|
WindowState = WindowState.Normal;
|
||||||
|
WindowStartupLocation = WindowStartupLocation.CenterScreen;
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -353,7 +349,7 @@ namespace Ryujinx.Ava.UI.Windows
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Position = windowCenter;
|
WindowStartupLocation = WindowStartupLocation.CenterScreen;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue