public List <string> GetAllNames(IGFXObject rootObject, int lvl) { List <string> lst = new List <string>(); foreach (var item in rootObject.GetChildren()) { lst.Add(" " + (new String('-', lvl)) + " " + item.Name); lst.AddRange(GetAllNames(item, lvl + 1)); } return(lst); }
public IGFXObject RemoveObject(IGFXObject obj) { if (obj != null) { String name = ""; try { name = obj.Name; GFXObjects.Remove(obj.Name); this.UpdateFrame -= obj.Frame_Update; //if (obj is IHasSeperateAnimationEvent) // always assume SeperateAnimation events this.UpdateAnimation -= obj.Animation_Update; obj.ParentContainer = null; // invoke UnregisterAllVisuals. important to set before event is removed obj.RegisterDrawingVisual -= this.RegisterVisual_Callback; obj.UnregisterDrawingVisual -= this.UnregisterVisual_Callback; } catch (Exception ex) { Debug.WriteLine("=> [GFXContainer]: failed to remove " + name); } } return(obj); }
public void AddObject(IGFXObject obj, string name = null) { if (name == null) { name = obj.GetType().Name + "::" + obj.GetHashCode().ToString(); } if ((obj.Name ?? "").Equals("")) { obj.Name = name; } if (GFXObjects.IndexOfKey(obj.Name) >= 0) { obj.Name += "#" + obj.GetHashCode().ToString(); } GFXObjects.Add(obj.Name, obj); obj.RegisterDrawingVisual += this.RegisterVisual_Callback; obj.UnregisterDrawingVisual += this.UnregisterVisual_Callback; obj.ParentContainer = this; this.UpdateFrame += obj.Frame_Update; //if (obj is IHasSeperateAnimationEvent) //this.UpdateAnimation += (obj as IHasSeperateAnimationEvent).Animation_Update; // always assume SeperateAnimation events this.UpdateAnimation += obj.Animation_Update; }
public void RemoveObject(IGFXObject obj) { Children.Remove(obj); }
public void AddObject(IGFXObject obj) { Children.Add(obj); }
public void AddObject(IGFXObject obj, string name = null) { if (name == null) name = obj.GetType().Name + "::" + obj.GetHashCode().ToString(); if ((obj.Name ?? "").Equals("")) obj.Name = name; if (GFXObjects.IndexOfKey(obj.Name) >= 0) obj.Name += "#" + obj.GetHashCode().ToString(); GFXObjects.Add(obj.Name, obj); obj.RegisterDrawingVisual += this.RegisterVisual_Callback; obj.UnregisterDrawingVisual += this.UnregisterVisual_Callback; obj.ParentContainer = this; this.UpdateFrame += obj.Frame_Update; //if (obj is IHasSeperateAnimationEvent) //this.UpdateAnimation += (obj as IHasSeperateAnimationEvent).Animation_Update; // always assume SeperateAnimation events this.UpdateAnimation += obj.Animation_Update; }
public IGFXObject RemoveObject(IGFXObject obj) { if (obj != null) { String name = ""; try { name = obj.Name; GFXObjects.Remove(obj.Name); this.UpdateFrame -= obj.Frame_Update; //if (obj is IHasSeperateAnimationEvent) // always assume SeperateAnimation events this.UpdateAnimation -= obj.Animation_Update; obj.ParentContainer = null; // invoke UnregisterAllVisuals. important to set before event is removed obj.RegisterDrawingVisual -= this.RegisterVisual_Callback; obj.UnregisterDrawingVisual -= this.UnregisterVisual_Callback; } catch (Exception ex) { Debug.WriteLine("=> [GFXContainer]: failed to remove " + name); } } return obj; }
public List<string> GetAllNames(IGFXObject rootObject, int lvl) { List<string> lst = new List<string>(); foreach (var item in rootObject.GetChildren()) { lst.Add(" " + (new String('-', lvl)) + " " + item.Name); lst.AddRange(GetAllNames(item, lvl + 1)); } return lst; }
public void RemoveObject(IGFXObject obj) { throw new NotImplementedException("A Leaf of a Composion cannot hold children.\nUse GFXComposition instead."); }