Beispiel #1
0
        private static void OnPropertyChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
        {
            var message        = sender.GetValue(MessageProperty) as string;
            var plural_message = sender.GetValue(PluralMessageProperty) as string;
            var modifier       = (StringModifier)sender.GetValue(ModifierProperty);
            var count          = 1;

            if (message == null)
            {
                return;
            }
            else if (plural_message != null)
            {
                count = (int)sender.GetValue(PluralCountProperty);
            }

            var localized = plural_message == null
                ? Vernacular.Catalog.GetString(message)
                : Vernacular.Catalog.GetPluralString(message, plural_message, count);

            localized = ModifyString(localized, modifier);
            localized = Format(localized, count);
            var property = FindMessageProperty(sender);

            if (property != null)
            {
                sender.SetValue(property, localized);
            }
#if !XAMARINFORMS
            else if (sender is Run)
            {
                (sender as Run).Text = localized;
            }
#endif
        }
Beispiel #2
0
 /// <summary>
 /// Sets a command into the attached property.
 /// </summary>
 /// <param name="dependencyObject">The dependency object to assign the command.</param>
 /// <param name="value">The command to attach.</param>
 public static void SetCommand(DependencyObject dependencyObject, ICommand value)
 {
     if (dependencyObject != null)
     {
         dependencyObject.SetValue(CommandProperty, value);
     }
 }
Beispiel #3
0
 public static void SetBackButtonBehavior(BindableObject obj, BackButtonBehavior behavior) => obj.SetValue(BackButtonBehaviorProperty, behavior);
Beispiel #4
0
 public static void SetShellUnselectedColor(BindableObject obj, Color value) => obj.SetValue(ShellUnselectedColorProperty, value);
Beispiel #5
0
 public static void SetTabBarDisabledColor(BindableObject obj, Color value) => obj.SetValue(TabBarDisabledColorProperty, value);
Beispiel #6
0
 public static void SetPluralCount(DependencyObject o, int value)
 {
     o.SetValue(PluralCountProperty, value);
 }
Beispiel #7
0
 public static void SetComment(DependencyObject o, string value)
 {
     o.SetValue(CommentProperty, value);
 }
Beispiel #8
0
 public static void SetSearchHandler(BindableObject obj, SearchHandler handler) => obj.SetValue(SearchHandlerProperty, handler);
Beispiel #9
0
 public static void SetMenu(BindableObject bindable, Menu menu) => bindable.SetValue(MenuProperty, menu);
Beispiel #10
0
 public static void SetRowSpan(BindableObject bindable, int value)
 {
     bindable.SetValue(RowSpanProperty, value);
 }
Beispiel #11
0
 public static void SetColumn(BindableObject bindable, int value)
 {
     bindable.SetValue(ColumnProperty, value);
 }
Beispiel #12
0
 public static void SetItemTemplate(BindableObject obj, DataTemplate itemTemplate) => obj.SetValue(ItemTemplateProperty, itemTemplate);
Beispiel #13
0
 public static void SetMenuItemTemplate(BindableObject obj, DataTemplate menuItemTemplate) => obj.SetValue(MenuItemTemplateProperty, menuItemTemplate);
Beispiel #14
0
 public static void SetTitleColor(BindableObject obj, Color value) => obj.SetValue(TitleColorProperty, value);
Beispiel #15
0
 public static void SetFlyoutBehavior(BindableObject obj, FlyoutBehavior value) => obj.SetValue(FlyoutBehaviorProperty, value);
Beispiel #16
0
 public static void SetNavBarIsVisible(BindableObject obj, bool value) => obj.SetValue(NavBarIsVisibleProperty, value);
Beispiel #17
0
        static void OnTransformChanged(BindableObject bindable, object oldValue, object newValue)
        {
            if ((string)newValue == "none")
            {
                bindable.ClearValue(TranslationXProperty);
                bindable.ClearValue(TranslationYProperty);
                bindable.ClearValue(RotationProperty);
                bindable.ClearValue(RotationXProperty);
                bindable.ClearValue(RotationYProperty);
                bindable.ClearValue(ScaleProperty);
                bindable.ClearValue(ScaleXProperty);
                bindable.ClearValue(ScaleYProperty);
                return;
            }
            var transforms = ((string)newValue).Split(' ');

            foreach (var transform in transforms)
            {
                if (string.IsNullOrEmpty(transform) || transform.IndexOf('(') < 0 || transform.IndexOf(')') < 0)
                {
                    throw new FormatException("Format for transform is 'none | transform(value) [transform(value) ]*'");
                }
                var    transformName = transform.Substring(0, transform.IndexOf('('));
                var    value = transform.Substring(transform.IndexOf('(') + 1, transform.IndexOf(')') - transform.IndexOf('(') - 1);
                double translationX, translationY, scaleX, scaleY, rotateX, rotateY, rotate;
                if (transformName.StartsWith("translateX", StringComparison.OrdinalIgnoreCase) && double.TryParse(value, out translationX))
                {
                    bindable.SetValue(TranslationXProperty, translationX);
                }
                else if (transformName.StartsWith("translateY", StringComparison.OrdinalIgnoreCase) && double.TryParse(value, out translationY))
                {
                    bindable.SetValue(TranslationYProperty, translationY);
                }
                else if (transformName.StartsWith("translate", StringComparison.OrdinalIgnoreCase))
                {
                    var translate = value.Split(',');
                    if (double.TryParse(translate[0], out translationX) && double.TryParse(translate[1], out translationY))
                    {
                        bindable.SetValue(TranslationXProperty, translationX);
                        bindable.SetValue(TranslationYProperty, translationY);
                    }
                }
                else if (transformName.StartsWith("scaleX", StringComparison.OrdinalIgnoreCase) && double.TryParse(value, out scaleX))
                {
                    bindable.SetValue(ScaleXProperty, scaleX);
                }
                else if (transformName.StartsWith("scaleY", StringComparison.OrdinalIgnoreCase) && double.TryParse(value, out scaleY))
                {
                    bindable.SetValue(ScaleYProperty, scaleY);
                }
                else if (transformName.StartsWith("scale", StringComparison.OrdinalIgnoreCase))
                {
                    var scale = value.Split(',');
                    if (double.TryParse(scale[0], out scaleX) && double.TryParse(scale[1], out scaleY))
                    {
                        bindable.SetValue(ScaleXProperty, scaleX);
                        bindable.SetValue(ScaleYProperty, scaleY);
                    }
                }
                else if (transformName.StartsWith("rotateX", StringComparison.OrdinalIgnoreCase) && double.TryParse(value, out rotateX))
                {
                    bindable.SetValue(RotationXProperty, rotateX);
                }
                else if (transformName.StartsWith("rotateY", StringComparison.OrdinalIgnoreCase) && double.TryParse(value, out rotateY))
                {
                    bindable.SetValue(RotationYProperty, rotateY);
                }
                else if (transformName.StartsWith("rotate", StringComparison.OrdinalIgnoreCase) && double.TryParse(value, out rotate))
                {
                    bindable.SetValue(RotationProperty, rotate);
                }
                else
                {
                    throw new FormatException("Invalid transform name");
                }
            }
        }
Beispiel #18
0
 public static void SetSetPaddingInsets(BindableObject obj, bool value) => obj.SetValue(SetPaddingInsetsProperty, value);
Beispiel #19
0
 public static void SetTitleView(BindableObject obj, View value) => obj.SetValue(TitleViewProperty, value);
Beispiel #20
0
 public static void SetPluralMessage(DependencyObject o, string value)
 {
     o.SetValue(PluralMessageProperty, value);
 }
Beispiel #21
0
 public static void SetShellForegroundColor(BindableObject obj, Color value) => obj.SetValue(ShellForegroundColorProperty, value);
Beispiel #22
0
 public static void SetModifier(DependencyObject o, StringModifier value)
 {
     o.SetValue(ModifierProperty, value);
 }
Beispiel #23
0
 public static void SetShellTabBarTitleColor(BindableObject obj, Color value) => obj.SetValue(ShellTabBarTitleColorProperty, value);
Beispiel #24
0
 public static void SetToolTip(DependencyObject o, string value)
 {
     o.SetValue(ToolTipProperty, value);
 }
Beispiel #25
0
 public static void SetBackgroundColor(BindableObject obj, Color value) => obj.SetValue(BackgroundColorProperty, value);