Пример #1
0
        } //end GetResolutions

        public static Win32Api.DevMode ChangeDisplaySettings(int width, int height, int bitCount)
        {
            var originalMode = new Win32Api.DevMode();

            originalMode.dmSize = (short)Marshal.SizeOf(originalMode);

            // Retrieving current settings
            // to edit them
            Win32Api.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 = Win32Api.ChangeDisplaySettings(ref newMode, 0);

            if (result != DispChangeSuccessful)
            {
                MessageBox.Show(@"Resolution change failed. Unable to modify resolution.");
            }

            return(originalMode);
        } //end ChangeDisplaySettings
Пример #2
0
        } //end ChangeDisplaySettings

        public static List <Resolution> GetResolutions(bool isWin8OrHigher)
        {
            var currentResolution = new Win32Api.DevMode();

            Win32Api.EnumDisplaySettings(null, EnumCurrentSettings, ref currentResolution);

            var returnValue   = new List <Resolution>();
            var i             = 0;
            var displayDevice = new Win32Api.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 (Win32Api.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());
        } //end GetResolutions
Пример #3
0
        private void Launch(Server server)
        {
            var settings = Helpers.LoadSettings(this._config.KeyName);
            var binFile  = Path.GetFileNameWithoutExtension(settings.ClientBin);
            var binpath  = Path.Combine(this._config.InstallDir, binFile);

            IPAddress[] ipOrDns;

            try
            {
                ipOrDns = Dns.GetHostAddresses(server.IpOrDns);
            }
            catch (SocketException)
            {
                MessageBox.Show(@"There was an error connecting to the server. Check the forums for any issues.",
                                @"Error Connecting!",
                                MessageBoxButtons.OK, MessageBoxIcon.Error);
                this.CheckServerStatus(false);
                return;
            }

            var revertResolution = new Win32Api.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);
            }

            try
            {
                ProxyServer proxyServer = null;
                if (settings.UseProxy)
                {
                    proxyServer = new ProxyServer();
                    proxyServer.LocalAddress = "127.0.0.1";
                    proxyServer.LocalPort    = new Random().Next(1025, 50000);

                    proxyServer.RemoteAddress = server.IpOrDns;
                    proxyServer.RemotePort    = server.Port;
                    proxyServer.Start();
                }

                if (Lineage.Run(settings, this._config.InstallDir, settings.ClientBin,
                                (ushort)(settings.UseProxy ? proxyServer.LocalPort : server.Port), settings.UseProxy ? null : ipOrDns[0]))
                {
                    var client = new LineageClient(this._config.KeyName, binFile, this._config.InstallDir,
                                                   proxyServer, ipOrDns[0], server.Port, Clients);
                    client.Initialize();

                    lock (this._lockObject)
                        Clients.Add(client);

                    if (!tmrCheckProcess.Enabled)
                    {
                        this._revertResolution       = revertResolution;
                        this.tmrCheckProcess.Enabled = true;
                    }

                    if (!settings.Windowed && this._isWin8OrHigher)
                    {
                        this.Win10SetClientFocus();
                    }
                }
                else
                {
                    MessageBox.Show("There was an error injecting into the Lineage client. Try running it again!", "Error Launching!",
                                    MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
            catch (Exception)
            {
                MessageBox.Show("An unknown error occurred launching the Lineage client. Try running it again!", "Error Launching!",
                                MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Пример #4
0
        } //end ChangeDisplayColour

        public static Win32Api.DevMode ChangeDisplaySettings(Win32Api.DevMode mode)
        {
            return(LineageClient.ChangeDisplaySettings(mode.dmPelsWidth, mode.dmPelsHeight, mode.dmBitsPerPel));
        } //end ChangeDisplaySettings