Ejemplo n.º 1
0
        /// <summary>
        /// When a cell value changes, we replace the new name.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void setsGrid_CellValidating(object sender, DataGridViewCellValidatingEventArgs e)
        {
            DataGridViewRow row  = setsGrid.Rows[e.RowIndex];
            string          text = e.FormattedValue?.ToString() ?? String.Empty;

            // If the user forgets the edition and there is no bound set
            // or the given name exceeds 255 characters
            // or the name is empty,
            // we replace <New set> by an empty value
            if ((row.Tag == null && text == PhantomSetName) ||
                text.Length > EveMonConstants.ImplantSetNameMaxLength ||
                String.IsNullOrWhiteSpace(text))
            {
                row.Cells[0].Value = String.Empty;
                return;
            }

            // Updates the set's name
            EnsureRowSetInitialized(row);
            if (row.Tag == null)
            {
                return;
            }

            SerializableSettingsImplantSet set = (SerializableSettingsImplantSet)row.Tag;

            if (e.FormattedValue != null)
            {
                set.Name = e.FormattedValue.ToString();
            }
        }
Ejemplo n.º 2
0
        /// <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]);
        }
Ejemplo n.º 3
0
        /// <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;
            }
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Adds the row for the given set.
        /// </summary>
        /// <param name="set"></param>
        private void AddRow(SerializableSettingsImplantSet set)
        {
            var row = new DataGridViewRow();

            row.CreateCells(setsGrid, set.Name);
            row.Tag = set;
            setsGrid.Rows.Add(row);
        }
Ejemplo n.º 5
0
        /// <summary>
        /// On OK, let's fetch the serialization object to the real implant sets.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnOK_Click(object sender, EventArgs e)
        {
            SerializableSettingsImplantSet set = GetSelectedSet();

            if (set != null && !String.IsNullOrWhiteSpace(set.Name))
            {
                m_character.ImplantSets.Import(m_sets);
            }

            Close();
        }
Ejemplo n.º 6
0
        /// <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);
        }
Ejemplo n.º 7
0
 /// <summary>
 /// Imports data from a settings serialization object.
 /// </summary>
 /// <param name="serial"></param>
 internal void Import(SerializableSettingsImplantSet serial)
 {
     m_name = serial.Name;
     Import(ImplantSlots.Intelligence, serial.Intelligence);
     Import(ImplantSlots.Perception, serial.Perception);
     Import(ImplantSlots.Willpower, serial.Willpower);
     Import(ImplantSlots.Charisma, serial.Charisma);
     Import(ImplantSlots.Memory, serial.Memory);
     Import(ImplantSlots.Slot6, serial.Slot6);
     Import(ImplantSlots.Slot7, serial.Slot7);
     Import(ImplantSlots.Slot8, serial.Slot8);
     Import(ImplantSlots.Slot9, serial.Slot9);
     Import(ImplantSlots.Slot10, serial.Slot10);
 }
Ejemplo n.º 8
0
        /// <summary>
        /// Generates a serialization object.
        /// </summary>
        /// <returns></returns>
        internal SerializableSettingsImplantSet Export()
        {
            var serial = new SerializableSettingsImplantSet();

            serial.Intelligence = Export(ImplantSlots.Intelligence);
            serial.Perception   = Export(ImplantSlots.Perception);
            serial.Willpower    = Export(ImplantSlots.Willpower);
            serial.Charisma     = Export(ImplantSlots.Charisma);
            serial.Memory       = Export(ImplantSlots.Memory);
            serial.Slot6        = Export(ImplantSlots.Slot6);
            serial.Slot7        = Export(ImplantSlots.Slot7);
            serial.Slot8        = Export(ImplantSlots.Slot8);
            serial.Slot9        = Export(ImplantSlots.Slot9);
            serial.Slot10       = Export(ImplantSlots.Slot10);
            serial.Name         = m_name;
            return(serial);
        }
Ejemplo n.º 9
0
        /// <summary>
        /// Adds the row for the given set.
        /// </summary>
        /// <param name="set"></param>
        private void AddRow(SerializableSettingsImplantSet set)
        {
            DataGridViewRow tempRow = null;

            try
            {
                tempRow = new DataGridViewRow();
                tempRow.CreateCells(setsGrid, set.Name);
                tempRow.Tag = set;

                DataGridViewRow row = tempRow;
                tempRow = null;

                setsGrid.Rows.Add(row);
            }
            finally
            {
                tempRow?.Dispose();
            }
        }
Ejemplo n.º 10
0
        /// <summary>
        /// Sets the selected implant slot
        /// </summary>
        /// <param name="set"></param>
        private void SetSelectedSet(SerializableSettingsImplantSet set)
        {
            setsGrid.ClearSelection();

            // Get the string representation of the ImplantSlots enumeration
            if (set == m_sets.API)
            {
                setsGrid.Rows[0].Selected = true;
            }
            else if (set == m_sets.OldAPI)
            {
                setsGrid.Rows[1].Selected = true;
            }
            else
            {
                int index = m_sets.CustomSets.IndexOf(set);
                index = (index == -1 ? -1 : 2 + index);
                setsGrid.Rows[index].Selected = true;
            }
        }
Ejemplo n.º 11
0
        internal SerializableSettingsImplantSet ToSerializableImplantSet()
        {
            var ccpImplantSet = new SerializableSettingsImplantSet();

            return(ccpImplantSet);
        }