Skip to content
This repository has been archived by the owner on Jan 24, 2022. It is now read-only.

Commit

Permalink
Merge pull request #7 from AdamKauffman/threaded
Browse files Browse the repository at this point in the history
Threaded is now Tasked
  • Loading branch information
mdhiggins authored May 12, 2020
2 parents 812afda + a4e77f8 commit 105413f
Show file tree
Hide file tree
Showing 3 changed files with 281 additions and 273 deletions.
10 changes: 4 additions & 6 deletions CenterTaskbar/CenterTaskbar.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
<PublisherName>Michael Higgins</PublisherName>
<SuiteName>Center Taskbar</SuiteName>
<OpenBrowserOnPublish>false</OpenBrowserOnPublish>
<ApplicationRevision>5</ApplicationRevision>
<ApplicationRevision>9</ApplicationRevision>
<ApplicationVersion>1.1.0.%2a</ApplicationVersion>
<UseApplicationTrust>false</UseApplicationTrust>
<ExcludeDeploymentUrl>true</ExcludeDeploymentUrl>
Expand Down Expand Up @@ -72,17 +72,15 @@
<PropertyGroup>
<SignManifests>false</SignManifests>
</PropertyGroup>
<PropertyGroup>
<StartupObject>CenterTaskbar.Program</StartupObject>
</PropertyGroup>
<ItemGroup>
<Reference Include="PresentationCore" />
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Deployment" />
<Reference Include="System.Drawing" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Windows.Forms" />
<Reference Include="System.Xml" />
<Reference Include="UIAutomationClient" />
Expand Down
56 changes: 24 additions & 32 deletions CenterTaskbar/DisplaySettings.cs
Original file line number Diff line number Diff line change
@@ -1,24 +1,22 @@
using System;
using System.Runtime.InteropServices;
using System.Runtime.InteropServices;
using System.Windows.Forms;

namespace CenterTaskbar
{
static class DisplaySettings
internal static class DisplaySettings
{

[DllImport("user32.dll")]
private static extern bool EnumDisplaySettings(string deviceName, int modeNum, ref DEVMODE devMode);
const int ENUM_CURRENT_SETTINGS = -1;
//const int ENUM_REGISTRY_SETTINGS = -2;
const int ENUM_REGISTRY_SETTINGS = -2;

[StructLayout(LayoutKind.Sequential)]
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)]
private struct DEVMODE
{

private const int CCHDEVICENAME = 0x20;
private const int CCHFORMNAME = 0x20;
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 0x20)]
private const int CCHDEVICENAME = 32;
private const int CCHFORMNAME = 32;
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = CCHDEVICENAME)]
public string dmDeviceName;
public short dmSpecVersion;
public short dmDriverVersion;
Expand All @@ -34,7 +32,7 @@ private struct DEVMODE
public short dmYResolution;
public short dmTTOption;
public short dmCollate;
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 0x20)]
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = CCHFORMNAME)]
public string dmFormName;
public short dmLogPixels;
public int dmBitsPerPel;
Expand All @@ -50,33 +48,27 @@ private struct DEVMODE
public int dmReserved2;
public int dmPanningWidth;
public int dmPanningHeight;

}

public static void ListAllDisplayModes()
{
DEVMODE vDevMode = new DEVMODE();
int i = 0;
while (EnumDisplaySettings(null, i, ref vDevMode))
{
Console.WriteLine("Width:{0} Height:{1} Color:{2} Frequency:{3}",
vDevMode.dmPelsWidth,
vDevMode.dmPelsHeight,
1 << vDevMode.dmBitsPerPel, vDevMode.dmDisplayFrequency
);
i++;
}
}
//public static void ListAllDisplayModes()
//{
// DEVMODE vDevMode = new DEVMODE();
// int i = 0;
// while (EnumDisplaySettings(null, i, ref vDevMode))
// {
// Console.WriteLine("Width:{0} Height:{1} Color:{2} Frequency:{3}",
// vDevMode.dmPelsWidth,
// vDevMode.dmPelsHeight,
// 1 << vDevMode.dmBitsPerPel, vDevMode.dmDisplayFrequency
// );
// i++;
// }
//}

public static int CurrentRefreshRate()
{
DEVMODE vDevMode = new DEVMODE();
if (EnumDisplaySettings(null, ENUM_CURRENT_SETTINGS, ref vDevMode)) {
return vDevMode.dmDisplayFrequency;
} else
{
return 60;
}
var vDevMode = new DEVMODE();
return EnumDisplaySettings(null, ENUM_CURRENT_SETTINGS, ref vDevMode) ? vDevMode.dmDisplayFrequency : 60;
}
}
}
Loading

0 comments on commit 105413f

Please sign in to comment.