Skip to content

Commit

Permalink
Code cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
lpeyr committed Aug 24, 2023
1 parent 724e165 commit a873079
Show file tree
Hide file tree
Showing 31 changed files with 759 additions and 881 deletions.
17 changes: 8 additions & 9 deletions Gavilya/Components/GameCardComponent.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,16 +24,15 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE

using System.Windows.Controls;

namespace Gavilya.Components
namespace Gavilya.Components;

/// <summary>
/// Interaction logic for GameCardComponent.xaml
/// </summary>
public partial class GameCardComponent : UserControl
{
/// <summary>
/// Interaction logic for GameCardComponent.xaml
/// </summary>
public partial class GameCardComponent : UserControl
public GameCardComponent()
{
public GameCardComponent()
{
InitializeComponent();
}
InitializeComponent();
}
}
17 changes: 8 additions & 9 deletions Gavilya/Components/GameListComponent.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,16 +24,15 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE

using System.Windows.Controls;

namespace Gavilya.Components
namespace Gavilya.Components;

/// <summary>
/// Interaction logic for GameListComponent.xaml
/// </summary>
public partial class GameListComponent : UserControl
{
/// <summary>
/// Interaction logic for GameListComponent.xaml
/// </summary>
public partial class GameListComponent : UserControl
public GameListComponent()
{
public GameListComponent()
{
InitializeComponent();
}
InitializeComponent();
}
}
17 changes: 8 additions & 9 deletions Gavilya/Components/TagSelectorComponent.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,16 +24,15 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE

using System.Windows.Controls;

namespace Gavilya.Components
namespace Gavilya.Components;

/// <summary>
/// Interaction logic for TagSelectorComponent.xaml
/// </summary>
public partial class TagSelectorComponent : UserControl
{
/// <summary>
/// Interaction logic for TagSelectorComponent.xaml
/// </summary>
public partial class TagSelectorComponent : UserControl
public TagSelectorComponent()
{
public TagSelectorComponent()
{
InitializeComponent();
}
InitializeComponent();
}
}
63 changes: 31 additions & 32 deletions Gavilya/Helpers/WindowHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,46 +25,45 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
using System;
using System.Windows;

namespace Gavilya.Helpers
namespace Gavilya.Helpers;

public class WindowHelper
{
public class WindowHelper
private readonly Window _window;

/// <summary>
/// The first value is the maximum height, and the seconde one is the maximum width.
/// </summary>
/// <returns></returns>
public (double, double) GetMaximumSize()
{
private readonly Window _window;
System.Windows.Forms.Screen currentScreen = System.Windows.Forms.Screen.FromHandle(new System.Windows.Interop.WindowInteropHelper(_window).Handle); // The current screen

/// <summary>
/// The first value is the maximum height, and the seconde one is the maximum width.
/// </summary>
/// <returns></returns>
public (double, double) GetMaximumSize()
{
System.Windows.Forms.Screen currentScreen = System.Windows.Forms.Screen.FromHandle(new System.Windows.Interop.WindowInteropHelper(_window).Handle); // The current screen
float dpiX;
double scaling = 100; // Default scaling = 100%

float dpiX;
double scaling = 100; // Default scaling = 100%
using (System.Drawing.Graphics graphics = System.Drawing.Graphics.FromHwnd(IntPtr.Zero))
{
dpiX = graphics.DpiX; // Get the DPI

using (System.Drawing.Graphics graphics = System.Drawing.Graphics.FromHwnd(IntPtr.Zero))
scaling = dpiX switch
{
dpiX = graphics.DpiX; // Get the DPI

scaling = dpiX switch
{
96 => 100, // Get the %
120 => 125, // Get the %
144 => 150, // Get the %
168 => 175, // Get the %
192 => 200, // Get the %
_ => 100
};
}
96 => 100, // Get the %
120 => 125, // Get the %
144 => 150, // Get the %
168 => 175, // Get the %
192 => 200, // Get the %
_ => 100
};
}

double factor = scaling / 100d; // Calculate factor
double factor = scaling / 100d; // Calculate factor

return (currentScreen.WorkingArea.Height / factor + 8, currentScreen.WorkingArea.Width / factor + 8);
}
return (currentScreen.WorkingArea.Height / factor + 8, currentScreen.WorkingArea.Width / factor + 8);
}

public WindowHelper(Window window)
{
_window = window;
}
public WindowHelper(Window window)
{
_window = window;
}
}
4 changes: 2 additions & 2 deletions Gavilya/Models/GameList.cs
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ public List<GameList> GetSortedGameLists()

public List<GameList> GetSortedGameByTag()
{
Dictionary<Tag, List<Game>> tagGamesMap = new Dictionary<Tag, List<Game>>();
Dictionary<Tag, List<Game>> tagGamesMap = new();

// Associate games with their corresponding tags
foreach (var game in this)
Expand All @@ -107,7 +107,7 @@ public List<GameList> GetSortedGameByTag()
}

// Create GameList instances for each tag and add associated games
List<GameList> sortedGameLists = new List<GameList>();
List<GameList> sortedGameLists = new();
foreach (var kvp in tagGamesMap)
{
var tag = kvp.Key;
Expand Down
32 changes: 13 additions & 19 deletions Gavilya/Models/Rawg/Achievement.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,30 +22,24 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.Json.Serialization;
using System.Threading.Tasks;

namespace Gavilya.Models.Rawg
namespace Gavilya.Models.Rawg;

public class Achievement
{
public class Achievement
{
[JsonPropertyName("id")]
public int Id { get; set; }
[JsonPropertyName("id")]
public int Id { get; set; }

[JsonPropertyName("name")]
public string Name { get; set; }
[JsonPropertyName("name")]
public string Name { get; set; }

[JsonPropertyName("description")]
public string Description { get; set; }
[JsonPropertyName("description")]
public string Description { get; set; }

[JsonPropertyName("image")]
public string Image { get; set; }
[JsonPropertyName("image")]
public string Image { get; set; }

[JsonPropertyName("percent")]
public string Percent { get; set; }
}
[JsonPropertyName("percent")]
public string Percent { get; set; }
}
27 changes: 11 additions & 16 deletions Gavilya/Models/Rawg/AchievementsResults.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,27 +22,22 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.Json.Serialization;
using System.Threading.Tasks;

namespace Gavilya.Models.Rawg
namespace Gavilya.Models.Rawg;

public class AchievementsResults
{
public class AchievementsResults
{
[JsonPropertyName("count")]
public int Count { get; set; }
[JsonPropertyName("count")]
public int Count { get; set; }

[JsonPropertyName("next")]
public string Next { get; set; }
[JsonPropertyName("next")]
public string Next { get; set; }

[JsonPropertyName("previous")]
public string Previous { get; set; }
[JsonPropertyName("previous")]
public string Previous { get; set; }

[JsonPropertyName("results")]
public List<Achievement> Results { get; set; }
}
[JsonPropertyName("results")]
public List<Achievement> Results { get; set; }
}
36 changes: 15 additions & 21 deletions Gavilya/Models/Rawg/AddedByStatus.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,33 +22,27 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.Json.Serialization;
using System.Threading.Tasks;

namespace Gavilya.Models.Rawg
namespace Gavilya.Models.Rawg;

public class AddedByStatus
{
public class AddedByStatus
{
[JsonPropertyName("yet")]
public int Yet { get; set; }
[JsonPropertyName("yet")]
public int Yet { get; set; }

[JsonPropertyName("owned")]
public int Owned { get; set; }
[JsonPropertyName("owned")]
public int Owned { get; set; }

[JsonPropertyName("beaten")]
public int Beaten { get; set; }
[JsonPropertyName("beaten")]
public int Beaten { get; set; }

[JsonPropertyName("toplay")]
public int ToPlay { get; set; }
[JsonPropertyName("toplay")]
public int ToPlay { get; set; }

[JsonPropertyName("dropped")]
public int Dropped { get; set; }
[JsonPropertyName("dropped")]
public int Dropped { get; set; }

[JsonPropertyName("playing")]
public int Playing { get; set; }
}
[JsonPropertyName("playing")]
public int Playing { get; set; }
}
28 changes: 11 additions & 17 deletions Gavilya/Models/Rawg/Clip.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,27 +22,21 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.Json.Serialization;
using System.Threading.Tasks;

namespace Gavilya.Models.Rawg
namespace Gavilya.Models.Rawg;

public class Clip
{
public class Clip
{
[JsonPropertyName("clip")]
public string ClipValue { get; set; }
[JsonPropertyName("clip")]
public string ClipValue { get; set; }

[JsonPropertyName("clips")]
public Clips ClipsValue { get; set; }
[JsonPropertyName("clips")]
public Clips ClipsValue { get; set; }

[JsonPropertyName("video")]
public string Video { get; set; }
[JsonPropertyName("video")]
public string Video { get; set; }

[JsonPropertyName("preview")]
public string Preview { get; set; }
}
[JsonPropertyName("preview")]
public string Preview { get; set; }
}
25 changes: 9 additions & 16 deletions Gavilya/Models/Rawg/Clips.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,25 +22,18 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.Json.Serialization;
using System.Threading.Tasks;

namespace Gavilya.Models.Rawg
{
public class Clips
{
[JsonPropertyName("_320")]
public string Size320 { get; set; }
namespace Gavilya.Models.Rawg;

[JsonPropertyName("_640")]
public string Size640 { get; set; }
public class Clips
{
[JsonPropertyName("_320")]
public string Size320 { get; set; }

[JsonPropertyName("full")]
public string Full { get; set; }
}
[JsonPropertyName("_640")]
public string Size640 { get; set; }

[JsonPropertyName("full")]
public string Full { get; set; }
}
Loading

0 comments on commit a873079

Please sign in to comment.