Exemple #1
0
        // Method to generate the rectangle to draw into
        public Rectangle GetIconRectangle(DragDropObject ddobj)
        {
            int index = dragDropObjects.IndexOf(ddobj);

            if (index == -1)
            {
                return(new Rectangle(0, 0, 0, 0));
            }

            IconSize = ClientRectangle.Height;
            int numDDObjectsX = ClientRectangle.Width / IconSize;

            if (numDDObjectsX == 0)
            {
                numDDObjectsX = 1;
            }
            int ddObjectsX = index % numDDObjectsX;
            int ddObjectsY = index / numDDObjectsX;

            Rectangle rect = new Rectangle(ddObjectsX * IconSize, ddObjectsY * IconSize, IconSize, IconSize);

            rect.Inflate(-IconSize / 10, -IconSize / 10);

            return(rect);
        }
Exemple #2
0
 // Method enabling client DragDropObjects to add a new member
 public void AddDragDropObject(DragDropObject senderDDObj, DragDropObject newDDObj)
 {
     this.Controls.Add(newDDObj);
     dragDropObjects.Insert(dragDropObjects.IndexOf(senderDDObj) + 1, newDDObj);
     for (int i = dragDropObjects.IndexOf(newDDObj) + 1; i < dragDropObjects.Count(); i++)
     {
         dragDropObjects[i].UpdateLocation(dragDropObjects[i - 1]);
     }
 }
Exemple #3
0
 // Method enabling client DragDropObjects to delete themselves
 public void RemoveDragDropObject(DragDropObject senderDDObj)
 {
     dragDropObjects[dragDropObjects.IndexOf(senderDDObj)].Location = new Point(
         dragDropObjects[dragDropObjects.IndexOf(senderDDObj)].Location.X - dragDropObjects[dragDropObjects.IndexOf(senderDDObj)].Size.Width,
         dragDropObjects[dragDropObjects.IndexOf(senderDDObj)].Location.Y);
     for (int i = dragDropObjects.IndexOf(senderDDObj) + 1; i < dragDropObjects.Count(); i++)
     {
         dragDropObjects[i].UpdateLocation(dragDropObjects[i - 1]);
     }
     this.Controls.Remove(senderDDObj);
     dragDropObjects.Remove(senderDDObj);
 }
Exemple #4
0
        protected override void OnDragDrop(DragEventArgs drgevent)
        {
            if (Int32.TryParse(drgevent.Data.GetData(DataFormats.Text).ToString(), out int newDDObjectType))
            {
                if (newDDObjectType > 2)
                {
                    return;
                }
            }
            else
            {
                return;
            }
            Point          newObjLocation = this.PointToClient(new Point(drgevent.X, drgevent.Y));
            Size           newObjSize     = new Size(50, 50);
            DragDropObject newDDObject    = GetDragDropItem(newDDObjectType, newObjLocation, newObjSize);

            this.Controls.Add(newDDObject);
            dragDropObjects.Add(newDDObject);

            Invalidate();
        }
Exemple #5
0
        // Method to generate new DragDrop elemnts
        public DragDropObject GetDragDropItem(int type, Point location, Size size)
        {
            DragDropObject newDDObject = new DragDropObject();

            switch (type)
            {
            case (1):
                newDDObject = new BasicSectionDragDropObject(this);
                break;

            case (2):
                newDDObject = new BasicConditionDragDropObject(this);
                break;

            default:
                newDDObject = new DragDropObject();
                break;
            }
            newDDObject.Location = location;
            newDDObject.Size     = size;

            return(newDDObject);
        }
Exemple #6
0
        // Method to add colors to the pallete
        public void AddElementType(DragDropObject ddobj)
        {
            dragDropObjects.Add(ddobj);

            Invalidate();
        }