Esempio n. 1
0
        /// <summary>
        /// Initializes the specified element and its descendants by hooking property bindings and events.
        /// </summary>
        /// <param name="element">The element.</param>
        private void InitElement(SkiaFrameworkElement element)
        {
            if (!GetIsInitialized(element))
            {
                if (EnableBinding)
                {
                    foreach (var bindingProperty in element.GetBindingProperties())
                    {
                        var container = BindingEventContainer.Generate(element, bindingProperty);
                        container.ValueChanged += OnBindingContainerValueChanged;
                        _containers.Add(container);

                        _bindingThrottlers.Add(container.BindingProperty, new ActionThrottle(TimeSpan.FromMilliseconds(1000d / BindingFPS), _host.Dispatcher));
                    }
                }

                element.ChildAdded   += Element_ChildAdded;
                element.ChildRemoved += Element_ChildRemoved;

                SetIsInitialized(element, true);
            }

            foreach (var child in element.Children)
            {
                InitElement(child);
            }
        }
Esempio n. 2
0
        /// <summary>
        /// Generates a new <see cref="BindingEventContainer"/> for the specified Skia element and binding property.
        /// </summary>
        /// <param name="skiaElement">The skia element.</param>
        /// <param name="bindingProperty">The binding property.</param>
        /// <returns></returns>
        public static BindingEventContainer Generate(SkiaFrameworkElement skiaElement, BindingProperty bindingProperty)
        {
            BindingEventContainer container = new BindingEventContainer(skiaElement, bindingProperty);

            Binding binding = new Binding();

            binding.Mode    = BindingMode.OneWay;
            binding.Source  = skiaElement.WpfElement;
            binding.Path    = new PropertyPath(bindingProperty.DependencyProperty);
            binding.IsAsync = true;
            BindingOperations.SetBinding(container, BindingEventContainer.ValueProperty, binding);

            return(container);
        }