Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

v0.10 #728

Merged
merged 38 commits into from
Aug 3, 2021
Merged

v0.10 #728

Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
59a0516
Updated Greek Translation (#495)
VasilisPat Mar 15, 2021
1614cf9
Flyout animation toggle (#511)
karpovv-boris Mar 23, 2021
cf2848b
Update Russian translation (#510)
ANT0x1 Mar 23, 2021
1ba3833
- Updated Nuget Packages
Mar 24, 2021
35ab3e1
Merge branch 'dev' of https://github.com/ModernFlyouts-Community/Mode…
Mar 24, 2021
82e346d
Localized Manifest
Mar 25, 2021
5c6ece1
Remove redundant playground
Samuel12321 Mar 31, 2021
8c6d72b
.wapproj simplification
Samuel12321 Mar 31, 2021
a3d7dae
.
Samuel12321 Mar 31, 2021
433ef3c
Update nuget packages
Samuel12321 Mar 31, 2021
5a0c3f9
Update Nuget Packages
Apr 1, 2021
0c35fc8
Minor cleanup
ShankarBUS Apr 5, 2021
adb52c2
Finally!
ShankarBUS Apr 8, 2021
4ef6985
fix null crash
Samuel12321 Apr 8, 2021
d623918
Revert "fix null crash"
ShankarBUS Apr 8, 2021
0558e79
Minor fixes
ShankarBUS Apr 8, 2021
4212f43
Translated all strings to danish (#516)
emilnymann Apr 10, 2021
7bb8a68
Temp enable both zh-hans and zh-cn
Apr 22, 2021
e06ea92
Update Ukrainian translation (#545)
playday3008 Apr 22, 2021
2108174
Re-Updated Turkish Translation (#562)
insanolanbiri Apr 22, 2021
6c78038
Merge branch 'dev' of https://github.com/ModernFlyouts-Community/Mode…
Apr 22, 2021
3cc9a49
Fix syntax error for settings.off
Apr 22, 2021
48175a8
updates
Apr 22, 2021
4ee45ae
remove playground
Apr 22, 2021
78c54da
Fix crash when disabling Audio Flyout due to my stupidity.
ADeltaX Apr 30, 2021
b449d41
Update .appinstaller
Samuel12321 May 11, 2021
21738b0
translation updates
Samuel12321 May 11, 2021
a30e22d
update appinstaller
Samuel12321 May 13, 2021
18deaee
Update nuget packages + code cleanup
May 20, 2021
ac66d87
updates
May 20, 2021
f9079d9
Hehe
ShankarBUS May 27, 2021
c471283
Improvements to Brightness APIs
ShankarBUS May 29, 2021
c18df0f
For Testing ExternalDisplayBrightnessController
ShankarBUS Jun 16, 2021
d9c1b33
Fixed #584 - Bug: Volume flyout pops up when changing keyboard layout
ShankarBUS Jun 19, 2021
ca515f1
Media Controls® UI/UX Update™
ShankarBUS Jul 28, 2021
e2809bc
New Feature & Bug Fix
ShankarBUS Jul 29, 2021
8eaceaf
Make volume changing behaviour consistent with OS (#638)
krlvm Aug 3, 2021
5414459
v0.10
ShankarBUS Aug 3, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ assignees: ShankarBUS
2. It would be best to create the issue in English language.
3. Properly follow the issue template and do not delete the template.
🟥🟥🟥 All good? Continue with your issue :) 🟥🟥🟥
--!>
-->

**Describe the bug:**
<!-- A clear and concise description of what the bug is. -->
Expand Down
2 changes: 1 addition & 1 deletion Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@
<PropertyGroup>
<Authors>ModernFlyouts Community</Authors>
<LangVersion>latest</LangVersion>
<Version>0.9.1</Version>
<Version>0.10.0</Version>
</PropertyGroup>
</Project>
204 changes: 204 additions & 0 deletions ModernFlyouts.Core/Display/BrightnessController.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,204 @@
using System;
using System.Management;
using Microsoft.Toolkit.Mvvm.ComponentModel;
using ModernFlyouts.Core.Interop;

namespace ModernFlyouts.Core.Display
{
public abstract class BrightnessController : ObservableObject, IDisposable
{
#region Properties

private DisplayMonitor associatedDisplayMonitor;

public DisplayMonitor AssociatedDisplayMonitor
{
get => associatedDisplayMonitor;
internal set => SetProperty(ref associatedDisplayMonitor, value);
}

private double minimum = 0.0;

public double Minimum
{
get => minimum;
protected set => SetProperty(ref minimum, value);
}

private double maximum = 100.0;

public double Maximum
{
get => maximum;
protected set => SetProperty(ref maximum, value);
}

private double brightness = 0.0;

public double Brightness
{
get => brightness;
set
{
value = Math.Min(Math.Max(minimum, value), maximum);
if (SetProperty(ref brightness, value))
{
SetBrightness(value);
}
}
}

#endregion

public BrightnessController()
{
Brightness = GetBrightness();
}

internal abstract double GetBrightness();

internal abstract void SetBrightness(double value);

internal void UpdateBrightness(double value)
{
value = Math.Min(Math.Max(minimum, value), maximum);
SetProperty(ref brightness, value, nameof(Brightness));
}

protected virtual void Dispose(bool disposing)
{
}

~BrightnessController()
{
Dispose(false);
}

public void Dispose()
{
Dispose(true);
GC.SuppressFinalize(this);
}
}

public class MockBrightnessController : BrightnessController
{
internal override double GetBrightness()
{
return new Random().NextDouble() * 100.0;
}

internal override void SetBrightness(double value)
{
}
}

public class BuiltInDisplayBrightnessController : BrightnessController
{
internal BuiltInDisplayBrightnessController(byte[] levels)
{
Maximum = levels.Length - 1;
Minimum = levels[0];
}

internal override double GetBrightness()
{
try
{
var s = new ManagementScope("root\\WMI");
var q = new SelectQuery("WmiMonitorBrightness");
var mos = new ManagementObjectSearcher(s, q);
var moc = mos.Get();

foreach (var managementBaseObject in moc)
{
return Convert.ToDouble(managementBaseObject.GetPropertyValue("CurrentBrightness"));
}

moc.Dispose();
mos.Dispose();
}
catch { }

return 0.0;
}

internal override void SetBrightness(double value)
{
try
{
var s = new ManagementScope("root\\WMI");
var q = new SelectQuery("WmiMonitorBrightnessMethods");
var mos = new ManagementObjectSearcher(s, q);
var moc = mos.Get();

foreach (var managementBaseObject in moc)
{
var o = (ManagementObject)managementBaseObject;
o.InvokeMethod("WmiSetBrightness", new object[]
{
uint.MaxValue,
(int)Math.Truncate(value)
});
}

moc.Dispose();
mos.Dispose();
}
catch { }
}
}

public class ExternalDisplayBrightnessController : BrightnessController
{
private IntPtr hPhysicalMonitor;
private double currentValue;

internal ExternalDisplayBrightnessController(MonitorInfo info, DisplayMonitor displayMonitor)
{
Maximum = info.MaxValue;
Minimum = info.MinValue;
currentValue = info.CurrentValue;
hPhysicalMonitor = info.Handle;
Brightness = currentValue;

AssociatedDisplayMonitor = displayMonitor;
}

internal override double GetBrightness()
{
return currentValue;
}

internal override void SetBrightness(double value)
{
if (NativeMethods.SetMonitorBrightness(hPhysicalMonitor, (uint)Math.Truncate(value)))
{
currentValue = value;
}
}

private bool disposedValue;

protected override void Dispose(bool disposing)
{
base.Dispose(disposing);

if (!disposedValue)
{
AssociatedDisplayMonitor = null;
NativeMethods.DestroyPhysicalMonitor(hPhysicalMonitor);

disposedValue = true;
}
}
}

internal class MonitorInfo
{
public uint MinValue { get; set; }
public uint MaxValue { get; set; }
public IntPtr Handle { get; set; }
public uint CurrentValue { get; set; }
}
}
Loading