コード例 #1
0
        void LoadInstrumentCurrency()
        {
            var             section = new Section("Instrument Currency");
            List <Aircraft> list;

            // Instrument currency is per-AircraftCategory
            if (LogBook.Pilot.InstrumentRatings.HasFlag(InstrumentRating.Airplane))
            {
                list = LogBook.GetAircraft(AircraftCategory.Airplane, false);
                AddInstrumentCurrency(section, "Airplane", list);
            }

            if (LogBook.Pilot.InstrumentRatings.HasFlag(InstrumentRating.Helicopter))
            {
                list = LogBook.GetAircraft(AircraftClassification.Helicoptor, false);
                AddInstrumentCurrency(section, "Helicopter", list);
            }

            if (LogBook.Pilot.InstrumentRatings.HasFlag(InstrumentRating.PoweredLift))
            {
                list = LogBook.GetAircraft(AircraftClassification.PoweredLift, false);
                AddInstrumentCurrency(section, "Powered-Lift", list);
            }

            if (section.Count > 0)
            {
                Root.Add(section);
            }
        }
コード例 #2
0
        void LoadDayAndNightCurrency()
        {
            if (LogBook.Pilot.Endorsements.HasFlag(AircraftEndorsement.TailDragger))
            {
                var list         = LogBook.GetAircraft(AircraftCategory.Airplane, false);
                var taildraggers = new List <Aircraft> ();

                foreach (var aircraft in list)
                {
                    if (aircraft.IsTailDragger)
                    {
                        taildraggers.Add(aircraft);
                    }
                }

                var section = new Section("Taildragger Currency");
                AddLandingCurrency(section, taildraggers, false);
                AddLandingCurrency(section, taildraggers, true);
                Root.Add(section);
            }

            // Day/Night currency is per-AircraftClassification
            foreach (AircraftClassification @class in Enum.GetValues(typeof(AircraftClassification)))
            {
                AircraftCategory    category = Aircraft.GetCategoryFromClass(@class);
                AircraftEndorsement endorsement;

                if (!Enum.TryParse <AircraftEndorsement> (@class.ToString(), out endorsement))
                {
                    continue;
                }

                if (!LogBook.Pilot.Endorsements.HasFlag(endorsement))
                {
                    continue;
                }

                var    list = LogBook.GetAircraft(@class, false);
                string caption;

                if (category == AircraftCategory.Airplane)
                {
                    caption = "Airplane " + @class.ToHumanReadableName();
                }
                else
                {
                    caption = @class.ToHumanReadableName();
                }

                var section = new Section(string.Format("{0} Currency", caption));
                AddLandingCurrency(section, list, false);
                AddLandingCurrency(section, list, true);
                Root.Add(section);
            }
        }
コード例 #3
0
        void LoadDayAndNightCurrency()
        {
            // Day/Night currency is per-AircraftClassification and TailDragger vs not.
            foreach (var value in Enum.GetValues(typeof(AircraftClassification)))
            {
                AircraftClassification @class = (AircraftClassification)value;

                List <Aircraft> list = LogBook.GetAircraft(@class, false);
                if (list == null || list.Count == 0)
                {
                    continue;
                }

                AircraftCategory category = Aircraft.GetCategoryFromClass(@class);
                Section          section;
                string           caption;

                if (category == AircraftCategory.Airplane)
                {
                    caption = string.Format("{0} {1}", category.ToHumanReadableName(), @class.ToHumanReadableName());
                }
                else
                {
                    caption = @class.ToHumanReadableName();
                }

                section = new Section(caption);

                // Only Airplanes can be tail-draggers
                if (category == AircraftCategory.Airplane)
                {
                    List <Aircraft> taildraggers = new List <Aircraft> ();
                    foreach (var aircraft in list)
                    {
                        if (aircraft.IsTailDragger)
                        {
                            taildraggers.Add(aircraft);
                        }
                    }

                    if (taildraggers.Count > 0)
                    {
                        AddLandingCurrency(section, taildraggers, @class, false, true);
                        AddLandingCurrency(section, taildraggers, @class, true, true);
                    }
                }

                AddLandingCurrency(section, list, @class, false, false);
                AddLandingCurrency(section, list, @class, true, false);

                Root.Add(section);
            }
        }
コード例 #4
0
        public override void ViewWillAppear(bool animated)
        {
            base.ViewWillAppear(animated);

            if (aircraft == null)
            {
                List <Aircraft> list = LogBook.GetAircraft(1);
                aircraft = list != null && list.Count > 0 ? list[0] : null;
            }

            if (aircraft != null)
            {
                UpdateDetails();
            }
        }
コード例 #5
0
        void LoadInstrumentCurrency()
        {
            // Instrument currency is per-AircraftCategory
            foreach (var value in Enum.GetValues(typeof(AircraftCategory)))
            {
                AircraftCategory category = (AircraftCategory)value;
                List <Aircraft>  list     = LogBook.GetAircraft(category, false);
                if (list == null || list.Count == 0)
                {
                    continue;
                }

                Section section = new Section(category.ToHumanReadableName());
                AddInstrumentCurrency(section, list, category);
                Root.Add(section);
            }
        }
コード例 #6
0
        void OnFlightTimeEntered(object sender, EventArgs e)
        {
            int seconds = total.ValueAsSeconds;

            if (autoFlightTimes)
            {
                if (certification == PilotCertification.Student)
                {
                    dual.ValueAsSeconds = seconds;
                }
                else
                {
                    pic.ValueAsSeconds = seconds;
                }

                var    craft    = LogBook.GetAircraft(aircraft.Value);
                double minimum  = GetMinimumCrossCountryDistance(craft);
                var    airports = GetAirports();

                if (airports != null && IsCrossCountry(airports, minimum))
                {
                    xc.ValueAsSeconds = seconds;
                }
            }

            // Cap the time limit for each of the time-based entry elements to the total time.
            simulator.MaxValueAsSeconds = seconds;
            actual.MaxValueAsSeconds    = seconds;
            hood.MaxValueAsSeconds      = seconds;
            night.MaxValueAsSeconds     = seconds;
            dual.MaxValueAsSeconds      = seconds;
            cfi.MaxValueAsSeconds       = seconds;
            pic.MaxValueAsSeconds       = seconds;
            sic.MaxValueAsSeconds       = seconds;
            xc.MaxValueAsSeconds        = seconds;
        }
コード例 #7
0
            public override void Draw(RectangleF area)
            {
                UIColor   textColor, airportColor, aircraftColor, remarksColor;
                CGContext ctx         = UIGraphics.GetCurrentContext();
                bool      highlighted = cell.Selected;
                var       bounds      = Bounds;
                var       midx        = bounds.Width / 2;

                if (highlighted)
                {
                    UIColor.FromRGB(4, 0x79, 0xef).SetColor();
                    ctx.FillRect(bounds);
                    //Images.MenuShadow.Draw (bounds, CGBlendMode.Normal, 0.5f);
                    aircraftColor = UIColor.White;
                    airportColor  = UIColor.White;
                    remarksColor  = UIColor.White;
                    textColor     = UIColor.White;
                }
                else
                {
                    UIColor.White.SetColor();
                    ctx.FillRect(bounds);
                    ctx.DrawLinearGradient(BottomGradient, new PointF(midx, bounds.Height - 17), new PointF(midx, bounds.Height), 0);
                    ctx.DrawLinearGradient(TopGradient, new PointF(midx, 1), new PointF(midx, 3), 0);
                    aircraftColor = AircraftColor;
                    airportColor  = AirportColor;
                    remarksColor  = RemarksColor;
                    textColor     = UIColor.Black;
                }

                UIImage image = CalendarImageForDate(Flight.Date);

                image.Draw(new RectangleF(new PointF(bounds.X + ImagePadding, bounds.Y + ImagePadding), image.Size));

                float      width = bounds.Width - (ImagePadding + image.Size.Width + TextPadding * 2);
                float      x     = bounds.X + ImagePadding + image.Size.Width + TextPadding;
                float      y     = bounds.Y + AirportYOffset;
                RectangleF rect;
                SizeF      size;

                if (flight.AirportDeparted != null || flight.AirportArrived != null)
                {
                    // Render the departed airport
                    airportColor.SetColor();
                    rect = new RectangleF(x, y, width, AirportFontSize);
                    if (flight.AirportDeparted != null)
                    {
                        size = DrawString(Flight.AirportDeparted, rect, AirportFont, UILineBreakMode.TailTruncation, UITextAlignment.Left);
                    }
                    else
                    {
                        size = DrawString(Flight.AirportArrived, rect, AirportFont, UILineBreakMode.TailTruncation, UITextAlignment.Left);
                    }
                    width -= size.Width;
                    x     += size.Width;

                    if (flight.AirportArrived != null)
                    {
                        // Render the '-' between the departed and arrived airports
                        textColor.SetColor();
                        rect   = new RectangleF(x, y, width, AirportFontSize);
                        size   = DrawString("-", rect, AirportFont, UILineBreakMode.TailTruncation, UITextAlignment.Left);
                        width -= size.Width;
                        x     += size.Width;

                        // Render the arrived airport
                        airportColor.SetColor();
                        rect   = new RectangleF(x, y, width, AirportFontSize);
                        size   = DrawString(Flight.AirportArrived, rect, AirportFont, UILineBreakMode.TailTruncation, UITextAlignment.Left);
                        width -= size.Width;
                        x     += size.Width;
                    }

                    // Render any additional airports visited
                    if (flight.AirportVisited != null)
                    {
                        var visited = flight.AirportVisited.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);

                        for (int i = 0; i < visited.Length; i++)
                        {
                            string prefix = i == 0 ? " via " : ", ";

                            textColor.SetColor();
                            rect   = new RectangleF(x, bounds.Y + ViaYOffset, width, ViaFontSize);
                            size   = DrawString(prefix, rect, ViaFont, UILineBreakMode.TailTruncation, UITextAlignment.Left);
                            width -= size.Width;
                            x     += size.Width;

                            airportColor.SetColor();
                            rect   = new RectangleF(x, bounds.Y + ViaYOffset, width, ViaFontSize);
                            size   = DrawString(visited[i], rect, ViaBoldFont, UILineBreakMode.TailTruncation, UITextAlignment.Left);
                            width -= size.Width;
                            x     += size.Width;
                        }
                    }
                }

                // Move down onto the next line (to render the aircraft info)
                width = bounds.Width - (ImagePadding + image.Size.Width + TextPadding * 2);
                x     = bounds.X + ImagePadding + image.Size.Width + TextPadding;
                y     = bounds.Y + AircraftYOffset;

                // Render the Aircraft tail number
                aircraftColor.SetColor();
                rect   = new RectangleF(x, y, width, AircraftFontSize);
                size   = DrawString(Flight.Aircraft, rect, AircraftFont, UILineBreakMode.TailTruncation, UITextAlignment.Left);
                width -= size.Width;
                x     += size.Width;

                // Render the Aircraft model
                Aircraft aircraft = LogBook.GetAircraft(Flight.Aircraft);

                if (aircraft != null && aircraft.Model != null)
                {
                    width -= TextPadding;
                    x     += TextPadding;
                    textColor.SetColor();
                    rect   = new RectangleF(x, y, width, AircraftFontSize);
                    size   = DrawString(aircraft.Model, rect, ModelFont, UILineBreakMode.TailTruncation, UITextAlignment.Left);
                    width -= size.Width;
                    x     += size.Width;
                }

                // Render the Flight Time
                textColor.SetColor();
                width -= TextPadding;
                x     += TextPadding;
                rect   = new RectangleF(x, y, width, AircraftFontSize);
                size   = DrawString(FormatFlightTime(Flight.FlightTime), rect, ModelFont, UILineBreakMode.TailTruncation,
                                    UITextAlignment.Right);
                width -= size.Width;
                x     += size.Width;

                // Move down onto the next line (to render the remarks)
                width = bounds.Width - (ImagePadding + image.Size.Width + TextPadding * 2);
                x     = bounds.X + ImagePadding + image.Size.Width + TextPadding;
                y     = bounds.Y + RemarksYOffset;

                // Render the remarks
                if (Flight.Remarks != null)
                {
                    remarksColor.SetColor();
                    rect   = new RectangleF(x, y, width, RemarksFontSize);
                    size   = DrawString(Flight.Remarks, rect, RemarksFont, UILineBreakMode.TailTruncation, UITextAlignment.Left);
                    width -= size.Width;
                    x     += size.Width;
                }
            }
コード例 #8
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;
            }

            // We need at least a departure airport
            var    missing  = new HashSet <string> ();
            var    airports = new List <Airport> ();
            var    via      = new List <string> ();
            string code;

            if ((code = GetAirportCode(departed.Value, airports, missing)) == null)
            {
                return;
            }

            // Save the values back to the Flight record
            Flight.AirportDeparted = code;

            foreach (var airport in visited)
            {
                if (string.IsNullOrEmpty(airport.Value))
                {
                    continue;
                }

                code = GetAirportCode(airport.Value, airports, missing);
                via.Add(code);
            }

            if (via.Count > 0)
            {
                Flight.AirportVisited = string.Join(", ", via);
            }
            else
            {
                Flight.AirportVisited = null;
            }

            Flight.AirportArrived = GetAirportCode(arrived.Value, airports, missing);
            if (Flight.AirportArrived == null)
            {
                Flight.AirportArrived = Flight.AirportDeparted;
            }

            Flight.Date     = date.DateValue;
            Flight.Aircraft = aircraft.Value;

            // Flight Time values
            Flight.FlightTime = total.ValueAsSeconds;
            Flight.CertifiedFlightInstructor = cfi.ValueAsSeconds;
            Flight.SecondInCommand           = sic.ValueAsSeconds;
            Flight.PilotInCommand            = pic.ValueAsSeconds;
            Flight.DualReceived = dual.ValueAsSeconds;
            Flight.CrossCountry = xc.ValueAsSeconds;
            Flight.Night        = night.ValueAsSeconds;

            // Landings
            Flight.NightLandings = landNight.Value;
            Flight.DayLandings   = landDay.Value;

            // Flight Time values
            Flight.InstrumentSimulator = simulator.ValueAsSeconds;
            Flight.InstrumentActual    = actual.ValueAsSeconds;
            Flight.InstrumentHood      = hood.ValueAsSeconds;

            // Holding Procedures and Approaches
            Flight.InstrumentHoldingProcedures = holds.Value;
            Flight.InstrumentApproaches        = approaches.Value;

            // Safety Pilot info
            Flight.InstrumentSafetyPilot = safetyPilot.Value;

            if (Flight.InstrumentSimulator == 0)
            {
                Flight.Day = Flight.FlightTime - Flight.Night;
            }
            else
            {
                Flight.Day = 0;
            }

            // Remarks
            Flight.Remarks = remarks.Value;

            // Verify that the flight was really cross-country.
            var    craft   = LogBook.GetAircraft(Flight.Aircraft);
            double minimum = GetMinimumCrossCountryDistance(craft);

            if (Flight.CrossCountry > 0 && !IsCrossCountry(airports, minimum))
            {
                ShowCrossCountryAlert(craft, Flight.AirportDeparted, missing, minimum);
                return;
            }

            SaveAndClose();
        }