private void removeCategoryFromResourceButton_Click(object sender, System.EventArgs evt)
        {
            Resource resource = (Resource)resourcesList.SelectedItem;

            ListBox.SelectedObjectCollection categories = resourceCategoriesList.SelectedItems;

            if (resource == null || categories.Count == 0)
            {
                return;
            }

            // can't use an enumerator because we'll be removing categories from the list
            Category[] cats = new Category[categories.Count];
            categories.CopyTo(cats, 0);

            for (int i = 0; i < cats.Length; i++)
            {
                Category cat = cats[i];

                bool success = resourceDAO.RemoveResourceFromCategory(resource, cat.Name);

                if (success)
                {
                    resourceCategoriesList.Items.Remove(cat);
                    availableCategoriesList.Items.Add(cat);
                }
                else
                {
                    Error("Could not remove resource from category.");
                }
            }
        }
Example #2
0
        private void buttonRemove_Click(object sender, EventArgs e)
        {
            ListBox.SelectedObjectCollection currentSelectedItems = listBoxFiles.SelectedItems;
            int selectedItemsCount = currentSelectedItems.Count;

            if (selectedItemsCount < 1)
            {
                return;
            }

            var selectedItems = new object[selectedItemsCount];

            try
            {
                currentSelectedItems.CopyTo(selectedItems, 0);
            }
            catch
            {
                return;
            }

            listBoxFiles.BeginUpdate();

            foreach (object item in selectedItems)
            {
                listBoxFiles.Items.Remove(item);
            }

            listBoxFiles.EndUpdate();
        }
Example #3
0
 private void removeResults_Click(object sender, EventArgs e)
 {
     ListBox.ObjectCollection         items         = this.resultsLST.Items;
     ListBox.SelectedObjectCollection selectedItems = this.resultsLST.SelectedItems;
     object[] itemsToRemove = new object[selectedItems.Count];
     selectedItems.CopyTo(itemsToRemove, 0);
     for (int i = itemsToRemove.Length - 1; i >= 0; i--)
     {
         items.Remove(itemsToRemove[i]);
     }
 }
Example #4
0
        private void buttonRemove_Click(object sender, EventArgs e)
        {
            Result result = new Result();

            if (0 == listBoxPidOut.SelectedItems.Count)
            {
                MessageBox.Show("Please select one item on the right side.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                result.SetResult(ResultCode.INVALID_DATA);
            }

            if (result.Fine)
            {
                ListBox.SelectedObjectCollection selectedProfileCollection = listBoxPidOut.SelectedItems;
                Array selectedPidUpdateArray = Array.CreateInstance(typeof(PidUpdate), listBoxPidOut.SelectedItems.Count);
                selectedProfileCollection.CopyTo(selectedPidUpdateArray, 0);//Make a copy of all the selected items.

                foreach (PidUpdate pidUpdate in selectedPidUpdateArray)
                {
                    int rightIndex = listBoxPidOut.Items.IndexOf(pidUpdate);
                    //Remove the right item.
                    listBoxPidOut.Items.Remove(pidUpdate);

                    //Recover the item on the left side and insert it into the right position.
                    int leftIndex = AddPidProfile(pidUpdate.GetOldPidProfile());
                    listBoxPidIn.SelectedIndex = leftIndex;

                    if (listBoxPidOut.Items.Count > 0)
                    {
                        if (rightIndex < listBoxPidOut.Items.Count)
                        {
                            listBoxPidOut.SelectedIndex = rightIndex;
                        }
                        else
                        {
                            if ((rightIndex - 1) >= 0)
                            {
                                listBoxPidOut.SelectedIndex = rightIndex - 1;
                            }
                        }
                    }
                } //foreach (PidProfile pidUpdate in selectedPidUpdateArray)
            }
        }         //buttonRemove_Click
Example #5
0
        private void buttonOneToLeaved_Click(object sender, System.EventArgs e)
        {
            Debug.Assert(listSplittedContacts.SelectedIndex != -1);
            if (buttonOneToLeaved.Enabled)
            {
                ListBox.SelectedObjectCollection coll = listSplittedContacts.SelectedItems;
                foreach (IResource res in coll)
                {
                    listLeavedContacts.Items.Add(res);
                }

                IResource[] list = new IResource[coll.Count];
                coll.CopyTo(list, 0);
                foreach (IResource res in list)
                {
                    listSplittedContacts.Items.Remove(res);
                    AccumulatedContactsToSplit = AccumulatedContactsToSplit.Minus(res.ToResourceList());
                }

                VerifyButtonsAccessibility();
            }
        }
Example #6
0
        /// <summary>Populate the list boxes with the hidden and displayed columns available.</summary>
        private void DrawListBoxes()
        {
            // Populate the 'Available' list of columns with the hidden columns.  Note that a 'ColumnItem' class is needed to get a
            // readable name for the items displayed in the list box.
            // HACK - This needs to work with the ViewColumns list.
            Stylesheet.ColumnsNode availableList = new Stylesheet.ColumnsNode();
            Stylesheet.ColumnsNode displayedList = new Stylesheet.ColumnsNode();
            //foreach (Stylesheet.ColumnNode column in this.columnList)
            //    (column.IsDisplayed ? displayedList : availableList).Add(column);
            Stylesheet.ColumnNode[] availableColumns = new Stylesheet.ColumnNode[availableList.Count];
            availableList.CopyTo(availableColumns, 0);
            Stylesheet.ColumnNode[] displayedColumns = new Stylesheet.ColumnNode[displayedList.Count];
            displayedList.CopyTo(displayedColumns, 0);

            // This will preserve the selection of the available (hidden) columns when the list is redrawn.
            ListBox.SelectedObjectCollection selectedAvailableObjects = this.listBoxAvailableFields.SelectedItems;
            Stylesheet.ColumnNode[]          selectedAvailableColumns = new Stylesheet.ColumnNode[selectedAvailableObjects.Count];
            selectedAvailableObjects.CopyTo(selectedAvailableColumns, 0);

            // This will preserve the selection of the displayed (visible) columns when the list is redrawn.
            ListBox.SelectedObjectCollection selectedDisplayedObjects = this.listBoxDisplayedFields.SelectedItems;
            Stylesheet.ColumnNode[]          selectedDisplayedColumns = new Stylesheet.ColumnNode[selectedDisplayedObjects.Count];
            selectedDisplayedObjects.CopyTo(selectedDisplayedColumns, 0);

            // Clear out the previous entries and repopulate the list of available (hidden) fields.  Note that the updating is
            // suspended so the user doesn't see the items cleared out.  If the updating were not inhibited, there would be a
            // noticable 'blink' as the items were cleared and repopulated.  Note that the selected state of the items is preserved when the list is
            // redrawn.
            this.listBoxAvailableFields.BeginUpdate();
            this.listBoxAvailableFields.Items.Clear();
            this.listBoxAvailableFields.Items.AddRange(availableColumns);
            foreach (Stylesheet.ColumnNode column in selectedAvailableColumns)
            {
                int index = this.listBoxAvailableFields.Items.IndexOf(column);
                if (index != -1)
                {
                    this.listBoxAvailableFields.SetSelected(index, true);
                }
            }
            foreach (Stylesheet.ColumnNode column in selectedDisplayedColumns)
            {
                int index = this.listBoxAvailableFields.Items.IndexOf(column);
                if (index != -1)
                {
                    this.listBoxAvailableFields.SetSelected(index, true);
                }
            }
            this.listBoxAvailableFields.EndUpdate();

            // Do the same for the displayed fields.  Note that the selected state of the items is preserved when the list is
            // redrawn.
            this.listBoxDisplayedFields.BeginUpdate();
            this.listBoxDisplayedFields.Items.Clear();
            this.listBoxDisplayedFields.Items.AddRange(displayedColumns);
            foreach (Stylesheet.ColumnNode column in selectedAvailableColumns)
            {
                int index = this.listBoxDisplayedFields.Items.IndexOf(column);
                if (index != -1)
                {
                    this.listBoxDisplayedFields.SetSelected(index, true);
                }
            }
            foreach (Stylesheet.ColumnNode column in selectedDisplayedColumns)
            {
                int index = this.listBoxDisplayedFields.Items.IndexOf(column);
                if (index != -1)
                {
                    this.listBoxDisplayedFields.SetSelected(index, true);
                }
            }
            this.listBoxDisplayedFields.EndUpdate();
        }
Example #7
0
        private void buttonAdd_Click(object sender, EventArgs e)
        {
            Result     result                = new Result();
            PidProfile selectedItem          = (PidProfile)listBoxPidIn.SelectedItem;
            int        leftSideSelectedIndex = listBoxPidIn.SelectedIndex;

            if (result.Fine)
            {
                if (null == selectedItem)
                {
                    MessageBox.Show("Please select one PID one the left side.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    result.SetResult(ResultCode.INVALID_DATA);
                }
            }

            UInt16 newPid = 0;

            if (result.Fine)
            {
                //Force the user to enter a new PID.
                if (enforceNewPid)
                {
                    try
                    {
                        //Get the new PID from user input.
                        newPid = UInt16.Parse(maskedTextBoxNewPid.Text);

                        Console.WriteLine("New PID is " + newPid);
                    }
                    catch (Exception)
                    {
                        MessageBox.Show("Invalid PID. Please enter a valid UInt16 PID.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        result.SetResult(ResultCode.INVALID_DATA);
                        maskedTextBoxNewPid.Focus();
                    }
                }
                else
                {
                    //New PID in fact is the same with the old PID on left side. Just to reuse the same structurer to make the code simple.
                    newPid = selectedItem.PID;
                }
            }

            if (result.Fine)
            {
                ListBox.SelectedObjectCollection selectedProfileCollection = listBoxPidIn.SelectedItems;
                Array selectedProfileArray = Array.CreateInstance(typeof(PidProfile), listBoxPidIn.SelectedItems.Count);
                selectedProfileCollection.CopyTo(selectedProfileArray, 0);//Make a copy of all the selected items.

                foreach (PidProfile pidProfile in selectedProfileArray)
                {
                    int leftIndex = listBoxPidIn.Items.IndexOf(pidProfile);
                    //Remove the left item.
                    listBoxPidIn.Items.Remove(pidProfile);

                    //Add to the right side.
                    int rightIndex = listBoxPidOut.Items.Add(new PidUpdate(pidProfile, newPid, enforceNewPid));
                    listBoxPidOut.SelectedIndex = rightIndex;

                    //Select the next item.
                    if (listBoxPidIn.Items.Count > 0)
                    {
                        if (leftIndex < listBoxPidIn.Items.Count)
                        {
                            listBoxPidIn.SelectedIndex = leftIndex;
                        }
                        else
                        {
                            if ((leftIndex - 1) >= 0)
                            {
                                listBoxPidIn.SelectedIndex = leftIndex - 1;
                            }
                        }
                    } //if (listBoxPid.Items.Count > 0)
                }     //foreach (PidProfile pidProfile in selectedProfileArray)
            }
        }
Example #8
0
        /// <summary>
        /// Populate the two list boxes with the hidden and displayed columns.
        /// </summary>
        private void DrawListBoxes()
        {
            DataTransform.ColumnNode[] availableColumns = new DataTransform.ColumnNode[availableList.Count];
            availableList.CopyTo(availableColumns, 0);

            DataTransform.ColumnNode[] displayedColumns = new DataTransform.ColumnNode[displayedList.Count];
            displayedList.CopyTo(displayedColumns, 0);

            // The idea here is to preserve the selected items in the 'available' list box when it is redrawn with the new
            // elements.
            ListBox.SelectedObjectCollection selectedAvailableObjects = this.listBoxAvailableFields.SelectedItems;
            DataTransform.ColumnNode[]       selectedAvailableColumns = new DataTransform.ColumnNode[selectedAvailableObjects.Count];
            selectedAvailableObjects.CopyTo(selectedAvailableColumns, 0);

            // The idea here is to preserve the selected items in the 'displayed' list box when it is redrawn with the new
            // elements.
            ListBox.SelectedObjectCollection selectedDisplayedObjects = this.listBoxDisplayedFields.SelectedItems;
            DataTransform.ColumnNode[]       selectedDisplayedColumns = new DataTransform.ColumnNode[selectedDisplayedObjects.Count];
            selectedDisplayedObjects.CopyTo(selectedDisplayedColumns, 0);

            // Clear out the previous entries and repopulate the list of available (hidden) fields.  Note that the updating is
            // suspended so the user doesn't see the items cleared out.  If the updating were not inhibited, there would be a
            // noticable 'blink' as the items were cleared and repopulated.  Note that the selected state of the items is preserved
            // when the list is redrawn.
            this.listBoxAvailableFields.BeginUpdate();
            this.listBoxAvailableFields.Items.Clear();
            this.listBoxAvailableFields.Items.AddRange(availableColumns);
            foreach (DataTransform.ColumnNode column in selectedAvailableColumns)
            {
                int index = this.listBoxAvailableFields.Items.IndexOf(column);
                if (index != -1)
                {
                    this.listBoxAvailableFields.SetSelected(index, true);
                }
            }
            foreach (DataTransform.ColumnNode column in selectedDisplayedColumns)
            {
                int index = this.listBoxAvailableFields.Items.IndexOf(column);
                if (index != -1)
                {
                    this.listBoxAvailableFields.SetSelected(index, true);
                }
            }
            this.listBoxAvailableFields.EndUpdate();

            // Do the same for the displayed fields.  Note that the selected state of the items is preserved when the list is
            // redrawn.
            this.listBoxDisplayedFields.BeginUpdate();
            this.listBoxDisplayedFields.Items.Clear();
            this.listBoxDisplayedFields.Items.AddRange(displayedColumns);
            foreach (DataTransform.ColumnNode column in selectedAvailableColumns)
            {
                int index = this.listBoxDisplayedFields.Items.IndexOf(column);
                if (index != -1)
                {
                    this.listBoxDisplayedFields.SetSelected(index, true);
                }
            }
            foreach (DataTransform.ColumnNode column in selectedDisplayedColumns)
            {
                int index = this.listBoxDisplayedFields.Items.IndexOf(column);
                if (index != -1)
                {
                    this.listBoxDisplayedFields.SetSelected(index, true);
                }
            }
            this.listBoxDisplayedFields.EndUpdate();
        }