static IDynamicControl GetDynamicControl(DependencyObject parent)
        {
            IDynamicControl iDynamicParent = parent as IDynamicControl;

            if (iDynamicParent != null)
            {
                return(iDynamicParent);
            }

            var numChildren = VisualTreeHelper.GetChildrenCount(parent);

            for (int i = 0; i < numChildren; i++)
            {
                DependencyObject childControl    = VisualTreeHelper.GetChild(parent, i);
                IDynamicControl  iDynamicControl = childControl as IDynamicControl;
                if (iDynamicControl != null)
                {
                    return(iDynamicControl);
                }

                iDynamicControl = GetDynamicControl(childControl);
                if (iDynamicControl != null)
                {
                    return(iDynamicControl);
                }
            }
            return(null);
        }
        /// <summary>
        /// Sets the IDynamicControl's OriginalValue property, and also calls LoadValue
        /// so the object's data is transferred into the control's representation of that data.
        /// If you are deserializing instances of your IDynamicControls, then call this method
        /// after those instances have been deserialized.
        /// </summary>
        public static void Initialize(this IDynamicControl control)
        {
            var value = control.Blueprint.GetValue();

            control.InitialValue = value;
            control.LoadValue(value);
        }
        public static void SaveValue(this IDynamicControl control, object value)
        {
            if (control.Blueprint.IsEmpty)
            {
                return;
            }

            control.Blueprint.SetValue(value);
        }
        static Visibility GetDynamicVisibility(DependencyObject parent)
        {
            IDynamicControl dynamicControl = GetDynamicControl(parent);

            if (dynamicControl != null)
            {
                if (!dynamicControl.Blueprint.IsVisible())
                {
                    return(Visibility.Collapsed);
                }
            }

            return(Visibility.Visible);
        }
示例#5
0
 public static void HookStateChangedEvents(this IDynamicControl iDynamicControl, EventHandler StateChangeHandler)
 {
     iDynamicControl.StateChanged += StateChangeHandler;
     iDynamicControl.StateChanged += VisibilityManager.StateChangeHandler;
 }
 public static void Initialize(this IDynamicControl control, Blueprint blueprint)
 {
     control.Blueprint = blueprint;
     control.Initialize();
 }
示例#7
0
 public static ValueBase <T> Add <T>(this EloBuddy.SDK.Menu.Menu menu, IDynamicControl <T> item)
 {
     return(menu.Add(item.GetConfigValue().Name(), item.GetControl()));
 }