private static void InitLanguagePolish() { InterfaceLanguage pols = new InterfaceLanguage("pols", "Polski"); pols.Title = "FOnline konfigurator"; // buttons pols.Play = "Graj"; pols.Save = "Zapisz"; pols.Exit = "Wyjdź"; // tabs pols.Other = "Inne"; pols.Game = "Gra"; pols.Combat = "Walka"; pols.Net = "Połączenie"; pols.Video = "Grafika"; pols.Sound = "Dźwięk"; // tabOther pols.Language = "Język"; // tabNet pols.Server = "Serwer gry"; // tabSound pols.Music = "Muzyka"; InterfaceLanguage.Add(pols); }
/// <summary> /// Returns a CultureInfo instance for the specified language. /// </summary> /// <param name="language"> /// Interface language to get the CultureInfo for. /// </param> /// <returns> /// Returns a CultureInfo instance. /// </returns> public static CultureInfo GetCultureInfo(InterfaceLanguage language) { switch (language) { case InterfaceLanguage.English: return(new CultureInfo("en")); case InterfaceLanguage.Spanish: return(new CultureInfo("es")); case InterfaceLanguage.Russian: return(new CultureInfo("ru")); case InterfaceLanguage.Ukrainian: return(new CultureInfo("uk")); case InterfaceLanguage.Dutch: return(new CultureInfo("nl")); case InterfaceLanguage.SChinese: return(new CultureInfo("zh-CN")); default: throw new ArgumentOutOfRangeException(nameof(language), language, null); } }
public static CultureInfo GetCultureInfo(InterfaceLanguage language) { CultureInfo cultureInfo; switch (language) { case InterfaceLanguage.English: cultureInfo = new CultureInfo("en"); break; case InterfaceLanguage.Spanish: cultureInfo = new CultureInfo("es"); break; case InterfaceLanguage.Russian: cultureInfo = new CultureInfo("ru"); break; case InterfaceLanguage.Ukrainian: cultureInfo = new CultureInfo("uk"); break; case InterfaceLanguage.Dutch: cultureInfo = new CultureInfo("nl"); break; default: throw new ArgumentOutOfRangeException(nameof(language), language, null); } return(cultureInfo); }
private static void ChangeInterfaceLanguage(InterfaceLanguage language) { CultureInfo newCulture; switch (language) { case InterfaceLanguage.Dutch: newCulture = new CultureInfo("nl"); break; case InterfaceLanguage.English: newCulture = new CultureInfo("en"); break; case InterfaceLanguage.Russian: newCulture = new CultureInfo("ru"); break; case InterfaceLanguage.Spanish: newCulture = new CultureInfo("es"); break; case InterfaceLanguage.Ukranian: newCulture = new CultureInfo("uk"); break; default: newCulture = Thread.CurrentThread.CurrentCulture; break; } Thread.CurrentThread.CurrentUICulture = newCulture; }
static void Main() { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); // always add "engl" language as default InterfaceLanguage.AddDefault(new InterfaceLanguage()); formMain = new frmMain(); bool init = false; string rootName = "FOnlineConfigExtension"; if (DllExtension.Load("FOnlineConfig.dll", rootName)) { init = true; } if (DllExtension.LoadPattern("FOnlineConfig.*.dll", rootName) > 0) { init = true; } if (init) { DllExtension.Run("OnInit"); } Application.Run(formMain); }
/// <summary> /// Subscribes a listener to the language changes. /// Returns false if the listener was already subscribed. /// </summary> /// <param name="listener">The listener to subscribe</param> /// <returns>If the listener was successfully subscribed</returns> public bool AddListener(InterfaceLanguage listener) { if (_observers.Contains(listener)) return false; _observers.Add(listener); return true; }
private static void InitLanguageRussian() { InterfaceLanguage russ = new InterfaceLanguage("russ", "Русский"); russ.Title = "FOnline конфигуратор"; // buttons russ.Play = "Играть"; russ.Save = "Сохранить"; russ.Exit = "Выход"; // tabs russ.Other = "Разное"; russ.Game = "Игра"; russ.Combat = "Боевка"; russ.Net = "Сеть"; russ.Video = "Видео"; russ.Sound = "Звук"; // tabOther russ.Language = "Язык"; russ.Flush = "Извещение о сообщениях при неактивном окне"; russ.Beep = "Звуковое извещение о сообщениях при неактивном окн"; russ.Invert = "Инвертирование текста в окне сообщений"; russ.Log = "Ведение лога в 'FOnline.log'"; russ.LogTime = "Запись в лог с указанием времени"; // tabGame russ.ScrollDelay = "Задержка скроллинга"; russ.ScrollStep = "Шаг скроллинга"; russ.TextDelay = "Время задержки текста (мс)"; russ.AlwaysRun = "Постоянный бег"; // tabCombat russ.CombatMode = "Режим боя по-умолчанию"; russ.CombatModeBoth = "Оба режима"; russ.CombatModeRT = "Реальное время"; russ.CombatModeTB = "Пошаговый режим"; russ.CombatAmmo = "Индикатор патронов и износа"; russ.CombatAmmoBoth = "Линии и номера"; russ.CombatAmmoLines = "Линии"; russ.CombatAmmoNumbers = "Номера"; russ.CombatMessages = "Боевые сообщения"; russ.CombatMessagesVerbose = "Полные"; russ.CombatMessagesBrief = "Краткие"; russ.CombatDamage = "Режим индикации повреждений над головой"; russ.CombatDamageDelay = "Задержка, в мс"; InterfaceLanguage.Add(russ); }
/// <summary> /// Create locale method /// </summary> /// <param name="language">Language</param> /// <returns>Locale</returns> public static Locale CreateLocale(InterfaceLanguage language) { switch (language) { case InterfaceLanguage.en: return(new ENLocale()); case InterfaceLanguage.ru: return(new RULocale()); } return(new ENLocale()); }
/// <summary> /// Set language menu flags on UI /// </summary> /// <param name="localization"></param> private void SetLanguageFlags(InterfaceLanguage localization) { if (localization.Equals(InterfaceLanguage.en)) { RussianItem.Checked = false; EnglishItem.Checked = true; } if (localization.Equals(InterfaceLanguage.ru)) { EnglishItem.Checked = false; RussianItem.Checked = true; } }
/// <summary> /// Gets the user interface culture name from the current request, as specified by the client. /// The first culture, if any, that matches one of the available user interface languages is returned. /// </summary> /// <param name="request">HTTP request.</param> /// <returns>Culture name. Empty if not matched.</returns> public static string GetInterfaceCultureName(HttpRequestBase request) { if (request.UserLanguages == null || !request.UserLanguages.Any()) { return(string.Empty); } return(GetUserLanguageCodes(request) .Select(l => l.GetCultureInfoSafe()) .Where(l => l != null && InterfaceLanguage.IsValidUserInterfaceCulture(l)) .Select(l => l.Name) .FirstOrDefault() ?? string.Empty); }
private void ChangeLanguage(InterfaceLanguage lang) { List <Control> controls = new List <Control>(); controls.Add(this); this.GetAllControls(ref controls); foreach (Control control in controls) { if (control.Tag == null) { continue; } control.Translate(lang); } DllExtension.Run("OnLanguageChange"); this.RefreshSize(); this.OnAutoSizeChanged(EventArgs.Empty); }
private static void ChangeLanguage(InterfaceLanguage language) { CurrentThread.CurrentUICulture = Language.GetCultureInfo(language); }
protected bool Equals(InterfaceLanguage other) { return(string.Equals(this.Culture, other.Culture)); }
private void TranslationProgress(InterfaceLanguage engl, InterfaceLanguage lang) { }
private void TestAvailableLanguageCode(string expected, string cultureName) { var result = InterfaceLanguage.GetAvailableLanguageCode(CultureInfo.GetCultureInfo(cultureName)); Assert.AreEqual(expected, result, cultureName); }
private void cmbLanguages_SelectedIndexChanged(object sender, EventArgs e) { InterfaceLanguage lang = InterfaceLanguage.Languages[this.cmbLanguages.SelectedIndex]; this.ChangeLanguage(lang); }
/// <summary> /// Initializes a new instance of the <see cref="ShellView"/> class. /// </summary> public ShellView() { this.InitializeComponent(); IUserSettingService userSettingService = IoC.Get <IUserSettingService>(); bool minimiseToTray = userSettingService.GetUserSetting <bool>(UserSettingConstants.MainWindowMinimize); if (minimiseToTray) { INotifyIconService notifyIconService = IoC.Get <INotifyIconService>(); this.notifyIcon = new NotifyIcon(); notifyIconService.RegisterNotifyIcon(this.notifyIcon); StreamResourceInfo streamResourceInfo = Application.GetResourceStream(new Uri("pack://application:,,,/handbrakepineapple.ico")); if (streamResourceInfo != null) { Stream iconStream = streamResourceInfo.Stream; this.notifyIcon.Icon = new Icon(iconStream); } this.notifyIcon.Click += this.NotifyIconClick; this.StateChanged += this.ShellViewStateChanged; } this.InputBindings.Add(new InputBinding(new ProcessShortcutCommand(new KeyGesture(Key.E, ModifierKeys.Control)), new KeyGesture(Key.E, ModifierKeys.Control))); // Start Encode this.InputBindings.Add(new InputBinding(new ProcessShortcutCommand(new KeyGesture(Key.K, ModifierKeys.Control)), new KeyGesture(Key.K, ModifierKeys.Control))); // Stop Encode this.InputBindings.Add(new InputBinding(new ProcessShortcutCommand(new KeyGesture(Key.L, ModifierKeys.Control)), new KeyGesture(Key.L, ModifierKeys.Control))); // Open Log Window this.InputBindings.Add(new InputBinding(new ProcessShortcutCommand(new KeyGesture(Key.Q, ModifierKeys.Control)), new KeyGesture(Key.Q, ModifierKeys.Control))); // Open Queue Window this.InputBindings.Add(new InputBinding(new ProcessShortcutCommand(new KeyGesture(Key.A, ModifierKeys.Control)), new KeyGesture(Key.A, ModifierKeys.Control))); // Add to Queue this.InputBindings.Add(new InputBinding(new ProcessShortcutCommand(new KeyGesture(Key.A, ModifierKeys.Alt)), new KeyGesture(Key.A, ModifierKeys.Alt))); // Add all to Queue this.InputBindings.Add(new InputBinding(new ProcessShortcutCommand(new KeyGesture(Key.A, ModifierKeys.Control | ModifierKeys.Shift)), new KeyGesture(Key.A, ModifierKeys.Control | ModifierKeys.Shift))); // Add selection to Queue this.InputBindings.Add(new InputBinding(new ProcessShortcutCommand(new KeyGesture(Key.O, ModifierKeys.Control)), new KeyGesture(Key.O, ModifierKeys.Control))); // File Scan this.InputBindings.Add(new InputBinding(new ProcessShortcutCommand(new KeyGesture(Key.O, ModifierKeys.Alt)), new KeyGesture(Key.O, ModifierKeys.Alt))); // Scan Window this.InputBindings.Add(new InputBinding(new ProcessShortcutCommand(new KeyGesture(Key.O, ModifierKeys.Control | ModifierKeys.Shift)), new KeyGesture(Key.O, ModifierKeys.Control | ModifierKeys.Shift))); // Scan a Folder this.InputBindings.Add(new InputBinding(new ProcessShortcutCommand(new KeyGesture(Key.G, ModifierKeys.Control | ModifierKeys.Shift)), new KeyGesture(Key.G, ModifierKeys.Control | ModifierKeys.Shift))); // Garbage Collection this.InputBindings.Add(new InputBinding(new ProcessShortcutCommand(new KeyGesture(Key.F1, ModifierKeys.None)), new KeyGesture(Key.F1, ModifierKeys.None))); // Help this.InputBindings.Add(new InputBinding(new ProcessShortcutCommand(new KeyGesture(Key.S, ModifierKeys.Control)), new KeyGesture(Key.S, ModifierKeys.Control))); // Browse Destination // Tabs Switching this.InputBindings.Add(new InputBinding(new ProcessShortcutCommand(new KeyGesture(Key.D1, ModifierKeys.Control)), new KeyGesture(Key.D1, ModifierKeys.Control))); this.InputBindings.Add(new InputBinding(new ProcessShortcutCommand(new KeyGesture(Key.D2, ModifierKeys.Control)), new KeyGesture(Key.D2, ModifierKeys.Control))); this.InputBindings.Add(new InputBinding(new ProcessShortcutCommand(new KeyGesture(Key.D3, ModifierKeys.Control)), new KeyGesture(Key.D3, ModifierKeys.Control))); this.InputBindings.Add(new InputBinding(new ProcessShortcutCommand(new KeyGesture(Key.D4, ModifierKeys.Control)), new KeyGesture(Key.D4, ModifierKeys.Control))); this.InputBindings.Add(new InputBinding(new ProcessShortcutCommand(new KeyGesture(Key.D5, ModifierKeys.Control)), new KeyGesture(Key.D5, ModifierKeys.Control))); this.InputBindings.Add(new InputBinding(new ProcessShortcutCommand(new KeyGesture(Key.D6, ModifierKeys.Control)), new KeyGesture(Key.D6, ModifierKeys.Control))); this.InputBindings.Add(new InputBinding(new ProcessShortcutCommand(new KeyGesture(Key.D7, ModifierKeys.Control)), new KeyGesture(Key.D7, ModifierKeys.Control))); // Enable Windows 7 Taskbar progress indication. if (this.TaskbarItemInfo == null) { this.TaskbarItemInfo = Win7.WindowsTaskbar; } // Setup the UI Language string culture = userSettingService.GetUserSetting <string>(UserSettingConstants.UiLanguage); if (!string.IsNullOrEmpty(culture)) { InterfaceLanguage language = InterfaceLanguageUtilities.FindInterfaceLanguage(culture); if (language != null) { if (language.RightToLeft) { if (Application.Current.MainWindow != null) { Application.Current.MainWindow.FlowDirection = FlowDirection.RightToLeft; } } } } }
public void AddLanguage(InterfaceLanguage lang) { this.cmbLanguages.Items.Add(lang.Name); this.cmbLanguages.Enabled = cmbLanguages.Items.Count > 1; }
private void TestAvailableLanguageCode(string expected, string cultureName) { var result = InterfaceLanguage.GetAvailableLanguageCode(CultureInfo.GetCultureInfo(cultureName)); result.Should().Be(expected, cultureName); }
private static void ChangeLanguage(InterfaceLanguage language) { Thread.CurrentThread.CurrentUICulture = Utility.GetCulture(language); }
/// <summary> /// Unsubscribes a listener to the language changes. /// Returns false if the listener wasn't subscribed yet. /// </summary> /// <param name="listener">The listener to unsubscribe</param> /// <returns>If the listener was successfully unsubscribed</returns> public bool RemoveListener(InterfaceLanguage listener) { if (!_observers.Contains(listener)) return false; _observers.Remove(listener); return true; }
/// <summary> /// Override the startup behavior to handle files dropped on the app icon. /// </summary> /// <param name="e"> /// The StartupEventArgs. /// </param> protected override void OnStartup(StartupEventArgs e) { // We don't support Windows earlier than 10. if (!SystemInfo.IsWindows10OrLater()) { MessageBox.Show(HandBrakeWPF.Properties.Resources.OsVersionWarning, HandBrakeWPF.Properties.Resources.Warning, MessageBoxButton.OK, MessageBoxImage.Warning); Application.Current.Shutdown(); return; } if (!Environment.Is64BitOperatingSystem) { MessageBox.Show(HandBrakeWPF.Properties.Resources.OsBitnessWarning, HandBrakeWPF.Properties.Resources.Warning, MessageBoxButton.OK, MessageBoxImage.Warning); Application.Current.Shutdown(); return; } if (e.Args.Any(f => f.Equals("--reset"))) { HandBrakeApp.ResetToDefaults(); Application.Current.Shutdown(); return; } if (e.Args.Any(f => f.StartsWith("--recover-queue-ids"))) { string command = e.Args.FirstOrDefault(f => f.StartsWith("--recover-queue-ids")); if (!string.IsNullOrEmpty(command)) { command = command.Replace("--recover-queue-ids=", string.Empty); List <string> processIds = command.Split(',').ToList(); StartupOptions.QueueRecoveryIds = processIds; } } if (e.Args.Any(f => f.Equals("--auto-start-queue"))) { StartupOptions.AutoRestartQueue = true; } // Portable Mode if (Portable.IsPortable()) { int portableInit = Portable.Initialise(); if (portableInit != 0) { switch (portableInit) { case -1: MessageBox.Show( HandBrakeWPF.Properties.Resources.Portable_IniFileError, HandBrakeWPF.Properties.Resources.Error, MessageBoxButton.OK, MessageBoxImage.Error); break; case -2: MessageBox.Show( HandBrakeWPF.Properties.Resources.Portable_TmpNotWritable, HandBrakeWPF.Properties.Resources.Error, MessageBoxButton.OK, MessageBoxImage.Error); break; case -3: MessageBox.Show( HandBrakeWPF.Properties.Resources.Portable_StorageNotWritable, HandBrakeWPF.Properties.Resources.Error, MessageBoxButton.OK, MessageBoxImage.Error); break; } Application.Current.Shutdown(); return; } } // Setup the UI Language IUserSettingService userSettingService = IoC.Get <IUserSettingService>(); string culture = userSettingService.GetUserSetting <string>(UserSettingConstants.UiLanguage); if (!string.IsNullOrEmpty(culture)) { InterfaceLanguage language = InterfaceLanguageUtilities.FindInterfaceLanguage(culture); if (language != null) { CultureInfo ci = new CultureInfo(language.Culture); Thread.CurrentThread.CurrentUICulture = ci; } } int runCounter = userSettingService.GetUserSetting <int>(UserSettingConstants.RunCounter); // Software Rendering if (e.Args.Any(f => f.Equals("--force-software-rendering")) || Portable.IsForcingSoftwareRendering() || userSettingService.GetUserSetting <bool>(UserSettingConstants.ForceSoftwareRendering)) { RenderOptions.ProcessRenderMode = RenderMode.SoftwareOnly; } // Check if the user would like to check for updates AFTER the first run, but only once. if (runCounter == 1) { CheckForUpdateCheckPermission(userSettingService); } // Increment the counter so we can change startup behavior for the above warning and update check question. userSettingService.SetUserSetting(UserSettingConstants.RunCounter, runCounter + 1); // Only display once. // App Theme DarkThemeMode useDarkTheme = (DarkThemeMode)userSettingService.GetUserSetting <int>(UserSettingConstants.DarkThemeMode); ResourceDictionary dark = new ResourceDictionary { Source = new Uri("pack://application:,,,/MahApps.Metro;component/Styles/Themes/Dark.Blue.xaml") }; ResourceDictionary light = new ResourceDictionary { Source = new Uri("pack://application:,,,/MahApps.Metro;component/Styles/Themes/Light.Blue.xaml") }; Application.Current.Resources.MergedDictionaries.Add(new ResourceDictionary { Source = new Uri("Themes/Generic.xaml", UriKind.Relative) }); bool themed = false; if (SystemParameters.HighContrast) { Application.Current.Resources["Ui.Light"] = new SolidColorBrush(SystemColors.HighlightTextColor); Application.Current.Resources["Ui.ContrastLight"] = new SolidColorBrush(SystemColors.ActiveBorderBrush.Color); useDarkTheme = DarkThemeMode.None; } switch (useDarkTheme) { case DarkThemeMode.System: if (SystemInfo.IsAppsUsingDarkTheme()) { Application.Current.Resources.MergedDictionaries.Add(dark); Application.Current.Resources.MergedDictionaries.Add(new ResourceDictionary { Source = new Uri("Themes/Dark.xaml", UriKind.Relative) }); } else { Application.Current.Resources.MergedDictionaries.Add(light); Application.Current.Resources.MergedDictionaries.Add(new ResourceDictionary { Source = new Uri("Themes/Light.xaml", UriKind.Relative) }); } themed = true; break; case DarkThemeMode.Dark: Application.Current.Resources.MergedDictionaries.Add(dark); Application.Current.Resources.MergedDictionaries.Add(new ResourceDictionary { Source = new Uri("Themes/Dark.xaml", UriKind.Relative) }); themed = true; break; case DarkThemeMode.Light: Application.Current.Resources.MergedDictionaries.Add(light); Application.Current.Resources.MergedDictionaries.Add(new ResourceDictionary { Source = new Uri("Themes/Light.xaml", UriKind.Relative) }); themed = true; break; case DarkThemeMode.None: Application.Current.Resources["Ui.Light"] = new SolidColorBrush(SystemColors.HighlightTextColor); Application.Current.Resources["Ui.ContrastLight"] = new SolidColorBrush(SystemColors.ActiveBorderBrush.Color); themed = false; break; } Application.Current.Resources.MergedDictionaries.Add(new ResourceDictionary { Source = new Uri("Views/Styles/Styles.xaml", UriKind.Relative) }); if (themed) { Application.Current.Resources.MergedDictionaries.Add(new ResourceDictionary { Source = new Uri("Views/Styles/ThemedStyles.xaml", UriKind.Relative) }); } // NO-Hardware Mode bool noHardware = e.Args.Any(f => f.Equals("--no-hardware")) || (Portable.IsPortable() && !Portable.IsHardwareEnabled()); // Initialise the Engine Services.Logging.GlobalLoggingManager.Init(); HandBrakeInstanceManager.Init(noHardware, userSettingService); // Initialise the GUI base.OnStartup(e); // If we have a file dropped on the icon, try scanning it. string[] args = e.Args; if (args.Any() && (File.Exists(args[0]) || Directory.Exists(args[0]))) { IMainViewModel mvm = IoC.Get <IMainViewModel>(); mvm.StartScan(args[0], 0); } }
/// <summary> /// Override the startup behavior to handle files dropped on the app icon. /// </summary> /// <param name="e"> /// The StartupEventArgs. /// </param> protected override void OnStartup(StartupEventArgs e) { // We don't support Windows XP / 2003 / 2003 R2 / Vista / 2008 OperatingSystem os = Environment.OSVersion; if (((os.Platform == PlatformID.Win32NT) && (os.Version.Major == 5)) || ((os.Platform == PlatformID.Win32NT) && (os.Version.Major == 6 && os.Version.Minor < 1))) { MessageBox.Show(HandBrakeWPF.Properties.Resources.OsVersionWarning, HandBrakeWPF.Properties.Resources.Warning, MessageBoxButton.OK, MessageBoxImage.Warning); Application.Current.Shutdown(); return; } if (!Environment.Is64BitOperatingSystem) { MessageBox.Show(HandBrakeWPF.Properties.Resources.OsBitnessWarning, HandBrakeWPF.Properties.Resources.Warning, MessageBoxButton.OK, MessageBoxImage.Warning); Application.Current.Shutdown(); return; } if (e.Args.Any(f => f.Equals("--reset"))) { HandBrakeApp.ResetToDefaults(); Application.Current.Shutdown(); return; } if (e.Args.Any(f => f.StartsWith("--recover-queue-ids"))) { string command = e.Args.FirstOrDefault(f => f.StartsWith("--recover-queue-ids")); if (!string.IsNullOrEmpty(command)) { command = command.Replace("--recover-queue-ids=", string.Empty); List <string> processIds = command.Split(',').ToList(); StartupOptions.QueueRecoveryIds = processIds; } } if (e.Args.Any(f => f.Equals("--auto-start-queue"))) { StartupOptions.AutoRestartQueue = true; } // Portable Mode if (Portable.IsPortable()) { if (!Portable.Initialise()) { Application.Current.Shutdown(); return; } } // Setup the UI Language IUserSettingService userSettingService = IoC.Get <IUserSettingService>(); string culture = userSettingService.GetUserSetting <string>(UserSettingConstants.UiLanguage); if (!string.IsNullOrEmpty(culture)) { InterfaceLanguage language = InterfaceLanguageUtilities.FindInterfaceLanguage(culture); if (language != null) { CultureInfo ci = new CultureInfo(language.Culture); Thread.CurrentThread.CurrentUICulture = ci; } } int runCounter = userSettingService.GetUserSetting <int>(UserSettingConstants.RunCounter); if (!SystemInfo.IsWindows10() && runCounter < 2) { MessageBox.Show(HandBrakeWPF.Properties.Resources.OldOperatingSystem, HandBrakeWPF.Properties.Resources.Warning, MessageBoxButton.OK, MessageBoxImage.Warning); } // Software Rendering if (e.Args.Any(f => f.Equals("--force-software-rendering")) || Portable.IsForcingSoftwareRendering() || userSettingService.GetUserSetting <bool>(UserSettingConstants.ForceSoftwareRendering)) { RenderOptions.ProcessRenderMode = RenderMode.SoftwareOnly; } // Check if the user would like to check for updates AFTER the first run, but only once. if (runCounter == 1) { CheckForUpdateCheckPermission(userSettingService); } // Increment the counter so we can change startup behavior for the above warning and update check question. userSettingService.SetUserSetting(UserSettingConstants.RunCounter, runCounter + 1); // Only display once. // App Theme DarkThemeMode useDarkTheme = (DarkThemeMode)userSettingService.GetUserSetting <int>(UserSettingConstants.DarkThemeMode); if (SystemInfo.IsWindows10()) { ResourceDictionary dark = new ResourceDictionary { Source = new Uri("pack://application:,,,/MahApps.Metro;component/Styles/Themes/Dark.Blue.xaml") }; ResourceDictionary light = new ResourceDictionary { Source = new Uri("pack://application:,,,/MahApps.Metro;component/Styles/Themes/Light.Blue.xaml") }; ResourceDictionary theme = new ResourceDictionary(); switch (useDarkTheme) { case DarkThemeMode.System: if (SystemInfo.IsAppsUsingDarkTheme()) { theme.Source = new Uri("Themes/Dark.xaml", UriKind.Relative); Application.Current.Resources.MergedDictionaries.Add(theme); Application.Current.Resources.MergedDictionaries.Add(dark); } else if (!SystemParameters.HighContrast) { theme.Source = new Uri("Themes/Light.xaml", UriKind.Relative); Application.Current.Resources.MergedDictionaries.Add(theme); Application.Current.Resources.MergedDictionaries.Add(light); } break; case DarkThemeMode.Dark: theme.Source = new Uri("Themes/Dark.xaml", UriKind.Relative); Application.Current.Resources.MergedDictionaries.Add(theme); Application.Current.Resources.MergedDictionaries.Add(dark); break; case DarkThemeMode.Light: if (!SystemParameters.HighContrast) { theme.Source = new Uri("Themes/Light.xaml", UriKind.Relative); Application.Current.Resources.MergedDictionaries.Add(theme); Application.Current.Resources.MergedDictionaries.Add(light); } break; } } Application.Current.Resources.MergedDictionaries.Add(new ResourceDictionary { Source = new Uri("Views/Styles/Styles.xaml", UriKind.Relative) }); // NO-Hardware Mode bool noHardware = e.Args.Any(f => f.Equals("--no-hardware")) || (Portable.IsPortable() && !Portable.IsHardwareEnabled()); // Initialise the Engine HandBrakeWPF.Helpers.LogManager.Init(); try { HandBrakeInstanceManager.Init(noHardware); } catch (Exception) { if (!noHardware) { MessageBox.Show(HandBrakeWPF.Properties.Resources.Startup_InitFailed, HandBrakeWPF.Properties.Resources.Error, MessageBoxButton.OK, MessageBoxImage.Error); } throw; } // Initialise the GUI base.OnStartup(e); // If we have a file dropped on the icon, try scanning it. string[] args = e.Args; if (args.Any() && (File.Exists(args[0]) || Directory.Exists(args[0]))) { IMainViewModel mvm = IoC.Get <IMainViewModel>(); mvm.StartScan(args[0], 0); } }
/// <summary> /// Override the startup behavior to handle files dropped on the app icon. /// </summary> /// <param name="e"> /// The StartupEventArgs. /// </param> protected override void OnStartup(StartupEventArgs e) { // We don't support Windows XP / 2003 / 2003 R2 / Vista / 2008 OperatingSystem os = Environment.OSVersion; if (((os.Platform == PlatformID.Win32NT) && (os.Version.Major == 5)) || ((os.Platform == PlatformID.Win32NT) && (os.Version.Major == 6 && os.Version.Minor < 1))) { MessageBox.Show(HandBrakeWPF.Properties.Resources.OsVersionWarning, HandBrakeWPF.Properties.Resources.Warning, MessageBoxButton.OK, MessageBoxImage.Warning); Application.Current.Shutdown(); return; } if (!Environment.Is64BitOperatingSystem) { MessageBox.Show(HandBrakeWPF.Properties.Resources.OsBitnessWarning, HandBrakeWPF.Properties.Resources.Warning, MessageBoxButton.OK, MessageBoxImage.Warning); Application.Current.Shutdown(); return; } if (e.Args.Any(f => f.Equals("--reset"))) { HandBrakeApp.ResetToDefaults(); Application.Current.Shutdown(); return; } if (e.Args.Any(f => f.StartsWith("--recover-queue-ids"))) { string command = e.Args.FirstOrDefault(f => f.StartsWith("--recover-queue-ids")); if (!string.IsNullOrEmpty(command)) { command = command.Replace("--recover-queue-ids=", string.Empty); List <string> processIds = command.Split(',').ToList(); StartupOptions.QueueRecoveryIds = processIds; } } if (e.Args.Any(f => f.Equals("--auto-start-queue"))) { StartupOptions.AutoRestartQueue = true; } // Portable Mode if (Portable.IsPortable()) { Portable.Initialise(); } // Setup the UI Language IUserSettingService userSettingService = IoC.Get <IUserSettingService>(); string culture = userSettingService.GetUserSetting <string>(UserSettingConstants.UiLanguage); if (!string.IsNullOrEmpty(culture) && !"en".Equals(culture)) { InterfaceLanguage language = InterfaceLanguageUtilities.FindInterfaceLanguage(culture); if (language != null) { CultureInfo ci = new CultureInfo(language.Culture); Thread.CurrentThread.CurrentCulture = ci; Thread.CurrentThread.CurrentUICulture = ci; } } base.OnStartup(e); // If we have a file dropped on the icon, try scanning it. string[] args = e.Args; if (args.Any() && (File.Exists(args[0]) || Directory.Exists(args[0]))) { IMainViewModel mvm = IoC.Get <IMainViewModel>(); mvm.StartScan(args[0], 0); } }
/// <summary> /// Override the startup behavior to handle files dropped on the app icon. /// </summary> /// <param name="e"> /// The StartupEventArgs. /// </param> protected override void OnStartup(StartupEventArgs e) { // We don't support Windows XP / 2003 / 2003 R2 / Vista / 2008 OperatingSystem os = Environment.OSVersion; if (((os.Platform == PlatformID.Win32NT) && (os.Version.Major == 5)) || ((os.Platform == PlatformID.Win32NT) && (os.Version.Major == 6 && os.Version.Minor < 1))) { MessageBox.Show(HandBrakeWPF.Properties.Resources.OsVersionWarning, HandBrakeWPF.Properties.Resources.Warning, MessageBoxButton.OK, MessageBoxImage.Warning); Application.Current.Shutdown(); return; } if (!Environment.Is64BitOperatingSystem) { MessageBox.Show(HandBrakeWPF.Properties.Resources.OsBitnessWarning, HandBrakeWPF.Properties.Resources.Warning, MessageBoxButton.OK, MessageBoxImage.Warning); Application.Current.Shutdown(); return; } if (e.Args.Any(f => f.Equals("--reset"))) { HandBrakeApp.ResetToDefaults(); Application.Current.Shutdown(); return; } if (e.Args.Any(f => f.StartsWith("--recover-queue-ids"))) { string command = e.Args.FirstOrDefault(f => f.StartsWith("--recover-queue-ids")); if (!string.IsNullOrEmpty(command)) { command = command.Replace("--recover-queue-ids=", string.Empty); List <string> processIds = command.Split(',').ToList(); StartupOptions.QueueRecoveryIds = processIds; } } if (e.Args.Any(f => f.Equals("--auto-start-queue"))) { StartupOptions.AutoRestartQueue = true; } // Portable Mode if (Portable.IsPortable()) { if (!Portable.Initialise()) { Application.Current.Shutdown(); return; } } // Setup the UI Language IUserSettingService userSettingService = IoC.Get <IUserSettingService>(); string culture = userSettingService.GetUserSetting <string>(UserSettingConstants.UiLanguage); if (!string.IsNullOrEmpty(culture)) { InterfaceLanguage language = InterfaceLanguageUtilities.FindInterfaceLanguage(culture); if (language != null) { CultureInfo ci = new CultureInfo(language.Culture); Thread.CurrentThread.CurrentUICulture = ci; } } DarkThemeMode useDarkTheme = (DarkThemeMode)userSettingService.GetUserSetting <int>(UserSettingConstants.DarkThemeMode); if (SystemInfo.IsWindows10()) { ResourceDictionary theme = new ResourceDictionary(); switch (useDarkTheme) { case DarkThemeMode.System: if (SystemInfo.IsAppsUsingDarkTheme()) { theme.Source = new Uri("Themes/Dark.xaml", UriKind.Relative); Application.Current.Resources.MergedDictionaries.Add(theme); } else if (!SystemParameters.HighContrast) { theme.Source = new Uri("Themes/Light.xaml", UriKind.Relative); Application.Current.Resources.MergedDictionaries.Add(theme); } break; case DarkThemeMode.Dark: theme.Source = new Uri("Themes/Dark.xaml", UriKind.Relative); Application.Current.Resources.MergedDictionaries.Add(theme); break; case DarkThemeMode.Light: if (!SystemParameters.HighContrast) { theme.Source = new Uri("Themes/Light.xaml", UriKind.Relative); Application.Current.Resources.MergedDictionaries.Add(theme); } break; default: break; } } // NO-Hardware Mode bool noHardware = e.Args.Any(f => f.Equals("--no-hardware")) || (Portable.IsPortable() && !Portable.IsHardwareEnabled()); // Initialise the Engine HandBrakeWPF.Helpers.LogManager.Init(); try { HandBrakeInstanceManager.Init(noHardware); } catch (Exception) { if (!noHardware) { MessageBox.Show(HandBrakeWPF.Properties.Resources.Startup_InitFailed, HandBrakeWPF.Properties.Resources.Error, MessageBoxButton.OK, MessageBoxImage.Error); } throw; } // Initialise the GUI base.OnStartup(e); // If we have a file dropped on the icon, try scanning it. string[] args = e.Args; if (args.Any() && (File.Exists(args[0]) || Directory.Exists(args[0]))) { IMainViewModel mvm = IoC.Get <IMainViewModel>(); mvm.StartScan(args[0], 0); } }
private static void InitLanguage(Form formMain, frmDebug formDebug) { InterfaceLanguage engl = null; foreach (InterfaceLanguage lang in InterfaceLanguage.Languages) { if (lang.Id == "engl") { engl = lang; break; } } if (engl == null) { return; } List <Control> controls = new List <Control>(); formMain.GetAllControls(ref controls); List <string> tags = new List <string>(); foreach (Control control in controls) { if (control.Tag != null && control.Tag.ToString().StartsWith("lang")) { string tag = control.Tag.ToString().Substring(4); if (!tags.Contains(tag)) { tags.Add(tag); } } } List <string> unusedTags = tags; TreeNode loaded = new TreeNode("Loaded"); foreach (InterfaceLanguage lang in InterfaceLanguage.Languages) { TreeNode langNode = new TreeNode(lang.Id + " (" + lang.Name + ")"); TreeNode fields = langNode.Nodes.Add("Fields"); TreeNode missing = new TreeNode("Missing"); FieldInfo[] fieldInfos = lang.GetType().GetFields(); int fieldsCount = 0, missingCount = 0; foreach (FieldInfo field in fieldInfos) { if (field.FieldType != typeof(string)) { continue; } if (lang.Id == "engl") { tags.Remove(field.Name); } if (field.IsInitOnly) // readonly { continue; } fieldsCount++; string englValue = (string)engl.GetType().GetField(field.Name).GetValue(engl); string value = (string)field.GetValue(lang); fields.Nodes.Add(field.Name + " = " + value); if (lang.Id != "engl" && value == englValue) { missingCount++; missing.Nodes.Add(field.Name); } } if (missing.Nodes.Count > 0) { missing.Text += " (" + missingCount + "/" + fieldsCount + ")"; langNode.Nodes.Add(missing); } loaded.Nodes.Add(langNode); } if (tags.Count > 0) { TreeNode notImplemented = formDebug.treeLang.Nodes.Add("Not implemented (" + tags.Count + ")"); foreach (string tag in tags) { notImplemented.Nodes.Add(tag); } } if (loaded.Nodes.Count > 0) { loaded.Text += " (" + loaded.Nodes.Count + ")"; formDebug.treeLang.Nodes.Add(loaded); } if (formDebug.treeLang.Nodes.Count == 1) { formDebug.treeLang.Nodes[0].Expand(); } }