-
Notifications
You must be signed in to change notification settings - Fork 204
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Moved some code to a separate project.
This will simply the codebase and keep the solution clean, compact and easy to maintain or code.
- Loading branch information
1 parent
bff841f
commit b42729b
Showing
28 changed files
with
254 additions
and
258 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
<Project> | ||
<PropertyGroup> | ||
<Authors>ModernFlyouts Community</Authors> | ||
<LangVersion>latest</LangVersion> | ||
<Version>0.8.4.1-beta</Version> | ||
</PropertyGroup> | ||
</Project> |
4 changes: 2 additions & 2 deletions
4
ModernFlyouts/Interop/KeyboardHook.cs → ModernFlyouts.Core/Interop/KeyboardHook.cs
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
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,14 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<TargetFramework>net5.0-windows10.0.19041.0</TargetFramework> | ||
<UseWPF>true</UseWPF> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="NAudio" Version="1.10.0" /> | ||
<PackageReference Include="System.Drawing.Common" Version="5.0.0" /> | ||
<PackageReference Include="System.Management" Version="5.0.0" /> | ||
</ItemGroup> | ||
|
||
</Project> |
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,10 @@ | ||
using System.Windows; | ||
|
||
[assembly: ThemeInfo( | ||
ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located | ||
//(used if a resource is not found in the page, | ||
// or application resource dictionaries) | ||
ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located | ||
//(used if a resource is not found in the page, | ||
// app, or any theme specific resource dictionaries) | ||
)] |
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,62 @@ | ||
using System; | ||
using System.Diagnostics; | ||
using System.Management; | ||
|
||
namespace ModernFlyouts.Core.Utilities | ||
{ | ||
public class AirplaneModeWatcher | ||
{ | ||
private readonly ManagementEventWatcher watcher; | ||
|
||
public event EventHandler<AirplaneModeChangedEventArgs> Changed; | ||
|
||
public AirplaneModeWatcher() | ||
{ | ||
try | ||
{ | ||
WqlEventQuery query = new( | ||
"SELECT * FROM RegistryValueChangeEvent WHERE " + | ||
"Hive = 'HKEY_LOCAL_MACHINE'" + | ||
@"AND KeyPath = 'SYSTEM\\CurrentControlSet\\Control\\RadioManagement\\SystemRadioState' AND ValueName=''"); | ||
|
||
watcher = new ManagementEventWatcher(query); | ||
watcher.EventArrived += new EventArrivedEventHandler(HandleEvent); | ||
} | ||
catch (ManagementException managementException) | ||
{ | ||
Debug.WriteLine($"{nameof(AirplaneModeWatcher)}: " + managementException.Message); | ||
} | ||
} | ||
|
||
public void Start() | ||
{ | ||
watcher.Start(); | ||
} | ||
|
||
public void Stop() | ||
{ | ||
watcher.Stop(); | ||
} | ||
|
||
public static bool GetIsAirplaneModeEnabled() | ||
{ | ||
var regkey = Microsoft.Win32.Registry.LocalMachine.OpenSubKey(@"SYSTEM\CurrentControlSet\Control\RadioManagement\SystemRadioState", false); | ||
return (int)regkey?.GetValue("", 1) == 1; | ||
} | ||
|
||
private void HandleEvent(object sender, EventArrivedEventArgs e) | ||
{ | ||
Changed?.Invoke(this, new AirplaneModeChangedEventArgs(GetIsAirplaneModeEnabled())); | ||
} | ||
} | ||
|
||
public class AirplaneModeChangedEventArgs : EventArgs | ||
{ | ||
public AirplaneModeChangedEventArgs(bool isEnabled) | ||
{ | ||
IsEnabled = isEnabled; | ||
} | ||
|
||
public bool IsEnabled { get; } | ||
} | ||
} |
31 changes: 31 additions & 0 deletions
31
ModernFlyouts.Core/Utilities/AudioDeviceNotificationClient.cs
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,31 @@ | ||
using NAudio.CoreAudioApi; | ||
using NAudio.CoreAudioApi.Interfaces; | ||
using System; | ||
|
||
namespace ModernFlyouts.Core.Utilities | ||
{ | ||
public class AudioDeviceNotificationClient : IMMNotificationClient | ||
{ | ||
public event EventHandler<string> DefaultDeviceChanged; | ||
|
||
public void OnDefaultDeviceChanged(DataFlow dataFlow, Role deviceRole, string defaultDeviceId) | ||
{ | ||
if (dataFlow == DataFlow.Render && deviceRole == Role.Multimedia) | ||
{ | ||
DefaultDeviceChanged?.Invoke(this, defaultDeviceId); | ||
} | ||
} | ||
|
||
public void OnDeviceAdded(string deviceId) | ||
{ } | ||
|
||
public void OnDeviceRemoved(string deviceId) | ||
{ } | ||
|
||
public void OnDeviceStateChanged(string deviceId, DeviceState newState) | ||
{ } | ||
|
||
public void OnPropertyValueChanged(string deviceId, PropertyKey propertyKey) | ||
{ } | ||
} | ||
} |
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,68 @@ | ||
using System; | ||
using System.Diagnostics; | ||
using System.Management; | ||
|
||
namespace ModernFlyouts.Core.Utilities | ||
{ | ||
public class BrightnessWatcher | ||
{ | ||
private readonly ManagementEventWatcher watcher; | ||
|
||
public event EventHandler<BrightnessChangedEventArgs> Changed; | ||
|
||
public BrightnessWatcher() | ||
{ | ||
try | ||
{ | ||
var scope = new ManagementScope("root\\WMI"); | ||
var query = new WqlEventQuery("SELECT * FROM WmiMonitorBrightnessEvent"); | ||
watcher = new ManagementEventWatcher(scope, query); | ||
watcher.EventArrived += new EventArrivedEventHandler(HandleEvent); | ||
} | ||
catch (ManagementException managementException) | ||
{ | ||
Debug.WriteLine($"{nameof(BrightnessWatcher)}: " + managementException.Message); | ||
} | ||
} | ||
|
||
public void Start() | ||
{ | ||
try | ||
{ | ||
watcher.Start(); | ||
} | ||
catch (ManagementException managementException) | ||
{ | ||
Debug.WriteLine($"{nameof(BrightnessWatcher)}: " + managementException.Message); | ||
} | ||
} | ||
|
||
public void Stop() | ||
{ | ||
try | ||
{ | ||
watcher.Stop(); | ||
} | ||
catch (ManagementException managementException) | ||
{ | ||
Debug.WriteLine($"{nameof(BrightnessWatcher)}: " + managementException.Message); | ||
} | ||
} | ||
|
||
private void HandleEvent(object sender, EventArrivedEventArgs e) | ||
{ | ||
int value = int.Parse(e.NewEvent.Properties["Brightness"].Value.ToString()); | ||
Changed?.Invoke(this, new BrightnessChangedEventArgs(value)); | ||
} | ||
} | ||
|
||
public class BrightnessChangedEventArgs : EventArgs | ||
{ | ||
public BrightnessChangedEventArgs(int newValue) | ||
{ | ||
NewValue = newValue; | ||
} | ||
|
||
public int NewValue { get; set; } | ||
} | ||
} |
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 |
---|---|---|
|
@@ -256,4 +256,4 @@ void Arrange(UIElement child, bool isLast = false) | |
return finalSize; | ||
} | ||
} | ||
} | ||
} |
Oops, something went wrong.
b42729b
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Samuel12321,
I also removed some no more used string resources. Make sure to update other related files too.
Sorry for the burden 😅. I did what I had to do.
This repo will receive much more breaking changes in the upcoming weeks.
Make sure you pull the origin in VS Team Explorer or VS Git or any other git tool you use before every commit. And make your local clone is in sync with this repo.
Unnecessary merge commits at these kinda times would be worse (no more spaghett please). Please be careful.