コード例 #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);
        }
コード例 #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);
 }
コード例 #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;
 }
コード例 #4
0
 public void RemoveObject(IGFXObject obj)
 {
     Children.Remove(obj);
 }
コード例 #5
0
 public void AddObject(IGFXObject obj)
 {
     Children.Add(obj);
 }
コード例 #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;
 }
コード例 #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;
 }
コード例 #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;
 }
コード例 #9
0
 public void RemoveObject(IGFXObject obj)
 {
     Children.Remove(obj);
 }
コード例 #10
0
 public void AddObject(IGFXObject obj)
 {
     Children.Add(obj);
 }
コード例 #11
0
 public void RemoveObject(IGFXObject obj)
 {
     throw new NotImplementedException("A Leaf of a Composion cannot hold children.\nUse GFXComposition instead.");
 }