/// <summary> /// Set the current resolution in the windows registry the selected item in the resolution combobox, /// if there is no selected resolution set the 1280 x 720 pixels resolution /// </summary> /// <param name="resolutionCombobox"></param> public void ReadSelectedResolution(ComboBox resolutionCombobox) { WindowsRegisterManager windowsRegisterManager = new WindowsRegisterManager(); Microsoft.Win32.RegistryKey key = windowsRegisterManager.OpenWindowsRegister(true); string selectedResolution = ""; if (key.GetValue("SelectedResolution") != null) { selectedResolution = key.GetValue("SelectedResolution").ToString(); } if (selectedResolution.Equals("")) { selectedResolution = "1280x720"; key.SetValue("SelectedResolution", selectedResolution); } if (CheckResolutionComboboxSelection(selectedResolution, resolutionCombobox) != -1) { CheckResolutionComboboxSelection(selectedResolution, resolutionCombobox); } else { resolutionCombobox.SelectedIndex = 0; } windowsRegisterManager.CloseWindowsRegister(key); }
public void LogoutButton_MouseClick(object sender, MouseEventArgs e) { if (downloadCancellationTokenSource != null) { if (!downloadCancellationTokenSource.IsCancellationRequested) { downloadCancellationTokenSource.Cancel(); } } WindowsRegisterManager windowsRegisterManager = new WindowsRegisterManager(); Microsoft.Win32.RegistryKey key = windowsRegisterManager.OpenWindowsRegister(true); bool keepSessionOpen = Convert.ToBoolean(key.GetValue("KeepSessionOpen")); if (keepSessionOpen) { key.DeleteValue("KeepSessionOpen"); key.DeleteValue("Username"); } string resolution = SaveData(); if (resolution.Equals("1280x720")) { ClientAplicationLarge.aplicationClosing = true; } else { ClientAplicationSmall.aplicationClosing = true; } MultipleResources.RestartApp(Process.GetCurrentProcess().Id, Process.GetCurrentProcess().ProcessName); }
/// <summary> /// Change the resolution stored in the windows registry and change the resolution of the application /// Cambia la resolución del almacenado en la entrada del registro de windows y cambia la resolución de la aplicación /// </summary> /// <param name="resolutionCombobox">Combobox with all the resolutions</param> /// <param name="clientLogin">Boolean that indicates if the current form is the login form or the aplication form</param> public void ResolutionCombobox_ResolutionChanged(ComboBox resolutionCombobox) { string[] selectedResolutionArray = resolutionCombobox.SelectedItem.ToString().Split(' '); WindowsRegisterManager windowsRegisterManager = new WindowsRegisterManager(); Microsoft.Win32.RegistryKey key = windowsRegisterManager.OpenWindowsRegister(true); key.SetValue("SelectedResolution", selectedResolutionArray[0]); windowsRegisterManager.CloseWindowsRegister(key); }
private string SaveData() { WindowsRegisterManager windowsRegisterManager = new WindowsRegisterManager(); windowsRegisterManager.SaveWindowPosition(windowApp); Microsoft.Win32.RegistryKey key = windowsRegisterManager.OpenWindowsRegister(true); key.SetValue("selectedTileSize", tileSizeSelected); string resolution = key.GetValue("SelectedResolution").ToString(); windowsRegisterManager.CloseWindowsRegister(key); return(resolution); }
/// <summary> /// Change the language stored in the windows registry and change the language of the application /// Cambia el idioma del almacenado en la entrada del registro de windows y cambia el idioma de la aplicación /// </summary> /// <param name="languageCombobox">Combobox with all the languages</param> public void LanguageCombobox_LanguageChanged(ComboBox languageCombobox) { string[] selectedLanguageArray = languageCombobox.SelectedItem.ToString().Split('('); string selectedLanguage = selectedLanguageArray[1].Remove(selectedLanguageArray[1].Length - 1); WindowsRegisterManager windowsRegisterManager = new WindowsRegisterManager(); Microsoft.Win32.RegistryKey key = windowsRegisterManager.OpenWindowsRegister(true); key.SetValue("selectedLanguage", selectedLanguage); windowsRegisterManager.CloseWindowsRegister(key); ChangeCurrentLanguage(selectedLanguage); ChangeAplicationLanguage(); CheckLanguageComboboxSelection(selectedLanguage, languageCombobox); }
/// <summary> /// It reads the language that is being used from the windows registry, if there is none, it sets Spanish by default. /// If the application is opening then change the language of the application if it is not Spanish and if you enter /// settings then set the language that is in use in the dropdown /// /// Lee el idioma que se está usando del registro del windows, si no hay ninguno establece el español por defecto. /// Si la aplicación se esta abriendo entonces cambia el idioma de la aplicación si no es español y si entras a /// ajustes entonces establece en el desplegable el idioma que está en uso /// </summary> /// <param name="appLoading">boolean that indicates if the application is loading for the first time or if you /// are entering the method after the entire application has loaded</param> /// <param name="languageCombobox">Combobox with all the languages</param> public void ReadSelectedLanguage(bool appLoading, ComboBox languageCombobox) { WindowsRegisterManager windowsRegisterManager = new WindowsRegisterManager(); Microsoft.Win32.RegistryKey key = windowsRegisterManager.OpenWindowsRegister(true); string selectedLanguage = (string)key.GetValue("selectedLanguage"); if (selectedLanguage == null || selectedLanguage.Equals("")) { selectedLanguage = "es-ES"; key.SetValue("selectedLanguage", selectedLanguage); } if (languageCombobox != null && !appLoading) { if (CheckLanguageComboboxSelection(selectedLanguage, languageCombobox) != -1) { CheckLanguageComboboxSelection(selectedLanguage, languageCombobox); } else { languageCombobox.SelectedIndex = 0; } } else if (appLoading) { ChangeCurrentLanguage(selectedLanguage); // If the language is not spanish when the aplication starts then translate it if (!selectedLanguage.Equals("es-ES")) { ChangeAplicationLanguage(); } } windowsRegisterManager.CloseWindowsRegister(key); }
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); } } }
/// <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); }