Ejemplo n.º 1
0
        /// <summary>
        /// When the item has changed.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void listBoxPasswordName_SelectedIndexChanged(object sender, EventArgs e)
        {
            // Assign the values.
            if (_manager != null)
            {
                // If a real item has been selected.
                if (listBoxPasswordName.SelectedIndex > -1)
                {
                    // If items exist.
                    if (listBoxPasswordName.Items.Count > 0)
                    {
                        try
                        {
                            // Find the selected item.
                            _currentItem         = _items.First(u => u.name == listBoxPasswordName.SelectedItem.ToString());
                            groupBoxItem.Enabled = true;

                            // Assign the data.
                            AssignData();
                        }
                        catch { }
                    }
                }
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Add an item.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnAddItem_Click(object sender, EventArgs e)
        {
            UI.Input input = new UI.Input();
            input.ShowDialog(this);

            // If ok then add.
            if (input.InputType == InputType.OK)
            {
                // A value must exist.
                if (!String.IsNullOrEmpty(input.InputValue))
                {
                    // Does the name already exist.
                    int count = _items.Count(u => u.name == input.InputValue);

                    // If already exists.
                    if (count > 0)
                    {
                        MessageBox.Show("The item '" + input.InputValue + "' already exists!", "Input");
                    }
                    else
                    {
                        try
                        {
                            listBoxPasswordName.Items.Add(input.InputValue);

                            // Add a new item.
                            Data.passwordManagerItem newItem = new Data.passwordManagerItem();
                            newItem.name = input.InputValue;
                            _items.Add(newItem);

                            // Assign the current item user.
                            _currentItem = newItem;

                            // If no items exist.
                            if (listBoxPasswordName.Items.Count > 0)
                            {
                                btnRemoveItem.Enabled = true;
                            }
                        }
                        catch { }
                    }
                }
            }
        }