private void RefreshInfoDisplayedInUI()
{
if (DateTime.UtcNow > _nextUIDataRefresh && DateTime.UtcNow > Cache.Instance.QuestorStarted_DateTime.AddSeconds(15))
{
_nextUIDataRefresh = DateTime.UtcNow.AddMilliseconds(1000);
try
{
if (Cache.Instance.LastInSpace.AddMilliseconds(1000) > DateTime.UtcNow)
{
CurrentTimeData1.Text = DateTime.UtcNow.ToLongTimeString();
CurrentTimeData2.Text = DateTime.UtcNow.ToLongTimeString();
NextOpenContainerInSpaceActionData.Text = Cache.Instance.NextOpenContainerInSpaceAction.ToLongTimeString();
NextOpenLootContainerActionData.Text = Cache.Instance.NextOpenLootContainerAction.ToLongTimeString();
NextDroneBayActionData.Text = Cache.Instance.NextDroneBayAction.ToLongTimeString();
NextOpenHangarActionData.Text = Cache.Instance.NextOpenHangarAction.ToLongTimeString();
NextOpenCargoActionData.Text = Cache.Instance.NextOpenCargoAction.ToLongTimeString();
LastActionData.Text = "";
NextArmActionData.Text = Cache.Instance.NextArmAction.ToLongTimeString();
NextSalvageActionData.Text = Cache.Instance.NextSalvageAction.ToLongTimeString();
NextLootActionData.Text = Cache.Instance.NextLootAction.ToLongTimeString();
LastJettisonData.Text = Cache.Instance.LastJettison.ToLongTimeString();
NextActivateSupportModulesData.Text = Cache.Instance.NextActivateSupportModules.ToLongTimeString();
NextApproachActionData.Text = Cache.Instance.NextApproachAction.ToLongTimeString();
NextOrbitData.Text = Cache.Instance.NextOrbit.ToLongTimeString();
NextWarpToData.Text = Cache.Instance.NextWarpAction.ToLongTimeString();
NextTravelerActionData.Text = Cache.Instance.NextTravelerAction.ToLongTimeString();
NextTargetActionData.Text = Cache.Instance.NextTargetAction.ToLongTimeString();
NextActivateActionData.Text = Cache.Instance.NextActivateAction.ToLongTimeString();
NextAlignData.Text = Cache.Instance.NextAlign.ToLongTimeString();
NextUndockActionData.Text = Cache.Instance.NextUndockAction.ToLongTimeString();
NextDockActionData.Text = Cache.Instance.NextDockAction.ToLongTimeString();
NextDroneRecallData.Text = Cache.Instance.NextDroneRecall.ToLongTimeString();
NextStartupActionData.Text = Cache.Instance.NextStartupAction.ToLongTimeString();
LastSessionChangeData.Text = Cache.Instance.LastSessionChange.ToLongTimeString();
AutostartData.Text = Settings.Instance.AutoStart.ToString(CultureInfo.InvariantCulture);
if (Settings.Instance.UserDefinedLavishScriptScript1Description != string.Empty)
{
lblUserDefinedScript1.Text = Settings.Instance.UserDefinedLavishScriptScript1Description;
}
if (Settings.Instance.UserDefinedLavishScriptScript2Description != string.Empty)
{
lblUserDefinedScript2.Text = Settings.Instance.UserDefinedLavishScriptScript2Description;
}
if (Settings.Instance.UserDefinedLavishScriptScript3Description != string.Empty)
{
lblUserDefinedScript3.Text = Settings.Instance.UserDefinedLavishScriptScript3Description;
}
if (Settings.Instance.UserDefinedLavishScriptScript4Description != string.Empty)
{
lblUserDefinedScript4.Text = Settings.Instance.UserDefinedLavishScriptScript4Description;
}
DamageTypeData.Text = Cache.Instance.MissionDamageType.ToString();
//OrbitDistanceData.Text = Cache.Instance.OrbitDistance.ToString(CultureInfo.InvariantCulture);
//AgentStationIDData.Text = Cache.Instance.AgentStationID.ToString(CultureInfo.InvariantCulture);
//AgentIdData.Text = Cache.Instance.AgentId.ToString(CultureInfo.InvariantCulture);
//AgentData.Text = Cache.Instance.CurrentAgent.ToString(CultureInfo.InvariantCulture);
AgentInteractionPurposeData.Text = AgentInteraction.Purpose.ToString();
MissionsThisSessionData.Text = Cache.Instance.MissionsThisSession.ToString(CultureInfo.InvariantCulture);
//crashes questor when in station?
//
//if (Cache.Instance.MaxRange > 0)
//{
// MaxRangeData.Text = Cache.Instance.MaxRange.ToString(CultureInfo.InvariantCulture);
//causes problems / crashes
//}
//WeaponRangeData.Text = Cache.Instance.WeaponRange.ToString(CultureInfo.InvariantCulture); //causes problems / crashes
//ActiveDronesData.Text = Cache.Instance.ActiveDrones.Count().ToString(); //causes problems / crashes
//if (!Cache.Instance.InWarp && DateTime.UtcNow > _nextWreckUpdate) //this was causing exceptions we cant check inWarp from the UI?
//{
// _nextWreckUpdate = DateTime.UtcNow.AddSeconds(10);
//WrecksData.Text = Cache.Instance.Wrecks.Count().ToString(CultureInfo.InvariantCulture);
//UnlootedContainersData.Text = Cache.Instance.UnlootedContainers.Count().ToString(CultureInfo.InvariantCulture);
//ApproachingData.Text = Cache.Instance.IsApproaching.ToString(CultureInfo.InvariantCulture);
//}
//DamagedDronesData.Text = Cache.Instance.DamagedDrones.Count().ToString(CultureInfo.InvariantCulture);
//PriorityTargetsData.Text = Cache.Instance.PriorityTargets.Count().ToString(CultureInfo.InvariantCulture);
//if (Cache.Instance.IsMissionPocketDone) IsMissionPocketDoneData.Text = "true";
//else if (!Cache.Instance.IsMissionPocketDone) IsMissionPocketDoneData.Text = "false";
}
if (Cache.Instance.LastInStation.AddSeconds(2) > DateTime.UtcNow)
{
MaxRangeData.Text = Resources.QuestorfrmMain_RefreshInfoDisplayedInUI_n_a;
ActiveDronesData.Text = Resources.QuestorfrmMain_RefreshInfoDisplayedInUI_n_a;
ApproachingData.Text = Resources.QuestorfrmMain_RefreshInfoDisplayedInUI_n_a;
DamagedDronesData.Text = Resources.QuestorfrmMain_RefreshInfoDisplayedInUI_n_a;
PriorityTargetsData.Text = Resources.QuestorfrmMain_RefreshInfoDisplayedInUI_n_a;
WeaponRangeData.Text = Resources.QuestorfrmMain_RefreshInfoDisplayedInUI_n_a;
IsMissionPocketDoneData.Text = Resources.QuestorfrmMain_RefreshInfoDisplayedInUI_n_a;
WrecksData.Text = Resources.QuestorfrmMain_RefreshInfoDisplayedInUI_n_a;
UnlootedContainersData.Text = Resources.QuestorfrmMain_RefreshInfoDisplayedInUI_n_a;
DataAmmoHangarID.Text = Cache.Instance.AmmoHangarID.ToString(CultureInfo.InvariantCulture);
DataAmmoHangarName.Text = Settings.Instance.AmmoHangarTabName;
DataLootHangarID.Text = Cache.Instance.LootHangarID.ToString(CultureInfo.InvariantCulture);
DataLootHangarName.Text = Settings.Instance.LootHangarTabName;
}
}
catch (Exception ex)
{
if (Settings.Instance.DebugUI) Logging.Log("QuestorUI", "RefreshInfoDisplayedInUI: unable to update all UI labels: exception was [" + ex.Message + "]", Logging.Teal);
}
}
if (DateTime.UtcNow > _nextScheduleUpdate)
{
_nextScheduleUpdate = DateTime.UtcNow.AddSeconds(90);
if (Cache.Instance.StopTimeSpecified)
{
ScheduledStopTimeData.Text = Cache.Instance.StopTime.ToLongTimeString();
}
//
// if control is enabled (checked) then update ManualStopTime so that on next idle questor will check to see if it needs to stop
//
if (dateTimePicker1.Checked)
{
Cache.Instance.ManualStopTime = dateTimePicker1.Value;
if (Cache.Instance.ManualStopTime > Cache.Instance.StopTime)
{
Cache.Instance.StopTimeSpecified = false;
}
if (Cache.Instance.ManualStopTime < Cache.Instance.StopTime)
{
Cache.Instance.StopTimeSpecified = true;
}
}
else
{
dateTimePicker1.Value = DateTime.Now.AddHours(1);
if (!dateTimePicker2.Checked)
{
Cache.Instance.StopTimeSpecified = true;
}
}
//
// if control is enabled (checked) then update ManualRestartTime so that on next idle questor will check to see if it needs to stop/restart
//
if (dateTimePicker2.Checked)
{
Cache.Instance.ManualRestartTime = dateTimePicker2.Value;
if (Cache.Instance.ManualRestartTime > Cache.Instance.StopTime)
{
Cache.Instance.StopTimeSpecified = false;
}
if (Cache.Instance.ManualRestartTime < Cache.Instance.StopTime)
{
Cache.Instance.StopTimeSpecified = true;
}
}
else
{
dateTimePicker1.Value = DateTime.Now.AddHours(1);
if (!dateTimePicker1.Checked)
{
Cache.Instance.StopTimeSpecified = true;
}
}
}
}