Exemplo n.º 1
0
 public static void SetAdornedElement(Visual adorner, Visual adorned)
 {
     adorner.SetValue(AdornedElementProperty, adorned);
 }
Exemplo n.º 2
0
        private void UpdateAdornedElement(Visual adorner, Visual adorned)
        {
            var info = adorner.GetValue(s_adornedElementInfoProperty);

            if (info != null)
            {
                info.Subscription.Dispose();

                if (adorned == null)
                {
                    adorner.ClearValue(s_adornedElementInfoProperty);
                }
            }

            if (adorned != null)
            {
                if (info == null)
                {
                    info = new AdornedElementInfo();
                    adorner.SetValue(s_adornedElementInfoProperty, info);
                }

                info.Subscription = _tracker.Track(adorned).Subscribe(x =>
                {
                    info.Bounds = x;
                    InvalidateArrange();
                });
            }
        }
Exemplo n.º 3
0
        public override bool ApplyTemplate()
        {
            if (this.IsInitialized && this.visualChild == null)
            {
                Visual visual = this.Content as Visual;

                if (visual == null && this.Content != null)
                {
                    DataTemplate template = this.ContentTemplate;

                    if (template == null)
                    {
                        DataTemplateKey key = new DataTemplateKey(this.Content.GetType());
                        template = this.TryFindResource(key) as DataTemplate;
                    }

                    if (template != null)
                    {
                        visual = template.CreateVisualTree(this);

                        FrameworkElement fe = visual as FrameworkElement;

                        if (fe != null)
                        {
                            fe.DataContext = this.Content;
                        }
                    }
                    else
                    {
                        visual = new TextBlock
                        {
                            Text = this.Content.ToString(),
                        };
                    }
                }

                if (visual != null)
                {
                    this.visualChild = visual;
                    this.AddVisualChild(this.visualChild);
                    this.OnApplyTemplate();
                    return true;
                }
            }

            return false;
        }
Exemplo n.º 4
0
 public static Visual GetAdornedElement(Visual adorner)
 {
     return adorner.GetValue(AdornedElementProperty);
 }
Exemplo n.º 5
0
 /// <summary>
 /// Gets the transformed bounds of the visual.
 /// </summary>
 /// <param name="visual">The visual.</param>
 /// <returns>The transformed bounds.</returns>
 public static TransformedBounds GetTransformedBounds(Visual visual) => visual.GetValue(TransformedBoundsProperty);
Exemplo n.º 6
0
        private void ContentChanged(object oldValue, object newValue)
        {
            if (oldValue != null)
            {
                this.RemoveLogicalChild(oldValue);
                this.RemoveVisualChild(this.visualChild);
                this.visualChild = null;
            }

            if (newValue != null)
            {
                this.AddLogicalChild(newValue);
            }

            this.ApplyTemplate();
        }
Exemplo n.º 7
0
 /// <summary>
 /// Starts tracking the specified visual.
 /// </summary>
 /// <param name="visual">The visual.</param>
 /// <returns>An observable that returns the tracked bounds.</returns>
 public IObservable<TransformedBounds> Track(Visual visual)
 {
     return visual.GetObservable(TransformedBoundsProperty);
 }
Exemplo n.º 8
0
 internal static void SetTransformedBounds(Visual visual, TransformedBounds bounds)
 {
     visual.SetValue(TransformedBoundsProperty, bounds);
 }
Exemplo n.º 9
0
 public PointHitTestResult(Visual visualHit, Point pointHit)
 {
     this.VisualHit = visualHit;
     this.PointHit = pointHit;
 }
Exemplo n.º 10
0
 /// <summary>
 /// Removes a child <see cref="Visual"/> from the visual tree.
 /// </summary>
 /// <param name="child">The child visual.</param>
 protected internal void RemoveVisualChild(Visual child)
 {
     child.VisualParent     = null;
     child.DependencyParent = null;
 }
Exemplo n.º 11
0
        /// <summary>
        /// Adds a child <see cref="Visual"/> to the visual tree.
        /// </summary>
        /// <param name="child">The child visual.</param>
        protected internal void AddVisualChild(Visual child)
        {
            if (child == null)
            {
                throw new ArgumentNullException("child");
            }

            DependencyObject oldParent = child.VisualParent;
            child.DependencyParent = this;
            child.VisualParent = this;
            child.OnVisualParentChanged(oldParent);
        }
Exemplo n.º 12
0
 /// <summary>
 /// Removes a child <see cref="Visual"/> from the visual tree.
 /// </summary>
 /// <param name="child">The child visual.</param>
 protected internal void RemoveVisualChild(Visual child)
 {
     child.VisualParent = null;
     child.DependencyParent = null;
 }
Exemplo n.º 13
0
        public sealed override bool ApplyTemplate()
        {
            if (this.IsInitialized && this.child == null)
            {
                if (this.Template == null)
                {
                    this.ApplyTheme();
                }

                if (this.Template != null)
                {
                    this.child = this.Template.CreateVisualTree(this);
                    this.AddVisualChild(this.child);
                    this.OnApplyTemplate();
                    return true;
                }
            }

            return false;
        }