Skip to content

Commit

Permalink
Merge pull request #406 from Leo-Corporation/vNext
Browse files Browse the repository at this point in the history
Version 4.0.1.2309
  • Loading branch information
lpeyr authored Sep 2, 2023
2 parents e1c9f54 + dde0ddd commit 562a7cc
Show file tree
Hide file tree
Showing 6 changed files with 115 additions and 5 deletions.
65 changes: 65 additions & 0 deletions Gavilya/Commands/DropBehavior.cs
Original file line number Diff line number Diff line change
@@ -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
{
/// <summary>
/// The Dependency property. To allow for Binding, a dependency
/// property must be used.
/// </summary>
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;

Check warning on line 55 in Gavilya/Commands/DropBehavior.cs

View workflow job for this annotation

GitHub Actions / build

Converting null literal or possible null value to non-nullable type.

Check warning on line 55 in Gavilya/Commands/DropBehavior.cs

View workflow job for this annotation

GitHub Actions / build

Converting null literal or possible null value to non-nullable type.
if (null == uiElement) return;

uiElement.Drop += (sender, args) =>
{
GetPreviewDropCommand(uiElement).Execute(args.Data);
args.Handled = true;
};
}
}
}
8 changes: 4 additions & 4 deletions Gavilya/Gavilya.csproj
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>WinExe</OutputType>
Expand All @@ -8,7 +8,7 @@
<UseWindowsForms>True</UseWindowsForms>
<ApplicationManifest>app.manifest</ApplicationManifest>
<Title>Gavilya</Title>
<Version>4.0.0.2309</Version>
<Version>4.0.1.2309</Version>
<Authors>Léo Corporation</Authors>
<Description>Gavilya is a simple game launcher for Windows.</Description>
<Copyright>© 2023</Copyright>
Expand Down Expand Up @@ -53,8 +53,8 @@
<ItemGroup>
<PackageReference Include="Microsoft.Xaml.Behaviors.Wpf" Version="1.1.39" />
<PackageReference Include="MouseKeyHook" Version="5.7.1" />
<PackageReference Include="PeyrSharp.Core" Version="1.8.0.2308" />
<PackageReference Include="PeyrSharp.Env" Version="1.8.0.2308" />
<PackageReference Include="PeyrSharp.Core" Version="1.9.0.2309" />
<PackageReference Include="PeyrSharp.Env" Version="1.9.0.2309" />
<PackageReference Include="RestSharp" Version="110.2.0" />
</ItemGroup>

Expand Down
2 changes: 1 addition & 1 deletion Gavilya/Helpers/Context.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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";
}
28 changes: 28 additions & 0 deletions Gavilya/ViewModels/GameEditionViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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; }

/// <summary>
/// This constructor is used when editing an exisiting game.
Expand All @@ -247,6 +250,8 @@ public GameEditionViewModel(Game game, GameList games, List<Tag> 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;
Expand Down Expand Up @@ -310,6 +315,9 @@ public GameEditionViewModel(GameType gameType, GameList games, List<Tag> 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
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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);
}
}
13 changes: 13 additions & 0 deletions Gavilya/ViewModels/MainViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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) =>
Expand All @@ -170,6 +174,7 @@ public MainViewModel(Window window, Profile profile, ProfileData profiles, Page?
profiles.Save();
};


RegisterKeyBoardShortcuts();

CheckUpdateOnStart();
Expand Down Expand Up @@ -220,13 +225,21 @@ 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;
}
else
{
(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;
}
Expand Down
4 changes: 4 additions & 0 deletions Gavilya/Views/GameEditionView.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -57,6 +58,8 @@
<StackPanel x:Name="DragWin32Games" Visibility="{Binding DragAreaVis}">
<Button
HorizontalContentAlignment="Stretch"
commands:DropBehavior.PreviewDropCommand="{Binding DropCommand}"
AllowDrop="True"
Background="Transparent"
Command="{Binding BrowseFileCommand}"
Cursor="Hand"
Expand Down Expand Up @@ -666,6 +669,7 @@
Padding="5"
VerticalAlignment="Center"
Background="{DynamicResource Background2}"
Command="{Binding ProcessHelpCommand}"
Content="&#xF63E;"
Cursor="Hand"
FontFamily="..\Fonts\#FluentSystemIcons-Regular"
Expand Down

0 comments on commit 562a7cc

Please sign in to comment.