Пример #1
0
        public override void Initialize()
        {
            AvaloniaXamlLoader.Load(this);

            /* Clean everything from the old run up */
            if (PlatformUtils.IsWindows)
            {
#if WindowsNoARM
                ThePBone.Interop.Win32.TrayIcon.ResourceLoader.ClearCache();
#endif
            }

            if (Loc.IsTranslatorModeEnabled())
            {
                SettingsProvider.Instance.Locale = Locales.custom;
            }

            ThemeUtils.Reload();
            Loc.Load();

            MediaKeyRemoteImpl.Init();
            DeviceMessageCache.Init();
            UpdateManager.Init();
            ExperimentManager.Init();

            Log.Information($"Translator mode file location: {Loc.GetTranslatorModeFile()}");

            ScriptManager.Instance.RegisterUserHooks();
        }
Пример #2
0
        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);
        }
Пример #3
0
        public override void OnPageShown()
        {
            _minimizeTray.IsChecked = SettingsProvider.Instance.MinimizeToTray;
            _autostart.IsChecked    = AutoStartImpl.Instance.Enabled;
            _darkMode.IsChecked     = SettingsProvider.Instance.DarkMode == DarkModes.Dark;
            _locale.Description     = SettingsProvider.Instance.Locale.GetDescription();

            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) =>
                {
                    _locale.Description = locale.GetDescription();
                    SettingsProvider.Instance.Locale = locale;
                    Loc.Load();
                };
            }
            _locale.Items = localeMenuActions;
        }
Пример #4
0
        private void App_Startup(object sender, StartupEventArgs e)
        {
            if (Loc.IsTranslatorModeEnabled())
            {
                Galaxy_Buds_Client.Properties.Settings.Default.CurrentLocale = Locale.custom;
                Galaxy_Buds_Client.Properties.Settings.Default.Save();
            }
            Loc.Load();

            bool startMinimized = false;

            for (int i = 0; i != e.Args.Length; ++i)
            {
                if (e.Args[i] == "/StartMinimized")
                {
                    startMinimized = true;
                }
            }

            MainWindow mainWindow = new MainWindow();

            if (!startMinimized)
            {
                mainWindow.Show();
            }


            _mainWindow = mainWindow;
        }
Пример #5
0
        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);
                }
            }
        }
Пример #6
0
        private void ReloadXaml_OnClick(object?sender, RoutedEventArgs e)
        {
            if (_locales.SelectedItem is Locales locale)
            {
                SettingsProvider.Instance.Locale = locale;
            }

            Loc.Load();
        }
Пример #7
0
        private void Menu_AddItem(ContextMenu c, Locale loc)
        {
            MenuItem m = new MenuItem();

            m.Header = loc.GetDescription();
            m.Click += delegate
            {
                Properties.Settings.Default.CurrentLocale = loc;
                Properties.Settings.Default.Save();
                Loc.Load();
            };
            m.Style = (Style)FindResource("MenuItemStyle");
            c.Items.Add(m);
        }
Пример #8
0
        private void Locale_Menu_AddItem(ContextMenu c, Locale loc)
        {
            MenuItem m = new MenuItem();

            m.Header = loc.GetDescription();
            m.Click += delegate
            {
                LocaleSelect.TextDetail = loc.GetDescription();
                Properties.Settings.Default.CurrentLocale = loc;
                Properties.Settings.Default.Save();
                Loc.Load();

                /* Update cached strings */
                DarkModeBorder.ContextMenu = DarkMode_GenerateMenu(DarkModeBorder);
                DarkModeSelect.TextDetail  = Properties.Settings.Default.DarkMode2.GetDescription();
            };
            m.Style = (Style)FindResource("MenuItemStyle");
            c.Items.Add(m);
        }
Пример #9
0
        public override void Initialize()
        {
            AvaloniaXamlLoader.Load(this);

            if (Loc.IsTranslatorModeEnabled())
            {
                SettingsProvider.Instance.Locale = Locales.custom;
            }

            ThemeUtils.Reload();
            Loc.Load();

            MediaKeyRemoteImpl.Init();
            DeviceMessageCache.Init();
            UpdateManager.Init();
            ExperimentManager.Init();

            Log.Information($"Translator mode file location: {Loc.GetTranslatorModeFile()}");

            ScriptManager.Instance.RegisterUserHooks();
        }
Пример #10
0
        private void Locale_Menu_AddItem(ContextMenu c, Locale loc)
        {
            MenuItem m = new MenuItem();

            m.Header = loc.GetDescription();
            m.Click += delegate
            {
                LocaleSelect.TextDetail = loc.GetDescription();
                Properties.Settings.Default.CurrentLocale = loc;
                Properties.Settings.Default.Save();
                Loc.Load();

                /* Update cached strings */
                DarkModeBorder.ContextMenu = DarkMode_GenerateMenu(DarkModeBorder);
                DarkModeSelect.TextDetail  = Properties.Settings.Default.DarkMode2.GetDescription();

                if (BluetoothService.Instance.IsConnected)
                {
                    BluetoothService.Instance.SendAsync(SPPMessageBuilder.Info.GetAllData());
                }
            };
            m.Style = (Style)FindResource("MenuItemStyle");
            c.Items.Add(m);
        }
Пример #11
0
 private void ReloadXaml_Click(object sender, RoutedEventArgs e)
 {
     Properties.Settings.Default.CurrentLocale = (Locale)Language.SelectedValue;
     Properties.Settings.Default.Save();
     Loc.Load();
 }