Inheritance: Caliburn.Micro.PropertyChangedBase
Beispiel #1
0
        private void UpdateState(PhaseState phase)
        {
            // Clear computations
            foreach (var threat in phase.Threats)
            {
                threat.InfluencedBy.Clear();
                threat.CombinedEffects.Clear();
            }
            foreach (var measure in phase.Measures)
            {
                measure.Influences.Clear();
                measure.CombinedEffects.Clear();
            }

            // Determine which measure influences which threat (and vice versa)
            foreach (var measure in phase.Measures)
            {
                if (measure.InfluenceRadiusInMeter <= 0) continue;
                foreach (var threat in phase.Threats)
                {
                    var overlap = threat.Effects.Select(effect => effect.Name).Intersect(measure.Effects.Select(effect => effect.Name)).Any();
                    if (!overlap) continue;
                    //var distanceInMeter = CoordinateUtils.Distance(measure.Position.Latitude, measure.Position.Longitude, threat.Position.Latitude, threat.Position.Longitude) * 1000;
                    //if (distanceInMeter > measure.InfluenceRadiusInMeter) continue;
                    //var relPoint = new Point(threat.Position.Longitude - measure.Position.Longitude, threat.Position.Latitude - measure.Position.Latitude);
                    if (!isInArcSegment(measure.Position, threat.Position, measure.StartAngleInDegree, measure.EndAngleInDegree, measure.InfluenceRadiusInMeter)) continue;
                    threat.InfluencedBy.Add(measure);
                    measure.Influences.Add(threat);
                }
            }
            // Compute the effects of this influence: threat is reduced, measure effectiveness is increased, labels are updated
            foreach (var threat in phase.Threats)
            {
                foreach (var threatEffect in threat.Effects)
                {
                    var combinedEffect = new EffectState(threatEffect.Name);
                    combinedEffect.AddEffectState(threatEffect);
                    foreach (var measure in threat.InfluencedBy)
                    {
                        foreach (var measureEffect in measure.Effects)
                        {
                            combinedEffect.SubtractEffectState(measureEffect);
                        }
                    }
                    threat.CombinedEffects.Add(combinedEffect);
                    updateThreatVisualisation(threat);
                }

                // For this phase, compute the combined threat
                foreach (var ce in threat.CombinedEffects)
                {
                    if (!phase.threatStates.ContainsKey(ce.Name)) phase.threatStates[ce.Name] = ce;
                    else phase.threatStates[ce.Name].AddEffectState(ce);
                }
            }
            foreach (var measure in phase.Measures)
            {
                // For this phase, compute the combined effect
                foreach (var ce in measure.Effects)
                {
                    if (!phase.measureStates.ContainsKey(ce.Name)) phase.measureStates[ce.Name] = ce;
                    else phase.measureStates[ce.Name].AddEffectState(ce);
                }
            }
        }
 private void TrySetSelectedPhase()
 {
     if (!string.IsNullOrEmpty(selectedPhaseTitle))
     {
         foreach (var phase in Phases)
         {
             if (!string.Equals(phase.Title, selectedPhaseTitle)) continue;
             selectedPhase = phase;
             selectedPhase.Activate();
             return;
         }
     }
     if (Phases.Count > 0)
     {
         selectedPhase = Phases[0];
         selectedPhase.Activate();
     }
 }