コード例 #1
0
ファイル: ProfileService.cs プロジェクト: daleghent/NINA
        public bool SelectProfile(ProfileMeta info)
        {
            lock (lockobj) {
                using (MyStopWatch.Measure()) {
                    try {
                        var p = Profile.Load(info.Location);

                        UnregisterChangedEventHandlers();
                        if (ActiveProfile != null)
                        {
                            ActiveProfile.Dispose();
                            Profiles.Where(x => x.Id == ActiveProfile.Id).First().IsActive = false;
                        }

                        ActiveProfile = p;
                        info.IsActive = true;

                        System.Threading.Thread.CurrentThread.CurrentUICulture = ActiveProfile.ApplicationSettings.Language;
                        System.Threading.Thread.CurrentThread.CurrentCulture   = ActiveProfile.ApplicationSettings.Language;
                        Locale.Loc.Instance.ReloadLocale(ActiveProfile.ApplicationSettings.Culture);

                        LocaleChanged?.Invoke(this, null);
                        ProfileChanged?.Invoke(this, null);
                        LocationChanged?.Invoke(this, null);
                        RegisterChangedEventHandlers();
                    } catch (Exception ex) {
                        Logger.Debug(ex.Message + Environment.NewLine + ex.StackTrace);
                        return(false);
                    }
                    return(true);
                }
            }
        }
コード例 #2
0
ファイル: CoreApplication.cs プロジェクト: wonrst/TizenFX
        /// <summary>
        /// Overrides this method if want to handle behavior when the system language is changed.
        /// If base.OnLocaleChanged() is not called, the event 'LocaleChanged' will not be emitted.
        /// </summary>
        /// <param name="e">The locale changed event argument</param>
        /// <since_tizen> 3 </since_tizen>
        protected virtual void OnLocaleChanged(LocaleChangedEventArgs e)
        {
            if (!GlobalizationMode.Invariant)
            {
                ChangeCurrentUICultureInfo(e.Locale);
            }

            LocaleChanged?.Invoke(this, e);
        }
コード例 #3
0
ファイル: ProfileService.cs プロジェクト: daleghent/NINA
        public void ChangeLocale(CultureInfo language)
        {
            ActiveProfile.ApplicationSettings.Language = language;

            System.Threading.Thread.CurrentThread.CurrentUICulture = language;
            System.Threading.Thread.CurrentThread.CurrentCulture   = language;

            Locale.Loc.Instance.ReloadLocale(ActiveProfile.ApplicationSettings.Culture);
            LocaleChanged?.Invoke(this, null);
        }
コード例 #4
0
        /// <summary>
        /// Default class constructor.
        /// </summary>
        public Settings()
        {
            _service = DependencyService.Get <ISettings>();

            _service.LocaleChanged       += (s, e) => { LocaleChanged?.Invoke(s, e); };
            _service.UserSettingsChanged += (s, e) => { UserSettingsChanged?.Invoke(s, e); };
            _service.FontChanged         += (s, e) => { FontChanged?.Invoke(s, e); };
            _service.SoundChanged        += (s, e) => { SoundChanged?.Invoke(s, e); };
            _service.OtherChanged        += (s, e) => { OtherChanged?.Invoke(s, e); };

            _service.StartListening();
        }
コード例 #5
0
        public static void SetLocale(string locale)
        {
            locale = locale.ToUpper();

            if (Locales.ContainsKey(locale))
            {
                currentLocale = Locales[locale];
            }
            else
            {
                currentLocale = fallbackLocale;
            }

            LocaleChanged?.Invoke();
        }
コード例 #6
0
        /// <summary>
        /// Changes the current locale
        /// </summary>
        /// <param name="newLocaleName">IETF locale name (e.g. en-US, en-GB)</param>
        public static void ChangeLocale(string newLocaleName)
        {
            CultureInfo newCultureInfo = new CultureInfo(newLocaleName);

            Thread.CurrentThread.CurrentCulture   = newCultureInfo;
            Thread.CurrentThread.CurrentUICulture = newCultureInfo;

            Locale newLocale = new Locale()
            {
                Name = newLocaleName, RTL = newCultureInfo.TextInfo.IsRightToLeft
            };
            Locale oldLocale = CurrentLocale?.Clone();

            CurrentLocale = newLocale;

            LocaleChanged?.Invoke(null, new ValueChangedEventArgs <Locale>(oldLocale, newLocale));
        }
コード例 #7
0
        /// <summary>
        /// Starts observing system settings for changes.
        /// </summary>
        /// <remarks>
        /// System settings events will be never invoked before calling this method.
        /// </remarks>
        public void StartListening()
        {
            SystemSettings.LocaleCountryChanged +=
                (s, e) => { LocaleChanged?.Invoke(s, new EventArgs()); };
            SystemSettings.LocaleLanguageChanged +=
                (s, e) => { LocaleChanged?.Invoke(s, new EventArgs()); };
            SystemSettings.LocaleTimeFormat24HourSettingChanged +=
                (s, e) => { LocaleChanged?.Invoke(s, new EventArgs()); };
            SystemSettings.LocaleTimeZoneChanged +=
                (s, e) => { LocaleChanged?.Invoke(s, new EventArgs()); };

            try
            {
                SystemSettings.IncomingCallRingtoneChanged +=
                    (s, e) => { UserSettingsChanged?.Invoke(s, new EventArgs()); };
            }
            catch (NotSupportedException e)
            {
                Log.Warn("SystemInfo", e.Message);
            }

            try
            {
                SystemSettings.EmailAlertRingtoneChanged +=
                    (s, e) => { UserSettingsChanged?.Invoke(s, new EventArgs()); };
            }
            catch (NotSupportedException e)
            {
                Log.Warn("SystemInfo", e.Message);
            }

            try
            {
                SystemSettings.WallpaperHomeScreenChanged +=
                    (s, e) => { UserSettingsChanged?.Invoke(s, new EventArgs()); };
            }
            catch (NotSupportedException e)
            {
                Log.Warn("SystemInfo", e.Message);
            }

            try
            {
                SystemSettings.WallpaperLockScreenChanged +=
                    (s, e) => { UserSettingsChanged?.Invoke(s, new EventArgs()); };
            }
            catch (NotSupportedException e)
            {
                Log.Warn("SystemInfo", e.Message);
            }

            SystemSettings.FontSizeChanged += (s, e) => { FontChanged?.Invoke(s, new EventArgs()); };
            SystemSettings.FontTypeChanged += (s, e) => { FontChanged?.Invoke(s, new EventArgs()); };

            SystemSettings.SoundLockSettingChanged +=
                (s, e) => { SoundChanged?.Invoke(s, new EventArgs()); };
            SystemSettings.SoundSilentModeSettingChanged +=
                (s, e) => { SoundChanged?.Invoke(s, new EventArgs()); };
            SystemSettings.SoundTouchSettingChanged +=
                (s, e) => { SoundChanged?.Invoke(s, new EventArgs()); };
            SystemSettings.SoundNotificationRepetitionPeriodChanged +=
                (s, e) => { SoundChanged?.Invoke(s, new EventArgs()); };

            SystemSettings.DeviceNameChanged    += (s, e) => { OtherChanged?.Invoke(s, new EventArgs()); };
            SystemSettings.MotionSettingChanged += (s, e) => { OtherChanged?.Invoke(s, new EventArgs()); };
        }
コード例 #8
0
 /// <summary>
 /// Overrides this method if want to handle behavior when the system language is changed.
 /// If base.OnLocaleChanged() is not called, the event 'LocaleChanged' will not be emitted.
 /// </summary>
 /// <param name="e">The locale changed event argument</param>
 /// <since_tizen> 3 </since_tizen>
 protected virtual void OnLocaleChanged(LocaleChangedEventArgs e)
 {
     ChangeCurrentCultureInfo(e.Locale);
     LocaleChanged?.Invoke(this, e);
 }
コード例 #9
0
 /// <summary>
 /// Overrides this method if want to handle behavior when the system language is changed.
 /// If base.OnLocaleChanged() is not called, the event 'LocaleChanged' will not be emitted.
 /// </summary>
 protected virtual void OnLocaleChanged(LocaleChangedEventArgs e)
 {
     LocaleChanged?.Invoke(this, e);
 }
コード例 #10
0
ファイル: BaseComponent.cs プロジェクト: yoowonyoung/TizenFX
 internal void OnLanguageChangedCallback(string language)
 {
     LocaleChanged?.Invoke(this, new LocaleChangedEventArgs(language));
 }
コード例 #11
0
 /// <summary>
 /// Invoked on system country change.
 /// </summary>
 /// <param name="s">Object that sent event.</param>
 /// <param name="e">Event parameters.</param>
 private void OnLocaleCountryChanged(object s, LocaleCountryChangedEventArgs e)
 {
     LocaleChanged?.Invoke(s, new EventArgs());
 }
コード例 #12
0
 /// <summary>
 /// Invoked on time format change.
 /// </summary>
 /// <param name="s">Object that sent event.</param>
 /// <param name="e">Event parameters.</param>
 private void OnLocaleTimeFormat24HourSettingChanged(object s, LocaleTimeFormat24HourSettingChangedEventArgs e)
 {
     LocaleChanged?.Invoke(s, new EventArgs());
 }