Skip to content
This repository was archived by the owner on Oct 23, 2022. It is now read-only.

Commit d8cf28c

Browse files
committed
tidied up things uwu
1 parent 22e8461 commit d8cf28c

File tree

5 files changed

+52
-43
lines changed

5 files changed

+52
-43
lines changed

.editorconfig

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
[*.{cs,vb}]
2+
3+
# IDE0044: Add readonly modifier
4+
dotnet_style_readonly_field = true:silent

ActiveDesktop.sln

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,11 @@ VisualStudioVersion = 16.0.29230.47
55
MinimumVisualStudioVersion = 10.0.40219.1
66
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ActiveDesktop", "ActiveDesktop\ActiveDesktop.csproj", "{B51E0A72-E7FD-4CD3-AF12-9D78703574E1}"
77
EndProject
8+
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{F4FC857A-57C6-40EC-8DFF-9289E0A15432}"
9+
ProjectSection(SolutionItems) = preProject
10+
.editorconfig = .editorconfig
11+
EndProjectSection
12+
EndProject
813
Global
914
GlobalSection(SolutionConfigurationPlatforms) = preSolution
1015
Debug|Any CPU = Debug|Any CPU

ActiveDesktop/ADPVideoWallpaper.xaml.cs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -65,13 +65,13 @@ private void worker_DoWork(object sender, DoWorkEventArgs e)
6565
MainWindow.DwmGetWindowAttribute(wnd, Convert.ToInt32(DwmApi.DWMWINDOWATTRIBUTE.DWMWA_CLOAKED), out cloaked, Marshal.SizeOf(typeof(bool)));
6666
if (MainWindow.IsZoomed(wnd) && MainWindow.IsWindowVisible(wnd) && cloaked <= 0)
6767
{
68-
MainWindow.RECT WindowRect;
69-
MainWindow.RECT VideoPlayerRect;
70-
MainWindow.GetWindowRect(wnd, out WindowRect);
71-
MainWindow.GetWindowRect(VideoPlayerHandle, out VideoPlayerRect);
72-
MainWindow.POINT Corner = new MainWindow.POINT();
73-
Corner.X = VideoPlayerRect.Left + 10;
74-
Corner.Y = VideoPlayerRect.Top + 10;
68+
MainWindow.GetWindowRect(wnd, out MainWindow.RECT WindowRect);
69+
MainWindow.GetWindowRect(VideoPlayerHandle, out MainWindow.RECT VideoPlayerRect);
70+
MainWindow.POINT Corner = new MainWindow.POINT
71+
{
72+
X = VideoPlayerRect.Left + 10,
73+
Y = VideoPlayerRect.Top + 10
74+
};
7575
if (MainWindow.PtInRect(in WindowRect, Corner) && PauseOnMax)
7676
{
7777
Dispatcher.Invoke(() =>

ActiveDesktop/ActiveDesktop.csproj

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,9 @@
177177
<Generator>ResXFileCodeGenerator</Generator>
178178
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
179179
</EmbeddedResource>
180+
<None Include="..\.editorconfig">
181+
<Link>.editorconfig</Link>
182+
</None>
180183
<None Include="app.manifest" />
181184
<None Include="packages.config" />
182185
<None Include="Properties\Settings.settings">

ActiveDesktop/MainWindow.xaml.cs

Lines changed: 33 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -253,19 +253,21 @@ public void AddButton_Click(object sender, RoutedEventArgs e)
253253
{
254254
if (SavedAppsPage.CmdBox.Text != "Command Line")
255255
{
256-
App AppToAdd = new App();
257-
AppToAdd.Cmd = SavedAppsPage.CmdBox.Text;
258-
AppToAdd.Xpos = SavedAppsPage.XBox.Text;
259-
AppToAdd.Ypos = SavedAppsPage.YBox.Text;
260-
AppToAdd.Width = SavedAppsPage.WidthBox.Text;
261-
AppToAdd.Height = SavedAppsPage.HeightBox.Text;
262-
AppToAdd.Flags = SavedAppsPage.FlagBox.Text;
263-
AppToAdd.Name = SavedAppsPage.NameBox.Text;
264-
AppToAdd.Time = SavedAppsPage.TimeBox.Text;
265-
AppToAdd.Lock = SavedAppsPage.LockedCheckBox.IsChecked ?? false;
266-
AppToAdd.Startup = SavedAppsPage.AutostartCheckBox.IsChecked ?? false;
267-
AppToAdd.Fix = SavedAppsPage.FixCheckBox.IsChecked ?? false;
268-
AppToAdd.Pin = SavedAppsPage.PinnedCheckBox.IsChecked ?? false;
256+
App AppToAdd = new App
257+
{
258+
Cmd = SavedAppsPage.CmdBox.Text,
259+
Xpos = SavedAppsPage.XBox.Text,
260+
Ypos = SavedAppsPage.YBox.Text,
261+
Width = SavedAppsPage.WidthBox.Text,
262+
Height = SavedAppsPage.HeightBox.Text,
263+
Flags = SavedAppsPage.FlagBox.Text,
264+
Name = SavedAppsPage.NameBox.Text,
265+
Time = SavedAppsPage.TimeBox.Text,
266+
Lock = SavedAppsPage.LockedCheckBox.IsChecked ?? false,
267+
Startup = SavedAppsPage.AutostartCheckBox.IsChecked ?? false,
268+
Fix = SavedAppsPage.FixCheckBox.IsChecked ?? false,
269+
Pin = SavedAppsPage.PinnedCheckBox.IsChecked ?? false
270+
};
269271
JSONArrayList.Add(AppToAdd);
270272

271273

@@ -363,15 +365,13 @@ public void SaveButton_Click(object sender, RoutedEventArgs e)
363365
{
364366
if (CurrentAppsPage.HandleListBox.SelectedIndex != -1)
365367
{
366-
RECT PosTarget;
367-
uint PID;
368368
string SyllyIsAwesome;
369369
IntPtr hwnd = IntPtr.Zero;
370370
hwnd = new IntPtr(Convert.ToInt32(DesktopWindowPropertyList[Convert.ToInt32(CurrentAppsPage.HandleListBox.SelectedItem.ToString().Substring(CurrentAppsPage.HandleListBox.SelectedItem.ToString().Length - 3))][2]));
371371
StringBuilder WindowTitle = new StringBuilder(1000);
372372
StringBuilder FileName = new StringBuilder(1000);
373373
uint size = (uint)FileName.Capacity;
374-
GetWindowThreadProcessId(hwnd, out PID);
374+
GetWindowThreadProcessId(hwnd, out uint PID);
375375
IntPtr handle = OpenProcess(0x1000, false, PID);
376376
if (QueryFullProcessImageNameW(handle, 0, FileName, ref size) != 0)
377377
{
@@ -383,7 +383,7 @@ public void SaveButton_Click(object sender, RoutedEventArgs e)
383383
}
384384
CloseHandle(handle);
385385

386-
GetWindowRect(hwnd, out PosTarget);
386+
GetWindowRect(hwnd, out RECT PosTarget);
387387
GetWindowText(hwnd, WindowTitle, 1000);
388388
SavedAppsPage.CmdBox.Text = SyllyIsAwesome;
389389
SavedAppsPage.XBox.Text = PosTarget.Left.ToString();
@@ -580,8 +580,7 @@ private void NavView_ItemInvoked(NavigationView sender, NavigationViewItemInvoke
580580
}
581581
else
582582
{
583-
TextBlock ItemContent = args.InvokedItem as TextBlock;
584-
if (ItemContent != null)
583+
if (args.InvokedItem is TextBlock ItemContent)
585584
{
586585
switch (ItemContent.Tag)
587586
{
@@ -758,15 +757,17 @@ public DisplayInfoCollection GetDisplays()
758757
bool success = GetMonitorInfo(hMonitor, ref mi);
759758
if (success)
760759
{
761-
DisplayInfo di = new DisplayInfo();
762-
di.ScreenWidth = (mi.rcMonitor.Right - mi.rcMonitor.Left).ToString();
763-
di.ScreenHeight = (mi.rcMonitor.Bottom - mi.rcMonitor.Top).ToString();
764-
di.MonitorArea = mi.rcMonitor;
765-
di.WorkArea = mi.rcWork;
766-
di.Availability = mi.dwFlags.ToString();
767-
di.Handle = hMonitor;
768-
di.Top = mi.rcMonitor.Top;
769-
di.Left = mi.rcMonitor.Left;
760+
DisplayInfo di = new DisplayInfo
761+
{
762+
ScreenWidth = (mi.rcMonitor.Right - mi.rcMonitor.Left).ToString(),
763+
ScreenHeight = (mi.rcMonitor.Bottom - mi.rcMonitor.Top).ToString(),
764+
MonitorArea = mi.rcMonitor,
765+
WorkArea = mi.rcWork,
766+
Availability = mi.dwFlags.ToString(),
767+
Handle = hMonitor,
768+
Top = mi.rcMonitor.Top,
769+
Left = mi.rcMonitor.Left
770+
};
770771
col.Add(di);
771772
}
772773
return true;
@@ -777,10 +778,9 @@ public DisplayInfoCollection GetDisplays()
777778
// Deals with getting a window's size
778779
public static Size GetWindowSize(IntPtr hWnd)
779780
{
780-
RECT pRect;
781781
Size cSize = new Size();
782782
// get coordinates relative to window
783-
GetWindowRect(hWnd, out pRect);
783+
GetWindowRect(hWnd, out RECT pRect);
784784

785785
cSize.Width = pRect.Right - pRect.Left;
786786
cSize.Height = pRect.Bottom - pRect.Top;
@@ -790,8 +790,7 @@ public static Size GetWindowSize(IntPtr hWnd)
790790
// Have a guess what this does you fkn idiot
791791
public static Point GetCursorPosition()
792792
{
793-
POINT lpPoint;
794-
GetCursorPos(out lpPoint);
793+
GetCursorPos(out POINT lpPoint);
795794
return lpPoint;
796795
}
797796

@@ -820,8 +819,7 @@ public static List<IntPtr> GetChildWindows(IntPtr parent)
820819
private static bool EnumWindow(IntPtr handle, IntPtr pointer)
821820
{
822821
GCHandle gch = GCHandle.FromIntPtr(pointer);
823-
List<IntPtr> list = gch.Target as List<IntPtr>;
824-
if (list == null)
822+
if (!(gch.Target is List<IntPtr> list))
825823
{
826824
throw new InvalidCastException("GCHandle Target could not be cast as List<IntPtr>");
827825
}
@@ -970,8 +968,7 @@ public void SetWindowSizeAndLock(App i, IntPtr hwnd)
970968
try
971969
{
972970
SetParent(hwnd, DesktopHandle);
973-
RECT PosTarget;
974-
GetWindowRect(hwnd, out PosTarget);
971+
GetWindowRect(hwnd, out RECT PosTarget);
975972
if (i.Xpos == "X")
976973
{
977974
i.Xpos = PosTarget.Top.ToString();

0 commit comments

Comments
 (0)