39 lines
1.6 KiB
C#
39 lines
1.6 KiB
C#
using System.Runtime.InteropServices;
|
|
using System.Windows;
|
|
using System.Windows.Media.Animation;
|
|
|
|
namespace CapyLauncher
|
|
{
|
|
public partial class App : Application
|
|
{
|
|
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
|
|
struct DisplayMode
|
|
{
|
|
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 32)] public string DeviceName;
|
|
public short SpecVersion, DriverVersion, Size, DriverExtra;
|
|
public int Fields, PositionX, PositionY, Orientation, FixedOutput;
|
|
public short Color, Duplex, YResolution, TTOption, Collate;
|
|
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 32)] public string FormName;
|
|
public short LogPixels;
|
|
public int BitsPerPel, PelsWidth, PelsHeight, DisplayFlags, DisplayFrequency;
|
|
public int IcmMethod, IcmIntent, MediaType, DitherType, Reserved1, Reserved2, PanningWidth, PanningHeight;
|
|
}
|
|
|
|
[DllImport("user32.dll", CharSet = CharSet.Unicode)]
|
|
static extern bool EnumDisplaySettings(string device, int mode, ref DisplayMode devMode);
|
|
|
|
static int RefreshRate()
|
|
{
|
|
var mode = new DisplayMode { Size = (short)Marshal.SizeOf(typeof(DisplayMode)) };
|
|
if (!EnumDisplaySettings(null, -1, ref mode) || mode.DisplayFrequency <= 1)
|
|
return 60;
|
|
return mode.DisplayFrequency;
|
|
}
|
|
|
|
public App()
|
|
{
|
|
Timeline.DesiredFrameRateProperty.OverrideMetadata(typeof(Timeline), new FrameworkPropertyMetadata { DefaultValue = RefreshRate() });
|
|
}
|
|
}
|
|
}
|