Exemplo n.º 1
0
        static void OnSortTypeChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
        {
            VesselCollection me = sender as VesselCollection;

            if (me != null)
            {
                switch (me.SortType)
                {
                case VesselSortType.UniqueIDAscending:
                    VesselSort(me, CompareVesselsByIDAscending);
                    break;

                case VesselSortType.UniqueIDDescending:
                    VesselSort(me, CompareVesselsByIDDescending);
                    break;

                case VesselSortType.SideAscending:
                    VesselSort(me, CompareVesselsBySideAscending);
                    break;

                case VesselSortType.SideDescending:
                    VesselSort(me, CompareVesselsBySideDescending);
                    break;
                }
                me.SetChanged();
            }
        }
 //PerformValidation once data is loaded, and again when saving.
 public VesselDataObject()
 {
     Storage   = new List <XmlNode>();
     HullRaces = new HullRaceCollection();
     Vessels   = new VesselCollection();
     Version   = DataStrings.VesselDataCurrentVersion;
     HullRaces.ObjectChanged += new EventHandler(HullRaces_ObjectChanged);
     Vessels.ObjectChanged   += new EventHandler(Vessels_ObjectChanged);
 }
Exemplo n.º 3
0
 static void VesselSort(VesselCollection me, Comparison <Vessel> comparer)
 {
     if (me != null)
     {
         List <Vessel> vesselList = new List <Vessel>(me);
         vesselList.Sort(comparer);
         me.Clear();
         foreach (Vessel v in vesselList)
         {
             me.Add(v);
         }
     }
 }