Ejemplo n.º 1
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);
     }
 }
Ejemplo n.º 2
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
        }
Ejemplo n.º 3
0
        protected override DataTemplate OnSelectTemplate(object item, Xamarin.Forms.BindableObject container)
        {
            var selector = item as ScatteringTemplateSelector;
            //var scattType = e.NewValue as string;
            var scattType = selector.ScatteringType;

            if (scattType == typeof(MieScatterer).FullName)
            {
                //selector.Content = selector.MieScatteringTemplate.LoadContent() as UIElement;
                return(MieScatteringTemplate);
            }
            else if (scattType == typeof(PowerLawScatterer).FullName)
            {
                //selector.Content = selector.PowerLawScatteringTemplate.LoadContent() as UIElement;
                _scatteringType = "Vts.SpectralMapping.PowerLawScatterer";
                return(PowerLawScatteringTemplate);
            }
            else if (scattType == typeof(IntralipidScatterer).FullName)
            {
                //selector.Content = selector.IntralipidScatteringTemplate.LoadContent() as UIElement;
                _scatteringType = "Vts.SpectralMapping.Intralipid";
                return(IntralipidScatteringTemplate);
            }
            else
            {
                return(null);
            }
        }
 private static void OnPageContentPropertyChanged(xam.BindableObject bindable, object oldValue, object newValue)
 {
     if (newValue != null)
     {
         var page        = (SwitchMasterPage)bindable;
         var contentView = (xam.ContentView)newValue;
         page.Content = contentView; //  page.PageContent;
     }
 }
Ejemplo n.º 5
0
        private static void OnCommandPropertyChanged(DependencyObject dependencyObject, DependencyPropertyChangedEventArgs args)
        {
#if UWP
            var control = dependencyObject as Hub;
            if (control != null)
            {
                control.SectionHeaderClick += OnSectionHeaderClick;
            }
#endif
        }
Ejemplo n.º 6
0
        /// <summary>
        /// Handles the <see cref="E:CommandPropertyChanged" /> event.
        /// </summary>
        /// <param name="dependencyObject">The dependency object changed.</param>
        /// <param name="e">The <see cref="DependencyPropertyChangedEventArgs"/> instance containing the event data.</param>
        private static void OnCommandPropertyChanged(DependencyObject dependencyObject, DependencyPropertyChangedEventArgs e)
        {
            var element = dependencyObject as FrameworkElement;

            if (element != null)
            {
                element.Loaded -= ElementLoaded;
                element.Loaded += ElementLoaded;
            }
        }
Ejemplo n.º 7
0
        private static void ActionsSourcePropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            var control = d as ActionsCommandBar;

            if (control != null)
            {
                foreach (var action in control.ActionsSource)
                {
                    var label = GetText(action, ActionTextProperties.Label);
                    var automationPropertiesName = GetText(action, ActionTextProperties.AutomationPropertiesName);
                    var button = FindButton(label, control);
                    if (button == null)
                    {
                        button = new AppBarButton();

                        if (action.ActionType == ActionType.Primary)
                        {
                            control.PrimaryCommands.Add(button);
                        }
                        else if (action.ActionType == ActionType.Secondary)
                        {
                            control.SecondaryCommands.Add(button);
                        }
                    }
                    button.Command          = action.Command;
                    button.CommandParameter = action.CommandParameter;
                    button.Label            = label;
                    AutomationProperties.SetName(button, automationPropertiesName);
                    if (!string.IsNullOrEmpty(label))
                    {
                        ToolTipService.SetToolTip(button, GetTooltip(label));
                        ToolTipService.SetPlacement(button, PlacementMode.Mouse);
                    }
                    if (Application.Current.Resources.ContainsKey(action.Style))
                    {
                        button.Style = Application.Current.Resources[action.Style] as Style;
                    }
                    if (button.Command?.CanExecute(button?.CommandParameter) == true)
                    {
                        button.Visibility = Visibility.Visible;
                    }
                    else
                    {
                        button.Visibility = Visibility.Collapsed;
                    }
                }
            }
        }
Ejemplo n.º 8
0
        private static void OnIsVisiblePropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            var self = d as ActionsCommandBar;

#if UWP
            var isVisible = (bool)e.NewValue;
            if (isVisible)
            {
                self.Visibility = Visibility.Visible;
            }
            else
            {
                self.Visibility = Visibility.Collapsed;
            }
#else
            self.IsVisible = (bool)e.NewValue;
#endif
        }
Ejemplo n.º 9
0
        private static void OnToolTipPropertyChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
        {
            var framework_element = sender as FrameworkElement;

            if (framework_element == null)
            {
                return;
            }

            var tooltip = sender.GetValue(ToolTipProperty) as string;

            if (tooltip == null)
            {
                return;
            }

            var localized = Vernacular.Catalog.GetString(tooltip);

            ToolTipService.SetToolTip(framework_element, localized);
        }
Ejemplo n.º 10
0
        public void Attach(DependencyObject dependencyObject)
        {
#if XAMARIN_FORMS
            this.Parent = dependencyObject as Element;
#endif
            if (this.associatedObject != null)
            {
                throw new InvalidOperationException();
            }

            if (!InternalDesigner.IsDesignTime)
            {
                this.WritePreamble();
                this.associatedObject = dependencyObject;
                this.WritePostscript();

                foreach (var item in this)
                {
                    item.Attach(dependencyObject);
                }
            }

            this.OnAttached();
        }
Ejemplo n.º 11
0
 public static void SetModifier(DependencyObject o, StringModifier value)
 {
     o.SetValue(ModifierProperty, value);
 }
Ejemplo n.º 12
0
 public static void SetPluralCount(DependencyObject o, int value)
 {
     o.SetValue(PluralCountProperty, value);
 }
Ejemplo n.º 13
0
 public static StringModifier GetModifier(DependencyObject o)
 {
     return((StringModifier)o.GetValue(ModifierProperty));
 }
Ejemplo n.º 14
0
 public static void SetPluralMessage(DependencyObject o, string value)
 {
     o.SetValue(PluralMessageProperty, value);
 }
Ejemplo n.º 15
0
 public static int GetPluralCount(DependencyObject o)
 {
     return((int)o.GetValue(PluralCountProperty));
 }
Ejemplo n.º 16
0
 public static void SetComment(DependencyObject o, string value)
 {
     o.SetValue(CommentProperty, value);
 }
Ejemplo n.º 17
0
 public static string GetPluralMessage(DependencyObject o)
 {
     return(o.GetValue(PluralMessageProperty) as string);
 }
Ejemplo n.º 18
0
 public static string GetToolTip(DependencyObject o)
 {
     return((string)o.GetValue(ToolTipProperty));
 }
 private static void OnHeaderTextChanged(xam.BindableObject bindable, object oldValue, object newValue)
 {
 }
Ejemplo n.º 20
0
 internal override void TearDown(BindableObject bindable)
 {
     bindable.ClearValue(_stateProperty);
     bindable.PropertyChanged -= OnAttachedObjectPropertyChanged;
 }
        private static void ViewModelLoaderChanged(BindableObject bindable, object oldvalue, object newvalue)
        {
            var taskLoader = (TaskLoaderView)bindable;

            taskLoader.SetBindings();
        }
Ejemplo n.º 22
0
 /// <summary>
 /// Gets the command from the attached property.
 /// </summary>
 /// <param name="dependencyObject">The dependency object to query.</param>
 /// <returns>The ICommand attached.</returns>
 public static ICommand GetCommand(DependencyObject dependencyObject)
 {
     return(dependencyObject == null ? null : (ICommand)dependencyObject.GetValue(CommandProperty));
 }
 private static void OnImageSourceChanged(xam.BindableObject bindable, object oldValue, object newValue)
 {
 }
 private void Bind(XamarinBindableObject bindableObject, IViewModel viewModel)
 {
     bindableObject.BindingContext = viewModel;
 }
Ejemplo n.º 25
0
        private static DependencyProperty FindMessageProperty(DependencyObject e)
        {
            DependencyProperty property;

            if (FindMessageDependencyProperty != null)
            {
                property = FindMessageDependencyProperty(e);
                if (property != null)
                {
                    return(property);
                }
            }

            if (MessageDependencyPropertyMap.TryGetValue(e.GetType(), out property))
            {
                return(property);
            }
#if !XAMARINFORMS
            if (e is TextBlock)
            {
                return(TextBlock.TextProperty);

#if WINDOWS_PHONE
            }
            else if (e is PanoramaItem)
            {
                return(PanoramaItem.HeaderProperty);
            }
            else if (e is Pivot)
            {
                return(Pivot.TitleProperty);
            }
            else if (e is PivotItem)
            {
                return(PivotItem.HeaderProperty);
            }
            else if (e is ListPicker)
            {
                return(ListPicker.HeaderProperty);
#endif
#if SILVERLIGHT
            }
            else if (e is TabItem)
            {
                return(TabItem.HeaderProperty);
#endif
            }
            else if (e is ContentControl)
            {
                return(ContentControl.ContentProperty);
            }
            else if (e is TextBox)
            {
                return(TextBox.TextProperty);
            }
#else
            if (e is Label)
            {
                return(Label.TextProperty);
            }
            else if (e is Entry)
            {
                return(Entry.TextProperty);
            }
            else if (e is Page)
            {
                return(Page.TitleProperty);
            }
            else if (e is Button)
            {
                return(Button.TextProperty);
            }
            else if (e is TextCell)
            {
                return(TextCell.TextProperty);
            }
            else if (e is EntryCell)
            {
                return(EntryCell.LabelProperty);
            }
            else if (e is SwitchCell)
            {
                return(SwitchCell.TextProperty);
            }
#endif

            return(null);
        }
 public void SetParent(object parentElement)
 {
     Target = (XF.BindableObject)parentElement;
 }
Ejemplo n.º 27
0
 public static void SetToolTip(DependencyObject o, string value)
 {
     o.SetValue(ToolTipProperty, value);
 }
        private static void OnCurrentPageChanged(xam.BindableObject bindable, object oldValue, object newValue)
        {
            var obj = (SwitchMasterPage)bindable;

            SetActiveBottomNavBar(obj);
        }
Ejemplo n.º 29
0
 public static string GetComment(DependencyObject o)
 {
     return(o.GetValue(CommentProperty) as string);
 }
Ejemplo n.º 30
0
 public static EventsCollection?GetEvents(DependencyObject d) =>
 (EventsCollection?)d.GetValue(EventsProperty);