// Token: 0x06001C66 RID: 7270 RVA: 0x00085AAC File Offset: 0x00083CAC
        internal override void InitializeClone(BindingBase baseClone, BindingMode mode)
        {
            PriorityBinding priorityBinding = (PriorityBinding)baseClone;

            for (int i = 0; i <= this._bindingCollection.Count; i++)
            {
                priorityBinding._bindingCollection.Add(this._bindingCollection[i].Clone(mode));
            }
            base.InitializeClone(baseClone, mode);
        }
        internal override void InitializeClone(BindingBase baseClone, BindingMode mode)
        {
            PriorityBinding clone = (PriorityBinding)baseClone;

            for (int i = 0; i <= _bindingCollection.Count; ++i)
            {
                clone._bindingCollection.Add(_bindingCollection[i].Clone(mode));
            }

            base.InitializeClone(baseClone, mode);
        }
        private Style CreateStyle()
        {
            var style = new Style();

            var multibinding = new PriorityBinding();
            multibinding.Bindings.Add(new Binding("FirstName"));
            multibinding.Bindings.Add(new Binding("LstName")); //purposefully misspelled

            var trigger = new DataTrigger();
            trigger.Binding = multibinding;
            trigger.Value = "Rob Eisenberg";

            style.Triggers.Add(trigger);

            return style;
        }
        public SimpleUIWithPriorityBinding()
        {
            var stack = new StackPanel();
            Content = stack;

            var priorityBinding = new PriorityBinding();
            priorityBinding.Bindings.Add(new Binding("FirstName"));
            priorityBinding.Bindings.Add(new Binding("LstName")); //purposefully misspelled

            var textBlock = new TextBlock();
            textBlock.SetBinding(TextBlock.TextProperty, priorityBinding);
            stack.Children.Add(textBlock);

            textBlock = new TextBlock();
            textBlock.SetBinding(TextBlock.TextProperty, new Binding("Age"));
            stack.Children.Add(textBlock);
        }
        private Style CreateStyle()
        {
            var style = new Style();

            var priorityBinding = new PriorityBinding();
            priorityBinding.Bindings.Add(new Binding("FirstName"));
            priorityBinding.Bindings.Add(new Binding("LstName")); //purposefully misspelled

            style.Setters.Add(
                new Setter(
                    TextBlock.FontFamilyProperty,
                    priorityBinding
                    )
                );

            return style;
        }
Пример #6
0
        public static BindingBase CloneBinding(BindingBase bindingBase, object source)
        {
            var binding = bindingBase as Binding;
            if (binding != null)
            {
                var result = new Binding
                {
                    Source = source,
                    AsyncState = binding.AsyncState,
                    BindingGroupName = binding.BindingGroupName,
                    BindsDirectlyToSource = binding.BindsDirectlyToSource,
                    Converter = binding.Converter,
                    ConverterCulture = binding.ConverterCulture,
                    ConverterParameter = binding.ConverterParameter,
                    //ElementName = binding.ElementName,
                    FallbackValue = binding.FallbackValue,
                    IsAsync = binding.IsAsync,
                    Mode = binding.Mode,
                    NotifyOnSourceUpdated = binding.NotifyOnSourceUpdated,
                    NotifyOnTargetUpdated = binding.NotifyOnTargetUpdated,
                    NotifyOnValidationError = binding.NotifyOnValidationError,
                    Path = binding.Path,
                    //RelativeSource = binding.RelativeSource,
                    StringFormat = binding.StringFormat,
                    TargetNullValue = binding.TargetNullValue,
                    UpdateSourceExceptionFilter = binding.UpdateSourceExceptionFilter,
                    UpdateSourceTrigger = binding.UpdateSourceTrigger,
                    ValidatesOnDataErrors = binding.ValidatesOnDataErrors,
                    ValidatesOnExceptions = binding.ValidatesOnExceptions,
                    XPath = binding.XPath,
                };

                foreach (var validationRule in binding.ValidationRules)
                {
                    result.ValidationRules.Add(validationRule);
                }

                return result;
            }

            var multiBinding = bindingBase as MultiBinding;
            if (multiBinding != null)
            {
                var result = new MultiBinding
                {
                    BindingGroupName = multiBinding.BindingGroupName,
                    Converter = multiBinding.Converter,
                    ConverterCulture = multiBinding.ConverterCulture,
                    ConverterParameter = multiBinding.ConverterParameter,
                    FallbackValue = multiBinding.FallbackValue,
                    Mode = multiBinding.Mode,
                    NotifyOnSourceUpdated = multiBinding.NotifyOnSourceUpdated,
                    NotifyOnTargetUpdated = multiBinding.NotifyOnTargetUpdated,
                    NotifyOnValidationError = multiBinding.NotifyOnValidationError,
                    StringFormat = multiBinding.StringFormat,
                    TargetNullValue = multiBinding.TargetNullValue,
                    UpdateSourceExceptionFilter = multiBinding.UpdateSourceExceptionFilter,
                    UpdateSourceTrigger = multiBinding.UpdateSourceTrigger,
                    ValidatesOnDataErrors = multiBinding.ValidatesOnDataErrors,
                    ValidatesOnExceptions = multiBinding.ValidatesOnDataErrors,
                };

                foreach (var validationRule in multiBinding.ValidationRules)
                {
                    result.ValidationRules.Add(validationRule);
                }

                foreach (var childBinding in multiBinding.Bindings)
                {
                    result.Bindings.Add(CloneBinding(childBinding, source));
                }

                return result;
            }

            var priorityBinding = bindingBase as PriorityBinding;
            if (priorityBinding != null)
            {
                var result = new PriorityBinding
                {
                    BindingGroupName = priorityBinding.BindingGroupName,
                    FallbackValue = priorityBinding.FallbackValue,
                    StringFormat = priorityBinding.StringFormat,
                    TargetNullValue = priorityBinding.TargetNullValue,
                };

                foreach (var childBinding in priorityBinding.Bindings)
                {
                    result.Bindings.Add(CloneBinding(childBinding, source));
                }

                return result;
            }

            throw new NotSupportedException("Failed to clone binding");
        }
Пример #7
0
        private BindingBase CreateHexTileBackgroundBinding(HexTile tile)
        {
            var baseBinding = new PriorityBinding();

            if (tile != null)
            {
                BindingBase bind;

                bind = TryCreateHighQualityBinding(this, tile.TileType.ToString() + tile.CustomTileType + tile.TileVariant + "TileBackground");
                if (bind != null)
                    baseBinding.Bindings.Add(bind);
                
                bind = TryCreateBinding(this, tile.TileType.ToString() + tile.CustomTileType + tile.TileVariant + "TileBackground");
                if (bind != null)
                    baseBinding.Bindings.Add(bind);

                bind = TryCreateHighQualityBinding(this, tile.TileType.ToString() + tile.CustomTileType + "TileBackground");
                if (bind != null)
                    baseBinding.Bindings.Add(bind);

                bind = TryCreateBinding(this, tile.TileType.ToString() + tile.CustomTileType + "TileBackground");
                if (bind != null)
                    baseBinding.Bindings.Add(bind);

                bind = TryCreateHighQualityBinding(this, tile.TileType.ToString() + "TileBackground");
                if (bind != null)
                    baseBinding.Bindings.Add(bind);

                bind = TryCreateBinding(this, tile.TileType.ToString() + "TileBackground");
                if (bind != null)
                    baseBinding.Bindings.Add(bind);

                bind = TryCreateHighQualityBinding(this, "TileBackground");
                if (bind != null)
                    baseBinding.Bindings.Add(bind);

                bind = TryCreateBinding(this, "TileBackground");
                if (bind != null)
                    baseBinding.Bindings.Add(bind);

            }

            baseBinding.Bindings.Add(new Binding { Source = Brushes.Red });
            //baseBinding.FallbackValue = Brushes.Transparent;

            return baseBinding;
        }
Пример #8
0
        //------------------------------------------------------
        //
        //  Constructors
        //
        //------------------------------------------------------

        private PriorityBindingExpression(PriorityBinding binding, BindingExpressionBase owner)
            : base(binding, owner)
        {
        }
Пример #9
0
        //------------------------------------------------------
        //
        //  Internal Methods
        //
        //------------------------------------------------------

        // Create a new BindingExpression from the given Binding description
        internal static PriorityBindingExpression CreateBindingExpression(DependencyObject d, DependencyProperty dp, PriorityBinding binding, BindingExpressionBase owner)
        {
            FrameworkPropertyMetadata fwMetaData = dp.GetMetadata(d.DependencyObjectType) as FrameworkPropertyMetadata;

            if ((fwMetaData != null && !fwMetaData.IsDataBindingAllowed) || dp.ReadOnly)
            {
                throw new ArgumentException(SR.Get(SRID.PropertyNotBindable, dp.Name), "dp");
            }

            // create the BindingExpression
            PriorityBindingExpression bindExpr = new PriorityBindingExpression(binding, owner);

            return(bindExpr);
        }
Пример #10
0
    //------------------------------------------------------
    //
    //  Constructors
    //
    //------------------------------------------------------

    private PriorityBindingExpression(PriorityBinding binding, BindingExpressionBase owner)
        : base(binding, owner)
    {
    }
Пример #11
0
    //------------------------------------------------------
    //
    //  Internal Methods
    //
    //------------------------------------------------------

    // Create a new BindingExpression from the given Binding description
    internal static PriorityBindingExpression CreateBindingExpression(DependencyObject d, DependencyProperty dp, PriorityBinding binding, BindingExpressionBase owner)
    {
        FrameworkPropertyMetadata fwMetaData = dp.GetMetadata(d.DependencyObjectType) as FrameworkPropertyMetadata;

        if ((fwMetaData != null && !fwMetaData.IsDataBindingAllowed) || dp.ReadOnly)
            throw new ArgumentException(SR.Get(SRID.PropertyNotBindable, dp.Name), "dp");

        // create the BindingExpression
        PriorityBindingExpression bindExpr = new PriorityBindingExpression(binding, owner);

        return bindExpr;
    }
        // Token: 0x06001C70 RID: 7280 RVA: 0x00085BF8 File Offset: 0x00083DF8
        internal static PriorityBindingExpression CreateBindingExpression(DependencyObject d, DependencyProperty dp, PriorityBinding binding, BindingExpressionBase owner)
        {
            FrameworkPropertyMetadata frameworkPropertyMetadata = dp.GetMetadata(d.DependencyObjectType) as FrameworkPropertyMetadata;

            if ((frameworkPropertyMetadata != null && !frameworkPropertyMetadata.IsDataBindingAllowed) || dp.ReadOnly)
            {
                throw new ArgumentException(SR.Get("PropertyNotBindable", new object[]
                {
                    dp.Name
                }), "dp");
            }
            return(new PriorityBindingExpression(binding, owner));
        }
Пример #13
0
        private void findPath_Click(object sender, RoutedEventArgs e)
        {
            PriorityBinding priorityBinding = new PriorityBinding { FallbackValue = "0" };
            Binding superPrecise = new Binding("SuperPrecise") { IsAsync = true };
            Binding precise = new Binding("Precise") { IsAsync = true };
            Binding regular = new Binding("Regular") { IsAsync = true };
            Binding quick = new Binding("Quick") { IsAsync = true };
            Binding superQuick = new Binding("SuperQuick");
            priorityBinding.Bindings.Add(superPrecise);
            priorityBinding.Bindings.Add(precise);
            priorityBinding.Bindings.Add(regular);
            priorityBinding.Bindings.Add(quick);
            priorityBinding.Bindings.Add(superQuick);
            textBox.SetBinding(TextBox.TextProperty, priorityBinding);

            /*
            if (image.Source == null) return;
            System.Drawing.Bitmap b = new System.Drawing.Bitmap(BitmapImage2Bitmap(image.Source as BitmapImage));
            PathFinder.PathFinder pF = new PathFinder.PathFinder(b);
            IList<PathFinder.PathSegment> pathList = pF.FindPath(new System.Drawing.Point(0,0), new System.Drawing.Point(200, 200), PathFinder.PathFindingPrecision.SuperQuick);
            double length = 0;
            foreach (var p in pathList)
            {
                length += p.Length;
            }
            textBox.Text = length.ToString();
            */
        }