/**
  * Add a new Box to the Grid - Debugging purposes only
  */
 public void Add(ScheduleBox newBox)
 {
     newBox.ScheduleBoxEvent += this.ScheduleBox_Event;
     timeGrid.Children.Add(newBox);
 }
        /**
         * Called when moving from the Canvas to the Grid. This way it snaps into a place
         * and can be processed easier in the future
         */
        private bool SnapToGrid(ScheduleBox sb)
        {
            if (theCanvas.Children.Contains(sb))
            {
                double x = Canvas.GetLeft(sb);
                double y = Canvas.GetTop(sb);
                //Get Center Point
                Point p = theCanvas.TranslatePoint(new Point(x+sb.Width/2,y+sb.Height/2), timeGrid);
                GridPos gp = CanvasToGrid(p.X, p.Y);
                theCanvas.Children.Remove(sb);
                Grid.SetColumn(sb, gp.Col);
                Grid.SetRow(sb, gp.Row);
                switch (gp.WhichGrid)
                {
                    case GridNames.Time: timeGrid.Children.Add(sb); break;
                    //case GridNames.Event: eventGrid.Children.Add(sb); break;
                }

                return true;
            }
            return false;
        }
        private bool PopFromGrid(ScheduleBox sb)
        {
            if (timeGrid.Children.Contains(sb))
            {
                timeGrid.Children.Remove(sb);
                theCanvas.Children.Add(sb);
                return true;
            }

            else if (eventGrid.Children.Contains(sb))
            {
                /* Adding events to the event list, will leave them there
                 * As resources to be chosen and dragged on to the schedule grid
                 * So here we clone the schedule box and add it to the canvas
                 * at the location of the original Event Box
                 */
                ScheduleBox nsb = new ScheduleBox(sb.Title(), sb.Description(), sb.ScheduleID, sb.BgColor());
                nsb.ScheduleBoxEvent += this.ScheduleBox_Event;
                Canvas.SetLeft(nsb, Canvas.GetLeft(sb));
                Canvas.SetTop(nsb, Canvas.GetTop(sb));
                ((ArrayList)UsedEventsList[EventList.IndexOf(sb)]).Add(nsb);
                theCanvas.Children.Add(nsb);
               return true;
            }
            return false;
        }
 public void NewEvent(String title = "New Event", String desc = "A New Event")
 {
     ScheduleBox newBox = new ScheduleBox(title,desc);
     newBox.ScheduleBoxEvent += this.ScheduleBox_Event;
     eventGrid.Children.Add(newBox);
     EventList.Add(newBox);
     UsedEventsList.Add(new ArrayList());
     Grid.SetColumn(newBox, (EventList.Count-1));
 }
 public bool DeleteScheduleBox(ScheduleBox sb)
 {
     if (timeGrid.Children.Contains(sb))
     {
         //Update our list of lists
         int nID = ScheduleIDToEventID(sb.ScheduleID);
         if (nID >= 0)
         {
             ((ArrayList)UsedEventsList[nID]).Remove(sb);
         }
         timeGrid.Children.Remove(sb);
         return true;
     }
     else if (eventGrid.Children.Contains(sb))
     {
         //When we delete someone from the event grid
         //Slide all of the remaining grid items to the left
         int c = Grid.GetColumn(sb);
         eventGrid.Children.Remove(sb);
         for (int col = c+1; col < EventList.Count; col++)
         {
             Grid.SetColumn((UIElement)EventList[col], col - 1);
         }
         //Update our List of Lists
         int nID = ScheduleIDToEventID(sb.ScheduleID);
         foreach(ScheduleBox tb in ((ArrayList)UsedEventsList[nID]))
         {
             timeGrid.Children.Remove(tb);
         }
         UsedEventsList.RemoveAt(nID);
         EventList.Remove(sb);
         return true;
     }
     else if (theCanvas.Children.Contains(sb))
     {
         theCanvas.Children.Remove(sb);
         return true;
     }
     return false;
 }
 public bool ChangeScheduleBox(ScheduleBox sb)
 {
     if (timeGrid.Children.Contains(sb))
     {
         //Do Nothing yet
         return true;
     }
     else if (eventGrid.Children.Contains(sb))
     {
         int nID = ScheduleIDToEventID(sb.ScheduleID);
         foreach (ScheduleBox tb in ((ArrayList)UsedEventsList[nID]))
         {
             tb.Title(sb.Title());
             tb.BgColor(sb.BgColor());
         }
         return true;
     }
     else if (theCanvas.Children.Contains(sb))
     {
         //Do Nothing yet ... though Nothing should need done here
         return true;
     }
     return false;
 }