Пример #1
0
        public bool check(DisplayObjectContainer child, Dictionary <int, bool> dic = null)
        {
            if (dic == null)
            {
                dic = new Dictionary <int, bool>();
            }
            bool ok = true;
            List <DisplayObject> list = child.getChildrenList();

            foreach (DisplayObject d in list)
            {
                if (!dic.ContainsKey(d.GetHashCode()))
                {
                    dic.Add(d.GetHashCode(), true);
                }
                else
                {
                    return(false);
                }
                if (d is DisplayObjectContainer)
                {
                    if (!check((DisplayObjectContainer)d, dic))
                    {
                        ok = false;
                        break;
                    }
                }
            }
            return(ok);
        }
Пример #2
0
        public void add(DisplayObjectContainer parent, DisplayObject child)
        {
            parent.addChild(child);
            ChildLink link = new ChildLink();

            link.parent = parent;
            link.child  = child;
            children.Add(link);
        }
Пример #3
0
 public bool removeParent(DisplayObjectContainer p)
 {
     if (parent == p)
     {
         parent = null;
         return(true);
     }
     return(false);
 }
Пример #4
0
 public bool setParent(DisplayObjectContainer p)
 {
     if (check(this, p))
     {
         parent = p;
         return(true);
     }
     return(false);
 }
Пример #5
0
 private bool check(DisplayObject child, DisplayObjectContainer parent)
 {
     if (parent == null)
     {
         return(true);
     }
     if (child == parent)
     {
         return(false);
     }
     return(check(child, parent.parent));
 }
Пример #6
0
 public View(Model model, GCore.DisplayObjectContainer container)
 {
     this.model     = model;
     this.container = container;
     container.addChild(this);
 }
Пример #7
0
        public void render(DisplayObjectContainer child, RenderType type, int k = 0)
        {
            dispatchEvent(new Event(this, Event.ENTER_FRAME));
            if (k > MAX_DEPTH)
            {
                return;
            }
            List <DisplayObject> list = child.getChildrenList();

            for (int i = 0; i < list.Count; i++)
            {
                DisplayObject d = list[i];
                if (d.visible)
                {
                    if (d is ISource)
                    {
                        if (d.isLoaded)
                        {
                            SharpDX.Direct2D1.Bitmap b = ((ISource)d).getSource();
                            float      alpha           = d.alpha;
                            bool       needRender      = true;
                            RectangleF rf = d.getRenderBounds();
                            needRender = inView(rf);
                            if (needRender)
                            {
                                this.render2d.Transform = d.getRenderMatrix();
                                this.render2d.DrawBitmap(b, alpha, BitmapInterpolationMode.NearestNeighbor);
                                if (DEBUG)
                                {
                                    this.render2d.Transform = SharpDX.Matrix.Identity;
                                    brush.Color             = Color.GreenYellow;
                                    this.render2d.DrawRectangle(rf, brush);

                                    brush.Color = Color.Yellow;
                                    Point   p = d.globalToLocal(d.rotationPoint);
                                    Ellipse c = new Ellipse(new DrawingPointF(p.x, p.y), 5, 5);
                                    this.render2d.DrawEllipse(c, brush);
                                }
                            }
                        }
                    }
                    else if (d is TextField)
                    {
                        GCore.TextField tf = (GCore.TextField)d;

                        if (DEBUG)
                        {
                            this.render2d.Transform = SharpDX.Matrix.Identity;
                            brush.Color             = Color.Aquamarine;
                            this.render2d.DrawRectangle(d.getRenderBounds(), brush);
                        }

                        this.render2d.Transform = d.getRenderMatrix();
                        var format = new SharpDX.DirectWrite.TextFormat(factoryText, "Arial", tf.size);
                        brush.Color = new Color4(tf.color);
                        this.render2d.DrawText(tf.text, format, new RectangleF(0, 0, tf.size * tf.text.Length, 0),
                                               brush);
                        format.Dispose();
                    }
                    else if (d is DisplayObjectContainer)
                    {
                        this.render((DisplayObjectContainer)d, type, k + 1);
                        if (DEBUG)
                        {
                            this.render2d.Transform = SharpDX.Matrix.Identity;
                            brush.Color             = Color.Red;
                            this.render2d.DrawRectangle(d.getRenderBounds(), brush);

                            brush.Color = Color.IndianRed;
                            //Point p = d.globalToLocal(d.rotationPoint);
                            Point   p = new Point(d.x, d.y);
                            Ellipse c = new Ellipse(new DrawingPointF(p.x, p.y), 5, 5);
                            this.render2d.DrawEllipse(c, brush);
                        }
                    }
                }
            }
        }