public Configuration() { //First Time Installs redist_first_time = true; logitech_first_time = true; corsair_first_time = true; razer_first_time = true; //General Program Settings allow_peripheral_devices = true; use_volume_as_brightness = false; allow_wrappers_in_background = true; allow_all_logitech_bitmaps = true; GlobalBrightness = 1.0f; KeyboardBrightness = 1.0f; peripheralBrightness = 1.0f; updates_check_on_start_up = true; updates_allow_silent_minor = true; start_silently = false; close_mode = AppExitMode.Ask; mouse_orientation = MouseOrientationType.RightHanded; keyboard_brand = PreferredKeyboard.None; keyboard_localization = PreferredKeyboardLocalization.None; mouse_preference = PreferredMouse.None; virtualkeyboard_keycap_type = KeycapType.Default; detection_mode = ApplicationDetectionMode.WindowsEvents; excluded_programs = new HashSet <string>(); //additional_profiles = new Dictionary<string, GenericApplicationProfileManager>(); devices_disable_keyboard = false; devices_disable_mouse = false; devices_disable_headset = false; devices_disabled = new HashSet <Type>(); OverlaysInPreview = false; //Blackout and Night theme time_based_dimming_enabled = false; time_based_dimming_affect_games = false; time_based_dimming_start_hour = 21; time_based_dimming_start_minute = 0; time_based_dimming_end_hour = 8; time_based_dimming_end_minute = 0; nighttime_enabled = true; nighttime_start_hour = 20; nighttime_start_minute = 0; nighttime_end_hour = 7; nighttime_end_minute = 0; //// Idle Effects idle_type = IdleEffects.None; idle_delay = 5; idle_speed = 1.0f; idle_effect_primary_color = Color.FromArgb(0, 255, 0); idle_effect_secondary_color = Color.FromArgb(0, 0, 0); idle_amount = 5; idle_frequency = 2.5f; //Overlay Settings volume_overlay_settings = new VolumeOverlaySettings(); skype_overlay_settings = new SkypeOverlaySettings(); //ProfileOrder = new List<string>(ApplicationProfiles.Keys); VarRegistry = new VariableRegistry(); }
public void LoadBrand(PreferredKeyboard keyboard_preference = PreferredKeyboard.None, PreferredMouse mouse_preference = PreferredMouse.None, MouseOrientationType mouse_orientation = MouseOrientationType.RightHanded) { try { //System.Threading.Thread.CurrentThread.CurrentCulture = new CultureInfo("de-DE"); //Global.logger.LogLine("Loading brand: " + brand.ToString() + " for: " + System.Threading.Thread.CurrentThread.CurrentCulture.Name); //Load keyboard layout if (Directory.Exists(layoutsPath)) { string culture = System.Threading.Thread.CurrentThread.CurrentCulture.Name; switch (Global.Configuration.keyboard_localization) { case PreferredKeyboardLocalization.None: break; case PreferredKeyboardLocalization.intl: culture = "intl"; break; case PreferredKeyboardLocalization.us: culture = "en-US"; break; case PreferredKeyboardLocalization.uk: culture = "en-GB"; break; case PreferredKeyboardLocalization.ru: culture = "ru-RU"; break; case PreferredKeyboardLocalization.fr: culture = "fr-FR"; break; case PreferredKeyboardLocalization.de: culture = "de-DE"; break; case PreferredKeyboardLocalization.jpn: culture = "ja-JP"; break; } switch (culture) { case ("ja-JP"): LoadCulture("jpn"); break; case ("de-DE"): case ("hsb-DE"): case ("dsb-DE"): _loaded_localization = PreferredKeyboardLocalization.de; LoadCulture("de"); break; case ("fr-FR"): case ("br-FR"): case ("oc-FR"): case ("co-FR"): case ("gsw-FR"): _loaded_localization = PreferredKeyboardLocalization.fr; LoadCulture("fr"); break; case ("cy-GB"): case ("gd-GB"): case ("en-GB"): _loaded_localization = PreferredKeyboardLocalization.uk; LoadCulture("uk"); break; case ("ru-RU"): case ("tt-RU"): case ("ba-RU"): case ("sah-RU"): _loaded_localization = PreferredKeyboardLocalization.ru; LoadCulture("ru"); break; case ("en-US"): _loaded_localization = PreferredKeyboardLocalization.us; LoadCulture("us"); break; default: _loaded_localization = PreferredKeyboardLocalization.intl; LoadCulture("intl"); break; } } var layoutConfigPath = ""; if (keyboard_preference == PreferredKeyboard.Logitech_G910) { layoutConfigPath = Path.Combine(layoutsPath, "logitech_g910.json"); } else if (keyboard_preference == PreferredKeyboard.Logitech_G810) { layoutConfigPath = Path.Combine(layoutsPath, "logitech_g810.json"); } else if (keyboard_preference == PreferredKeyboard.Logitech_G410) { layoutConfigPath = Path.Combine(layoutsPath, "logitech_g410.json"); } else if (keyboard_preference == PreferredKeyboard.Corsair_K95) { layoutConfigPath = Path.Combine(layoutsPath, "corsair_k95.json"); } else if (keyboard_preference == PreferredKeyboard.Corsair_K70) { layoutConfigPath = Path.Combine(layoutsPath, "corsair_k70.json"); } else if (keyboard_preference == PreferredKeyboard.Corsair_K65) { layoutConfigPath = Path.Combine(layoutsPath, "corsair_k65.json"); } else if (keyboard_preference == PreferredKeyboard.Corsair_STRAFE) { layoutConfigPath = Path.Combine(layoutsPath, "corsair_strafe.json"); } else if (keyboard_preference == PreferredKeyboard.Razer_Blackwidow) { layoutConfigPath = Path.Combine(layoutsPath, "razer_blackwidow.json"); } else if (keyboard_preference == PreferredKeyboard.Razer_Blackwidow_X) { layoutConfigPath = Path.Combine(layoutsPath, "razer_blackwidow_x.json"); } else if (keyboard_preference == PreferredKeyboard.Razer_Blackwidow_TE) { layoutConfigPath = Path.Combine(layoutsPath, "razer_blackwidow_te.json"); } else if (keyboard_preference == PreferredKeyboard.Masterkeys_Pro_L) { layoutConfigPath = Path.Combine(layoutsPath, "masterkeys_pro_l.json"); } else if (keyboard_preference == PreferredKeyboard.Masterkeys_Pro_S) { layoutConfigPath = Path.Combine(layoutsPath, "masterkeys_pro_s.json"); } //else if (keyboard_preference == PreferredKeyboard.Roccat_Ryos) // layoutConfigPath = Path.Combine(layoutsPath, "roccat_ryos.json"); else { LoadNone(); return; } if (!String.IsNullOrWhiteSpace(layoutConfigPath) && File.Exists(layoutConfigPath)) { string content = File.ReadAllText(layoutConfigPath, Encoding.UTF8); VirtualGroupConfiguration layoutConfig = JsonConvert.DeserializeObject <VirtualGroupConfiguration>(content, new JsonSerializerSettings { ObjectCreationHandling = ObjectCreationHandling.Replace }); if (layoutConfig.replace_RWin_with_FN) { virtual_keyboard_group.AdjustFNKey(); } virtual_keyboard_group.SetNewLineKeys(layoutConfig.keys_to_set_as_new_line); virtual_keyboard_group.RemoveKeys(layoutConfig.keys_to_remove); foreach (string feature in layoutConfig.included_features) { string feature_path = Path.Combine(layoutsPath, "Extra Features", feature); if (File.Exists(feature_path)) { string feature_content = File.ReadAllText(feature_path, Encoding.UTF8); VirtualGroup feature_config = JsonConvert.DeserializeObject <VirtualGroup>(feature_content, new JsonSerializerSettings { ObjectCreationHandling = ObjectCreationHandling.Replace }); virtual_keyboard_group.AddFeature(feature_config.grouped_keys.ToArray(), feature_config.origin_region); } } string mouse_feature_path = ""; switch (mouse_preference) { case PreferredMouse.Logitech_G900: mouse_feature_path = Path.Combine(layoutsPath, "Extra Features", "logitech_g900_features.json"); break; case PreferredMouse.Corsair_Sabre: mouse_feature_path = Path.Combine(layoutsPath, "Extra Features", "corsair_sabre_features.json"); break; case PreferredMouse.Corsair_M65: mouse_feature_path = Path.Combine(layoutsPath, "Extra Features", "corsair_m65_features.json"); break; case PreferredMouse.Corsair_Katar: mouse_feature_path = Path.Combine(layoutsPath, "Extra Features", "corsair_katar_features.json"); break; case PreferredMouse.Clevo_Touchpad: mouse_feature_path = Path.Combine(layoutsPath, "Extra Features", "clevo_touchpad_features.json"); break; } if (!string.IsNullOrWhiteSpace(mouse_feature_path)) { string feature_content = File.ReadAllText(mouse_feature_path, Encoding.UTF8); VirtualGroup feature_config = JsonConvert.DeserializeObject <VirtualGroup>(feature_content, new JsonSerializerSettings { ObjectCreationHandling = ObjectCreationHandling.Replace }); if (mouse_orientation == MouseOrientationType.LeftHanded) { if (feature_config.origin_region == KeyboardRegion.TopRight) { feature_config.origin_region = KeyboardRegion.TopLeft; } else if (feature_config.origin_region == KeyboardRegion.BottomRight) { feature_config.origin_region = KeyboardRegion.BottomLeft; } double outline_width = 0.0; int outline_width_bits = 0; foreach (var key in feature_config.grouped_keys) { if (outline_width == 0.0 && outline_width_bits == 0) //We found outline (NOTE: Outline has to be first in the grouped keys) { if (key.tag == DeviceKeys.NONE) { outline_width = key.width + 2 * key.margin_left; outline_width_bits = key.width_bits + 2 * key.margin_left_bits; } } key.margin_left -= outline_width; key.margin_left_bits -= outline_width_bits; } } virtual_keyboard_group.AddFeature(feature_config.grouped_keys.ToArray(), feature_config.origin_region); } } } catch (Exception e) { Console.WriteLine(e); } //Perform end of load functions CalculateBitmap(); CreateUserControl(); KeyboardLayoutUpdated?.Invoke(this); }