/// <summary> /// Gets the implant name for the given slot and the provided set. /// </summary> /// <param name="set"></param> /// <param name="slot"></param> /// <returns></returns> private static Implant GetImplant(SerializableSettingsImplantSet set, ImplantSlots slot) { // Invoke the property getter with the matching name through reflection object implantName = typeof(SerializableSettingsImplantSet).GetProperty(slot.ToString()).GetValue(set, null); return(StaticItems.GetImplants(slot)[(string)implantName]); }
/// <summary> /// Update the comboboxes' selections. /// </summary> private void UpdateSlots() { SerializableSettingsImplantSet set = GetSelectedSet(); // No set selected or row name empty? if (set == null || String.IsNullOrEmpty(set.Name)) { foreach (DropDownMouseMoveComboBox combo in Controls.OfType <DropDownMouseMoveComboBox>()) { // Disable the combo with the <None> implant combo.SelectedIndex = 0; combo.Visible = true; combo.Enabled = false; // Hide the label used for read-only sets ImplantSlots slot = (ImplantSlots)combo.Tag; Label label = m_labels[(int)slot]; label.Visible = false; } return; } // Scroll through comboboxes bool isReadOnly = set == m_sets.ActiveClone || m_sets.JumpClones.Any(x => x == set); foreach (DropDownMouseMoveComboBox combo in Controls.OfType <DropDownMouseMoveComboBox>()) { // Enable the combo with the <None> implant combo.SelectedIndex = 0; combo.Visible = !isReadOnly; combo.Enabled = true; ImplantSlots slot = (ImplantSlots)combo.Tag; Implant selectedImplant = GetImplant(set, slot); // Scroll through every implant and check whether it is the selected one. int index = 0; foreach (Implant implant in combo.Items) { if (implant == selectedImplant) { combo.SelectedIndex = index; break; } index++; } // Set "none" when the implant was not found. if (index == combo.Items.Count) { combo.SelectedIndex = 0; } // Updates the label displayed for read-only sets. Label label = m_labels[(int)slot]; label.Visible = isReadOnly; label.Text = selectedImplant.Name; label.Tag = selectedImplant; } }
/// <summary> /// Deserialization constructor. /// </summary> /// <param name="group"></param> /// <param name="src"></param> internal Implant(MarketGroup group, SerializableItem src) : base(group, src) { // Gets the slot var slotProperty = this.Properties[DBConstants.ImplantSlotPropertyID]; m_implantSlot = (slotProperty == null ? ImplantSlots.None : (ImplantSlots)(slotProperty.Value.IValue - 1)); // Get the bonus switch (m_implantSlot) { case ImplantSlots.Charisma: m_bonus = this.Properties[DBConstants.CharismaModifierPropertyID].Value.IValue; break; case ImplantSlots.Intelligence: m_bonus = this.Properties[DBConstants.IntelligenceModifierPropertyID].Value.IValue; break; case ImplantSlots.Memory: m_bonus = this.Properties[DBConstants.MemoryModifierPropertyID].Value.IValue; break; case ImplantSlots.Perception: m_bonus = this.Properties[DBConstants.PerceptionModifierPropertyID].Value.IValue; break; case ImplantSlots.Willpower: m_bonus = this.Properties[DBConstants.WillpowerModifierPropertyID].Value.IValue; break; default: break; } // Adds itself to the implants slot StaticItems.GetImplants(m_implantSlot).Add(this); }
/// <summary> /// Gets or sets the implant for the given slot. /// </summary> /// <param name="slot">The slot for the implant to retrieve</param> /// <returns>The requested implant when found; null otherwise.</returns> public Implant this[ImplantSlots slot] { get { if (slot == ImplantSlots.None) { return(null); } return(m_values[(int)slot]); } set { if (slot == ImplantSlots.None) { throw new InvalidOperationException("Cannot assign 'none' slot"); } if (value != null && value.Slot != slot) { throw new InvalidOperationException("Slot mismatch"); } if (value == null) { value = Implant.None; } else { m_values[(int)slot] = value; } EveClient.OnCharacterChanged(m_owner); } }
/// <summary> /// Updates the given slot with the provided serialization object. /// </summary> /// <param name="slot"></param> /// <param name="name"></param> private void Import(ImplantSlots slot, string name) { // Backwards compatibility for older versions name = name.Replace("<", String.Empty).Replace(">", String.Empty); m_values[(int)slot] = StaticItems.GetImplants(slot)[name] ?? new Implant(slot); }
/// <summary> /// Sets the implant name for the given slot and the provided set. /// </summary> /// <param name="set"></param> /// <param name="slot"></param> /// <param name="implant"></param> /// <returns></returns> private static void SetImplant(SerializableSettingsImplantSet set, ImplantSlots slot, Implant implant) { // Set may be null when the user is editing the phantom line if (set == null) { return; } // Invoke the property setter with the matching name through reflection typeof(SerializableSettingsImplantSet).GetProperty(slot.ToString()).SetValue(set, implant.Name, null); }
/// <summary> /// When the selection changes, we change the implant /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void cbSlotN_DropDownClosed(object sender, EventArgs e) { if (setsGrid.SelectedRows.Count != 0) { EnsureRowSetInitialized(setsGrid.SelectedRows[0]); } DropDownMouseMoveComboBox combo = (DropDownMouseMoveComboBox)sender; ImplantSlots slot = (ImplantSlots)combo.Tag; SetImplant(GetSelectedSet(), slot, (Implant)combo.SelectedItem); }
/// <summary> /// Adds the combo box and label. /// </summary> /// <param name="control">The control.</param> private void AddComboBoxAndLabel(IDisposable control) { DropDownMouseMoveComboBox combo = control as DropDownMouseMoveComboBox; if (combo == null) { return; } int slotIndex; if (!combo.Name.Replace("cbSlot", string.Empty).TryParseInv(out slotIndex) || slotIndex < 1) { return; } ImplantSlots slot = (ImplantSlots)(slotIndex - 1); combo.Tag = slot; combo.MouseMove += combo_MouseMove; combo.DropDownClosed += combo_DropDownClosed; combo.DropDownMouseMove += combo_DropDownMouseMove; foreach (Implant implant in StaticItems.GetImplants(slot)) { combo.Items.Add(implant); } Label tempLabel = null; try { tempLabel = new Label(); tempLabel.MouseMove += label_MouseMove; tempLabel.AutoSize = false; tempLabel.Anchor = combo.Anchor; tempLabel.Bounds = combo.Bounds; tempLabel.TextAlign = ContentAlignment.MiddleLeft; Label label = tempLabel; tempLabel = null; m_labels[(int)slot] = label; } finally { tempLabel?.Dispose(); } }
/// <summary> /// Converts the provided slot to an attribute. Returns <see cref="Attribute.None"/> when the provided slot does not match any attribute. /// </summary> /// <param name="slot"></param> /// <returns></returns> public static EveAttribute SlotToAttrib(ImplantSlots slot) { switch (slot) { case ImplantSlots.Perception: return EveAttribute.Perception; case ImplantSlots.Memory: return EveAttribute.Memory; case ImplantSlots.Willpower: return EveAttribute.Willpower; case ImplantSlots.Intelligence: return EveAttribute.Intelligence; case ImplantSlots.Charisma: return EveAttribute.Charisma; default: return EveAttribute.None; } }
/// <summary> /// Gets or sets the implant for the given slot. /// </summary> /// <param name="slot">The slot for the implant to retrieve</param> /// <returns>The requested implant when found; null otherwise.</returns> private Implant this[ImplantSlots slot] { get { return(slot == ImplantSlots.None ? new Implant(slot) : m_values[(int)slot]); } set { if (slot == ImplantSlots.None) { throw new InvalidOperationException("Cannot assign 'none' slot"); } if (value != null && value.Slot != slot) { throw new InvalidOperationException("Slot mismatch"); } m_values[(int)slot] = value ?? new Implant(slot); EveMonClient.OnCharacterUpdated(m_owner); } }
/// <summary> /// Converts the provided slot to an attribute. Returns <see cref="EveAttribute.None"/> when the provided slot does not match any attribute. /// </summary> /// <param name="slot"></param> /// <returns></returns> public static EveAttribute SlotToAttrib(ImplantSlots slot) { switch (slot) { case ImplantSlots.Perception: return(EveAttribute.Perception); case ImplantSlots.Memory: return(EveAttribute.Memory); case ImplantSlots.Willpower: return(EveAttribute.Willpower); case ImplantSlots.Intelligence: return(EveAttribute.Intelligence); case ImplantSlots.Charisma: return(EveAttribute.Charisma); default: return(EveAttribute.None); } }
/// <summary> /// Gets the collection of implants for the given slot. /// </summary> /// <param name="slot"></param> /// <returns></returns> public static ImplantCollection GetImplants(ImplantSlots slot) => s_implantSlots[(int)slot];
/// <summary> /// Deserialization constructor. /// </summary> /// <param name="slot"></param> internal ImplantCollection(ImplantSlots slot) { Items.Add(new Implant(slot)); }
/// <summary> /// Private constructor for the default. /// </summary> internal Implant() : base(-1, ImplantSlots.None.ToString()) { m_implantSlot = ImplantSlots.None; }
/// <summary> /// Deserialization constructor. /// </summary> /// <param name="src"></param> internal ImplantCollection(ImplantSlots slot) : base() { m_slot = slot; }
/// <summary> /// Gets the collection of implants for the given slot. /// </summary> /// <param name="slot"></param> /// <returns></returns> public static ImplantSlot GetImplants(ImplantSlots slot) { return(s_implantSlots[(int)slot]); }
/// <summary> /// Gets the implant name for the given slot and the provided set. /// </summary> /// <param name="set"></param> /// <param name="slot"></param> /// <returns></returns> private Implant GetImplant(SerializableSettingsImplantSet set, ImplantSlots slot) { // Invoke the property getter with the matching name through reflection var implantName = typeof(SerializableSettingsImplantSet).GetProperty(slot.ToString()).GetValue(set, null); return StaticItems.GetImplants(slot)[(string)implantName] as Implant; }
/// <summary> /// Exports an implant as a serialization object. /// </summary> /// <param name="slot"></param> /// <returns></returns> private string Export(ImplantSlots slot) { return(m_values[(int)slot].Name); }
/// <summary> /// Updates the given slot with the provided serialization object /// </summary> /// <param name="slot"></param> /// <param name="serial"></param> private void Import(ImplantSlots slot, string name) { m_values[(int)slot] = StaticItems.GetImplants(slot)[name]; }
/// <summary> /// Internal constructor for the default. /// </summary> internal Implant(ImplantSlots slot) : base(-1, ImplantSlots.None.ToString()) { Slot = slot; }
/// <summary> /// Private constructor for the default. /// </summary> internal Implant() : base(-1, "<None>") { m_implantSlot = ImplantSlots.None; }
/// <summary> /// Exports an implant as a serialization object. /// </summary> /// <param name="slot"></param> /// <returns></returns> private string Export(ImplantSlots slot) => m_values[(int)slot].Name;
/// <summary> /// Sets the implant name for the given slot and the provided set. /// </summary> /// <param name="set"></param> /// <param name="slot"></param> /// <param name="implantName"></param> /// <returns></returns> private void SetImplant(SerializableSettingsImplantSet set, ImplantSlots slot, Implant implant) { // Set may be null when the user is editing the phantom line if (set == null) return; // Invoke the property setter with the matching name through reflection typeof(SerializableSettingsImplantSet).GetProperty(slot.ToString()).SetValue(set, implant.Name, null); }
/// <summary> /// Updates the given slot with the provided implant's name. /// </summary> /// <param name="slot"></param> /// <param name="src"></param> private void Import(ImplantSlots slot, SerializableImplant src) { int index = (int)slot; m_values[index] = (src == null ? Implant.None : StaticItems.GetImplants(slot)[src.Name]); }
/// <summary> /// Deserialization constructor /// </summary> /// <param name="src"></param> internal ImplantSlot(ImplantSlots slot) : base() { m_slot = slot; }