Esempio n. 1
0
        /// <summary>
        /// Adds the dragged item to route task.
        /// </summary>
        /// <param name="destination">The destination.</param>
        /// <param name="routeTask">The route task.</param>
        /// <param name="dropPlacement">The drop placement.</param>
        public static void AddToRouteTask(RouteTask destination, RouteTask routeTask, DropPlacement dropPlacement)
        {
            var destinationRouteTask = destination;

            var placeInDestination = destinationRouteTask.OrderInRouteDestination;

            //Makes adjustments to the placeInDestination based on where routeTask is being dropped
            if (dropPlacement == DropPlacement.After)
                placeInDestination++;

            if (dropPlacement == DropPlacement.Before && placeInDestination > 0)
                placeInDestination--;

            //Add the RouteTask to the RouteDestination found above
            destinationRouteTask.RouteDestination.RouteTasksListWrapper.Insert(placeInDestination, routeTask);
        }
Esempio n. 2
0
        /// <summary>
        /// Adds to Route remove from task board.
        /// </summary>
        /// <param name="draggedItem">The dragged item.</param>
        /// <param name="destination">The destination.</param>
        /// <param name="dropPlacement">The drop placement.</param>
        /// <param name="placeInRoute">The place in route.</param>
        private void AddToRouteRemoveFromTaskBoard(object draggedItem, object destination, DropPlacement dropPlacement, int placeInRoute)
        {
            //We know they are all RouteTasks becuase they come from the TaskBoard
            var routeTask = draggedItem as RouteTask;

            //This will check the destination and call the correct method to add the RouteTask to the appropriate place
            DragDropTools.AddRouteTaskToRoute(routeTask, destination, placeInRoute, dropPlacement);

            //Remove the RouteTask from the TaskBoard
            ((ObservableCollection<RouteTask>)VM.TaskBoard.CollectionView.SourceCollection).Remove(((RouteTask)draggedItem));
        }
Esempio n. 3
0
        /// <summary> 
        /// Adds to route.
        /// </summary>
        /// <param name="draggedItem">The dragged item.</param>
        /// <param name="destination">The destination.</param>
        /// <param name="placeInRoute">The place in route.</param>
        /// <param name="dropPlacement">The drag placement.</param>
        private void AddToRoute(object draggedItem, object destination, int placeInRoute, DropPlacement dropPlacement)
        {
            //If the current draggedItem is a RouteDestination -> Add it to the Route in the correct position
            var draggedRouteDestination = draggedItem as RouteDestination;
            if (draggedRouteDestination != null)
            {
                if (destination is RouteDestination)
                    ((RouteDestination)destination).Route.RouteDestinationsListWrapper.Insert(placeInRoute, draggedRouteDestination);
                //TODO:add analytic

                if (destination is Route && dropPlacement == DropPlacement.After)
                    ((Route)destination).RouteDestinationsListWrapper.Add((RouteDestination)draggedItem);
                //TODO:add analytic
                else if (destination is Route)
                    ((Route)destination).RouteDestinationsListWrapper.Insert(placeInRoute, (RouteDestination)draggedItem);
                //TODO:add analytic
            }

            //If the current draggedItem is a RouteTask -> Either add it to the RouteDestination, or create a new RouteDestination
            var routeTask = draggedItem as RouteTask;
            if (routeTask != null)
            {
                //if the old route destination only has this one task, move the whole RouteDestination instead of the RouteTask
                if (routeTask.RouteDestination.RouteTasks.Count == 1)
                {
                    if (destination is Route && dropPlacement == DropPlacement.After)
                        ((Route)destination).RouteDestinationsListWrapper.Add(routeTask.RouteDestination);
                    //TODO:add analytic
                    else if (destination is Route)
                        ((Route)destination).RouteDestinationsListWrapper.Insert(placeInRoute, routeTask.RouteDestination);
                    //TODO:add analytic
                }
                //This will check the destination and call the correct method to add the RouteTask to the appropriate place
                else
                {
                    DragDropTools.AddRouteTaskToRoute(routeTask, destination, placeInRoute, dropPlacement);
                }
            }
        }
Esempio n. 4
0
        /// <summary>
        /// Adds the draggedItem to either the Route or RouteDestination it was dragged to.
        /// </summary>
        /// <param name="routeTask">The route task.</param>
        /// <param name="destination">The destination.</param>
        /// <param name="placeInRoute">The place in route.</param>
        /// <param name="dropPlacement"> </param>
        public static void AddRouteTaskToDestinationOrRoute(RouteTask routeTask, object destination, int placeInRoute, DropPlacement dropPlacement)
        {
            //If the user drops the task on a destination, just add it to the end of its list of RouteTasks
            if ((destination is RouteDestination) && dropPlacement == DropPlacement.In)
            {
                ((RouteDestination)destination).RouteTasksListWrapper.Add(routeTask);
                //TODO:add analytic

                //No need to do any of the other logic below, skip to the next iteration of the loop
                return;
            }

            routeTask.RemoveRouteDestination();

            //Create new destination
            var newDestination = new RouteDestination
            {
                Id = Guid.NewGuid(),
                LocationId =  routeTask.LocationId,
                ClientId = routeTask.ClientId
            };

            //Add the tasks to the destination
            newDestination.RouteTasks.Add(routeTask);

            if (destination is RouteDestination)
            {
                //Get the Destinations, Route
                var route = ((RouteDestination)destination).Route;

                //Add the new destination to the Route
                route.RouteDestinationsListWrapper.Insert(placeInRoute, newDestination);
                //TODO:add analytic
            }
            if (destination is Route)
            {
                //Add the new destination to the Route
                ((Route)destination).RouteDestinationsListWrapper.Insert(placeInRoute, newDestination);
                //TODO:add analytic
            }
        }
Esempio n. 5
0
        /// <summary>
        /// Adds the route task to a route in the correct destination. This also redirects to another method which will actually add it to the correct place
        /// </summary>
        /// <param name="routeTask">The route task.</param>
        /// <param name="destination">The destination.</param>
        /// <param name="placeInRoute">The place in route.</param>
        /// <param name="dropPlacement">The drop placement.</param>
        public static void AddRouteTaskToRoute(RouteTask routeTask, object destination, int placeInRoute, DropPlacement dropPlacement)
        {
            //Set RouteTask's Status to Routed
            //routeTask.Status = Status.Routed;

            //IF the drag destination is a RouteTask, add the draggedItem to that RouteTask
            var routeTaskDestination = destination as RouteTask;

            if (routeTaskDestination != null)
            {
                AddToRouteTask(routeTaskDestination, routeTask, dropPlacement);
                //TODO:add analytic

                //No need to do any of the other logic below, skip to the next iteration of the loop
                return;
            }

            AddRouteTaskToDestinationOrRoute(routeTask, destination, placeInRoute, dropPlacement);
            //TODO:add analytic
        }
Esempio n. 6
0
        /// <summary>
        /// Finds placeInRoute based on destination of the drop and the dropPlacement found earlier.
        /// </summary>
        /// <param name="destination">The destination.</param>
        /// <param name="dropPlacement">The drop placement.</param>
        /// <returns>The index that the object will be dropped at</returns>
        public static int GetDropPlacement(object destination, DropPlacement dropPlacement)
        {
            var placeInRoute = 0;

            if (destination is Route)
            {
                placeInRoute = ((Route)destination).RouteDestinationsListWrapper.Count;

                //Telerik does not allow you to drop above the root node in RadTreeView
                //We also know that the only time you could possibly drop into a Route and meet the condition below will be
                //if you try to drop above the root node. Therfore, if this occurs,
                //we reset placeInRoute to '0' so the drop occurs where the user anticipated 
                if (dropPlacement == DropPlacement.None || dropPlacement == DropPlacement.In)
                    placeInRoute = 0;
            }

            if (destination is RouteDestination || destination is RouteTask)
                placeInRoute =
                        destination is RouteDestination
                    //Choose the RouteDestination's OrderInRoute
                            ? ((RouteDestination)destination).OrderInRoute
                    //Choose the RouteTasks parent RouteDestination's OrderInRoute
                            : ((RouteTask)destination).RouteDestination.OrderInRoute;


            return placeInRoute;
        }