Exemplo n.º 1
0
 /// <summary>
 /// Updates lists of objects to back up.
 /// </summary>
 public void Update()
 {
     teams = new List <Team>(Team.getTeamList());
     activeInterventions    = new List <Intervention>(Intervention.getActiveInterventionList());
     completedInterventions = new List <Intervention>(Intervention.getCompletedInterventionList());
     equipments             = new List <Equipment>(Equipment.getEquipmentList());
 }
        //Called when a field on the intervention page was modified
        public void Update()
        {
            foreach (InterventionFormPage form in pages)
            {
                form.DeregisterFormFromObserver();
            }
            pages.Clear();
            InterventionsList.Children.Clear();

            foreach (Intervention intervention in Intervention.getActiveInterventionList())
            {
                Frame frame = new Frame();
                InterventionFormPage form = new InterventionFormPage(this, intervention);
                pages.Add(form);
                frame.Content = form;
                frame.Name    = "Intervention_" + form.getInterventionNumber();
                frame.Tag     = "Ongoing";
                if (!InterventionFilterLabel.Content.Equals(ETD.Properties.Resources.Label_InterventionFilterOngoing))
                {
                    frame.Visibility = Visibility.Collapsed;
                }
                InterventionsList.Children.Add(frame);
            }

            foreach (Intervention intervention in Intervention.getCompletedInterventionList())
            {
                Frame frame = new Frame();
                InterventionFormPage form = new InterventionFormPage(this, intervention);
                frame.Content = form;
                frame.Name    = "Intervention_" + form.getInterventionNumber();
                frame.Tag     = "Completed";
                if (!InterventionFilterLabel.Content.Equals(ETD.Properties.Resources.Label_InterventionFilterCompleted))
                {
                    frame.Visibility = Visibility.Collapsed;
                }
                InterventionsList.Children.Add(frame);
            }
        }
Exemplo n.º 3
0
        //Callback when any of the observed objects modified i.e. creation and addition of all pins (including new pins, excluding deleted pins)
        public void Update()
        {
            Pin.ClearAllPins(Canvas_map);             //Clearing all pins from the map

            //Creating all team pins and adding the map to their previous or a new position while detecting newly created collisions
            foreach (Team team in Team.getTeamList())
            {
                TeamPin teamPin = new TeamPin(team, this);
                Canvas_map.Children.Add(teamPin);

                //Redrawing arrow if the pin has one
                if (Pin.getPinArrow(team) != null && GPSServices.connectedToServer && teamPin.gpsLocation.PhoneOnline())
                {
                    Pin.getPinArrow(team).DisplayArrow();
                }

                //Setting the pin to it's previous position, if it exists, or to the top-left corner
                bool     ignoreSpecialCollisions = false;
                double[] previousPinPosition     = Pin.getPreviousPinPosition(team);
                if (previousPinPosition == null)
                {
                    ignoreSpecialCollisions = true;
                    previousPinPosition     = new double[] { teamPin.Width / 2, teamPin.Height / 2 };                //Top-left corner
                }
                teamPin.setPinPosition(previousPinPosition[0], previousPinPosition[1]);
                teamPin.CollisionDetectionAndResolution(ignoreSpecialCollisions);
            }

            //Creating team fragments when a team is split
            foreach (Team team in Team.getSplitTeamList())
            {
                TeamPin parentTeamPin = null;
                foreach (Team parentTeam in Team.getTeamList())
                {
                    if (team.getID() == parentTeam.getID())
                    {
                        foreach (Pin pin in Pin.getPinList())
                        {
                            if (pin.relatedObject == parentTeam)
                            {
                                parentTeamPin = (TeamPin)pin;
                                break;
                            }
                        }
                        break;
                    }
                }

                TeamPin teamPin = new TeamPin(team, this, parentTeamPin);
                Canvas_map.Children.Add(teamPin);

                //Setting the pin to it's previous position, if it exists, or to the top-left corner
                bool     ignoreSpecialCollisions = false;
                double[] previousPinPosition     = Pin.getPreviousPinPosition(team);
                if (previousPinPosition == null)
                {
                    ignoreSpecialCollisions = true;
                    previousPinPosition     = new double[] { teamPin.Width / 2, teamPin.Height / 2 }; //Top-left corner
                }
                teamPin.setPinPosition(previousPinPosition[0], previousPinPosition[1]);
                teamPin.CollisionDetectionAndResolution(ignoreSpecialCollisions);
            }

            //Creating all intervention pins and adding the map to their previous or a new position while detecting newly created collisions
            foreach (Intervention intervention in Intervention.getActiveInterventionList())
            {
                InterventionPin interventionPin = new InterventionPin(intervention, this);
                Canvas_map.Children.Add(interventionPin);

                //Redrawing arrow if the pin has one
                if (Pin.getPinArrow(intervention) != null && GPSServices.connectedToServer && interventionPin.gpsLocation != null && interventionPin.gpsLocation.PhoneOnline())
                {
                    Pin.getPinArrow(intervention).DisplayArrow();
                }

                //Setting the pin to it's previous position, if it exists, or to the top-left corner
                bool     ignoreSpecialCollisions = false;
                double[] previousPinPosition     = Pin.getPreviousPinPosition(intervention);
                if (previousPinPosition == null)
                {
                    ignoreSpecialCollisions = true;
                    previousPinPosition     = new double[] { (interventionPin.Width / 2), Canvas_map.ActualHeight - (interventionPin.Height / 2) };                 //Bottom-right corner
                }
                interventionPin.setPinPosition(previousPinPosition[0], previousPinPosition[1]);
                interventionPin.Update();
                interventionPin.CollisionDetectionAndResolution(ignoreSpecialCollisions);
            }

            //Creating all equipment pins and adding the map to their previous or a new position while detecting newly created collisions
            foreach (Equipment equipment in Equipment.getEquipmentList())
            {
                if (!equipment.IsAssigned())
                {
                    EquipmentPin equipmentPin = new EquipmentPin(equipment, this);
                    Canvas_map.Children.Add(equipmentPin);

                    //Setting the pin to it's previous position, if it exists, or to the top-left corner
                    bool     ignoreSpecialCollisions = true;
                    double[] previousPinPosition     = Pin.getPreviousPinPosition(equipment);
                    if (previousPinPosition == null)
                    {
                        previousPinPosition = new double[] { Canvas_map.ActualWidth - (equipmentPin.Width / 2), (equipmentPin.Height / 2) };                         //Top-right corner
                    }
                    equipmentPin.setPinPosition(previousPinPosition[0], previousPinPosition[1]);
                    equipmentPin.CollisionDetectionAndResolution(ignoreSpecialCollisions);
                }
            }
        }