public static bool ChangeResolutionEx(ResolutionModeWrapper resolutionMode, string lpszDeviceName) { Devmode mode = new Devmode(); if (GetCurrentResolutionSettings(out mode, lpszDeviceName)) { mode.dmPelsWidth = resolutionMode.DmPelsWidth; mode.dmPelsHeight = resolutionMode.DmPelsHeight; mode.dmBitsPerPel = resolutionMode.DmBitsPerPel; mode.dmDisplayFrequency = resolutionMode.DmDisplayFrequency; mode.dmDisplayFixedOutput = resolutionMode.DmDisplayFixedOutput; DispChange returnValue = (DispChange)ChangeDisplaySettingsEx(lpszDeviceName, ref mode, IntPtr.Zero, (ChangeDisplaySettingsFlags.CdsUpdateregistry | ChangeDisplaySettingsFlags.CdsNoreset), IntPtr.Zero); ChangeDisplaySettingsEx(null, IntPtr.Zero, (IntPtr)null, ChangeDisplaySettingsFlags.CdsNone, (IntPtr)null); if (DispChange.DispChangeSuccessful == returnValue) { return(true); } else { MessageBox.Show("Changing the resolution failed: " + Enum.GetName(typeof(DispChange), returnValue)); } } return(false); }
public ApplicationSetting(string name, string fileName, int ingameLevel, ResolutionModeWrapper resolutionSettings, bool isResolutionChangeNeeded) { this.Name = name; this.FileName = fileName; this.IngameLevel = ingameLevel; this.ResolutionSettings = resolutionSettings; this.IsResolutionChangeNeeded = isResolutionChangeNeeded; }
public VibranceGUI( Func <List <ApplicationSetting>, ResolutionModeWrapper, IVibranceProxy> getProxy, int defaultWindowsLevel, int minTrackBarValue, int maxTrackBarValue, int defaultIngameValue, Func <int, string> resolveLabelLevel) { _defaultWindowsLevel = defaultWindowsLevel; _minTrackBarValue = minTrackBarValue; _maxTrackBarValue = maxTrackBarValue; _defaultIngameValue = defaultIngameValue; _resolveLabelLevel = resolveLabelLevel; _allowVisible = true; InitializeComponent(); trackBarWindowsLevel.Minimum = minTrackBarValue; trackBarWindowsLevel.Maximum = maxTrackBarValue; _supportedResolutionList = ResolutionHelper.EnumerateSupportedResolutionModes(); Devmode currentResolutionMode; if (ResolutionHelper.GetCurrentResolutionSettings(out currentResolutionMode, null)) { _windowsResolutionSettings = new ResolutionModeWrapper(currentResolutionMode); } else { MessageBox.Show("Current resolution mode could not be determined. Switching back to your Windows resolution will not work."); } _applicationSettings = new List <ApplicationSetting>(); _v = getProxy(_applicationSettings, _windowsResolutionSettings); backgroundWorker.WorkerReportsProgress = true; settingsBackgroundWorker.WorkerReportsProgress = true; backgroundWorker.RunWorkerAsync(); }
public override bool Equals(object obj) { ResolutionModeWrapper that = null; //if the object is of type DEVMODE, it corresponding ResolutionModeWrapper //will be determined and the second check will always pass if (obj is Devmode) { that = new ResolutionModeWrapper((Devmode)obj); } if (obj is ResolutionModeWrapper || that != null) { that = that == null ? obj as ResolutionModeWrapper : that; if (this.DmPelsWidth == that.DmPelsWidth && this.DmPelsHeight == that.DmPelsHeight && this.DmBitsPerPel == that.DmBitsPerPel && this.DmDisplayFrequency == that.DmDisplayFrequency && this.DmDisplayFixedOutput == that.DmDisplayFixedOutput) { return(true); } } return(false); }
public static bool ChangeResolution(ResolutionModeWrapper resolutionMode) { Devmode mode = new Devmode(); if (GetCurrentResolutionSettings(out mode, null)) { mode.dmPelsWidth = resolutionMode.DmPelsWidth; mode.dmPelsHeight = resolutionMode.DmPelsHeight; mode.dmBitsPerPel = resolutionMode.DmBitsPerPel; mode.dmDisplayFrequency = resolutionMode.DmDisplayFrequency; mode.dmDisplayFixedOutput = resolutionMode.DmDisplayFixedOutput; DispChange returnValue = (DispChange)ChangeDisplaySettings(ref mode, 0); if (DispChange.DispChangeSuccessful == returnValue) { return(true); } else { MessageBox.Show("Changing the resolution failed: " + Enum.GetName(typeof(DispChange), returnValue)); } } return(false); }
public override bool Equals(object obj) { ResolutionModeWrapper that = null; //if the object is of type DEVMODE, it corresponding ResolutionModeWrapper //will be determined and the second check will always pass if (obj is Devmode) { that = new ResolutionModeWrapper((Devmode)obj); } if (obj is ResolutionModeWrapper) { that = that == null ? obj as ResolutionModeWrapper : that; if (this.DmPelsWidth == that.DmPelsWidth && this.DmPelsHeight == that.DmPelsHeight && this.DmBitsPerPel == that.DmBitsPerPel && this.DmDisplayFrequency == that.DmDisplayFrequency && this.DmDisplayFixedOutput == that.DmDisplayFixedOutput) { return true; } } return false; }
public static bool ChangeResolutionEx(ResolutionModeWrapper resolutionMode, string lpszDeviceName) { Devmode mode = new Devmode(); if (GetCurrentResolutionSettings(out mode, lpszDeviceName)) { mode.dmPelsWidth = resolutionMode.DmPelsWidth; mode.dmPelsHeight = resolutionMode.DmPelsHeight; mode.dmBitsPerPel = resolutionMode.DmBitsPerPel; mode.dmDisplayFrequency = resolutionMode.DmDisplayFrequency; mode.dmDisplayFixedOutput = resolutionMode.DmDisplayFixedOutput; DispChange returnValue = (DispChange)ChangeDisplaySettingsEx(lpszDeviceName, ref mode, IntPtr.Zero, (ChangeDisplaySettingsFlags.CdsUpdateregistry | ChangeDisplaySettingsFlags.CdsNoreset), IntPtr.Zero); ChangeDisplaySettingsEx(null, IntPtr.Zero, (IntPtr)null, ChangeDisplaySettingsFlags.CdsNone, (IntPtr)null); if (DispChange.DispChangeSuccessful == returnValue) { return true; } else { MessageBox.Show("Changing the resolution failed: " + Enum.GetName(typeof(DispChange), returnValue)); } } return false; }
public static bool ChangeResolution(ResolutionModeWrapper resolutionMode) { Devmode mode = new Devmode(); if (GetCurrentResolutionSettings(out mode, null)) { mode.dmPelsWidth = resolutionMode.DmPelsWidth; mode.dmPelsHeight = resolutionMode.DmPelsHeight; mode.dmBitsPerPel = resolutionMode.DmBitsPerPel; mode.dmDisplayFrequency = resolutionMode.DmDisplayFrequency; mode.dmDisplayFixedOutput = resolutionMode.DmDisplayFixedOutput; DispChange returnValue = (DispChange)ChangeDisplaySettings(ref mode, 0); if (DispChange.DispChangeSuccessful == returnValue) { return true; } else { MessageBox.Show("Changing the resolution failed: " + Enum.GetName(typeof(DispChange), returnValue)); } } return false; }