Ejemplo n.º 1
0
        ICollection IRefContainer.GetManagedRefs()
        {
            List <HeapRef> refs = new List <HeapRef> ();

            foreach (var keypair in strongRefs)
            {
                if (keypair.Value is INativeEventObjectWrapper)
                {
                    refs.Add(new HeapRef(true, (INativeEventObjectWrapper)keypair.Value, NativeDependencyObjectHelper.IdToName(keypair.Key)));
                }
            }

            return(refs);
        }
Ejemplo n.º 2
0
        void convert_setter_values_cb(IntPtr style_ptr)
        {
            Style style = NativeDependencyObjectHelper.FromIntPtr(style_ptr) as Style;

            style.ConvertSetterValues();
        }
Ejemplo n.º 3
0
 internal void ClearValueImpl(DependencyProperty dp)
 {
     RemoveExpression(dp);
     NativeDependencyObjectHelper.ClearValue(this, dp);
 }
Ejemplo n.º 4
0
        internal void SetValueImpl(DependencyProperty dp, object value)
        {
            if (value == DependencyProperty.UnsetValue)
            {
                ClearValue(dp);
                return;
            }

            bool                  updateTwoWay      = false;
            bool                  addingExpression  = false;
            Expression            existing          = null;
            Expression            expression        = value as Expression;
            BindingExpressionBase bindingExpression = expression as BindingExpressionBase;

            if (bindingExpression != null)
            {
                string path = bindingExpression.Binding.Path.Path;
                if ((string.IsNullOrEmpty(path) || path == ".") &&
                    bindingExpression.Binding.Mode == BindingMode.TwoWay)
                {
                    throw new ArgumentException("TwoWay bindings require a non-empty Path");
                }
                bindingExpression.Binding.Seal();
            }

            if (expressions != null)
            {
                if (!expressions.TryGetValue(dp, out existing))
                {
                    existing = null;
                }
            }

            if (expression != null)
            {
                if (existing != expression)
                {
                    if (expression.Attached)
                    {
                        throw new ArgumentException("Cannot attach the same Expression to multiple FrameworkElements");
                    }

                    if (existing != null)
                    {
                        RemoveExpression(dp);
                    }
                    if (expressions == null)
                    {
                        expressions = new Dictionary <DependencyProperty, Expression> ();
                    }

                    expressions.Add(dp, expression);
                    expression.OnAttached(this);
                }
                addingExpression = true;
                value            = expression.GetValue(dp);
            }
            else if (existing != null)
            {
                if (existing is BindingExpressionBase)
                {
                    BindingExpressionBase beb = (BindingExpressionBase)existing;

                    if (beb.Binding.Mode == BindingMode.TwoWay)
                    {
                        updateTwoWay = !beb.Updating && !(dp is CustomDependencyProperty);
                    }
                    else if (!beb.Updating || beb.Binding.Mode == BindingMode.OneTime)
                    {
                        RemoveExpression(dp);
                    }
                }
                else if (!existing.Updating)
                {
                    RemoveExpression(dp);
                }
            }

            try {
                NativeDependencyObjectHelper.SetValue(this, dp, value);
                if (updateTwoWay)
                {
                    ((BindingExpressionBase)existing).TryUpdateSourceObject(value);
                }
            } catch {
                if (!addingExpression)
                {
                    throw;
                }
                else
                {
                    NativeDependencyObjectHelper.SetValue(this, dp, dp.GetDefaultValue(this));
                    if (updateTwoWay)
                    {
                        ((BindingExpressionBase)existing).TryUpdateSourceObject(value);
                    }
                }
            }
        }
Ejemplo n.º 5
0
 public object GetAnimationBaseValue(DependencyProperty dp)
 {
     return(NativeDependencyObjectHelper.GetAnimationBaseValue(this, dp));
 }
Ejemplo n.º 6
0
        internal virtual void AccumulateManagedRefs(List <HeapRef> refs)
        {
            if (strongRefs != null)
            {
                foreach (var keypair in strongRefs)
                {
                    if (keypair.Value is INativeEventObjectWrapper)
                    {
                        refs.Add(new HeapRef(true, (INativeEventObjectWrapper)keypair.Value, NativeDependencyObjectHelper.IdToName(keypair.Key)));
                    }
                }
            }

            if (TemplateOwner != null)
            {
                refs.Add(new HeapRef(false,
                                     TemplateOwner,
                                     "TemplateOwner"));
            }
        }
Ejemplo n.º 7
0
        internal virtual void AddStrongRef(IntPtr id, object value)
        {
            if (strongRefs != null && strongRefs.ContainsKey(id))
            {
                return;
            }

            if (value != null)
            {
#if DEBUG_REF
                Console.WriteLine("Adding ref named `{4}' from {0}/{1} to {2}/{3} (referent = {5})", GetHashCode(), this, value.GetHashCode(), value, NativeDependencyObjectHelper.IdToName(id), value);
#endif
                if (strongRefs == null)
                {
                    strongRefs = new Dictionary <IntPtr, object> ();
                }
                strongRefs.Add(id, value);
            }
        }
Ejemplo n.º 8
0
        static void ClearRoot(IntPtr target, IntPtr calldata, IntPtr closure)
        {
            ContentPresenter presenter = (ContentPresenter)NativeDependencyObjectHelper.FromIntPtr(closure);

            presenter.ClearRoot();
        }
Ejemplo n.º 9
0
 public static object GetFocusedElement()
 {
     return(NativeDependencyObjectHelper.FromIntPtr(NativeMethods.surface_get_focused_element(Deployment.Current.Surface.Native)));
 }