Skip to content

Commit

Permalink
Added Executable component (Leo-Corporation#429)
Browse files Browse the repository at this point in the history
  • Loading branch information
lpeyr committed Nov 5, 2023
1 parent 8eece92 commit 4a42010
Show file tree
Hide file tree
Showing 3 changed files with 125 additions and 0 deletions.
32 changes: 32 additions & 0 deletions Gavilya/Components/ExecutableSelectorComponent.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<UserControl
x:Class="Gavilya.Components.ExecutableSelectorComponent"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:Gavilya.Components"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
FontFamily="..\Fonts\#Hauora"
Foreground="{DynamicResource Foreground}"
mc:Ignorable="d">
<Button
Padding="5"
Background="{DynamicResource Background2}"
Command="{Binding ClickCommand}"
Cursor="Hand"
Style="{DynamicResource RegularButton2}">
<StackPanel
Grid.Column="1"
Width="380"
VerticalAlignment="Center">
<TextBlock
x:Name="GameNameTxt"
FontSize="18"
FontWeight="ExtraBold"
Text="{Binding Name}" />
<TextBlock
x:Name="FilePathTxt"
FontSize="10"
Text="{Binding FilePath}" />
</StackPanel>
</Button>
</UserControl>
39 changes: 39 additions & 0 deletions Gavilya/Components/ExecutableSelectorComponent.xaml.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
/*
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.Controls;

namespace Gavilya.Components
{
/// <summary>
/// Interaction logic for ExecutableSelectorComponent.xaml
/// </summary>
public partial class ExecutableSelectorComponent : UserControl
{
public ExecutableSelectorComponent()
{
InitializeComponent();
}
}
}
54 changes: 54 additions & 0 deletions Gavilya/ViewModels/ExecutableViewModel.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
/*
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 Gavilya.Commands;
using System.Windows.Input;

namespace Gavilya.ViewModels;

public class ExecutableViewModel : ViewModelBase
{
private readonly GameEditionViewModel _gameEditionViewModel;

public string Name { get; }
public string FilePath { get; }

public ICommand ClickCommand { get; }

public ExecutableViewModel(string name, string filePath, GameEditionViewModel gameEditionViewModel)
{
Name = name;
FilePath = filePath;
_gameEditionViewModel = gameEditionViewModel;

ClickCommand = new RelayCommand(Click);
}

private void Click(object? obj)
{
_gameEditionViewModel.Name = Name;
_gameEditionViewModel.Command = FilePath;
_gameEditionViewModel.IsExeSelectorOpen = false;
}
}

0 comments on commit 4a42010

Please sign in to comment.