Beispiel #1
0
        /// <summary>Translates this view item using the specified localization provider.</summary>
        /// <param name="localizationProvider">The localization provider to use for translation.</param>
        /// <exception cref="ArgumentNullException">Thrown when the argument is null.</exception>
        public override void Translate(ILocalizationProvider localizationProvider)
        {
            if (localizationProvider == null)
            {
                throw new ArgumentNullException(nameof(localizationProvider));
            }

            UIComponent.tooltip = localizationProvider.Translate(UIComponent.name + TranslationKeys.Tooltip);

            UILabel label = UIComponent.parent?.Find <UILabel>(LabelName);

            if (label != null)
            {
                label.text       = localizationProvider.Translate(UIComponent.name);
                label.wordWrap   = true;
                label.autoSize   = false;
                label.autoHeight = true;
                label.width      = 240;
            }

            UIComponent.items         = itemIds.Select(item => localizationProvider.Translate($"{UIComponent.name}.{item}")).ToArray();
            UIComponent.selectedIndex = Value;
        }
Beispiel #2
0
        /// <summary>Checks for enabled incompatible mods and prepares a notification message text if any found.</summary>
        /// <param name="message">The translated message text about incompatible mods. If none found, <c>null</c>.</param>
        /// <returns><c>true</c> if there are any active incompatible mod detected; otherwise, <c>false</c>.</returns>
        public bool AreAnyIncompatibleModsActive(out string message)
        {
            List <string> incompatibleMods = GetIncompatibleModNames();

            if (incompatibleMods.Count == 0)
            {
                message = null;
                return(false);
            }

            string separator = Environment.NewLine + " - ";

            message = localizationProvider.Translate(TranslationKeys.IncompatibleModsFoundMessage)
                      + Environment.NewLine + separator
                      + string.Join(separator, incompatibleMods.ToArray())
                      + Environment.NewLine + Environment.NewLine;

            return(true);
        }
Beispiel #3
0
        /// <summary>Performs the actual view item translation.</summary>
        /// <param name="localizationProvider">The localization provider to use for translation. Guaranteed to be not null.</param>
        protected override void TranslateImpl(ILocalizationProvider localizationProvider)
        {
            var content = Container as UIHelper;

            if (content == null)
            {
                return;
            }

            UIComponent panel = ((UIComponent)content.self).parent;

            if (panel == null)
            {
                return;
            }

            UILabel label = panel.Find <UILabel>(LabelName);

            if (label != null)
            {
                label.text = localizationProvider.Translate(ItemId);
            }
        }
Beispiel #4
0
        private void InitWindow()
        {
            IResourceProvider     provider     = UIApplication.Service <IResourceProvider>();
            ILocalizationProvider localization = UIApplication.Service <ILocalizationProvider>();

            _button1.Visibility = Visibility.Hidden;
            _button2.Visibility = Visibility.Hidden;
            _button3.Visibility = Visibility.Hidden;

            if (_messageType == MessageType.Error)
            {
                _iconImage.Source   = provider.GetResource <ImageSource>("IconError");
                _button3.Visibility = Visibility.Visible;
                _button3.Content    = localization.Translate("Ok");
                _button3.Click     += OkButton_Click;
                _button3.Focus();
            }
            else if (_messageType == MessageType.Info)
            {
                _iconImage.Source   = provider.GetResource <ImageSource>("IconInfo");
                _button3.Visibility = Visibility.Visible;
                _button3.Content    = localization.Translate("Ok");
                _button3.Click     += OkButton_Click;
                _button3.Focus();
            }
            else if (_messageType == MessageType.Warning)
            {
                _iconImage.Source   = provider.GetResource <ImageSource>("IconWarning");
                _button3.Visibility = Visibility.Visible;
                _button3.Content    = localization.Translate("Ok");
                _button3.Click     += OkButton_Click;
                _button3.Focus();
            }
            else if (_messageType == MessageType.Question)
            {
                _iconImage.Source = provider.GetResource <ImageSource>("IconQuestion");
                if (QuestionWithCancel)
                {
                    _button1.Visibility = Visibility.Visible;
                    _button2.Visibility = Visibility.Visible;
                    _button3.Visibility = Visibility.Visible;

                    _button1.Content = localization.Translate("Yes");
                    _button2.Content = localization.Translate("No");
                    _button3.Content = localization.Translate("Cancel");

                    _button1.Click += YesButton_Click;
                    _button2.Click += NoButton_Click;
                    _button3.Click += CancelButton_Click;

                    _button1.Focus();
                }
                else
                {
                    _button2.Visibility = Visibility.Visible;
                    _button3.Visibility = Visibility.Visible;

                    _button2.Content = localization.Translate("Yes");
                    _button3.Content = localization.Translate("No");

                    _button2.Click += YesButton_Click;
                    _button3.Click += NoButton_Click;

                    _button2.Focus();
                }
            }
        }
Beispiel #5
0
 /// <summary>Performs the actual view item translation.</summary>
 /// <param name="localizationProvider">The localization provider to use for translation. Guaranteed to be not null.</param>
 protected override void TranslateImpl(ILocalizationProvider localizationProvider)
 {
     tabButton.text    = localizationProvider.Translate(ItemId);
     tabButton.tooltip = tabButton.text;
 }