Skip to content

Commit 4610478

Browse files
author
Aytackydln
committed
misc fixes
1 parent 9084add commit 4610478

3 files changed

Lines changed: 11 additions & 32 deletions

File tree

Project-Aurora/Project-Aurora/Bitmaps/GdiPlus/GdiPartialCopyBitmapReader.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ public sealed class GdiPartialCopyBitmapReader : IBitmapReader
1818
// ReSharper disable once CollectionNeverQueried.Local //to keep reference
1919
private static readonly Dictionary<Size, int[]> BitmapBuffers = new(20);
2020
private static readonly Vector256<int> FullVector = Vector256.Create(0xFF);
21+
private static GraphicsUnit _graphicsUnit = GraphicsUnit.Pixel;
2122

2223
private readonly Bitmap _bitmap;
2324
private readonly GdiBitmap _gdiBitmap;
@@ -31,8 +32,7 @@ public GdiPartialCopyBitmapReader(Bitmap bitmap, GdiBitmap gdiBitmap)
3132
{
3233
_bitmap = bitmap;
3334
_gdiBitmap = gdiBitmap;
34-
var graphicsUnit = GraphicsUnit.Pixel;
35-
_dimension = bitmap.GetBounds(ref graphicsUnit);
35+
_dimension = bitmap.GetBounds(ref _graphicsUnit);
3636
}
3737

3838
/**

Project-Aurora/Project-Aurora/Nodes/Razer/RazerFetcher.cs

Lines changed: 6 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ namespace AuroraRgb.Nodes.Razer;
1111

1212
internal abstract class RazerFetcher : IDisposable
1313
{
14-
private const string? GLOBAL_RAZERLINKREADWRITEGUARDMUTEX = "Global\\RazerLinkReadWriteGuardMutex";
14+
private const string GlobalRazerlinkreadwriteguardmutex = "Global\\RazerLinkReadWriteGuardMutex";
1515

1616
private const int HidReqSetReport = 0x09;
1717
private const int HidReqGetReport = 0x01; // Add GET_REPORT request
@@ -23,15 +23,12 @@ internal abstract class RazerFetcher : IDisposable
2323
private const int UsbTypeRequestIn = UsbTypeClass | UsbRecipInterface | UsbDirIn;
2424
private const int RazerUsbReportLen = 90; // Example length, set this according to actual length
2525

26-
private readonly Mutex _mutex;
26+
private static readonly Mutex Mutex;
2727

2828
static RazerFetcher()
2929
{
3030
UsbDevice.ForceLibUsbWinBack = true;
31-
}
3231

33-
protected RazerFetcher()
34-
{
3532
var rule = new MutexAccessRule(new SecurityIdentifier(WellKnownSidType.WorldSid, null),
3633
MutexRights.Synchronize | MutexRights.Modify | MutexRights.FullControl | MutexRights.ReadPermissions | MutexRights.TakeOwnership,
3734
AccessControlType.Allow);
@@ -40,31 +37,16 @@ protected RazerFetcher()
4037
mutexSecurity.AddAccessRule(rule);
4138

4239
// Create a mutex with a well-known name use acl
43-
_mutex = MutexAcl.Create(false, GLOBAL_RAZERLINKREADWRITEGUARDMUTEX, out _, mutexSecurity);
44-
45-
try
46-
{
47-
if (!_mutex.WaitOne(TimeSpan.FromMilliseconds(2000), false))
48-
{
49-
_mutex.ReleaseMutex();
50-
return;
51-
}
52-
}
53-
catch (AbandonedMutexException)
54-
{
55-
//continue
56-
}
57-
58-
_mutex.ReleaseMutex();
40+
Mutex = MutexAcl.Create(false, GlobalRazerlinkreadwriteguardmutex, out _, mutexSecurity);
5941
}
6042

6143
protected byte[]? Update()
6244
{
6345
try
6446
{
65-
if (!_mutex.WaitOne(TimeSpan.FromMilliseconds(2000), false))
47+
if (!Mutex.WaitOne(TimeSpan.FromMilliseconds(2000), false))
6648
{
67-
_mutex.ReleaseMutex();
49+
Mutex.ReleaseMutex();
6850
return null;
6951
}
7052
}
@@ -74,7 +56,7 @@ protected RazerFetcher()
7456
}
7557

7658
var report = UpdateLocked();
77-
_mutex.ReleaseMutex();
59+
Mutex.ReleaseMutex();
7860

7961
return report;
8062
}
@@ -169,9 +151,6 @@ private static string GetDeviceProductKeyString(UsbRegistry device)
169151

170152
protected virtual void Dispose(bool disposing)
171153
{
172-
if (!disposing) return;
173-
_mutex.Close();
174-
_mutex.Dispose();
175154
}
176155

177156
public void Dispose()

Project-Aurora/Project-Aurora/Settings/Layers/Controls/Control_PercentLayer.xaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,10 @@
3030
<ComboBox SelectedValue="{Binding Properties.PercentType}" ItemsSource="{utils:EnumToItemsSource {x:Type settings:PercentEffectType}}" DisplayMemberPath="Text" SelectedValuePath="Value" Margin="67,114,0,0" Width="200" HorizontalAlignment="Left" VerticalAlignment="Top" />
3131

3232
<Label HorizontalAlignment="Left" Margin="0,145,0,-23" Padding="0" Content="Blink threshold: " VerticalAlignment="Top"/>
33-
<xctk:IntegerUpDown Value="{Binding Properties._BlinkThreshold, Converter={StaticResource PercentageConverter}}" Minimum="0" Maximum="100" Margin="90,141,0,-27" Width="50" Height="24" HorizontalAlignment="Left" VerticalAlignment="Top" />
33+
<xctk:IntegerUpDown Value="{Binding Properties.BlinkThreshold, Converter={StaticResource PercentageConverter}}" Minimum="0" Maximum="100" Margin="90,141,0,-27" Width="50" Height="24" HorizontalAlignment="Left" VerticalAlignment="Top" />
3434
<Label HorizontalAlignment="Left" Margin="145,145,0,-23" Padding="0" Content="%" VerticalAlignment="Top" RenderTransformOrigin="0.6,0.542"/>
35-
<CheckBox Content="Reverse blink threshold" IsChecked="{Binding Properties._BlinkDirection}" Margin="3,166,0,0" HorizontalAlignment="Left" VerticalAlignment="Top" />
36-
<CheckBox Content="Blink background instead" IsChecked="{Binding Properties._BlinkBackground}" Margin="3,181,0,0" HorizontalAlignment="Left" VerticalAlignment="Top" />
35+
<CheckBox Content="Reverse blink threshold" IsChecked="{Binding Properties.BlinkDirection}" Margin="3,166,0,0" HorizontalAlignment="Left" VerticalAlignment="Top" />
36+
<CheckBox Content="Blink background instead" IsChecked="{Binding Properties.BlinkBackground}" Margin="3,181,0,0" HorizontalAlignment="Left" VerticalAlignment="Top" />
3737

3838
<controls1:KeySequence Sequence="{Binding Properties._Sequence}" RecordingTag="PercentLayer" Title="Affected Keys" Margin="272,0,0,0" Width="230" HorizontalAlignment="Left" />
3939
</Grid>

0 commit comments

Comments
 (0)