public EditAircraftDetailsViewController(Aircraft aircraft, bool exists)
     : base(UITableViewStyle.Grouped, new RootElement (null))
 {
     this.exists = exists;
     Aircraft = aircraft;
     Autorotate = false;
 }
Ejemplo n.º 2
0
 public AircraftElement(Aircraft aircraft)
     : base(null)
 {
     aircraft.Updated += OnAircraftUpdated;
     LogBook.FlightUpdated += OnFlightUpdated;
     LogBook.FlightDeleted += OnFlightDeleted;
     LogBook.FlightAdded += OnFlightAdded;
     Aircraft = aircraft;
 }
Ejemplo n.º 3
0
        /// <summary>
        /// Add the specified aircraft to the LogBook.
        /// </summary>
        /// <param name='aircraft'>
        /// The aircraft to add to the LogBook.
        /// </param>
        public static bool Add(Aircraft aircraft)
        {
            if (Contains (aircraft))
                return false;

            if (sqlitedb.Insert (aircraft) > 0) {
                OnAircraftAdded (aircraft);
                return true;
            }

            return false;
        }
Ejemplo n.º 4
0
 /// <summary>
 /// Gets a list of the logged flights flown with the specified aircraft since the specified date.
 /// </summary>
 /// <returns>
 /// A list of the logged flights flown with the specified aircraft since the specified date.
 /// </returns>
 /// <param name='aircraft'>
 /// The aircraft of interest.
 /// </param>
 /// <param name='since'>
 /// The start date.
 /// </param>
 public static List<Flight> GetFlights(Aircraft aircraft, DateTime since)
 {
     return sqlitedb.Query<Flight> ("select * from Flight where Aircraft = ? and Date >= ? order by Date desc",
         aircraft.TailNumber, since);
 }
Ejemplo n.º 5
0
        static void OnAircraftUpdateFailed(Aircraft aircraft)
        {
            var handler = AircraftUpdateFailed;

            if (handler != null)
                handler (null, new AircraftEventArgs (aircraft));
        }
Ejemplo n.º 6
0
 /// <summary>
 /// Determines whether the specified aircraft can be deleted.
 /// </summary>
 /// <returns>
 /// <c>true</c> if the specified aircraft can be deleted; otherwise, <c>false</c>.
 /// </returns>
 /// <param name='aircraft'>
 /// The aircraft to to delete.
 /// </param>
 public static bool CanDelete(Aircraft aircraft)
 {
     return sqlitedb.Query<Flight> ("select 1 from Flight where Aircraft = ?", aircraft.TailNumber).Count == 0;
 }
Ejemplo n.º 7
0
        /// <summary>
        /// Delete the specified aircraft from the LogBook.
        /// </summary>
        /// <param name='aircraft'>
        /// The aircraft to delete from the LogBook.
        /// </param>
        public static bool Delete(Aircraft aircraft)
        {
            if (!CanDelete (aircraft))
                return false;

            if (sqlitedb.Delete<Aircraft> (aircraft) > 0) {
                PhotoManager.Delete (aircraft.TailNumber);
                OnAircraftDeleted (aircraft);
                return true;
            }

            return false;
        }
        static double GetMinimumCrossCountryDistance(Aircraft aircraft)
        {
            if (aircraft != null) {
                // SportPilot + PoweredParachute = 15nm
                if (aircraft.Category == AircraftCategory.PoweredParachute)
                    return 15.0;

                // SportPilot = 25nm

                // Rotorcraft = 25nm
                if (aircraft.Category == AircraftCategory.Rotorcraft)
                    return 25.0;
            }

            return 50.0;
        }
        public override void LoadView()
        {
            base.LoadView ();

            if (Aircraft == null) {
                Aircraft = new Aircraft ();
                exists = false;
            }

            Title = exists ? Aircraft.TailNumber : "New Aircraft";

            profile = new EditAircraftProfileView (View.Bounds.Width);
            profile.Photograph = PhotoManager.Load (Aircraft.TailNumber, false);
            profile.TailNumber = Aircraft.TailNumber;
            profile.Model = Aircraft.Model;
            profile.Make = Aircraft.Make;

            Root.Add (CreateAircraftTypeSection ());
            Root.Add (new Section ("Notes") {
                (notes = new LimitedEntryElement (null, "Enter any additional notes about the aircraft here.",
                    Aircraft.Notes, 140)),
            });

            Root[0].HeaderView = profile;

            cancel = new UIBarButtonItem (UIBarButtonSystemItem.Cancel, OnCancelClicked);
            NavigationItem.LeftBarButtonItem = cancel;

            save = new UIBarButtonItem (UIBarButtonSystemItem.Save, OnSaveClicked);
            NavigationItem.RightBarButtonItem = save;
        }
Ejemplo n.º 10
0
        /// <summary>
        /// Enumerates the logged flights flown with the specified aircraft since the specified date.
        /// </summary>
        /// <returns>A list of the logged flights flown with the specified aircraft since the specified date.</returns>
        /// <param name="aircraft">The aircraft of interest.</param>
        /// <param name="since">The start date.</param>
        public static IEnumerable <Flight> GetFlights(Aircraft aircraft, DateTime since)
        {
            var query = "select * from Flight where Aircraft = ? and Date >= ?";

            return(EnumerateFlights(query, aircraft.TailNumber, since));
        }
Ejemplo n.º 11
0
        /// <summary>
        /// Update the specified aircraft.
        /// </summary>
        /// <param name='aircraft'>
        /// The aircraft to update.
        /// </param>
        public static bool Update(Aircraft aircraft)
        {
            if (sqlitedb.Update (aircraft) > 0) {
                aircraft.OnUpdated ();
                return true;
            }

            return false;
        }
Ejemplo n.º 12
0
 /// <summary>
 /// Checks whether or not the LogBook contains the specified aircraft.
 /// </summary>
 /// <returns><c>true</c> if the specified aircraft is already in the LogBook; otherwise, <c>false</c>.</returns>
 /// <param name="aircraft">The aircraft to check for.</param>
 public static bool Contains(Aircraft aircraft)
 {
     return(sqlitedb.Query <Flight> ("select 1 from Aircraft where TailNumber = ?", aircraft.TailNumber).Count == 1);
 }
Ejemplo n.º 13
0
        /// <summary>
        /// Enumerates the logged flights flown with the specified aircraft.
        /// </summary>
        /// <returns>A list of the logged flights flown with the specified aircraft.</returns>
        /// <param name="aircraft">The aircraft of interest.</param>
        public static IEnumerable <Flight> GetFlights(Aircraft aircraft)
        {
            var query = "select * from Flight where Aircraft = ?";

            return(EnumerateFlights(query, aircraft.TailNumber));
        }
Ejemplo n.º 14
0
 /// <summary>
 /// Determines whether the specified aircraft can be deleted.
 /// </summary>
 /// <returns><c>true</c> if the specified aircraft can be deleted; otherwise, <c>false</c>.</returns>
 /// <param name="aircraft">The aircraft to to delete.</param>
 public static bool CanDelete(Aircraft aircraft)
 {
     return(sqlitedb.Query <Flight> ("select 1 from Flight where Aircraft = ?", aircraft.TailNumber).Count == 0);
 }
Ejemplo n.º 15
0
 protected virtual void OnAircraftSelected(Aircraft aircraft)
 {
     details.Aircraft = aircraft;
 }
        void ShowCrossCountryAlert(Aircraft aircraft, string origin, HashSet<string> missing, double minimum)
        {
            var message = new StringBuilder ();
            string title = "Cross-Country Alert";
            int i = 0;

            if (aircraft == null) {
                message.AppendLine ("The classification of the aircraft you referenced is unknown.");
                message.AppendLine ();
                message.AppendLine ("Are you sure that this was a Cross-Country flight according to FAA regulations?");
            } else if (missing.Count > 0) {
                message.Append ("Could not verify that this flight was Cross-Country according to FAA regulations because ");

                if (missing.Count > 1)
                    message.Append ("the following airports are unknown: ");
                else
                    message.Append ("the following airport is unknown: ");

                foreach (var airport in missing) {
                    if (i > 0) {
                        if (i + 1 == missing.Count)
                            message.Append (" and ");
                        else
                            message.Append (", ");
                    }

                    message.Append (airport);
                    i++;
                }

                message.AppendLine (".");
                message.AppendLine ();

                if (missing.Count > 1)
                    message.AppendFormat ("Are any of these airports greater than {0} nautical miles from {1}?", minimum, origin);
                else
                    message.AppendFormat ("Is this airport greater than {0} nautical miles from {1}?", minimum, origin);

                message.AppendLine ();
            } else {
                message.AppendFormat ("None of the airports listed are greater than {0} nautical miles from {1}", minimum, origin);
                message.AppendLine ();
                message.AppendLine ();
                message.AppendLine ("Are you sure that this was a Cross-Country flight according to FAA regulations?");
            }

            del = new CrossCountryAlertDelegate (this);
            alert = new UIAlertView (title, message.ToString (), del, "No", "Yes");
            alert.Show ();
        }
Ejemplo n.º 17
0
        static int GetFlightTime(Aircraft aircraft)
        {
            int total = 0;

            foreach (Flight flight in LogBook.GetFlights (aircraft))
                total += flight.FlightTime;

            return total;
        }
 public EditAircraftDetailsViewController(Aircraft aircraft, bool exists) : base(UITableViewStyle.Grouped, new RootElement(null))
 {
     this.exists = exists;
     Aircraft    = aircraft;
     Autorotate  = false;
 }
Ejemplo n.º 19
0
        /// <summary>
        /// Delete the specified aircraft from the LogBook.
        /// </summary>
        /// <param name='aircraft'>
        /// The aircraft to delete from the LogBook.
        /// </param>
        public static bool Delete(Aircraft aircraft)
        {
            if (!CanDelete (aircraft))
                return false;

            PhotoManager.Delete (aircraft.TailNumber);

            return sqlitedb.Delete<Aircraft> (aircraft) > 0;
        }
        public void Edit(Aircraft aircraft, bool exists)
        {
            if (masterPopoverController != null)
                masterPopoverController.Dismiss (true);

            editor = new EditAircraftDetailsViewController (aircraft, exists);
            editor.EditorClosed += OnEditorClosed;

            NavigationController.PushViewController (editor, true);
        }
Ejemplo n.º 21
0
        void LoadFlightTimeTotals()
        {
            var totals          = new List <Totals> ();
            var twelveMonthsAgo = GetMonthsAgo(12);
            var sixMonthsAgo    = GetMonthsAgo(6);
            Dictionary <string, Aircraft> dict;
            Aircraft aircraft;
            int      time;

            dict = new Dictionary <string, Aircraft> ();
            foreach (var craft in LogBook.GetAllAircraft())
            {
                dict.Add(craft.TailNumber, craft);
            }

            totals.Add(new Totals("Flight Time Totals", FlightProperty.FlightTime));
            totals.Add(new Totals("Pilot-in-Command Totals", FlightProperty.PilotInCommand));
            totals.Add(new Totals("Certified Flight Instructor Totals", FlightProperty.CertifiedFlightInstructor));
            totals.Add(new Totals("Cross-Country Totals", FlightProperty.CrossCountry));
            totals.Add(new Totals("Cross-Country (PIC) Totals", FlightProperty.CrossCountryPIC));
            totals.Add(new Totals("Night Totals", FlightProperty.Night));
            totals.Add(new Totals("Instrument (Actual) Totals", FlightProperty.InstrumentActual));
            totals.Add(new Totals("Instrument (Hood) Totals", FlightProperty.InstrumentHood));

            if (LogBook.Pilot.Endorsements.HasFlag(AircraftEndorsement.Complex))
            {
                totals.Add(new Totals("Complex Totals", AircraftProperty.IsComplex));
            }
            if (LogBook.Pilot.Endorsements.HasFlag(AircraftEndorsement.HighPerformance))
            {
                totals.Add(new Totals("High-Performance Totals", AircraftProperty.IsHighPerformance));
            }
            if (LogBook.Pilot.Endorsements.HasFlag(AircraftEndorsement.TailDragger))
            {
                totals.Add(new Totals("Taildragger Totals", AircraftProperty.IsTailDragger));
            }

            foreach (AircraftClassification @class in Enum.GetValues(typeof(AircraftClassification)))
            {
                AircraftCategory category = Aircraft.GetCategoryFromClass(@class);
                string           title    = @class.ToHumanReadableName() + " Totals";

                if (category == AircraftCategory.Airplane)
                {
                    title = "Airplane " + title;
                }

                totals.Add(new Totals(title, @class));
            }

            foreach (var flight in LogBook.GetAllFlights())
            {
                if (!dict.TryGetValue(flight.Aircraft, out aircraft))
                {
                    continue;
                }

                if (aircraft.IsSimulator)
                {
                    continue;
                }

                foreach (var total in totals)
                {
                    if (total.Property is FlightProperty)
                    {
                        time = flight.GetFlightTime((FlightProperty)total.Property);
                    }
                    else if (total.Property is AircraftProperty)
                    {
                        if (!((bool)aircraft.GetValue((AircraftProperty)total.Property)))
                        {
                            continue;
                        }

                        time = flight.FlightTime;
                    }
                    else
                    {
                        if (aircraft.Classification != (AircraftClassification)total.Property)
                        {
                            continue;
                        }

                        time = flight.FlightTime;
                    }

                    if (flight.Date >= sixMonthsAgo)
                    {
                        total.Last12Months += time;
                        total.Last6Months  += time;
                    }
                    else if (flight.Date >= twelveMonthsAgo)
                    {
                        total.Last12Months += time;
                    }

                    total.Total += time;
                }
            }

            var aircraftTotals = new RootElement("By Aircraft Category...");
            var otherTotals    = new RootElement("Other Totals");

            for (int i = 1; i < totals.Count; i++)
            {
                if (totals[i].Total == 0)
                {
                    continue;
                }

                if (totals[i].Property is FlightProperty)
                {
                    otherTotals.Add(new Section(totals[i].Title)
                    {
                        new StringElement("Total", FlightExtension.FormatFlightTime(totals[i].Total, true)),
                        new StringElement("12 Months", FlightExtension.FormatFlightTime(totals[i].Last12Months, true)),
                        new StringElement("6 Months", FlightExtension.FormatFlightTime(totals[i].Last6Months, true)),
                    });
                }
                else
                {
                    aircraftTotals.Add(new Section(totals[i].Title)
                    {
                        new StringElement("Total", FlightExtension.FormatFlightTime(totals[i].Total, true)),
                        new StringElement("12 Months", FlightExtension.FormatFlightTime(totals[i].Last12Months, true)),
                        new StringElement("6 Months", FlightExtension.FormatFlightTime(totals[i].Last6Months, true)),
                    });
                }
            }

            Root.Add(new Section(totals[0].Title)
            {
                new StringElement("Total", FlightExtension.FormatFlightTime(totals[0].Total, true)),
                new StringElement("12 Months", FlightExtension.FormatFlightTime(totals[0].Last12Months, true)),
                new StringElement("6 Months", FlightExtension.FormatFlightTime(totals[0].Last6Months, true)),
                aircraftTotals,
                otherTotals
            });
        }
Ejemplo n.º 22
0
 public AircraftTableViewCell(Aircraft aircraft, NSString key)
     : base(UITableViewCellStyle.Default, key)
 {
     SelectionStyle = UITableViewCellSelectionStyle.Blue;
     ContentView.ClipsToBounds = true;
     view = new AircraftCellView ();
     view.Aircraft = aircraft;
     ContentView.Add (view);
 }
        static bool AircraftEqual(Aircraft aircraft1, Aircraft aircraft2)
        {
            if (aircraft1 == aircraft2)
                return true;

            if (aircraft1 != null && aircraft2 != null)
                return aircraft1.Id == aircraft2.Id;

            return false;
        }
Ejemplo n.º 24
0
        void ShowCrossCountryAlert(Aircraft aircraft, string origin, HashSet <string> missing, double minimum)
        {
            var    message = new StringBuilder();
            string title   = "Cross-Country Alert";
            int    i       = 0;

            if (aircraft == null)
            {
                message.AppendLine("The classification of the aircraft you referenced is unknown.");
                message.AppendLine();
                message.AppendLine("Are you sure that this was a Cross-Country flight according to FAA regulations?");
            }
            else if (missing.Count > 0)
            {
                message.Append("Could not verify that this flight was Cross-Country according to FAA regulations because ");

                if (missing.Count > 1)
                {
                    message.Append("the following airports are unknown: ");
                }
                else
                {
                    message.Append("the following airport is unknown: ");
                }

                foreach (var airport in missing)
                {
                    if (i > 0)
                    {
                        if (i + 1 == missing.Count)
                        {
                            message.Append(" and ");
                        }
                        else
                        {
                            message.Append(", ");
                        }
                    }

                    message.Append(airport);
                    i++;
                }

                message.AppendLine(".");
                message.AppendLine();

                if (missing.Count > 1)
                {
                    message.AppendFormat("Are any of these airports greater than {0} nautical miles from {1}?", minimum, origin);
                }
                else
                {
                    message.AppendFormat("Is this airport greater than {0} nautical miles from {1}?", minimum, origin);
                }

                message.AppendLine();
            }
            else
            {
                message.AppendFormat("None of the airports listed are greater than {0} nautical miles from {1}", minimum, origin);
                message.AppendLine();
                message.AppendLine();
                message.AppendLine("Are you sure that this was a Cross-Country flight according to FAA regulations?");
            }

            del   = new CrossCountryAlertDelegate(this);
            alert = new UIAlertView(title, message.ToString(), del, "No", "Yes");
            alert.Show();
        }
        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 ();
        }
Ejemplo n.º 26
0
        /// <summary>
        /// Enumerates the logged flights flown with the specified aircraft.
        /// </summary>
        /// <returns>A list of the logged flights flown with the specified aircraft.</returns>
        /// <param name="aircraft">The aircraft of interest.</param>
        public static IEnumerable<Flight> GetFlights(Aircraft aircraft)
        {
            var query = "select * from Flight where Aircraft = ?";

            return EnumerateFlights (query, aircraft.TailNumber);
        }
Ejemplo n.º 27
0
 public AircraftEventArgs(Aircraft aircraft)
 {
     Aircraft = aircraft;
 }
Ejemplo n.º 28
0
        /// <summary>
        /// Enumerates the logged flights flown with the specified aircraft since the specified date.
        /// </summary>
        /// <returns>A list of the logged flights flown with the specified aircraft since the specified date.</returns>
        /// <param name="aircraft">The aircraft of interest.</param>
        /// <param name="since">The start date.</param>
        public static IEnumerable<Flight> GetFlights(Aircraft aircraft, DateTime since)
        {
            var query = "select * from Flight where Aircraft = ? and Date >= ?";

            return EnumerateFlights (query, aircraft.TailNumber, since);
        }
Ejemplo n.º 29
0
 /// <summary>
 /// Checks whether or not the LogBook contains the specified aircraft.
 /// </summary>
 /// <returns>
 /// <c>true</c> if the specified aircraft is already in the LogBook; otherwise, <c>false</c>.
 /// </returns>
 /// <param name='aircraft'>
 /// The aircraft to check for.
 /// </param>
 public static bool Contains(Aircraft aircraft)
 {
     return sqlitedb.Query<Flight> ("select 1 from Aircraft where TailNumber = ?", aircraft.TailNumber).Count == 1;
 }
Ejemplo n.º 30
0
 public AircraftEventArgs(Aircraft aircraft)
 {
     Aircraft = aircraft;
 }
Ejemplo n.º 31
0
 /// <summary>
 /// Gets a list of the logged flights flown with the specified aircraft.
 /// </summary>
 /// <returns>
 /// A list of the logged flights flown with the specified aircraft.
 /// </returns>
 /// <param name='aircraft'>
 /// The aircraft of interest.
 /// </param>
 public static List<Flight> GetFlights(Aircraft aircraft)
 {
     return sqlitedb.Query<Flight> ("select * from Flight where Aircraft = ? order by Date desc", aircraft.TailNumber);
 }
Ejemplo n.º 32
0
 protected virtual void OnAircraftSelected(Aircraft aircraft)
 {
     details.Aircraft = aircraft;
 }
Ejemplo n.º 33
0
        /// <summary>
        /// Update the specified aircraft.
        /// </summary>
        /// <param name='aircraft'>
        /// The aircraft to update.
        /// </param>
        public static bool Update(Aircraft aircraft)
        {
            OnAircraftWillUpdate (aircraft);

            if (sqlitedb.Update (aircraft) > 0) {
                OnAircraftUpdated (aircraft);
                aircraft.OnUpdated ();
                return true;
            } else {
                OnAircraftUpdateFailed (aircraft);
            }

            return false;
        }
Ejemplo n.º 34
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;
                }
            }
Ejemplo n.º 35
0
        static void OnAircraftWillUpdate(Aircraft aircraft)
        {
            var handler = AircraftWillUpdate;

            if (handler != null)
                handler (null, new AircraftEventArgs (aircraft));
        }
Ejemplo n.º 36
0
        protected override void Dispose(bool disposing)
        {
            if (Aircraft != null) {
                Aircraft.Updated -= OnAircraftUpdated;
                Aircraft = null;
            }

            LogBook.FlightUpdated -= OnFlightUpdated;
            LogBook.FlightDeleted -= OnFlightDeleted;
            LogBook.FlightAdded -= OnFlightAdded;

            base.Dispose (disposing);
        }