示例#1
0
 /// <summary>
 /// It establishes in which form the language will be changed
 /// Establece en que formulario se va a cambiar el idioma
 /// </summary>
 /// <param name="clientLoginLarge">ClientLoginLarge class reference</param>
 /// <param name="clientAplicationLarge">ClientAplicationLarge class reference</param>
 /// <param name="clientLoginSmall">ClientLoginSmall class reference</param>
 /// <param name="clientAplicationSmall">ClientAplicationSmall class reference</param>
 public void SelectCurrentAplicationWindow(ClientLoginLarge clientLoginLarge, ClientAplicationLarge clientAplicationLarge,
                                           ClientLoginSmall clientLoginSmall, ClientAplicationSmall clientAplicationSmall)
 {
     this.clientLoginLarge      = clientLoginLarge;
     this.clientLoginSmall      = clientLoginSmall;
     this.clientAplicationLarge = clientAplicationLarge;
     this.clientAplicationSmall = clientAplicationSmall;
 }
示例#2
0
        static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            Rectangle resolution = Screen.PrimaryScreen.Bounds;

            WindowsRegisterManager windowsRegisterManager = new WindowsRegisterManager();

            Microsoft.Win32.RegistryKey key = windowsRegisterManager.OpenWindowsRegister(true);
            bool keepSessionOpen            = Convert.ToBoolean(key.GetValue("KeepSessionOpen"));

            string selectedResolution = "";

            if (key.GetValue("SelectedResolution") != null)
            {
                selectedResolution = key.GetValue("SelectedResolution").ToString();
            }

            if (selectedResolution.Equals(""))
            {
                ClientLoginLarge clientLoginLarge = new ClientLoginLarge();
                if (resolution.Width > clientLoginLarge.Size.Width && resolution.Height > clientLoginLarge.Size.Height)
                {
                    selectedResolution = "1280x720";
                }
                else
                {
                    selectedResolution = "800x600";
                }

                key.SetValue("SelectedResolution", selectedResolution);
            }

            if (keepSessionOpen)
            {
                string username = key.GetValue("Username").ToString();

                if (selectedResolution.Equals("1280x720"))
                {
                    ClientAplicationLarge clientAplicationLarge = new ClientAplicationLarge();
                    clientAplicationLarge.ReceiveClassInstance(clientAplicationLarge, username);
                    Application.Run(clientAplicationLarge);
                }
                else
                {
                    ClientAplicationSmall clientAplicationSmall = new ClientAplicationSmall();
                    clientAplicationSmall.ReceiveClassInstance(clientAplicationSmall, username);
                    Application.Run(clientAplicationSmall);
                }
            }
            else
            {
                if (selectedResolution.Equals("1280x720"))
                {
                    ClientLoginLarge clientLoginLarge = new ClientLoginLarge();
                    clientLoginLarge.ReceiveClassInstance(clientLoginLarge);
                    Application.Run(clientLoginLarge);
                }
                else
                {
                    ClientLoginSmall clientLoginSmall = new ClientLoginSmall();
                    clientLoginSmall.ReceiveClassInstance(clientLoginSmall);
                    Application.Run(clientLoginSmall);
                }
            }
        }
示例#3
0
        /// <summary>
        /// Read from the windows register the resolution of the form and establish it the current form, also hide the form passed by param
        /// </summary>
        /// <param name="clientLogin">Boolean that indicates if the current form is the login form or the aplication form</param>
        public void LoadWindowResolution(bool clientLogin, ClientLoginLarge clientLoginLarge, ClientAplicationLarge clientAplicationLarge,
                                         ClientLoginSmall clientLoginSmall, ClientAplicationSmall clientAplicationSmall, string username)
        {
            WindowsRegisterManager windowsRegisterManager = new WindowsRegisterManager();

            Microsoft.Win32.RegistryKey key = windowsRegisterManager.OpenWindowsRegister(true);

            if (key.GetValue("SelectedResolution") == null || key.GetValue("SelectedResolution").Equals(""))
            {
                key.SetValue("SelectedResolution", "1280x720");
            }

            if (clientLoginSmall != null)
            {
                windowsRegisterManager.SaveWindowPosition(clientLoginSmall);
                clientLoginSmall.Hide();
            }
            else if (clientLoginLarge != null)
            {
                windowsRegisterManager.SaveWindowPosition(clientLoginLarge);
                clientLoginLarge.Hide();
            }
            else if (clientAplicationSmall != null)
            {
                windowsRegisterManager.SaveWindowPosition(clientAplicationSmall);
                clientAplicationSmall.Hide();
            }
            else if (clientAplicationLarge != null)
            {
                windowsRegisterManager.SaveWindowPosition(clientAplicationLarge);
                clientAplicationLarge.Hide();
            }

            if (key.GetValue("SelectedResolution").ToString().Contains("800x600"))
            {
                if (clientLogin)
                {
                    // Cargar ClientLoginSmall
                    ClientLoginSmall newClientLoginSmall = new ClientLoginSmall();
                    newClientLoginSmall.ReceiveClassInstance(newClientLoginSmall);
                    newClientLoginSmall.ShowDialog();
                }
                else
                {
                    // Cargar clientAplicationSmall
                    ClientAplicationSmall newclientAplicationSmall = new ClientAplicationSmall();
                    newclientAplicationSmall.ReceiveClassInstance(newclientAplicationSmall, username);
                    newclientAplicationSmall.ShowDialog();
                }
            }
            else
            {
                if (clientLogin)
                {
                    // Cargar ClientLoginLarge
                    if (clientLoginLarge != null)
                    {
                        clientLoginLarge.Hide();
                    }
                    else if (clientLoginSmall != null)
                    {
                        clientLoginSmall.Hide();
                    }
                    ClientLoginLarge newClientLoginLarge = new ClientLoginLarge();
                    newClientLoginLarge.ReceiveClassInstance(newClientLoginLarge);
                    newClientLoginLarge.ShowDialog();
                }
                else
                {
                    // Cargar clientAplicationLarge
                    ClientAplicationLarge newclientAplicationLarge = new ClientAplicationLarge();
                    newclientAplicationLarge.ReceiveClassInstance(newclientAplicationLarge, username);
                    newclientAplicationLarge.ShowDialog();
                }
            }

            windowsRegisterManager.CloseWindowsRegister(key);
        }