public static User32.DevMode ChangeDisplaySettings(int width, int height, int bitCount) { var originalMode = new User32.DevMode(); originalMode.dmSize = (short)Marshal.SizeOf(originalMode); // Retrieving current settings // to edit them User32.EnumDisplaySettings(null, EnumCurrentSettings, ref originalMode); // Making a copy of the current settings // to allow reseting to the original mode var newMode = originalMode; // Changing the settings if (width != -1 && height != -1) { newMode.dmPelsHeight = height; newMode.dmPelsWidth = width; } newMode.dmBitsPerPel = bitCount; // Capturing the operation result var result = User32.ChangeDisplaySettings(ref newMode, 0); if (result != DispChangeSuccessful) { MessageBox.Show(@"Resolution change failed. Unable to modify resolution."); } return(originalMode); } //end ChangeDisplaySettings
public static List <Resolution> GetResolutions() { var currentResolution = new User32.DevMode(); User32.EnumDisplaySettings(null, EnumCurrentSettings, ref currentResolution); var returnValue = new List <Resolution>(); var i = 0; var displayDevice = new User32.DevMode(); while (User32.EnumDisplaySettings(null, i, ref displayDevice)) { var colour = displayDevice.dmBitsPerPel; var width = displayDevice.dmPelsWidth; var height = displayDevice.dmPelsHeight; // since windowed mode only supports 16 bit, only add 16 bit if (colour == 16 && currentResolution.dmDisplayFrequency == displayDevice.dmDisplayFrequency && displayDevice.dmDisplayFixedOutput == 0 && width >= 800 && (width != currentResolution.dmPelsWidth && height != currentResolution.dmPelsHeight)) { returnValue.Add(new Resolution { Width = width, Height = height, Colour = colour }); } i++; } return(returnValue.OrderByDescending(b => b.Width).ThenByDescending(b => b.Height).ToList()); }
private void Launch() { var settings = Helpers.LoadSettings(); if (settings.ClientDirectory == string.Empty || settings.ClientBin == string.Empty) { MessageBox.Show(@"You must select your lineage directory under settings before continuing.", @"Cannot continue!", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } var binFile = Path.GetFileNameWithoutExtension(settings.ClientBin); var selectedServer = this._servers[this.cmbServer.SelectedItem.ToString()]; var ip = (uint)IPAddress.NetworkToHostOrder(BitConverter.ToInt32(IPAddress.Parse(selectedServer.Ip).GetAddressBytes(), 0)); var revertResolution = new User32.DevMode(); if (settings.Resize) { revertResolution = WindowStyling.ChangeDisplaySettings(settings.Resolution.Width, settings.Resolution.Height, 16); } else if (settings.Windowed) { revertResolution = WindowStyling.ChangeDisplayColour(16); } Lineage.Run(settings, settings.ClientBin, ip, (ushort)selectedServer.Port); var hookedProcId = -1; if (settings.Windowed) { lock (this._lockObject) hookedProcId = WindowStyling.SetWindowed(binFile, HookedProcIds); } if (settings.Centred) { var windowSize = Screen.PrimaryScreen.WorkingArea; hookedProcId = WindowStyling.SetCentred(binFile, windowSize.Width, windowSize.Height, hookedProcId); } if (hookedProcId != -1) { lock (this._lockObject) HookedProcIds.Add(hookedProcId); } if (!this.processChecker.IsBusy) { this.processChecker.RunWorkerAsync(revertResolution); } }
private void Launch(ProxyServer proxyServer) { var settings = Helpers.LoadSettings(this._config.KeyName); var binFile = Path.GetFileNameWithoutExtension(settings.ClientBin); var ip = (uint)IPAddress.NetworkToHostOrder(BitConverter.ToInt32(IPAddress.Parse("127.0.0.1").GetAddressBytes(), 0)); var revertResolution = new User32.DevMode(); if (settings.Resize) { revertResolution = LineageClient.ChangeDisplaySettings(settings.Resolution.Width, settings.Resolution.Height, settings.Resolution.Colour); } else if (settings.Windowed) { revertResolution = LineageClient.ChangeDisplayColour(this._isWin8OrHigher ? 32 : 16); } Lineage.Run(settings, this._config.InstallDir, settings.ClientBin, ip, (ushort)proxyServer.LocalPort); var client = new LineageClient(this._config.KeyName, binFile, this._config.InstallDir, proxyServer, Clients); client.Initialize(); if (settings.Centred) { var windowSize = Screen.PrimaryScreen.WorkingArea; client.SetCentred(windowSize.Width, windowSize.Height); } if (settings.CaptureMouse) { client.SetAllowCapture(); } lock (this._lockObject) Clients.Add(client); if (!tmrCheckProcess.Enabled) { this._revertResolution = revertResolution; this.tmrCheckProcess.Enabled = true; } if (!tmrProxyStatus.Enabled) { tmrProxyStatus.Enabled = true; } }
public static List <Resolution> GetResolutions(bool isWin8OrHigher) { var currentResolution = new User32.DevMode(); User32.EnumDisplaySettings(null, EnumCurrentSettings, ref currentResolution); var returnValue = new List <Resolution>(); var i = 0; var displayDevice = new User32.DevMode(); // if we are pre Win 8, then use 16 bit colours, otherwise we use 32 bit since 16 bit isn't supported var colourBit = isWin8OrHigher ? 32 : 16; while (User32.EnumDisplaySettings(null, i, ref displayDevice)) { var colour = displayDevice.dmBitsPerPel; var width = displayDevice.dmPelsWidth; var height = displayDevice.dmPelsHeight; if (colour == colourBit && currentResolution.dmDisplayFrequency == displayDevice.dmDisplayFrequency && displayDevice.dmDisplayFixedOutput == 0 && width >= 800 && (width != currentResolution.dmPelsWidth && height != currentResolution.dmPelsHeight)) { returnValue.Add(new Resolution { Width = width, Height = height, Colour = colour }); } i++; } //end while return(returnValue.OrderByDescending(b => b.Width).ThenByDescending(b => b.Height).ToList()); }
public static User32.DevMode ChangeDisplaySettings(User32.DevMode mode) { return(LineageClient.ChangeDisplaySettings(mode.dmPelsWidth, mode.dmPelsHeight, mode.dmBitsPerPel)); }
public static User32.DevMode ChangeDisplaySettings(User32.DevMode mode) { return(WindowStyling.ChangeDisplaySettings(mode.dmPelsWidth, mode.dmPelsHeight, mode.dmBitsPerPel)); }