예제 #1
0
        //Handle special collisions between a TeamPin and another pin
        internal override bool HandleSpecialCollisions(Pin fixedPin)
        {
            //SpecialCollision: Team is dropped on intervention, add team to intervention
            if (fixedPin.IsOfType("InterventionPin") && SufficientOverlap(fixedPin))
            {
                interventionPin = (InterventionPin)fixedPin;
                interventionPin.getIntervention().AddInterveningTeam(team);
                if (parentPin != null)               //Making sure that the intervention count of the parent team accounts for the interventions that the team fragment intervenes on
                {
                    parentPin.getTeam().incrementInterventionCount();
                }
                return(true);
            }

            //SpecialCollision: Collision detection between team and intervention container
            if (fixedPin.IsOfType("InterventionContainer"))
            {
                if (interventionPin != null && interventionPin.getInterveningTeamsPin().Contains(this))
                {
                    return(true);
                }
            }

            //If none of the conditions are true, return false
            return(false);
        }
예제 #2
0
파일: Pin.cs 프로젝트: zukoj/SOEN490-ETD
        //Constructor for Creating border pin
        public Pin(InterventionPin interventionPin, MapSectionPage mapSection)
        {
            this.relatedObject = interventionPin;
            this.mapSection    = mapSection;

            //Adding the border pin to the list of all pins
            pinList.Add(this);
        }
예제 #3
0
        public InterventionContainer(InterventionPin interventionPin, MapSectionPage mapSection) : base(interventionPin, mapSection)
        {
            this.interventionPin = interventionPin;
            this.Canvas_map      = mapSection.Canvas_map;

            //Creating border that defines the edge of the container
            Border border = new Border();

            border.BorderThickness = new Thickness(1);
            border.CornerRadius    = new CornerRadius(5);
            border.BorderBrush     = new SolidColorBrush(Colors.Red);
            this.Children.Add(border);
        }
예제 #4
0
        //Change the status to what the user has chosen
        private void ChangeStatus_Click(object sender, RoutedEventArgs e)
        {
            MenuItem menuItem = (MenuItem)sender;

            team.setStatus(getMenuItemStatus(menuItem));

            //Clearing the arrow if the team got to where they are going
            if (getMenuItemStatus(menuItem).Equals("available") || getMenuItemStatus(menuItem).Equals("intervening"))
            {
                RemoveArrow();
            }

            //Handling the case when the user sets the status of a team to intervening
            if (getMenuItemStatus(menuItem).Equals("intervening"))
            {
                //Handling the case of when the user sets a team to intervening but it is not assigned to an intervention yet. Create the new intervention and assign the team to it.
                if (interventionPin == null)
                {
                    Intervention intervention = new Intervention();

                    //Getting references to the new team and intervention pins
                    TeamPin         teamPin = null; //Need to get a reference to the new teamPin and not use "this" because the map has been redrawn upon the intervention creation, i.e. this TeamPin is outdated
                    InterventionPin relatedInterventionPin = null;
                    foreach (Pin pin in pinList)
                    {
                        if (pin.relatedObject == team)
                        {
                            teamPin = (TeamPin)pin;
                        }
                        if (pin.relatedObject == intervention)
                        {
                            relatedInterventionPin = (InterventionPin)pin;
                            break;
                        }
                    }

                    //Setting the position of the intervention to be the position of the team and calling collision detection on the teamPin for the team to be added to the intervention
                    relatedInterventionPin.setPinPosition(teamPin.getX(), teamPin.getY());
                    teamPin.CollisionDetectionAndResolution(false);
                    relatedInterventionPin.getIntervention().InterveningTeamArrived(team);
                }
                else
                {
                    //Set team as "In position" on the intervention
                    interventionPin.getIntervention().InterveningTeamArrived(team);
                }
            }
        }
예제 #5
0
 internal void setInterventionPin(InterventionPin interventionPin)
 {
     this.interventionPin = interventionPin;
 }
예제 #6
0
        //Override the default DragStop method to add functionality to it
        public override void DragStop(Canvas Canvas_map, MouseButtonEventArgs e)
        {
            //Merging teams
            if (parentPin != null && SufficientOverlap(parentPin)) //Want to merge
            {
                Team.removeSplitTeam(team);                        //Delete the fragment
                if (gpsLocation != null)
                {
                    gpsLocation.setTeamSplit(false);                     //Reactivationg gps
                }

                //Removing rogue arrows that might appear by movement of the teams or interventions while teams where split
                RemoveArrow();
                parentPin.RemoveArrow();
                if (interventionPin != null)
                {
                    interventionPin.RemoveArrow();
                }

                mapSection.Update();
            }

            //Identifying whether the user wants to split the team
            Intervention splitIntervention = null;

            if (team.getStatus().ToString().Equals("intervening"))
            {
                foreach (Pin pin in pinList)
                {
                    if (SufficientOverlap(pin) && pin.IsOfType("InterventionPin") && pin != interventionPin)
                    {
                        splitIntervention = ((InterventionPin)pin).getIntervention();
                        break;
                    }
                }
            }

            bool accidentalDrag = false;

            if (splitIntervention != null)
            {
                //Disabling GPS because of its unreliability when the team is split
                if (gpsLocation != null)
                {
                    gpsLocation.setTeamSplit(true);
                }

                //Creating team as a duplicate of the initial team, name it using the number of the intervention it is assigned to
                Team team2 = new Team(team);
                team2.setName(team.getName() + splitIntervention.getInterventionNumber());
                splitIntervention.AddInterveningTeam(team2); //Assigning split team onto the second intervention
                mapSection.Update();                         //Redrawing map so that the split team pin gets recreated with a pointer to the interventionPin it is assigned to
                return;
            }
            else if (interventionPin != null && interventionPin.getInterventionContainer() != null) //Handling the case when the team was in an intervention, choose between keeping it on the intervention (for an accidental drag-and-drop) or removing it from the intervention
            {
                if (SufficientOverlap(interventionPin.getInterventionContainer()))                  //Considered accidental drag-and-drop
                {
                    accidentalDrag = true;
                    interventionPin.getInterventionContainer().PlaceAll();
                }
                else //Remove team from intervention
                {
                    interventionPin.getIntervention().RemoveInterveningTeam(team);
                    interventionPin.SelectGPSLocation();
                    team.setStatus("unavailable");

                    //If it was the last team on that intervention and it has been removed, force redrawing of the map so that the InterventionContainer is removed
                    if (interventionPin.getInterveningTeamsPin().Count == 0)
                    {
                        mapSection.Update();
                        return;
                    }

                    interventionPin = null;
                }
            }
            else if (team.getStatus().ToString().Equals("available"))            //If the team was available and has been moved, set the team as moving
            {
                team.setStatus("moving");
            }

            base.DragStop(Canvas_map, e);

            //Handle situation when the TeamPin is tracked by GPS and the user moves it
            if (gpsLocation != null && GPSLocation.gpsConfigured == true && !accidentalDrag)
            {
                //Create and draw the arrow to the destination point and replace pin at current GPS position
                GPSPinDrop(GPSServices.connectedToServer && gpsLocation.PhoneOnline());
            }
        }