Exemple #1
0
        public static bool GetData <TGoo, T>(ITargetParam <TGoo, T> owner, out GH_ParamAccess access, out T value) where TGoo : GH_Goo <T>
        {
            access = GH_ParamAccess.item;
            if (owner.Target.Attributes.HasInputGrip)
            {
                owner.Enable = owner.Target.SourceCount == 0;
            }
            else
            {
                owner.Enable = false;
            }


            if (owner.Target.VolatileData.AllData(true).Count() > 0)
            {
                if (owner.Target.VolatileData.AllData(false).Count() > 1)
                {
                    access = owner.Target.VolatileData.PathCount == 1 ? GH_ParamAccess.list : GH_ParamAccess.tree;
                }
                GH_Goo <T> gh_color = owner.Target.VolatileData.AllData(true).ElementAt(0) as GH_Goo <T>;
                value = gh_color.Value;
                return(true);
            }
            else
            {
                //ParamControlHelper.SetData<TGoo, T>(owner, owner.Default);
                //return owner.Default;
                value = default(T);
                return(false);
            }
        }
Exemple #2
0
        public static void SetData <TGoo, T>(ITargetParam <TGoo, T> owner, T value) where TGoo : GH_Goo <T>
        {
            GH_PersistentParam <TGoo> target = owner.Target;

            GH_Document.GH_ScheduleDelegate callback = new GH_Document.GH_ScheduleDelegate(ScheduleCallback);
            target.OnPingDocument().ScheduleSolution(20, callback);

            void ScheduleCallback(GH_Document doc)
            {
                target.RecordUndoEvent(typeof(T).Name + "Changed!");
                {
                    target.PersistentData.Clear();
                    target.SetPersistentData(value);
                }
            }
        }