public override void OnPageShown() { _darkMode.IsChecked = SettingsProvider.Instance.DarkMode == DarkModes.Dark; var localeMenuActions = new Dictionary <string, EventHandler <RoutedEventArgs>?>(); #pragma warning disable 8605 foreach (int value in Enum.GetValues(typeof(Locales))) #pragma warning restore 8605 { if (value == (int)Locales.custom && !Loc.IsTranslatorModeEnabled()) { continue; } var locale = (Locales)value; localeMenuActions[locale.GetDescription()] = (sender, args) => { SettingsProvider.Instance.Locale = locale; Loc.Load(); }; } _localeMenu = MenuFactory.BuildContextMenu(localeMenuActions, _locale); }
public override void OnPageShown() { _darkMode.IsChecked = SettingsProvider.Instance.DarkMode == DarkModes.Dark; var localeMenuActions = new Dictionary <string, EventHandler <RoutedEventArgs>?>(); #pragma warning disable 8605 foreach (int value in Enum.GetValues(typeof(Locales))) #pragma warning restore 8605 { if (value == (int)Locales.custom && !Loc.IsTranslatorModeEnabled()) { continue; } var locale = (Locales)value; localeMenuActions[locale.GetDescription()] = (sender, args) => { SettingsProvider.Instance.Locale = locale; Loc.Load(); }; } _localeMenu = MenuFactory.BuildContextMenu(localeMenuActions, _locale); // Only search for the Buds app on Windows 10 and above if (Environment.OSVersion.Platform == PlatformID.Win32NT && Environment.OSVersion.Version.Major >= 10) { try { ProcessStartInfo si = new ProcessStartInfo { FileName = "powershell", Arguments = "Get-AppxPackage SAMSUNGELECTRONICSCO.LTD.GalaxyBuds", RedirectStandardOutput = true, UseShellExecute = false, CreateNoWindow = true, }; ThreadPool.QueueUserWorkItem(delegate { try { var process = Process.Start(si); if (process?.WaitForExit(4000) ?? false) { officialAppInstalled = process?.StandardOutput.ReadToEnd().Contains("SAMSUNGELECTRONICSCO.LTD.GalaxyBuds") ?? false; } } catch (Exception exception) { Log.Warning("WelcomePage.BudsAppDetected.ThreadPool: " + exception); } }); } catch (Exception exception) { Log.Warning("WelcomePage.BudsAppDetected: " + exception); } } }
private void BuildOptionsMenu() { bool restricted = Pager.CurrentPage == AbstractPage.Pages.Welcome || Pager.CurrentPage == AbstractPage.Pages.DeviceSelect || !BluetoothImpl.Instance.RegisteredDeviceValid; var options = new Dictionary <string, EventHandler <RoutedEventArgs>?>() { [Loc.Resolve("optionsmenu_settings")] = (sender, args) => Pager.SwitchPage(AbstractPage.Pages.Settings), [Loc.Resolve("optionsmenu_refresh")] = async(sender, args) => await BluetoothImpl.Instance.SendRequestAsync(SPPMessage.MessageIds.DEBUG_GET_ALL_DATA), [Loc.Resolve("optionsmenu_deregister")] = (sender, args) => BluetoothImpl.Instance.UnregisterDevice() .ContinueWith((_) => Pager.SwitchPage(AbstractPage.Pages.Welcome)) }; if (restricted) { options.Clear(); } options[Loc.Resolve("optionsmenu_update")] = async(sender, args) => { var result = await UpdateManager.Instance.DoManualCheck(); if (result != UpdateStatus.UpdateAvailable) { await new MessageBox() { Title = Loc.Resolve("updater_noupdate_title"), Description = Loc.Resolve("updater_noupdate"), }.ShowDialog(this); } }; options[Loc.Resolve("optionsmenu_credits")] = (sender, args) => Pager.SwitchPage(AbstractPage.Pages.Credits); _titleBar.OptionsButton.ContextMenu = MenuFactory.BuildContextMenu(options); }