Exemplo n.º 1
0
        //Recursively find the last child and separate it
        public void Unpin()
        {
            ShapeGraphic tempChild  = childShapeGraphic;
            ShapeGraphic tempParent = parentShapeGraphic;

            childShapeGraphic  = new ShapeGraphic();
            parentShapeGraphic = new ShapeGraphic();
            childShapeGraphic  = null;
            parentShapeGraphic = null;

            if (tempChild != null)
            {
                if (tempParent == null)
                {
                    tempChild.removeParent();
                }
                else
                {
                    tempChild.giveParent(tempParent);
                }
            }
            if (tempParent != null)
            {
                if (tempChild == null)
                {
                    tempParent.removeChild();
                }
                else
                {
                    tempParent.giveChild(tempChild);
                }
            }
        }
Exemplo n.º 2
0
 public ShapeGraphic(Color selectedColour, Point selectedPosition)
 {
     shapeColour        = selectedColour;
     canvasPosition     = selectedPosition;
     childShapeGraphic  = null;
     parentShapeGraphic = null;
     copyId             = -1;
 }
Exemplo n.º 3
0
 //Recursively find the child who doesn't have a child yet
 public void Pin(ShapeGraphic childToPin)
 {
     if (childShapeGraphic == null)
     {
         //Find the highest parent in the child graphic
         while (true)
         {
             if (childToPin.hasParent())
             {
                 childToPin = childToPin.getParent();
             }
             else
             {
                 break;
             }
         }
         childShapeGraphic = childToPin;
         childToPin.giveParent(this);
     }
     else
     {
         childShapeGraphic.Pin(childToPin);
     }
 }
Exemplo n.º 4
0
 public void removeChild()
 {
     childShapeGraphic = null;
 }
Exemplo n.º 5
0
 public void removeParent()
 {
     parentShapeGraphic = null;
 }
Exemplo n.º 6
0
 public void giveChild(ShapeGraphic child)
 {
     childShapeGraphic = child;
 }
Exemplo n.º 7
0
 public void giveParent(ShapeGraphic parent)
 {
     parentShapeGraphic = parent;
 }
Exemplo n.º 8
0
        //Returns true if a passed shape is pinned to the shape in any way
        public bool checkIfAlreadyPinned(ShapeGraphic childToPin)
        {
            bool result = false;

            if (childToPin == this)
            {
                return(true);
            }
            if (childShapeGraphic != null)
            {
                result = childShapeGraphic.checkIfAlreadyPinned(childToPin);
                if (result == true)
                {
                    return(true);
                }
            }
            if (parentShapeGraphic != null)
            {
                result = parentShapeGraphic.checkIfAlreadyPinned(childToPin);
                if (result == true)
                {
                    return(true);
                }
            }

            //CHeck all the childToPin's children and parents
            if (childToPin.hasChild())
            {
                if (childShapeGraphic != null)
                {
                    result = childShapeGraphic.checkIfAlreadyPinned(childToPin.getChild());
                    if (result == true)
                    {
                        return(true);
                    }
                }
                if (parentShapeGraphic != null)
                {
                    result = parentShapeGraphic.checkIfAlreadyPinned(childToPin.getChild());
                    if (result == true)
                    {
                        return(true);
                    }
                }
            }
            if (childToPin.hasParent())
            {
                if (childShapeGraphic != null)
                {
                    result = childShapeGraphic.checkIfAlreadyPinned(childToPin.getParent());
                    if (result == true)
                    {
                        return(true);
                    }
                }
                if (parentShapeGraphic != null)
                {
                    result = parentShapeGraphic.checkIfAlreadyPinned(childToPin.getParent());
                    if (result == true)
                    {
                        return(true);
                    }
                }
            }

            return(false);
        }
Exemplo n.º 9
0
 public ShapeGraphic()
 {
     childShapeGraphic  = null;
     parentShapeGraphic = null;
     copyId             = -1;
 }
Exemplo n.º 10
0
 //Check is two shapes in a pin mass are connected at any points
 private bool checkIfPinned(ShapeGraphic pinnee, ShapeGraphic pinner)
 {
     return(false);
 }