/// <summary> /// Adds the list item for the given attribute. /// </summary> /// <param name="remap"></param> /// <param name="group"></param> /// <param name="attrib"></param> private void AddItemForAttribute(RemappingResult remap, ListViewGroup group, EveAttribute attrib) { // Add the list view item for this attribute string itemText = RemappingPoint.GetStringForAttribute(attrib, remap.BaseScratchpad, remap.BestScratchpad); lvPoints.Items.Add(new ListViewItem(itemText, group)); }
/// <summary> /// Starts optimization. /// </summary> private void Run() { // Compute best scratchpad var bestDuration = TimeSpan.Zero; AttributesOptimizer.RemappingResult remapping = null; List <AttributesOptimizer.RemappingResult> remappingList = null; switch (m_strategy) { case Strategy.ManualRemappingPointEdition: m_areRemappingPointsActive = true; if (m_update) { remapping = m_remapping; m_manuallyEditedRemappingPoint = remapping.Point.Clone(); } else { remapping = AttributesOptimizer.GetResultsFromRemappingPoints(m_plan).Single(x => x.Point == m_manuallyEditedRemappingPoint); m_manuallyEditedRemappingPoint = m_manuallyEditedRemappingPoint.Clone(); m_remapping = remapping; } remapping.Optimize(TimeSpan.MaxValue); break; case Strategy.Character: m_areRemappingPointsActive = false; remapping = AttributesOptimizer.OptimizeFromCharacter(m_character, m_plan); break; case Strategy.OneYearPlan: m_areRemappingPointsActive = false; remapping = AttributesOptimizer.OptimizeFromFirstYearOfPlan(m_plan); break; case Strategy.RemappingPoints: m_areRemappingPointsActive = true; remappingList = AttributesOptimizer.OptimizeFromPlanAndRemappingPoints(m_plan); break; default: throw new NotImplementedException(); } if (m_update) { // Update the controls for every attribute on the already shown form UpdateForm(remapping, remappingList); } else { // Update the controls for every attribute this.Invoke((MethodInvoker)(() => UpdateForm(remapping, remappingList))); } }
/// <summary> /// Constructor for use in code when the user wants to manually edit a remapping point. /// </summary> /// <param name="character">Character information</param> /// <param name="plan">Plan to optimize for</param> /// <param name="strategy">Optimization strategy</param> /// <param name="name">Title of this form</param> /// <param name="description">Description of the optimization operation</param> public AttributesOptimizationForm(Character character, BasePlan plan, RemappingPoint point, string planName) : this() { m_plan = plan; m_character = character; m_manuallyEditedRemappingPoint = point; m_strategy = Strategy.ManualRemappingPointEdition; this.Text = "Remapping point edition (" + planName + ")"; this.labelDescription.Text = "Manual edition of a remapping point"; }
/// <summary> /// Adds the list item for the given attribute. /// </summary> /// <param name="remap"></param> /// <param name="group"></param> /// <param name="attrib"></param> private void AddItemForAttribute(AttributesOptimizer.RemappingResult remap, ListViewGroup group, EveAttribute attrib) { StringBuilder builder = new StringBuilder(attrib.ToString()); int difference = remap.BestScratchpad[attrib].Base - remap.BaseScratchpad[attrib].Base; // Add the list view item for this attribute string itemText = RemappingPoint.GetStringForAttribute(attrib, remap.BaseScratchpad, remap.BestScratchpad); lvPoints.Items.Add(new ListViewItem(itemText, group)); }
/// <summary> /// Performs the given remapping /// </summary> /// <param name="point"></param> /// <exception cref="System.ArgumentNullException">point</exception> public void Remap(RemappingPoint point) { point.ThrowIfNull(nameof(point)); for (int i = 0; i < m_attributes.Length; i++) { EveAttribute attrib = (EveAttribute)i; m_attributes[i].Base = point[attrib]; } }
/// <summary> /// Constructor for use in code when the user wants to manually edit a remapping point. /// </summary> /// <param name="character">Character information</param> /// <param name="plan">Plan to optimize for</param> /// <param name="strategy">Optimization strategy</param> /// <param name="name">Title of this form</param> /// <param name="description">Description of the optimization operation</param> public AttributesOptimizationForm(Character character, Plan plan, RemappingPoint point) : this() { m_plan = plan; m_character = character; m_baseCharacter = character.After(plan.ChosenImplantSet); m_manuallyEditedRemappingPoint = point; m_strategy = Strategy.ManualRemappingPointEdition; m_description = "Manual editing of a remapping point"; Text = "Remapping point manual editing (" + plan.Name + ")"; }
/// <summary> /// Starts optimization. /// </summary> /// <param name="update">if set to <c>true</c> [update].</param> /// <exception cref="System.NotImplementedException"></exception> private void Run(bool update = false) { // Compute best scratchpad RemappingResult remapping = null; ICollection <RemappingResult> remappingList = null; switch (m_strategy) { case AttributeOptimizationStrategy.ManualRemappingPointEdition: m_areRemappingPointsActive = true; if (update) { remapping = m_remapping; m_manuallyEditedRemappingPoint = remapping.Point.Clone(); } else { remapping = AttributesOptimizer.GetResultsFromRemappingPoints(m_plan).Single( x => x.Point == m_manuallyEditedRemappingPoint); m_manuallyEditedRemappingPoint = m_manuallyEditedRemappingPoint.Clone(); m_remapping = remapping; } remapping.Optimize(TimeSpan.MaxValue); break; case AttributeOptimizationStrategy.Character: m_areRemappingPointsActive = false; remapping = AttributesOptimizer.OptimizeFromCharacter(m_character, m_plan); break; case AttributeOptimizationStrategy.OneYearPlan: m_areRemappingPointsActive = false; remapping = AttributesOptimizer.OptimizeFromFirstYearOfPlan(m_plan); break; case AttributeOptimizationStrategy.RemappingPoints: m_areRemappingPointsActive = true; remappingList = AttributesOptimizer.OptimizeFromPlanAndRemappingPoints(m_plan); break; default: throw new NotImplementedException(); } // Update the controls for every attribute Dispatcher.Invoke(() => UpdateForm(remapping, remappingList)); }
/// <summary> /// Updates the controls with the values from the current remapping point. /// </summary> /// <param name="point"></param> /// <exception cref="System.ArgumentNullException">point</exception> public void UpdateValuesFrom(RemappingPoint point) { point.ThrowIfNull(nameof(point)); // Creates a scratchpad with the base values from the provided point. CharacterScratchpad scratchpad = new CharacterScratchpad(m_character.After(m_plan.ChosenImplantSet)); for (int i = 0; i < 5; i++) { scratchpad[(EveAttribute)i].Base = point[(EveAttribute)i]; } RemappingResult remapping = new RemappingResult(m_remapping, scratchpad); remapping.Update(); // Update the controls UpdateControls(m_character, m_plan, remapping, m_description); // Fires the event AttributeChanged?.ThreadSafeInvoke(this, new AttributeChangedEventArgs(remapping)); }
/// <summary> /// Updates the controls with the values from the current remapping point. /// </summary> /// <param name="point"></param> public void UpdateValuesFrom(RemappingPoint point) { // Creates a scratchpad with the base values from the provided point. var scratchpad = new CharacterScratchpad(m_character); for (int i = 0; i < 5; i++) { scratchpad[(EveAttribute)i].Base = point[(EveAttribute)i]; } var remapping = new AttributesOptimizer.RemappingResult(m_remapping, scratchpad); remapping.Update(); // Update the controls UpdateControls(m_character, remapping); // Fires the event if (AttributeChanged != null) { AttributeChanged(this, remapping); } }
/// <summary> /// Constructor for use in code when the user wants to manually edit a remapping point. /// </summary> /// <param name="planEditorControl">The plan editor control.</param> /// <param name="point">The point.</param> public AttributesOptimizerWindow(PlanEditorControl planEditorControl, RemappingPoint point) : this(planEditorControl, AttributeOptimizationStrategy.ManualRemappingPointEdition) { m_manuallyEditedRemappingPoint = point; }
/// <summary> /// On a doube-click on one of the list items, we open the skill browser. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void lvSkills_MouseDoubleClick(object sender, MouseEventArgs e) { if (lvSkills.SelectedItems.Count != 1) return; // When the first entry is a skill, shows it in the skill browser if (GetFirstSelectedEntry() != null) miShowInSkillBrowser_Click(sender, e); // When it is a remapping point, edit it else { // Retrieves the point ListViewItem nextItem = lvSkills.Items[lvSkills.SelectedIndices[0] + 1]; RemappingPoint remappingPoint = GetPlanEntry(nextItem).Remapping; // Display the attributes optimizer // if it's not already shown // When we click on another point the previous form closes if (remappingPoint != m_previousRemappingPoint) WindowsFactory.GetAndCloseByTag<AttributesOptimizerWindow, PlanEditorControl>(this); m_previousRemappingPoint = remappingPoint; WindowsFactory.ShowByTag<AttributesOptimizerWindow, PlanEditorControl>(ParentForm, this, remappingPoint); } }
/// <summary> /// Starts optimization. /// </summary> /// <param name="update">if set to <c>true</c> [update].</param> /// <exception cref="System.NotImplementedException"></exception> private void Run(bool update = false) { // Compute best scratchpad RemappingResult remapping = null; ICollection<RemappingResult> remappingList = null; switch (m_strategy) { case AttributeOptimizationStrategy.ManualRemappingPointEdition: m_areRemappingPointsActive = true; if (update) { remapping = m_remapping; m_manuallyEditedRemappingPoint = remapping.Point.Clone(); } else { remapping = AttributesOptimizer.GetResultsFromRemappingPoints(m_plan).Single( x => x.Point == m_manuallyEditedRemappingPoint); m_manuallyEditedRemappingPoint = m_manuallyEditedRemappingPoint.Clone(); m_remapping = remapping; } remapping.Optimize(TimeSpan.MaxValue); break; case AttributeOptimizationStrategy.Character: m_areRemappingPointsActive = false; remapping = AttributesOptimizer.OptimizeFromCharacter(m_character, m_plan); break; case AttributeOptimizationStrategy.OneYearPlan: m_areRemappingPointsActive = false; remapping = AttributesOptimizer.OptimizeFromFirstYearOfPlan(m_plan); break; case AttributeOptimizationStrategy.RemappingPoints: m_areRemappingPointsActive = true; remappingList = AttributesOptimizer.OptimizeFromPlanAndRemappingPoints(m_plan); break; default: throw new NotImplementedException(); } // Update the controls for every attribute Dispatcher.Invoke(() => UpdateForm(remapping, remappingList)); }