Skip to content

Commit

Permalink
More code cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
marticliment committed Jun 3, 2024
1 parent 0224b92 commit ba13a05
Showing 1 changed file with 10 additions and 17 deletions.
27 changes: 10 additions & 17 deletions src/UniGetUI/Interface/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,22 +7,15 @@
using Microsoft.UI.Xaml.Input;
using Microsoft.UI.Xaml.Media.Imaging;
using Microsoft.Win32;
using System;
using System.Collections.Generic;
using System.IO;
using System.Reflection;
using System.Threading.Tasks;
using UniGetUI.Core;
using System.Runtime.InteropServices;
using UniGetUI.Core.Data;
using UniGetUI.Interface.Widgets;
using UniGetUI.PackageEngine.Classes;
using Windows.ApplicationModel.DataTransfer;
using UniGetUI.Core.Logging;
using Windows.Foundation.Collections;
using UniGetUI.Core.SettingsEngine;
using UniGetUI.PackageEngine.PackageClasses;
using UniGetUI.Core.Tools;
using System.Runtime.InteropServices;
using UniGetUI.Interface.Widgets;
using UniGetUI.PackageEngine.PackageClasses;
using Windows.ApplicationModel.DataTransfer;
using Windows.Foundation.Collections;

namespace UniGetUI.Interface
{
Expand Down Expand Up @@ -500,7 +493,7 @@ private async void SaveGeometry()
}
else Logger.Warn("MainWindow.AppWindow.Presenter is not OverlappedPresenter presenter!");

var geometry = $"{AppWindow.Position.X},{AppWindow.Position.Y},{AppWindow.Size.Width},{AppWindow.Size.Height},{windowState}";
string geometry = $"{AppWindow.Position.X},{AppWindow.Position.Y},{AppWindow.Size.Width},{AppWindow.Size.Height},{windowState}";

Logger.Debug($"Saving window geometry {geometry}");
Settings.SetValue("WindowGeometry", geometry);
Expand All @@ -509,7 +502,7 @@ private async void SaveGeometry()
private void RestoreSize()
{

var geometry = Settings.GetValue("WindowGeometry");
string geometry = Settings.GetValue("WindowGeometry");
string[] items = geometry.Split(",");
if (items.Length != 5)
{
Expand Down Expand Up @@ -550,11 +543,11 @@ private void RestoreSize()
}
private bool IsRectangleFullyVisible(int x, int y, int width, int height)
{
List<MONITORINFO> monitorInfos = new List<MONITORINFO>();
List<MONITORINFO> monitorInfos = new();

MonitorEnumDelegate callback = (IntPtr hMonitor, IntPtr hdcMonitor, ref RECT lprcMonitor, IntPtr dwData) =>
{
MONITORINFO monitorInfo = new MONITORINFO();
MONITORINFO monitorInfo = new();
monitorInfo.cbSize = Marshal.SizeOf(typeof(MONITORINFO));
if (GetMonitorInfo(hMonitor, ref monitorInfo)) monitorInfos.Add(monitorInfo);
return true;
Expand All @@ -567,7 +560,7 @@ private bool IsRectangleFullyVisible(int x, int y, int width, int height)
int maxX = int.MinValue;
int maxY = int.MinValue;

foreach (var monitorInfo in monitorInfos)
foreach (MONITORINFO monitorInfo in monitorInfos)
{
if (monitorInfo.rcMonitor.Left < minX) minX = monitorInfo.rcMonitor.Left;
if (monitorInfo.rcMonitor.Top < minY) minY = monitorInfo.rcMonitor.Top;
Expand Down

0 comments on commit ba13a05

Please sign in to comment.