Exemple #1
0
        void OnSaveClicked(object sender, EventArgs args)
        {
            FetchValues();

            // Don't let the user save if the info is incomplete
            if (aircraft.Value == null || aircraft.Value.Length < 2)
            {
                return;
            }

            // Save the values back to the Flight record
            Flight.Date            = date.DateValue;
            Flight.Aircraft        = aircraft.Value;
            Flight.AirportDeparted = departed.Value;
            Flight.AirportVisited1 = visited1.Value;
            Flight.AirportVisited2 = visited2.Value;
            Flight.AirportVisited3 = visited3.Value;
            Flight.AirportArrived  = arrived.Value;

            if (Flight.AirportArrived == null)
            {
                Flight.AirportArrived = Flight.AirportDeparted;
            }

            // Flight Time values
            Flight.FlightTime = total.ValueAsSeconds;
            Flight.CertifiedFlightInstructor = cfi.ValueAsSeconds;
            Flight.InstrumentSimulator       = simulator.ValueAsSeconds;
            Flight.InstrumentActual          = actual.ValueAsSeconds;
            Flight.InstrumentHood            = hood.ValueAsSeconds;
            Flight.SecondInCommand           = sic.ValueAsSeconds;
            Flight.PilotInCommand            = pic.ValueAsSeconds;
            Flight.DualReceived = dual.ValueAsSeconds;
            Flight.CrossCountry = xc.ValueAsSeconds;
            Flight.Night        = night.ValueAsSeconds;

            Flight.Day = Flight.FlightTime - Flight.Night;

            // Landings and Approaches
            Flight.InstrumentApproaches = approaches.Value;
            Flight.NightLandings        = landNight.Value;
            Flight.DayLandings          = landDay.Value;

            // Remarks
            Flight.Remarks = remarks.Value;

            if (exists)
            {
                LogBook.Update(Flight);
            }
            else
            {
                LogBook.Add(Flight);
            }

            NavigationController.PopViewControllerAnimated(true);

            OnEditorClosed();
        }
Exemple #2
0
        void OnSaveClicked(object sender, EventArgs args)
        {
            if (profile.TailNumber == null || profile.TailNumber.Length < 2)
            {
                return;
            }

            if (profile.Photograph != null)
            {
                UIImage thumbnail;
                NSError error;

                if (!PhotoManager.Save(profile.TailNumber, profile.Photograph, false, out error))
                {
                    var alert = new UIAlertView("Error", error.LocalizedDescription, null, "Dismiss", null);
                    alert.Show();
                    return;
                }

                thumbnail = PhotoManager.ScaleToSize(profile.Photograph, 96, 72);
                PhotoManager.Save(profile.TailNumber, thumbnail, true, out error);
                // Note: we don't dispose the thumbnail because it has been added to the cache.
                thumbnail = null;
            }

            // Save the values back to the Aircraft object
            Aircraft.TailNumber        = profile.TailNumber;
            Aircraft.Make              = profile.Make;
            Aircraft.Model             = profile.Model;
            Aircraft.Classification    = ClassificationFromIndexes(category.RadioSelected, classes.Selected);
            Aircraft.IsComplex         = isComplex.Value;
            Aircraft.IsHighPerformance = isHighPerformance.Value;
            Aircraft.IsTailDragger     = isTailDragger.Value;
            Aircraft.IsSimulator       = isSimulator.Value;
            Aircraft.Notes             = notes.Value;

            // We'll treat this as a special case for now...
            if (Aircraft.Make == null && Aircraft.IsSimulator)
            {
                Aircraft.Make = "Simulator";
            }

            if (exists)
            {
                LogBook.Update(Aircraft);
            }
            else
            {
                LogBook.Add(Aircraft);
            }

            NavigationController.PopViewControllerAnimated(true);

            OnEditorClosed();
        }
Exemple #3
0
        void SaveAndClose()
        {
            if (exists)
            {
                LogBook.Update(Flight);
            }
            else
            {
                LogBook.Add(Flight);
            }

            NavigationController.PopViewControllerAnimated(true);

            OnEditorClosed();
        }
Exemple #4
0
        void Save()
        {
            var  cert         = (PilotCertification)certification.RadioSelected;
            var  endorsements = AircraftEndorsement.None;
            var  ratings      = InstrumentRating.None;
            bool changed      = false;
            int  flag         = 1 << 0;

            foreach (var section in this.endorsements)
            {
                foreach (var element in section)
                {
                    if (((BooleanElement)element).Value)
                    {
                        endorsements |= (AircraftEndorsement)flag;
                    }

                    flag <<= 1;
                }
            }

            if (aifr.Value)
            {
                ratings |= InstrumentRating.Airplane;
            }
            if (hifr.Value)
            {
                ratings |= InstrumentRating.Helicopter;
            }
            if (lifr.Value)
            {
                ratings |= InstrumentRating.PoweredLift;
            }

            if (Pilot.Certification != cert)
            {
                Pilot.Certification = cert;
                changed             = true;
            }

            if (Pilot.Endorsements != endorsements)
            {
                Pilot.Endorsements = endorsements;
                changed            = true;
            }

            if (Pilot.IsCertifiedFlightInstructor != cfi.Value)
            {
                Pilot.IsCertifiedFlightInstructor = cfi.Value;
                changed = true;
            }

            if (Pilot.InstrumentRatings != ratings)
            {
                Pilot.InstrumentRatings = ratings;
                changed = true;
            }

            if (Pilot.BirthDate != birthday.DateValue)
            {
                Pilot.BirthDate = birthday.DateValue;
                changed         = true;
            }

            if (Pilot.Name != name.Value)
            {
                Pilot.Name = name.Value;
                changed    = true;
            }

            if (Pilot.LastMedicalExam != medical.DateValue)
            {
                Pilot.LastMedicalExam = medical.DateValue;
                changed = true;
            }

            if (Pilot.LastFlightReview != review.DateValue)
            {
                Pilot.LastFlightReview = review.DateValue;
                changed = true;
            }

            if (changed)
            {
                LogBook.Update(Pilot);
            }
        }