-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added a card recapitulating a game informations (#84)
- Loading branch information
Showing
11 changed files
with
198 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
<UserControl x:Class="Gavilya.UserControls.StatGameInfoControl" | ||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" | ||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | ||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" | ||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" | ||
xmlns:local="clr-namespace:Gavilya.UserControls" | ||
xmlns:lang="clr-namespace:Gavilya.Properties" | ||
mc:Ignorable="d" Foreground="#fff" | ||
FontFamily="..\Fonts\#Montserrat" | ||
d:DesignHeight="500" > | ||
<ScrollViewer Template="{DynamicResource ScrollViewerTemplate1}" HorizontalScrollBarVisibility="Hidden"> | ||
<Grid x:Name="ContentGrid" > | ||
<Grid.RowDefinitions> | ||
<RowDefinition Height="Auto"/> | ||
<RowDefinition/> | ||
</Grid.RowDefinitions> | ||
<Grid Grid.Row="0"> | ||
<Grid.RowDefinitions> | ||
<RowDefinition Height="Auto"/> | ||
<RowDefinition/> | ||
<RowDefinition/> | ||
</Grid.RowDefinitions> | ||
|
||
<Border Grid.Row="0" Margin="10" CornerRadius="10"> | ||
<Border.Background> | ||
<ImageBrush x:Name="BackgroundImage" Stretch="UniformToFill" Opacity="0.9"></ImageBrush> | ||
</Border.Background> | ||
|
||
<Grid Height="100"> | ||
<Grid.Background> | ||
<LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0"> | ||
<GradientStop Color="#FF0A0A1E" Offset="1"/> | ||
<GradientStop Color="#00000000" Offset="0"/> | ||
</LinearGradientBrush> | ||
</Grid.Background> | ||
<TextBlock x:Name="GameNameTxt" Grid.Row="0" d:Text="GameName" Margin="5" FontSize="24" FontWeight="Bold" TextAlignment="Left" VerticalAlignment="Bottom"/> | ||
</Grid> | ||
</Border> | ||
|
||
<Border Grid.Row="1" CornerRadius="10" Background="#FF28283C" Margin="10" Padding="10"> | ||
<Grid> | ||
<Grid.ColumnDefinitions> | ||
<ColumnDefinition/> | ||
<ColumnDefinition/> | ||
</Grid.ColumnDefinitions> | ||
|
||
<Grid.RowDefinitions> | ||
<RowDefinition Height="Auto"/> | ||
<RowDefinition/> | ||
</Grid.RowDefinitions> | ||
<TextBlock Text="{x:Static lang:Resources.StatsTimePlayed}" FontSize="14" FontWeight="Bold" Foreground="#FF64648C"/> | ||
<TextBlock Text="{x:Static lang:Resources.StatsLastTimePlayed}" FontSize="14" FontWeight="Bold" Foreground="#FF64648C" Grid.Column="1"/> | ||
|
||
<TextBlock x:Name="TotalTimePlayedTxt" d:Text="74,5h" Margin="0,10,10,10" FontSize="22" FontWeight="Bold" TextAlignment="Left" Grid.Column="0" Grid.Row="1"/> | ||
<TextBlock x:Name="LastTimePlayedTxt" d:Text="10 December 2021" Margin="0,10,10,10" FontSize="22" FontWeight="Bold" TextAlignment="Left" Grid.Column="1" Grid.Row="1"/> | ||
</Grid> | ||
</Border> | ||
|
||
<StackPanel Grid.Row="2" Orientation="Vertical"> | ||
<TextBlock Text="{x:Static lang:Resources.Description}" FontSize="18" FontWeight="Bold"/> | ||
<TextBlock x:Name="DescriptionTxt" d:Text="{x:Static lang:Resources.Description}" FontSize="14" FontWeight="Normal" Margin="0,3,0,0" TextWrapping="Wrap"/> | ||
</StackPanel> | ||
</Grid> | ||
|
||
</Grid> | ||
</ScrollViewer> | ||
</UserControl> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
/* | ||
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.Classes; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.IO; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
using System.Windows; | ||
using System.Windows.Controls; | ||
using System.Windows.Data; | ||
using System.Windows.Documents; | ||
using System.Windows.Input; | ||
using System.Windows.Media; | ||
using System.Windows.Media.Imaging; | ||
using System.Windows.Navigation; | ||
using System.Windows.Shapes; | ||
|
||
namespace Gavilya.UserControls | ||
{ | ||
/// <summary> | ||
/// Interaction logic for StatGameInfoControl.xaml | ||
/// </summary> | ||
public partial class StatGameInfoControl : UserControl | ||
{ | ||
public StatGameInfoControl() | ||
{ | ||
InitializeComponent(); | ||
} | ||
|
||
internal void InitUI(GameInfo gameInfo) | ||
{ | ||
// Text | ||
GameNameTxt.Text = gameInfo.Name; // Set text | ||
DescriptionTxt.Text = gameInfo.Description; // Set text | ||
|
||
double timePlayed = (double)gameInfo.TotalTimePlayed / 3600; | ||
TotalTimePlayedTxt.Text = $"{string.Format("{0:0.#}", timePlayed)}{Properties.Resources.HourShort}"; | ||
|
||
if (gameInfo.LastTimePlayed != 0) // If the game was played | ||
{ | ||
DateTime LastTimePlayed = Global.UnixTimeToDateTime(gameInfo.LastTimePlayed); // Get the date time | ||
LastTimePlayedTxt.Text = $"{LastTimePlayed.Day} {Global.NumberToMonth(LastTimePlayed.Month)} {LastTimePlayed.Year}"; // Last time played | ||
} | ||
else | ||
{ | ||
LastTimePlayedTxt.Text = Properties.Resources.Never; // Set the text | ||
} | ||
|
||
// Icon | ||
if (gameInfo.IconFileLocation != string.Empty) // If a custom image is used | ||
{ | ||
var bitmap = new BitmapImage(); | ||
var stream = File.OpenRead(gameInfo.IconFileLocation); | ||
|
||
bitmap.BeginInit(); | ||
bitmap.CacheOption = BitmapCacheOption.OnLoad; | ||
bitmap.StreamSource = stream; | ||
bitmap.EndInit(); | ||
stream.Close(); | ||
stream.Dispose(); | ||
bitmap.Freeze(); | ||
BackgroundImage.ImageSource = bitmap; | ||
} | ||
else | ||
{ | ||
System.Drawing.Icon icon = System.Drawing.Icon.ExtractAssociatedIcon(gameInfo.FileLocation); | ||
BackgroundImage.ImageSource = System.Windows.Interop.Imaging.CreateBitmapSourceFromHIcon(icon.Handle, Int32Rect.Empty, BitmapSizeOptions.FromEmptyOptions()); // Show the image | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters