示例#1
0
 private void btnEditKey_Click(object sender, EventArgs e)
 {
     if (lbxCollection.SelectedIndex > -1)
     {
         PriorityListIndex index    = getListBoxIndex();
         Priority          priority = keys[index.keyIndex];
         OnEditPriority(priority, index.index, changePriority);
     }
 }
示例#2
0
        private void lbxCollection_MouseDoubleClick(object sender, MouseEventArgs e)
        {
            int boxIndex = lbxCollection.IndexFromPoint(e.X, e.Y);

            if (boxIndex > -1)
            {
                PriorityListIndex priorityIndex = getListBoxIndex();
                Priority          priority      = keys[priorityIndex.keyIndex];
                int    index   = priorityIndex.index;
                object element = Collection.Get(priority, index);
                OnEditItem(priority, index, element, editItem);
            }
        }
示例#3
0
        private void btnDelete_Click(object sender, EventArgs e)
        {
            if (lbxCollection.SelectedIndex > -1)
            {
                PriorityListIndex index    = getListBoxIndex();
                Priority          priority = keys[index.keyIndex];
                Collection.RemoveAt(priority, index.index);
                if (Collection.GetCountAtPriority(priority) == 0)
                {
                    keys.RemoveAt(index.keyIndex);
                }

                lbxCollection.Items.RemoveAt(lbxCollection.SelectedIndex);
            }
        }
示例#4
0
        private void btnAdd_Click(object sender, EventArgs e)
        {
            int      boxIndex = lbxCollection.SelectedIndex;
            Priority priority = new Priority(0);
            int      index    = 0;

            if (boxIndex >= 0)
            {
                PriorityListIndex priorityIndex = getListBoxIndex();
                priority = keys[priorityIndex.keyIndex];
                index    = priorityIndex.index;
            }
            object element = null;

            OnEditItem(priority, index, element, insertItem);
        }
示例#5
0
        private void btnUp_Click(object sender, EventArgs e)
        {
            if (lbxCollection.SelectedIndex < 0)
            {
                return;
            }

            PriorityListIndex index           = getListBoxIndex();
            Priority          currentPriority = keys[index.keyIndex];

            if (index.index == 0)
            {
                Priority newPriority = (index.keyIndex > 0) ? keys[index.keyIndex - 1] : new Priority(currentPriority[0] - 1);

                //remove from current
                object obj = Collection.Get(currentPriority, index.index);
                Collection.RemoveAt(currentPriority, index.index);

                //send it to the higher tier
                Priority nextPriority = getNextPriority(currentPriority, newPriority);
                Collection.Add(nextPriority, obj);

                //synchronize key list
                if (Collection.GetCountAtPriority(currentPriority) == 0)
                {
                    keys.RemoveAt(index.keyIndex);
                }

                if (index.keyIndex == 0 || keys[index.keyIndex - 1] != nextPriority)
                {
                    keys.Insert(index.keyIndex, nextPriority);
                }

                //regardless, just change the name of the selected index
                lbxCollection.Items[lbxCollection.SelectedIndex] = getEntryString(nextPriority, obj);
            }
            else
            {
                //switch
                int selectedIndex = lbxCollection.SelectedIndex;
                Switch(currentPriority, index.index, index.index - 1, selectedIndex, selectedIndex - 1);
                lbxCollection.SelectedIndex = selectedIndex - 1;
            }
        }