Ejemplo n.º 1
0
        public void AddCustomControl(GHControl customControl)
        {
            if (customControl != null)
            {
                // check for prexisting data ;

                CustomControls.Add(customControl.Name, customControl);
                customControl.SetAttribute((GHCustomAttributes)m_attributes);
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// retrive the value of the custom control by name.
        /// if the path is invalid or the control is not a parameter then thorws an exception.
        ///
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="value">the current value of the control</param>
        /// <param name="path">path to the control</param>
        /// <returns></returns>
        public void GetControlData <T>(ref T value, params string[] path)
        {
            GHControl control = GetControl(path);


            if (control is GHParameter)
            {
                GHParameter param = (GHParameter)control;
                value = (T)param.CurrentValue;
                return;
            }

            throw new Exception("Invalid path to control");
        }
Ejemplo n.º 3
0
        public GHControl GetControl(params string[] path)
        {
            GHControl ct = CustomControls[path[0]];

            if (path.Length == 1)
            {
                return(ct);
            }
            if (ct is IGHPanel)
            {
                return(((IGHPanel)ct).GetControl(path.Skip(1)));
            }

            throw new Exception("Invalid path.");
        }
Ejemplo n.º 4
0
        /// <summary>
        /// get access to the child control in the panel and its children by set of the names (path).
        /// The path must start with a child name.
        /// throw exception if the path is not valid
        /// </summary>
        /// <param name="gHContainer"></param>
        /// <param name="path"></param>
        /// <returns></returns>
        public static GHControl GetControl(this IGHPanel gHContainer, IEnumerable <string> path)
        {
            string    name = path.First();
            GHControl ct   = gHContainer.Items.FirstOrDefault(item => item.Name == name);

            if (ct == null)
            {
                throw new Exception($"Invalid path, unable to find child control in control {gHContainer.Name}");
            }
            if (path.Count() == 1)
            {
                return(ct);
            }
            else if (ct is IGHPanel)
            {
                return(GetControl((IGHPanel)ct, path.Skip(1)));
            }
            else
            {
                throw new Exception($"Invalid path, Expected an IGHPanel in {gHContainer.Name} found {ct.GetType()}");
            }
        }
Ejemplo n.º 5
0
 /// <summary>
 /// return the defualt brush based on the control state (enable or disable)
 /// </summary>
 /// <param name="control"></param>
 /// <returns></returns>
 public static Brush ActiveBrush(this GHControl control)
 {
     return((control.Enabled) ? Brushes.Black : Brushes.Gray);
 }
Ejemplo n.º 6
0
 public void Add(GHControl control)
 {
     control.attributes = attributes;
     Items = Items.Append(control).ToArray();
 }