Beispiel #1
0
        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);
        }
Beispiel #2
0
 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);
 }
Beispiel #3
0
 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);
 }
Beispiel #6
0
 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;
 }
Beispiel #7
0
 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;
 }
Beispiel #8
0
 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;
 }
Beispiel #9
0
 public void RemoveObject(IGFXObject obj)
 {
     Children.Remove(obj);
 }
Beispiel #10
0
 public void AddObject(IGFXObject obj)
 {
     Children.Add(obj);
 }
Beispiel #11
0
 public void RemoveObject(IGFXObject obj)
 {
     throw new NotImplementedException("A Leaf of a Composion cannot hold children.\nUse GFXComposition instead.");
 }