internal void RaiseTestEvent() { try { String newSystem; if (Program.actualCondition.System == "Eravate") { newSystem = "Pai Huldr"; } else { newSystem = "Eravate"; } Program.actualCondition.System = newSystem; Program.actualCondition.Location = ""; var LI = new LocationInfoEventArgs() { System = Program.actualCondition.System, Location = Program.actualCondition.Location }; LocationInfo.Raise(this, LI); var EA = new LocationChangedEventArgs() { System = Program.actualCondition.System, Location = Program.actualCondition.Location, OldSystem = Program.actualCondition.System, OldLocation = Program.actualCondition.Location, Changed = enLogEvents.Jump | enLogEvents.System }; LocationChanged.Raise(this, EA); } catch (Exception ex) { throw new Exception("Error in RaiseEvent", ex); } }
/// <summary> /// processing the collected informations /// </summary> /// <param name="LoggedEvents"></param> private void processingLocationInfo(List <LogEvent> LoggedEvents) { //Boolean SystemHasChanged = false; //Boolean LocationHasChanged = false; String OldSystemString; String OldLocationString; String foundSystemString; String foundLocationString; enLogEvents EventFlags = enLogEvents.None; Point3Dbl usePosition = null; try { if (LoggedEvents.Count() > 0) { // order by date LoggedEvents = LoggedEvents.OrderBy(x => x.Time).ToList(); // scan sequence foreach (LogEvent Event in LoggedEvents) { OldSystemString = Program.actualCondition.System; OldLocationString = Program.actualCondition.Location; EventFlags = enLogEvents.None; usePosition = null; foundSystemString = ""; foundLocationString = ""; switch (Event.EventType) { case enLogEvents.Jump: // after a jump we are no longer on a station if (!m_InitialJumpFound) { // it's only the "startjump" of ED, not really a jump m_InitialJumpFound = true; Program.DBCon.setIniValue(DB_GROUPNAME, "InitialJumpFound", m_InitialJumpFound.ToString()); } else { if (!String.IsNullOrEmpty(OldLocationString)) { EventFlags |= enLogEvents.Location; foundLocationString = Event.Value; } EventFlags |= enLogEvents.Jump; Debug.Print("log - scanning : jump found"); } break; case enLogEvents.System: // a new system is everytime valid, check if the system has changed if ((Event.Value != "") && (!Event.Value.Equals(OldSystemString, StringComparison.InvariantCultureIgnoreCase))) { EventFlags |= enLogEvents.System; foundSystemString = Event.Value; usePosition = Event.Position; // after a jump we are no longer on a station if (!String.IsNullOrEmpty(OldLocationString)) { EventFlags |= enLogEvents.Location; foundLocationString = ""; } Debug.Print("log - scanning : system found : " + Event.Value); } break; case enLogEvents.Location: // a new station is everytime valid, check if the station has changed if ((Event.Value != "") && (!Event.Value.Equals(OldLocationString, StringComparison.InvariantCultureIgnoreCase))) { EventFlags |= enLogEvents.Location; foundLocationString = Event.Value; } Debug.Print("log - scanning : location found : " + Event.Value); break; } if (EventFlags != enLogEvents.None) { // something has changed -> fire events var LI = new LocationInfoEventArgs() { System = foundSystemString, Location = foundLocationString, Position = usePosition }; LocationInfo.Raise(this, LI); var EA = new LocationChangedEventArgs() { System = foundSystemString, Location = foundLocationString, OldSystem = OldSystemString, OldLocation = OldLocationString, Changed = EventFlags, Position = usePosition, TimeStamp = Event.Time }; LocationChanged.Raise(this, EA); } } } } catch (Exception ex) { throw new Exception("Error while processing location info", ex); } }