/// <summary> /// Updates eligibility label and planning menus. /// </summary> private void UpdateEligibility() { foreach (ToolStripItem control in tlStrpPlanTo.Items) { control.Visible = Plan != null; } // Not visible if (SelectedObject == null || Plan == null) { return; } MasteryShip masteryShip = masteryTreeDisplayControl.MasteryShip; if (masteryShip == null) { return; } // First we search the highest eligible mastery level after this plan IEnumerable <Mastery> eligibleMasteryLevel = masteryShip.TakeWhile(masteryLevel => Plan.WillGrantEligibilityFor(masteryLevel)).ToList(); Mastery lastEligibleMasteryLevel = null; if (!eligibleMasteryLevel.Any()) { tslbEligible.Text = @"(none)"; } else { lastEligibleMasteryLevel = eligibleMasteryLevel.Last(); tslbEligible.Text = lastEligibleMasteryLevel.ToString(); if (masteryShip.HighestTrainedLevel == null) { tslbEligible.Text += @" (improved from ""none"")"; } else if (lastEligibleMasteryLevel.Level > masteryShip.HighestTrainedLevel.Level) { tslbEligible.Text += string.Format(CultureConstants.DefaultCulture, " (improved from \"{0}\")", masteryShip.HighestTrainedLevel); } else { tslbEligible.Text += @" (no change)"; } } // "Plan to N" menus for (int i = 1; i <= 5; i++) { UpdatePlanningMenuStatus(tsPlanToMenu.DropDownItems[i - 1], masteryShip.GetLevel(i), lastEligibleMasteryLevel); } }
/// <summary> /// Plans to mastery level. /// </summary> /// <param name="node">The node.</param> private void PlanToMasteryLevel(TreeNode node) { cmiLvPlanTo.Visible = tsSeparatorPlanTo.Visible = Plan != null; if (Plan == null) { return; } ShipSelectControl shipSelectorControl = this as ShipSelectControl; cmiLvPlanTo.Visible = shipSelectorControl != null; tsSeparatorPlanTo.Visible = shipSelectorControl != null && lbSearchList.Items.Count == 0; if (shipSelectorControl == null || ((node != null) && node.GetNodeCount(true) > 0) || SelectedObject == null) { cmiLvPlanTo.Visible = false; tsSeparatorPlanTo.Visible = false; return; } MasteryShip masteryShip = ((Character)Plan.Character).MasteryShips.GetMasteryShipByID(SelectedObject.ID); if (masteryShip == null) { cmiLvPlanTo.Enabled = false; cmiLvPlanTo.Text = @"Plan Mastery to..."; return; } cmiLvPlanTo.Enabled = !Plan.WillGrantEligibilityFor(masteryShip.GetLevel(5)); cmiLvPlanTo.Text = $"Plan \"{masteryShip.Ship.Name}\" Mastery to..."; // "Plan to N" menus for (int i = 1; i <= 5; i++) { SetAdditionMenuStatus(cmiLvPlanTo.DropDownItems[i - 1], masteryShip.GetLevel(i)); } }