예제 #1
0
        /// <summary>
        /// adds the drw to inner drws of (this), and sets (this) as the drw parent,
        /// and adds the drw to the DC if it is initialized,
        /// this method doesn't draw the drawable
        /// </summary>
        public CompositeDrawable add(Drawable d)
        {
            //set changed to true, because it might has been drawn
            this.setChanged(true);
            //
            this.drawables.Add(d);
            d.parent = this;
            if (this.dc != null)
            {
                d.setDC(this.dc);
            }
            else
            {
                //dc must be set to parent before adding any children
                throw new Exception("'drawing controller' must be set to a parent before adding any children");
            }
            d.scaleToParent();
            //if composite init cache
            if (d is CompositeDrawable)
            {
                ((CompositeDrawable)d).initCache();
            }

            //
            return(this);
        }
 private void setDrwController(Drawable drw)
 {
     drw.setDC(this);
     if (drw is CompositeDrawable)
     {
         foreach (Drawable d in ((CompositeDrawable)drw).drawables)
         {
             setDrwController(d);
         }
     }
 }