Example #1
0
        /// <summary>
        /// Updates the system location of this contact. The 4 blocks of updates to the lists will, I hope, facilitate efficient updating of the binding list.
        /// </summary>
        /// <param name="system">new System.</param>
        public void UpdateSystem(StarSystem system)
        {
            CurrentSystem = system;

            DistanceTable.Clear();
            DistanceUpdate.Clear();

            DistanceTable.RaiseListChangedEvents  = false;
            DistanceUpdate.RaiseListChangedEvents = false;

            for (int loop = 0; loop < CurrentSystem.SystemContactList.Count; loop++)
            {
                DistanceTable.Add(0.0f);
                DistanceUpdate.Add(-1);
            }

            DistanceTable.RaiseListChangedEvents  = true;
            DistanceUpdate.RaiseListChangedEvents = true;

            /// <summary>
            /// BindingLists apparently do a bunch of events every time they are changed.
            /// This has hopefully circumvented that, with just 1 event.
            /// </summary>
            DistanceTable.ResetBindings();
            DistanceUpdate.ResetBindings();
        }
Example #2
0
 public override void OnReceive(Context context, Intent intent)
 {
     if (intent.Action == Message.Dist)
     {
         DistanceUpdate?.Invoke(this, new DistanceEventArgs(intent.GetDoubleExtra(Message.ValueKey, -1)));
     }
     if (intent.Action == Message.Dbg)
     {
         DebugUpdate?.Invoke(this, new MessageEventArgs(intent.GetStringExtra(Message.ValueKey)));
     }
     if (intent.Action == Message.Alarm)
     {
         AlarmUpdate?.Invoke(this, new MessageEventArgs(intent.GetStringExtra(Message.ValueKey)));
     }
 }