Esempio n. 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();
        }
Esempio n. 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();
        }
Esempio n. 3
0
        void SaveAndClose()
        {
            if (exists)
            {
                LogBook.Update(Flight);
            }
            else
            {
                LogBook.Add(Flight);
            }

            NavigationController.PopViewControllerAnimated(true);

            OnEditorClosed();
        }