Esempio n. 1
0
        public static void UpdateTypeToDrawable(this IHasTemplate template, Type type)
        {
            foreach (var singleDrawableObject in template.Components)
            {
                //all interface of a part of drawable object
                var singleObjectInterfaces = singleDrawableObject.GetType().GetInterfaces();

                //find all interface
                for (int i = 0; i < singleObjectInterfaces.Length; i++)
                {
                    //if has same interface
                    if (singleObjectInterfaces[i].ToString() == type.ToString())
                    {
                        //singleObjectInterfaces[i] = type;
                        //CopyPropertiesTo<Type>(type, singleObjectInterfaces[i]);

                        //TODO : 測試取得所有屬性

                        var allSourceProperty = type.GetPublicProperties();
                        var allDestProperty   = singleObjectInterfaces[i].GetPublicProperties();
                        for (int j = 0; j < allSourceProperty.Length; j++)
                        {
                            object property = allSourceProperty[j].GetValue(template.RpObject, null);
                            allDestProperty[j].SetValue(singleDrawableObject, property, null);
                        }
                        //foreach (PropertyInfo prop in allSourceProperty)
                        //{
                        //    //設定屬鏡
                        //    prop.SetValue(singleObjectInterfaces[i], prop.GetValue(type, null), null);
                        //}
                    }
                }
            }
        }
        private string RenderVariable(
            string param,
            Dictionary <string, object> variableDictionary)
        {
            string       objectParam;
            int?         objectArrayIndex;
            IHasTemplate obj = GetVarObject(param, variableDictionary, out objectParam, out objectArrayIndex) as IHasTemplate;

            if (obj == null)
            {
                obj = GetVariable(objectParam, variableDictionary, objectArrayIndex) as IHasTemplate;
            }

            if (string.IsNullOrEmpty(obj.TemplateName()))
            {
                ThrowTemplateException(
                    string.Format("Render called but the object does not have a template: {0}. {1}.",
                                  param,
                                  obj.ToString()));
            }

            IHasProps objProps = obj as IHasProps;


            variableDictionary["this"] = objProps;
            string rv = FormatTemplate(obj.TemplateName(), variableDictionary);

            variableDictionary.Remove("this");
            return(rv);
        }
 /// <summary>
 /// remove Object from ContainableObject
 /// </summary>
 /// <param name="iCanContainObject"></param>
 /// <param name="dragObject"></param>
 public static void RemoveObject(this ICanContainObject iCanContainObject, IHasTemplate dragObject)
 {
     foreach (var single in iCanContainObject.containListTemplate())
     {
         single.Remove(dragObject);
     }
 }
Esempio n. 4
0
 public static void UpdateObjectToDrawable(this IHasTemplate template)
 {
     foreach (var type in template.RpObject.GetType().GetInterfaces())
     {
         UpdateTypeToDrawable(template, type);
     }
 }
 public static void AddObject(this ICanContainObject iCanContainObject, IHasTemplate drawableObject)
 {
     foreach (var single in iCanContainObject.containListTemplate())
     {
         single.Add(drawableObject);
     }
 }
Esempio n. 6
0
        public static void InitialTemplate(this IHasTemplate drawableObject)
        {
            //set all attribute form object to drawable component
            drawableObject.UpdateObjectToDrawable();

            //adding all component into template
            InitialChild(drawableObject);
        }
Esempio n. 7
0
 //fade out
 public static IHasTemplate FadeOutComponents(this IHasTemplate drawableObject, double time = 0)
 {
     foreach (IComponentBase single in drawableObject.Components)
     {
         single.FadeOut(time);
     }
     return(drawableObject);
 }
        public void Add(IHasTemplate template)
        {
            this.AddTemplate(template);
            //時間位置
            var position = this.PositionOfTime(template.RpObject.StartTime - StartTime);

            template.DrawableObject.Position = position;
        }
Esempio n. 9
0
 //tickle
 public static IHasTemplate TickleComponents(this IHasTemplate drawableObject, HitResult result)
 {
     foreach (IComponentBase single in drawableObject.Components)
     {
         if (single is IComponentTickleByHit canTickleObject)
         {
             canTickleObject.Tickle(result);
         }
     }
     return(drawableObject);
 }
Esempio n. 10
0
        //update progress
        public static void UpdateTemplate(this IHasTemplate drawableObject, double currentTime)
        {
            //start progress
            var startProgress = PathPrecentageCounter.CalculatePrecentage(drawableObject.RpObject.StartTime - currentTime + DelayTime, 1);
            //end progress
            var endProgress = PathPrecentageCounter.CalculatePrecentage(drawableObject.RpObject.StartTime - currentTime + DelayTime, 1);

            //影響程度
            var CurveEasingTypesPrecentage = 0;

            //修正
            startProgress = MathHelper.Clamp(startProgress, 0, 1);
            endProgress   = MathHelper.Clamp(endProgress, 0, 1);
            //fix precentage by EasingTypes
            startProgress = Interpolation.ApplyEasing(Easing.None, startProgress, 0, 1, 1) * CurveEasingTypesPrecentage + startProgress * (1 - CurveEasingTypesPrecentage);
            endProgress   = Interpolation.ApplyEasing(Easing.None, endProgress, 0, 1, 1) * CurveEasingTypesPrecentage + endProgress * (1 - CurveEasingTypesPrecentage);

            //update all
            foreach (IComponentUpdateEachFrame single in drawableObject.Components.Where(n => n is IComponentUpdateEachFrame))
            {
                single.UpdateProgress(startProgress, endProgress);
            }
        }
Esempio n. 11
0
 public static void RemoveTemplate(this IComponentContainListTemplate listTemplate, IHasTemplate template)
 {
     //remove from drawable
     //template.AddTemplateToChild();
     (listTemplate as Container).Children.ToList().Remove(template.DrawableObject);
     //Add to list
     listTemplate.ListTemplate.Remove(template);
 }
 public void Add(IHasTemplate template)
 {
     this.AddTemplate(template);
     template.DrawableObject.Position = (template.RpObject as IHasLayerIndex).PositionOfLayer();
 }
Esempio n. 13
0
 //adding all component into template
 private static void InitialChild(this IHasTemplate drawableObject)
 {
     (drawableObject as Container).Children = drawableObject.Components.Select(s => s as Container).ToArray();
 }
 public void Remove(IHasTemplate template)
 {
     this.RemoveTemplate(template);
 }
Esempio n. 15
0
 /// <summary>
 /// Add
 /// </summary>
 /// <param name="template"></param>
 public void Add(IHasTemplate template)
 {
     ListTemplate.Add(template);
     createDrawable();
 }
Esempio n. 16
0
 /// <summary>
 /// Remove
 /// </summary>
 /// <param name="template"></param>
 public void Remove(IHasTemplate template)
 {
     ListTemplate.Remove(template);
     createDrawable();
 }
Esempio n. 17
0
        public static void AddTemplate(this IComponentContainListTemplate listTemplate, IHasTemplate template)
        {
            //Add to list
            listTemplate.ListTemplate.Add(template);

            //return;

            //TODO : get better
            //remove from origin drawable
            //template.RemoveTemplateFromChild();//TODO : impliment

            //add to drawable

            var list = (listTemplate as Container).Children.ToList();

            if (list.Count == 0)
            {
                list.Add(template.DrawableObject.CreateProxy());
                (listTemplate as Container).Children = list.ToArray();//TODO : impliment
            }
            else
            {
                //TODO : connot add
                (listTemplate as Container).Add((template.DrawableObject.CreateProxy()));
            }
        }