diff --git a/Gavilya/Commands/DropBehavior.cs b/Gavilya/Commands/DropBehavior.cs new file mode 100644 index 00000000..b9e90852 --- /dev/null +++ b/Gavilya/Commands/DropBehavior.cs @@ -0,0 +1,65 @@ +/* +MIT License + +Copyright (c) Léo Corporation + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. +*/ + +using System.Windows.Input; +using System.Windows; + +namespace Gavilya.Commands +{ + public static class DropBehavior + { + /// + /// The Dependency property. To allow for Binding, a dependency + /// property must be used. + /// + private static readonly DependencyProperty PreviewDropCommandProperty = + DependencyProperty.RegisterAttached + ( + "PreviewDropCommand", + typeof(ICommand), + typeof(DropBehavior), + new PropertyMetadata(PreviewDropCommandPropertyChangedCallBack) + ); + public static void SetPreviewDropCommand(this UIElement inUIElement, ICommand inCommand) + { + inUIElement.SetValue(PreviewDropCommandProperty, inCommand); + } + private static ICommand GetPreviewDropCommand(UIElement inUIElement) + { + return (ICommand)inUIElement.GetValue(PreviewDropCommandProperty); + } + private static void PreviewDropCommandPropertyChangedCallBack( + DependencyObject inDependencyObject, DependencyPropertyChangedEventArgs inEventArgs) + { + UIElement uiElement = inDependencyObject as UIElement; + if (null == uiElement) return; + + uiElement.Drop += (sender, args) => + { + GetPreviewDropCommand(uiElement).Execute(args.Data); + args.Handled = true; + }; + } + } +} diff --git a/Gavilya/Gavilya.csproj b/Gavilya/Gavilya.csproj index d606805b..3ceb437c 100644 --- a/Gavilya/Gavilya.csproj +++ b/Gavilya/Gavilya.csproj @@ -1,4 +1,4 @@ - + WinExe @@ -8,7 +8,7 @@ True app.manifest Gavilya - 4.0.0.2309 + 4.0.1.2309 Léo Corporation Gavilya is a simple game launcher for Windows. © 2023 @@ -53,8 +53,8 @@ - - + + diff --git a/Gavilya/Helpers/Context.cs b/Gavilya/Helpers/Context.cs index 984e604c..f2957beb 100644 --- a/Gavilya/Helpers/Context.cs +++ b/Gavilya/Helpers/Context.cs @@ -25,6 +25,6 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE namespace Gavilya.Helpers; public static class Context { - public static string Version => "4.0.0.2309"; + public static string Version => "4.0.1.2309"; public static string LastVersionLink => "https://raw.githubusercontent.com/Leo-Corporation/LeoCorp-Docs/master/Liens/Update%20System/Gavilya/Version.txt"; } diff --git a/Gavilya/ViewModels/GameEditionViewModel.cs b/Gavilya/ViewModels/GameEditionViewModel.cs index 016168d8..4e919370 100644 --- a/Gavilya/ViewModels/GameEditionViewModel.cs +++ b/Gavilya/ViewModels/GameEditionViewModel.cs @@ -37,6 +37,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE using System.Windows.Input; using System.Windows.Media; using System.Windows.Media.Imaging; +using System.Xml.Linq; namespace Gavilya.ViewModels; @@ -223,6 +224,8 @@ public bool CanExecute public ICommand AssociateRawgCommand { get; } public ICommand RawgSearchCommand { get; } public ICommand ShowConvertSectionCommand { get; } + public ICommand ProcessHelpCommand { get; } + public ICommand DropCommand { get; } /// /// This constructor is used when editing an exisiting game. @@ -247,6 +250,8 @@ public GameEditionViewModel(Game game, GameList games, List tags, MainViewM AssociateRawgCommand = new RelayCommand(OpenRawgPopup); RawgSearchCommand = new RelayCommand(SearchRawg); ShowConvertSectionCommand = new RelayCommand(ShowConvert); + ProcessHelpCommand = new RelayCommand(ShowProcessHelp); + DropCommand = new RelayCommand(ExecuteDrop); // Load properties Name = game.Name; @@ -310,6 +315,9 @@ public GameEditionViewModel(GameType gameType, GameList games, List tags, M AssociateTagCommand = new RelayCommand(OpenTagPopup); AssociateRawgCommand = new RelayCommand(OpenRawgPopup); RawgSearchCommand = new RelayCommand(SearchRawg); + ProcessHelpCommand = new RelayCommand(ShowProcessHelp); + DropCommand = new RelayCommand(ExecuteDrop); + SelectedTags = new(); // Load UI @@ -339,6 +347,21 @@ private void ShowConvert(object? obj) ConvertSteamVis = Visibility.Visible; } + private void ExecuteDrop(object parameter) + { + IDataObject ido = parameter as IDataObject; + if (null == ido) return; + string[] files = (string[])ido.GetData("FileName"); + if (files.Length > 0) + { + string filePath = files[0]; // Get the first dropped file + if (Path.GetExtension(filePath).Equals(".exe", StringComparison.OrdinalIgnoreCase)) + { + Command = filePath; + } + } + } + private async void BrowseUwp(object? obj) { IsUwpOpen = true; @@ -448,4 +471,9 @@ private void AddGame(object? obj) Games[Games.IndexOf(Game)] = Game; _mainViewModel.CurrentViewModel = new LibPageViewModel(Games, Tags, _mainViewModel); } + + private void ShowProcessHelp(object? obj) + { + MessageBox.Show(Properties.Resources.ProcessNameHelp, Properties.Resources.Help, MessageBoxButton.OK, MessageBoxImage.Information); + } } diff --git a/Gavilya/ViewModels/MainViewModel.cs b/Gavilya/ViewModels/MainViewModel.cs index 76497f2e..73ce17e1 100644 --- a/Gavilya/ViewModels/MainViewModel.cs +++ b/Gavilya/ViewModels/MainViewModel.cs @@ -148,7 +148,11 @@ public MainViewModel(Window window, Profile profile, ProfileData profiles, Page? }); // Window System + _window.WindowState = CurrentSettings.IsMaximized switch { true => WindowState.Maximized, _ => WindowState.Normal }; (MaxHeight, MaxWidth) = _windowHelper.GetMaximumSize(); + MaxiIcon = _window.WindowState == WindowState.Maximized ? "\uF670" : "\uFA40"; + MaxiIconFontSize = _window.WindowState == WindowState.Maximized ? 16 : 12; + BorderMargin = _window.WindowState == WindowState.Maximized ? new(0) : new(10); // Set // Events _window.StateChanged += (o, e) => @@ -170,6 +174,7 @@ public MainViewModel(Window window, Profile profile, ProfileData profiles, Page? profiles.Save(); }; + RegisterKeyBoardShortcuts(); CheckUpdateOnStart(); @@ -220,6 +225,10 @@ private void Maximize(object parameter) if (_window.WindowState == WindowState.Maximized) { _window.WindowState = WindowState.Normal; + CurrentSettings.IsMaximized = false; + _profiles.Profiles[_profiles.Profiles.IndexOf(_profile)].Settings.IsMaximized = false; + _profiles.Save(); + MaxiIcon = "\uFA40"; MaxiIconFontSize = 12; } @@ -227,6 +236,10 @@ private void Maximize(object parameter) { (MaxHeight, MaxWidth) = _windowHelper.GetMaximumSize(); _window.WindowState = WindowState.Maximized; + CurrentSettings.IsMaximized = true; + _profiles.Profiles[_profiles.Profiles.IndexOf(_profile)].Settings.IsMaximized = true; + _profiles.Save(); + MaxiIcon = "\uF670"; MaxiIconFontSize = 16; } diff --git a/Gavilya/Views/GameEditionView.xaml b/Gavilya/Views/GameEditionView.xaml index d3129bca..a3f5381f 100644 --- a/Gavilya/Views/GameEditionView.xaml +++ b/Gavilya/Views/GameEditionView.xaml @@ -2,6 +2,7 @@ x:Class="Gavilya.Views.GameEditionView" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" + xmlns:commands="clr-namespace:Gavilya.Commands" xmlns:components="clr-namespace:Gavilya.Components" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:lang="clr-namespace:Gavilya.Properties" @@ -57,6 +58,8 @@