Пример #1
0
        private void ProcessText()
        {
            if (Control == null || Element == null)
            {
                return;
            }

            // Gets the complete HTML string
            var isRtl      = Device.FlowDirection == Xamarin.Forms.FlowDirection.RightToLeft;
            var styledHtml = new RendererHelper(Element, Element.Text, Device.RuntimePlatform, isRtl).ToString();

            if (styledHtml == null)
            {
                return;
            }

            Control.Text = styledHtml;

            // Adds the HtmlTextBehavior because UWP's TextBlock
            // does not natively support HTML content
            var behavior = new HtmlTextBehavior((HtmlLabel)Element);
            BehaviorCollection behaviors = Interaction.GetBehaviors(Control);

            behaviors.Clear();
            behaviors.Add(behavior);
        }
Пример #2
0
        private void UpdateText()
        {
            if (Control == null || Element == null)
            {
                return;
            }

            if (string.IsNullOrEmpty(Control.Text))
            {
                return;
            }

            // Gets the complete HTML string
            var helper = new LabelRendererHelper(Element, Element.Text);

            Control.Text = helper.ToString();

            // Adds the HtmlTextBehavior because UWP's TextBlock
            // does not natively support HTML content
            var behavior = new HtmlTextBehavior((HtmlLabel)Element);
            BehaviorCollection behaviors = Interaction.GetBehaviors(Control);

            behaviors.Clear();
            behaviors.Add(behavior);
        }
Пример #3
0
        private static void OnPropertyChanged(DependencyObject dpo, DependencyPropertyChangedEventArgs e)
        {
            var uie = dpo as UIElement;

            if (uie == null)
            {
                return;
            }

            BehaviorCollection itemBehaviors = Interaction.GetBehaviors(uie);

            var newBehaviors = e.NewValue as StyleBehaviorCollection;
            var oldBehaviors = e.OldValue as StyleBehaviorCollection;

            if (newBehaviors == oldBehaviors)
            {
                return;
            }

            //if (oldBehaviors != null)
            //{
            //    foreach (var behavior in oldBehaviors)
            //    {
            //        int index = GetIndexOf(itemBehaviors, behavior);

            //        if (index >= 0)
            //        {
            //            itemBehaviors.RemoveAt(index);
            //        }
            //    }
            //}

            itemBehaviors.Clear();

            if (newBehaviors != null)
            {
                foreach (var behavior in newBehaviors)
                {
                    int index = GetIndexOf(itemBehaviors, behavior);

                    if (index < 0)
                    {
                        var  clone   = (Behavior)behavior.Clone();
                        Guid cloneId = GetBehaviorId(clone);

                        if (cloneId == Guid.Empty)
                        {
                            SetBehaviorId(clone, Guid.NewGuid());
                        }

                        itemBehaviors.Add(clone);
                    }
                }
            }
        }
Пример #4
0
        public static bool ClearManipulator(LayerControl SectionLayer)
        {
            if (SectionLayer == null)
            {
                return(false);
            }

            BehaviorCollection bc = Interaction.GetBehaviors(SectionLayer);

            bc.Clear();
            return(true);
        }
Пример #5
0
        public static bool SetManipulator(ManipulatorBase mp, LayerControl SectionLayer)
        {
            if (mp == null || SectionLayer == null)
            {
                return(false);
            }

            BehaviorCollection bc = Interaction.GetBehaviors(SectionLayer);

            bc.Clear();
            bc.Add(mp);
            return(true);
        }
Пример #6
0
 /// <summary>
 ///     Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
 /// </summary>
 public void Dispose()
 {
     if (Interlocked.Exchange(ref _lazyContext, DataContext.Empty) == DataContext.Empty)
     {
         return;
     }
     OnDispose();
     BindingServiceProvider.BindingManager.Unregister(this);
     BindingUpdated   = null;
     BindingException = null;
     _behaviors.Clear();
     _sourceAccessor.Dispose();
     _targetAccessor.Dispose();
 }
    private static void OnBehaviorsChanged(DependencyObject depObj, DependencyPropertyChangedEventArgs e)
    {
        if (e.NewValue is IEnumerable == false)
        {
            return;
        }
        var newBehaviorCollection             = e.NewValue as IEnumerable;
        BehaviorCollection behaviorCollection = Interaction.GetBehaviors(depObj);

        behaviorCollection.Clear();
        foreach (Behavior behavior in newBehaviorCollection)
        {
            behaviorCollection.Add(behavior);
        }
    }
Пример #8
0
    private static void OnBehaviorsChanged(DependencyObject depObj, DependencyPropertyChangedEventArgs e)
    {
        if (e.NewValue is BehaviorCreatorCollection == false)
        {
            return;
        }
        BehaviorCreatorCollection newBehaviorCollection = e.NewValue as BehaviorCreatorCollection;
        BehaviorCollection        behaviorCollection    = Interaction.GetBehaviors(depObj);

        behaviorCollection.Clear();
        foreach (IBehaviorCreator behavior in newBehaviorCollection)
        {
            behaviorCollection.Add(behavior.Create());
        }
    }
Пример #9
0
        private static void OnPropertyChanged(DependencyObject dpo, DependencyPropertyChangedEventArgs e)
        {
            var uie = dpo as UIElement;

            if (uie == null)
            {
                return;
            }

            BehaviorCollection itemBehaviors = Interaction.GetBehaviors(uie);

            itemBehaviors.Clear();
            var clone = (Behavior)(e.NewValue as BorderlessWindowBehavior).Clone();

            itemBehaviors.Add(clone);
        }
Пример #10
0
    private static void OnBehaviorsChanged(DependencyObject depObj, DependencyPropertyChangedEventArgs e)
    {
        if (e.NewValue is IEnumerable == false)
        {
            return;
        }
        var newBehaviorCollection             = e.NewValue as IEnumerable;
        BehaviorCollection behaviorCollection = Interaction.GetBehaviors(depObj);

        behaviorCollection.Clear();
        foreach (Behavior behavior in newBehaviorCollection)
        {
            // you need to make a copy of behavior in order to attach it to several controls
            var copy = behavior.Clone() as Behavior;
            behaviorCollection.Add(copy);
        }
    }
Пример #11
0
        public void VectorChanged_ResetWhileNotAttached_DetachNotCalled()
        {
            StubBehavior[] behaviorArray = { new StubBehavior(), new StubBehavior(), new StubBehavior() };

            BehaviorCollection behaviorCollection = new BehaviorCollection();

            foreach (StubBehavior behavior in behaviorArray)
            {
                behaviorCollection.Add(behavior);
            }

            behaviorCollection.Clear();

            foreach (StubBehavior behavior in behaviorArray)
            {
                TestUtilities.AssertNotDetached(behavior);
            }
        }