Exemplo n.º 1
0
        /// <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);
        }
Exemplo n.º 2
0
        /// <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();
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// When the mouse moves over the implants combos (used for writable sets), we display a tooltip on the right of the combo.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void combo_MouseMove(object sender, MouseEventArgs e)
        {
            DropDownMouseMoveComboBox combo = (DropDownMouseMoveComboBox)sender;
            Implant implant = combo.SelectedItem as Implant;

            if (implant == null)
            {
                return;
            }

            if (m_fakeToolTip.Visible && m_fakeToolTip.Implant == implant)
            {
                return;
            }

            Point point = new Point {
                X = combo.Width + 5, Y = 1
            };

            m_fakeToolTip.Location = combo.PointToScreen(point);
            m_fakeToolTip.Implant  = implant;
            m_fakeToolTip.ShowInactiveTopmost();
        }
Exemplo n.º 4
0
        /// <summary>
        /// Update the comboboxes' selections.
        /// </summary>
        private void UpdateSlots()
        {
            var set = GetSelectedSet();

            // No set selected or row name empty?
            if (set == null || String.IsNullOrEmpty(set.Name.ToString()))
            {
                foreach (var control in this.Controls)
                {
                    DropDownMouseMoveComboBox combo = control as DropDownMouseMoveComboBox;
                    if (combo == null)
                    {
                        continue;
                    }

                    // Disable the combo with the <None> implant
                    combo.SelectedIndex = 0;
                    combo.Visible       = true;
                    combo.Enabled       = false;

                    // Hide the label used for read-only sets
                    var slot  = (ImplantSlots)combo.Tag;
                    var label = m_labels[(int)slot];
                    label.Visible = false;
                }
                return;
            }

            // Scroll through comboboxes
            bool isReadOnly = (set == m_sets.API || set == m_sets.OldAPI);

            foreach (var control in this.Controls)
            {
                // Only look for combo boxes
                DropDownMouseMoveComboBox combo = control as DropDownMouseMoveComboBox;
                if (combo == null)
                {
                    continue;
                }

                // Enable the combo with the <None> implant
                combo.SelectedIndex = 0;
                combo.Visible       = !isReadOnly;
                combo.Enabled       = true;

                var slot            = (ImplantSlots)combo.Tag;
                var 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.
                var label = m_labels[(int)slot];
                label.Visible = isReadOnly;
                label.Text    = selectedImplant.Name;
                label.Tag     = selectedImplant;
            }
        }