/// <summary> /// Update the data we display. /// </summary> /// <returns> /// True if the display needs to be refreshed, false otherwise. /// </returns> public bool Refresh() { double now = Math.Floor(Planetarium.GetUniversalTime()); if (lastUniversalTime != now && model.ejectionBurn != null) { timeToWait = model.ejectionBurn.atTime != null ? new DateTimeParts((model.ejectionBurn.atTime ?? 0) - Planetarium.GetUniversalTime()) : null; duration = model.ejectionBurnDuration.HasValue ? new DateTimeParts(model.ejectionBurnDuration.Value) : null; lastUniversalTime = now; return(true); } return(false); }
/// <summary> /// Update the data we display. /// </summary> /// <returns> /// True if the display needs to be refreshed, false otherwise. /// </returns> public bool Refresh() { double now = Math.Floor(Planetarium.GetUniversalTime()); if (lastUniversalTime != now && model.ejectionBurn != null) { if (model.ejectionBurn.atTime != null) { timeToWait = new DateTimeParts((model.ejectionBurn.atTime ?? 0) - Planetarium.GetUniversalTime()); } else { timeToWait = null; } lastUniversalTime = now; return(true); } return(false); }
private void addRow(StringBuilder sb, TransferModel m, DateTimeParts dt, bool selected) { string destLabel = Localizer.Format("astrogator_planetLabel", TheName(m.destination)); sb.Append(Environment.NewLine); sb.Append(selected ? "> " : " "); for (int i = 0; i < Columns.Length; ++i) { ColumnDefinition col = Columns[i]; switch (col.content) { case ContentEnum.PlanetName: sb.AppendFormat( colContentFormat(col), (destLabel.Length > col.monospaceWidth ? destLabel.Substring(0, col.monospaceWidth) : destLabel) ); break; case ContentEnum.YearsTillBurn: if (dt == null) { sb.AppendFormat(colContentFormat(col), LoadingText); } else { sb.AppendFormat( colContentFormat(col), TimePieceString("astrogator_yearsValue", dt.years, dt.needYears) ); } break; case ContentEnum.DaysTillBurn: if (dt == null) { sb.AppendFormat(colContentFormat(col), LoadingText); } else { sb.AppendFormat( colContentFormat(col), TimePieceString("astrogator_daysValue", dt.days, dt.needDays) ); } break; case ContentEnum.HoursTillBurn: if (dt == null) { sb.AppendFormat(colContentFormat(col), LoadingText); } else { sb.AppendFormat( colContentFormat(col), TimePieceString("astrogator_hoursValue", dt.hours, dt.needHours) ); } break; case ContentEnum.MinutesTillBurn: if (dt == null) { sb.AppendFormat(colContentFormat(col), LoadingText); } else { sb.AppendFormat( colContentFormat(col), TimePieceString("astrogator_minutesValue", dt.minutes, dt.needMinutes) ); } break; case ContentEnum.SecondsTillBurn: if (dt == null) { sb.AppendFormat(colContentFormat(col), LoadingText); } else { sb.AppendFormat( colContentFormat(col), TimePieceString("astrogator_secondsValue", dt.seconds, true) ); } break; case ContentEnum.DeltaV: if (dt == null) { sb.AppendFormat(colContentFormat(col), LoadingText); } else { sb.AppendFormat( colContentFormat(col), FormatSpeed( ((m.planeChangeBurn == null || !Settings.Instance.AddPlaneChangeDeltaV) ? m.ejectionBurn?.totalDeltaV : (m.ejectionBurn?.totalDeltaV + m.planeChangeBurn.totalDeltaV)) ?? 0, Settings.Instance.DisplayUnits) ); } break; } sb.Append(" "); } }