Esempio n. 1
0
 internal void AddBindingObjcet(string identity, DataPointBindingObject obj)
 {
     if (!this.BindingDictionary.ContainsKey(identity))
     {
         this.BindingDictionary.Add(identity, obj);
     }
 }
Esempio n. 2
0
 public void SetBinding(DependencyObject target, DependencyProperty targetProperty, string identity)
 {
     if (string.IsNullOrEmpty(identity))
     {
         BindingOperations.ClearBinding(target, targetProperty);
     }
     else
     {
         DataPointBindingObject bindingObject = this.GetBindingObject(identity);
         if (bindingObject == null)
         {
             bindingObject = new DataPointBindingObject(identity);
             this.BindingDictionary.Add(identity, bindingObject);
         }
         Binding binding = new Binding("Value")
         {
             Source = bindingObject
         };
         if (target is RotateTransform)
         {
             binding.Converter = new RotateValueConverter();
         }
         BindingOperations.SetBinding(target, targetProperty, binding);
     }
 }
Esempio n. 3
0
 internal object this[string identity]
 {
     get
     {
         DataPointBindingObject bindingObject = this.GetBindingObject(identity);
         if (bindingObject != null)
         {
             return(bindingObject.Value);
         }
         return(null);
     }
 }
 public void RemoveBindingObject(DataPointBindingObject obj)
 {
     if (obj != null)
     {
         if (this.bindingSources == null)
         {
             this.bindingSources = new List <DataPointBindingObject>();
         }
         if (this.bindingSources.Contains(obj))
         {
             this.bindingSources.Remove(obj);
             obj.PropertyChanged -= new PropertyChangedEventHandler(this.obj_PropertyChanged);
         }
     }
 }
 private void obj_PropertyChanged(object sender, PropertyChangedEventArgs e)
 {
     if (e.PropertyName == "Value")
     {
         DataPointBindingObject obj2   = sender as DataPointBindingObject;
         DataPointValue         value2 = new DataPointValue
         {
             ID    = obj2.DataPointIdentity,
             Value = obj2.Value
         };
         if (this.targetElement != null)
         {
             this.targetElement.SetValue(value2);
         }
         else
         {
             this.Value = value2;
         }
     }
 }
Esempio n. 6
0
 public void SetBinding(DependencyObject target, DependencyProperty targetProperty, string[] identities)
 {
     if (identities != null)
     {
         Binding binding = BindingOperations.GetBinding(target, targetProperty);
         if (binding != null)
         {
             MultiDataPointBindingObject source = binding.Source as MultiDataPointBindingObject;
             if (source != null)
             {
                 source.Dispose();
             }
         }
         if (identities.Length == 1)
         {
             this.SetBinding(target, targetProperty, identities[0]);
         }
         else if (target is ISetValue)
         {
             BindingOperations.ClearBinding(target, targetProperty);
             MultiDataPointBindingObject obj3 = new MultiDataPointBindingObject(target as ISetValue);
             foreach (string str in identities)
             {
                 DataPointBindingObject bindingObject = this.GetBindingObject(str);
                 if (bindingObject == null)
                 {
                     bindingObject = new DataPointBindingObject(str);
                     this.AddBindingObjcet(str, bindingObject);
                 }
                 obj3.AddBindingObject(bindingObject);
             }
             Binding binding2 = new Binding("Value")
             {
                 Mode   = BindingMode.OneWay,
                 Source = obj3
             };
             BindingOperations.SetBinding(target, targetProperty, binding2);
         }
     }
 }
Esempio n. 7
0
        public void UpdateData(string identity, object value)
        {
            Action action2 = null;

            if (!this.BindingDictionary.ContainsKey(identity))
            {
                this.BindingDictionary.Add(identity, new DataPointBindingObject(identity));
            }
            DataPointBindingObject obj = this.BindingDictionary[identity];

            if (this.enableSafeMode && (this.dispatcher != null))
            {
                if (action2 == null)
                {
                    action2 = () => obj.Value = value;
                }
                Action method = action2;
                this.dispatcher.Invoke(method, new object[0]);
            }
            else if (obj.Value != value)
            {
                obj.Value = value;
            }
        }
Esempio n. 8
0
        private static string[] HandleBindingInformation(FrameworkElement ele, BindingInformation bindingInformation, string suffix)
        {
            List <string> list  = new List <string>();
            Regex         regex = new Regex(".*XPath=(?<path>.*)[},]");

            foreach (BindingTag tag in bindingInformation)
            {
                if (tag.ElementName != string.Empty)
                {
                    DependencyObject obj2 = ele.FindName(tag.ElementName) as DependencyObject;
                    if (obj2 != null)
                    {
                        Type      type  = obj2.GetType();
                        string    name  = tag.AttributeName + "Property";
                        FieldInfo field = type.GetField(name, System.Reflection.BindingFlags.FlattenHierarchy | System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.Static);
                        if ((field != null) && (field.FieldType == typeof(DependencyProperty)))
                        {
                            string             bindingPath;
                            DependencyProperty dp = field.GetValue(obj2) as DependencyProperty;
                            Match match           = regex.Match(tag.BindingPath);
                            if (match.Success)
                            {
                                bindingPath = match.Result("${path}");
                            }
                            else
                            {
                                bindingPath = tag.BindingPath;
                            }
                            bindingPath = bindingPath + string.Format("({0})", suffix);
                            DataPointBindingObject bindingObject = UIManager.Instance.GetBindingObject(bindingPath);
                            if (bindingObject == null)
                            {
                                bindingObject = new DataPointBindingObject(bindingPath);
                                UIManager.Instance.AddBindingObjcet(bindingPath, bindingObject);
                            }
                            Binding binding = BindingOperations.GetBinding(obj2, dp);
                            if (binding != null)
                            {
                                object source = binding.Source;
                                if (source is DataPointBindingObject)
                                {
                                    MultiDataPointBindingObject obj5 = new MultiDataPointBindingObject(obj2 as ISetValue);
                                    obj5.AddBindingObject(source as DataPointBindingObject);
                                    obj5.AddBindingObject(bindingObject);
                                    BindingOperations.ClearBinding(obj2, dp);
                                    Binding binding2 = new Binding("Value")
                                    {
                                        Mode    = BindingMode.OneWay,
                                        IsAsync = false,
                                        Source  = obj5
                                    };
                                    BindingOperations.SetBinding(obj2, dp, binding2);
                                }
                                else if (source is MultiDataPointBindingObject)
                                {
                                    (source as MultiDataPointBindingObject).AddBindingObject(bindingObject);
                                }
                            }
                            else
                            {
                                Binding binding3 = new Binding("Value")
                                {
                                    IsAsync = false,
                                    Mode    = BindingMode.OneWay,
                                    Source  = bindingObject
                                };
                                if (obj2 is RotateTransform)
                                {
                                    binding3.Converter = new RotateValueConverter();
                                }
                                if (!string.IsNullOrEmpty(tag.Expression))
                                {
                                    //binding3.Converter = new ExpressionCalculateConverter(tag.Expression);
                                }
                                BindingOperations.SetBinding(obj2, dp, binding3);
                            }
                            if (!list.Contains(bindingPath))
                            {
                                list.Add(bindingPath);
                            }
                        }
                    }
                }
            }
            return(list.ToArray());
        }