示例#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);
                }
            }
        }
示例#2
0
 public ShapeGraphic(Color selectedColour, Point selectedPosition)
 {
     shapeColour        = selectedColour;
     canvasPosition     = selectedPosition;
     childShapeGraphic  = null;
     parentShapeGraphic = null;
     copyId             = -1;
 }
示例#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);
     }
 }
示例#4
0
 public void removeChild()
 {
     childShapeGraphic = null;
 }
示例#5
0
 public void removeParent()
 {
     parentShapeGraphic = null;
 }
示例#6
0
 public void giveChild(ShapeGraphic child)
 {
     childShapeGraphic = child;
 }
示例#7
0
 public void giveParent(ShapeGraphic parent)
 {
     parentShapeGraphic = parent;
 }
示例#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);
        }
示例#9
0
 public ShapeGraphic()
 {
     childShapeGraphic  = null;
     parentShapeGraphic = null;
     copyId             = -1;
 }
 //Check is two shapes in a pin mass are connected at any points
 private bool checkIfPinned(ShapeGraphic pinnee, ShapeGraphic pinner)
 {
     return(false);
 }