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); } }
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); } }
public static void InitialTemplate(this IHasTemplate drawableObject) { //set all attribute form object to drawable component drawableObject.UpdateObjectToDrawable(); //adding all component into template InitialChild(drawableObject); }
//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; }
//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); }
//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); } }
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(); }
//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); }
/// <summary> /// Add /// </summary> /// <param name="template"></param> public void Add(IHasTemplate template) { ListTemplate.Add(template); createDrawable(); }
/// <summary> /// Remove /// </summary> /// <param name="template"></param> public void Remove(IHasTemplate template) { ListTemplate.Remove(template); createDrawable(); }
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())); } }