예제 #1
0
 private void buttonX_down_Click(object sender, EventArgs e)
 {
     try
     {
         ListBox.SelectedIndexCollection sic = listBox1.SelectedIndices;//得到选择的Item的下标
         if (sic.Count == 0)
         {
             return;
         }
         else
         {
             List <int> list = new List <int>();
             for (int i = 0; i < sic.Count; i++)
             {
                 list.Add(sic[i]);
             }
             list.Sort();
             for (int i = 0; i < list.Count; i++)
             {
                 if (list[i] >= 0 && list[i] != listBox1.Items.Count - 1)
                 {
                     string temp = listBox1.Items[list[i] + 1].ToString();
                     listBox1.Items[list[i] + 1] = listBox1.Items[list[i]].ToString();
                     listBox1.Items[list[i]]     = temp;
                 }
             }
         }
     }
     catch (Exception exp)
     {
         MessageBox.Show(exp.Message, "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }
예제 #2
0
        private List <PREH> GetPresetLocales(ListBox.SelectedIndexCollection indeces)
        {
            var list = new List <PREH>();

            if (0 == lstPreset.Items.Count)
            {
                return(list);
            }
            if (indeces.Count < 0)
            {
                return(list);
            }

            foreach (int index in indeces)
            {
                var cols   = lstPreset.Items[index].ToString().Split('|');
                var locale = new PREH();
                locale.IsDrum  = "Drum" == cols[0];
                locale.ProgNum = byte.Parse(cols[1]);
                locale.BankMSB = byte.Parse(cols[2]);
                locale.BankLSB = byte.Parse(cols[3]);
                list.Add(locale);
            }
            return(list);
        }
예제 #3
0
        private void deleteEntryToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (clipEntryListBox.SelectedIndices.Count > 0)
            {
                string msg;
                if (clipEntryListBox.SelectedIndices.Count == 1)
                {
                    msg = "Do you really want to remove the selected clip?";
                }
                else
                {
                    msg = String.Format("Do you really want to remove the {0} selected clips?", clipEntryListBox.SelectedIndices.Count);
                }

                if (MessageBox.Show(msg, "Clipboard Manager", MessageBoxButtons.YesNo, MessageBoxIcon.Question,
                                    MessageBoxDefaultButton.Button1) == DialogResult.Yes)
                {
                    ListBox.SelectedIndexCollection indices = clipEntryListBox.SelectedIndices;
                    for (int i = indices.Count - 1; i >= 0; i--)
                    {
                        clipEntryListBox.Items.RemoveAt(indices[i]);
                    }
                }
            }
        }
예제 #4
0
        private void Delbutn_Click(object sender, EventArgs e)
        {
            ListBox.SelectedIndexCollection sic = Selectlinelist.SelectedIndices;//得到选择的Item的下标

            if (sic.Count == 0)
            {
                return;
            }

            else

            {
                //  将选择的Item放入list中

                List <int> list = new List <int>();

                for (int i = 0; i < sic.Count; i++)

                {
                    list.Add(sic[i]);
                }

                list.Sort();            //对list进行排序(库里默认的排序结果一般指的是从下到大的排序)

                while (list.Count != 0) //按照下标从大到小的顺序从ListBox控件里删除选择的Item

                //如果这里采用其它顺序则可能破坏下标的有效性

                {
                    Selectlinelist.Items.RemoveAt(list[list.Count - 1]);
                    list.RemoveAt(list.Count - 1);
                }
            }
        }
예제 #5
0
        private void cmdAddToMission_Click(object sender, EventArgs e)
        {
            ListBox.SelectedIndexCollection sic = lstLibraryCraft.SelectedIndices;
            if (sic.Count == 0)
            {
                return;
            }
            int group = lstLibraryGroup.SelectedIndex;

            if (group < 0 || group >= _groupList.Count)
            {
                return;
            }
            object[] sendArray = new object[sic.Count];
            int      index     = 0;

            // Create an array of cloned objects to send back to the form.
            foreach (int si in sic)
            {
                using (MemoryStream ms = new MemoryStream())
                {
                    System.Runtime.Serialization.IFormatter formatter = new System.Runtime.Serialization.Formatters.Binary.BinaryFormatter();
                    formatter.Serialize(ms, _groupList[group][si]);
                    ms.Position = 0;
                    object fg = formatter.Deserialize(ms);
                    if (chkAutoscrubAddMission.Checked)
                    {
                        scanProblems(fg, true, false);
                    }
                    sendArray[index++] = fg;
                }
            }
            _onAddEvent(sendArray, new EventArgs());
        }
예제 #6
0
 private void Borrar_Click(object sender, EventArgs e)
 {
     lbl.Text = "";
     ListBox.SelectedIndexCollection col = listBox1.SelectedIndices;
     if (listBox1.Items.Count != 0 && frikis.Count != 0)
     {
         if (col.Count != 0)
         {
             System.Diagnostics.Debug.WriteLine("Count col:" + col.Count);
             for (int i = col.Count - 1; i >= 0; i--)
             {
                 System.Diagnostics.Debug.WriteLine("col i:" + col[i]);
                 listBox1.Items.RemoveAt(col[i]);
                 frikis.RemoveAt(col[i]);
             }
         }
         else
         {
             lbl.Text = "No se puede borrar porque no has selecionado nada";
         }
     }
     else
     {
         lbl.Text = "Listas Vacias";
     }
 }
예제 #7
0
 private void DeleteItem()
 {
     if (listBox1.SelectedIndices.Count > 0)
     {
         ListBox.SelectedIndexCollection indices = listBox1.SelectedIndices;
         ArrayList arr = new ArrayList();
         foreach (int i in indices)
         {
             arr.Add(i);
         }
         arr.Reverse();
         foreach (int i in arr)
         {
             listBox1.Items.RemoveAt(i);
         }
         arr.Clear();
         arr = null;
         pb_color.Image.Dispose();
         pb_color.Image = null;
     }
     else
     {
         if (listBox1.SelectedIndex > -1)
         {
             listBox1.Items.RemoveAt(listBox1.SelectedIndex);
             pb_color.Image.Dispose();
             pb_color.Image = null;
         }
     }
 }
예제 #8
0
        private void btnRemove_Click(object sender, EventArgs e)
        {
            ListBox.SelectedIndexCollection indices = lstPhotos.SelectedIndices;
            int    count = indices.Count;
            string msg;

            if (count == 1)
            {
                msg = "Do you really want to remove the  selected photograph?";
            }
            else
            {
                msg = String.Format("Do you really want to remove the {0} selected photographs?",
                                    count);
            }
            DialogResult result = MessageBox.Show(msg, "Remove Photos?",
                                                  MessageBoxButtons.YesNo,
                                                  MessageBoxIcon.Question,
                                                  MessageBoxDefaultButton.Button2);

            if (result == DialogResult.Yes)
            {
                for (int i = count - 1; i >= 0; i--)
                {
                    Manager.Album.RemoveAt(indices[i]);
                }
                DisplayAlbum();
            }
        }
        public void ListBoxSelectedIndexCollection_IListAdd_Invoke_ThrowsNotSupportedException(object value)
        {
            using var owner = new ListBox();
            IList collection = new ListBox.SelectedIndexCollection(owner);

            Assert.Throws <NotSupportedException>(() => collection.Add(value));
        }
        public void ListBoxSelectedIndexCollection_IListClear_Invoke_ThrowsNotSupportedException()
        {
            using var owner = new ListBox();
            IList collection = new ListBox.SelectedIndexCollection(owner);

            Assert.Throws <NotSupportedException>(() => collection.Clear());
        }
        public void ListBoxSelectedIndexCollection_IListItem_Set_ThrowsNotSupportedException(int index, object value)
        {
            using var owner = new ListBox();
            IList collection = new ListBox.SelectedIndexCollection(owner);

            Assert.Throws <NotSupportedException>(() => collection[index] = value);
        }
예제 #12
0
        // private method to determine the current value (as a string)
        // of the control;
        private string GetControlCurrentValue()
        {
            if (_control is TextBox)
            {
                return((_control as TextBox).Text);
            }

            if (_control is CheckBox)
            {
                return((_control as CheckBox).Checked.ToString());
            }

            if (_control is ComboBox)
            {
                return((_control as ComboBox).Text);
            }

            if (_control is ListBox)
            {
                // for a listbox, create a list of the selected indexes
                StringBuilder val = new StringBuilder();
                ListBox       lb  = (_control as ListBox);
                ListBox.SelectedIndexCollection coll = lb.SelectedIndices;
                for (int i = 0; i < coll.Count; i++)
                {
                    val.AppendFormat("{0};", coll[i]);
                }

                return(val.ToString());
            }

            return("");
        }
예제 #13
0
        private void cmdMoveCraftDown_Click(object sender, EventArgs e)
        {
            ListBox.SelectedIndexCollection sic = lstLibraryCraft.SelectedIndices;
            int group = lstLibraryGroup.SelectedIndex;

            if (sic.Count == 0 || group < 0 || group >= _groupList.Count)
            {
                return;
            }
            int[] selection = new int[sic.Count];
            for (int i = 0; i < sic.Count; i++)
            {
                selection[i] = sic[i];
            }
            if (selection[selection.Length - 1] == lstLibraryCraft.Items.Count - 1)
            {
                return;
            }
            for (int i = selection.Length - 1; i >= 0; i--)
            {
                object temp = _groupList[group][selection[i] + 1];
                _groupList[group][selection[i] + 1] = _groupList[group][selection[i]];
                _groupList[group][selection[i]]     = temp;
            }
            refreshLibraryCraft();
            for (int i = 0; i < selection.Length; i++)
            {
                lstLibraryCraft.SetSelected(selection[i] + 1, true);
            }
            _isDirty = true;
        }
예제 #14
0
 // Funcion que hice yo, para no andar repitiendo código al borrar cosas de la listbox
 // La uso en BtnDel y BtnTras1
 public void Delete_Elements(ListBox.SelectedIndexCollection col)
 {
     for (int i = col.Count - 1; i >= 0; i--)
     {
         listBox1.Items.RemoveAt(col[i]);
     }
 }
예제 #15
0
        private void btnRemove_Click(object sender, System.EventArgs e)
        {
            string msg;
            int    n = lstPhotos.SelectedItems.Count;

            if (n == 1)
            {
                msg = "Do your really want to remove the selected photo?";
            }
            else
            {
                msg = String.Format("Do you really want to remove the {0} selected photos?", n);
            }

            DialogResult result = MessageBox.Show(msg, "Remove Photos?",
                                                  MessageBoxButtons.YesNo,
                                                  MessageBoxIcon.Question);

            if (result == DialogResult.Yes)
            {
                ListBox.SelectedIndexCollection indices = lstPhotos.SelectedIndices;
                for (int i = indices.Count - 1; i >= 0; i--)
                {
                    _album.RemoveAt(indices[i]);
                }

                _bAlbumChanged = true;
                UpdateList();
            }
        }
예제 #16
0
        private void listBox1_KeyDown(object sender, KeyEventArgs e)
        {
            if (e.KeyData == Keys.Delete)
            {
                if (listBox1.Items.Count == 1)
                {
                    return;
                }

                ListBox.SelectedIndexCollection _list = listBox1.SelectedIndices;
                int count = _list.Count;

                while (count > 0 && Main_OMF.AnimsParams.Count > 1)
                {
                    int i = _list[count - 1];
                    Main_OMF.AnimsParams.RemoveAt(i);
                    Main_OMF.Anims.RemoveAt(i);
                    --count;
                }

                Main_OMF.RecalcAllAnimIndex();
                Main_OMF.RecalcAnimNum();
                UpdateList();
            }
        }
        public void SaveSelectedIndices()
        {
            m_selected.Clear();
            ListBox.SelectedIndexCollection selected = m_listbox.SelectedIndices;
            for (int i = 0; i < selected.Count; i++)
            {
                m_selected.Add(selected[i]);
            }

            string str;
            int    count = m_selected.Count;

            if (count == 0)
            {
                str = "0 objects selected";
            }
            else if (count == 1)
            {
                str = "1 objects selected";
            }
            else
            {
                str = string.Format("{0} objects selected", count);
            }
            m_count_label.Text = str;
        }
예제 #18
0
        private void sensorListBox_SelectedIndexChanged(object sender, EventArgs e)
        {
            ListBox.SelectedIndexCollection sic = sensorListBox.SelectedIndices;

            if (sic.Count == 0)
            {
                addButton.Enabled = false;
                return;
            }
            else
            {
                string orgin = "填写或选择分组";
                EnableAddButton = true;
                if (filOrChoGroupComboBox.Text != orgin &&
                    filOrChoGroupComboBox.Text != "" &&
                    EnableAddButton &&
                    sensorListBox.Items.Count > 0)
                {
                    addButton.Enabled = true;
                }
                itemsList.Clear();
                Collection <string> TempList = new Collection <string>();
                TempList.Clear();
                for (int i = 0; i < sensorListBox.SelectedItems.Count; i++)
                {
                    TempList.Add(sensorListBox.SelectedItems[i].ToString());
                }
                itemsList.AddRange(TempList);
            }
        }
예제 #19
0
        private void 排除文件ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            ListBox.SelectedIndexCollection sic = listBox1.SelectedIndices;//得到选择的Item的下标
            if (sic.Count == 0)
            {
                return;
            }
            List <int> list = new List <int>();

            for (int i = 0; i < sic.Count; i++)
            {
                list.Add(sic[i]);
            }
            list.Sort();

            listBox1.DataSource = null;
            while (list.Count != 0)
            {
                //listBox1.Items.RemoveAt(list[list.Count - 1]);
                sourceFileList.RemoveAt(list[list.Count - 1]);
                list.RemoveAt(list.Count - 1);
            }

            listBox1.DataSource = sourceFileList;
        }
예제 #20
0
        private void undoList_MouseMove(object sender, System.Windows.Forms.MouseEventArgs e)
        {
            int index = this.undoList.IndexFromPoint(e.X, e.Y);

            if (index != -1)
            {
                ListBox.SelectedIndexCollection selectedIndices = this.undoList.SelectedIndices;
                for (int i = index; i >= 0; i--)
                {
                    if (!selectedIndices.Contains(i))
                    {
                        this.undoList.SetSelected(i, true);
                    }
                }

                for (int i = index + 1; i < this.undoList.Items.Count; i++)
                {
                    if (selectedIndices.Contains(i))
                    {
                        this.undoList.SetSelected(i, false);
                    }
                }

                index++;
                this.undoLabel.Text = "Undo " + index.ToString() + " Actions.";
            }
        }
예제 #21
0
        private void button_moveLanguageDown_Click(object sender, EventArgs e)
        {
            int ilevel = 0;

            if (listBox_selectedLanguages.SelectedItems.Count > 0)
            {
                ListBox.SelectedIndexCollection selectedItems = listBox_selectedLanguages.SelectedIndices;
                int[] index_selectedItems = new int[selectedItems.Count];

                for (int i = 0; i < selectedItems.Count; i++)
                {
                    index_selectedItems[i] = selectedItems[i];
                }

                for (int i = index_selectedItems.Length - 1; i >= 0; i--)
                {
                    ilevel = index_selectedItems[i];

                    if ((ilevel + 1 >= 0) && (ilevel + 1 <= listBox_selectedLanguages.Items.Count - (index_selectedItems.Length - i)))
                    {
                        String lvitem = (String)listBox_selectedLanguages.Items[ilevel];
                        listBox_selectedLanguages.Items.Remove(lvitem);
                        listBox_selectedLanguages.Items.Insert(ilevel + 1, lvitem);
                        listBox_selectedLanguages.SetSelected(ilevel + 1, true);

                        // Do the same on the Property.
                        StringCollection languages = this.userSettingService.GetUserSetting <StringCollection>(UserSettingConstants.SelectedLanguages);
                        languages.Remove(lvitem);
                        languages.Insert(ilevel + 1, lvitem);
                        this.userSettingService.SetUserSetting(UserSettingConstants.SelectedLanguages, languages);
                    }
                }
            }
        }
        public void ListBoxSelectedIndexCollection_IListRemoveAt_Invoke_ThrowsNotSupportedException(int index)
        {
            using var owner = new ListBox();
            IList collection = new ListBox.SelectedIndexCollection(owner);

            Assert.Throws <NotSupportedException>(() => collection.RemoveAt(index));
        }
예제 #23
0
파일: Conexion.cs 프로젝트: newxas/NeonV2
        public void insertarExtraContrato(ListBox.SelectedIndexCollection list)
        {
            int idContrato = 0;

            cmd   = new SqlCommand("select IDENT_CURRENT('contrato')", cn);
            sqldr = cmd.ExecuteReader();
            while (sqldr.Read())
            {
                idContrato = Convert.ToInt32(sqldr.GetValue(0));
            }
            sqldr.Close();
            cmd = new SqlCommand("insert into relacionExtrasContrato(idContrato, idExtra) values (@idContrato, @extra)", cn);
            cmd.Parameters.Add("@idContrato", SqlDbType.Int);
            cmd.Parameters.Add("@extra", SqlDbType.Int);
            cmd.Parameters["@idContrato"].Value = idContrato;
            foreach (var item in list)
            {
                try
                {
                    cmd.Parameters["@extra"].Value = item;
                    cmd.ExecuteNonQuery();
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                }
            }
        }
예제 #24
0
        private void button3_Click(object sender, EventArgs e)
        {
            ListBox quito = null, anado = null;

            if (sender == button3)
            {
                quito = listBox1;
                anado = listBox2;
            }
            if (sender == button4)
            {
                quito = listBox2;
                anado = listBox1;
            }
            int cont = 0;

            ListBox.SelectedIndexCollection selec = quito.SelectedIndices;
            while (selec.Count > cont)
            {
                anado.Items.Insert(anado.Items.Count, quito.Items[selec[cont]]);
                cont++;
            }
            while (cont > 0)
            {
                quito.Items.RemoveAt(selec[cont - 1]);
                cont--;
            }
            rellenaLabels();
        }
예제 #25
0
        /// <summary>Deletes the selected library craft from the group.</summary>
        private void deleteLibraryCraftSelection()
        {
            // [JB] I tried adding a keypress handler for delete, but this caused all sorts of weird problems.  Possibly event race conditions with drag selection.
            ListBox.SelectedIndexCollection sic = lstLibraryCraft.SelectedIndices;
            int group = lstLibraryGroup.SelectedIndex;

            if (sic.Count > 0 && group >= 0 && group < _groupList.Count)
            {
                while (sic.Count > 0)
                {
                    int index = sic[sic.Count - 1];
                    _groupList[group].RemoveAt(index);
                    lstLibraryCraft.Items.RemoveAt(index);                     // Removing will modify the selected collection too.
                }
                _isDirty = true;
            }
            // There are some weird anomalies if deleting while a mouse-drag is in progress, where the underlying selection data doesn't correspond to what the user actually sees.
            // This doesn't entirely solve the problem, but it helps.  Keeping this just to be safe.
            lstLibraryCraft.Enabled = false;
            for (int i = 0; i < lstLibraryCraft.Items.Count; i++)
            {
                if (lstLibraryCraft.GetSelected(i))
                {
                    lstLibraryCraft.SetSelected(i, false);
                }
            }
            lstLibraryCraft.Enabled = true;

            refreshGroupCraftCount();
        }
예제 #26
0
        private void fullPathCheckBox_CheckedChanged(object sender, EventArgs e)
        {
            ListBox.SelectedIndexCollection oldSelection = this.oldListBox.SelectedIndices;
            ListBox.SelectedIndexCollection newSelection = this.newListBox.SelectedIndices;

            List <int> oldIndices = new List <int>();
            List <int> newIndices = new List <int>();

            foreach (int s in oldSelection)
            {
                oldIndices.Add(s);
            }
            foreach (int s in newSelection)
            {
                newIndices.Add(s);
            }

            this.oldListBox.DataSource = this.fullPathCheckBox.Checked ? this.oldFiles : this.oldFileNames;
            this.newListBox.DataSource = this.fullPathCheckBox.Checked ? this.newFiles : this.newFileNames;

            this.oldListBox.ClearSelected();
            this.newListBox.ClearSelected();

            foreach (int s in oldIndices)
            {
                this.oldListBox.SelectedIndex = s;
            }
            foreach (int s in newIndices)
            {
                this.newListBox.SelectedIndex = s;
            }
        }
예제 #27
0
        private void routesListBox_SelectedIndexChanged(object sender, EventArgs e)
        {
            try
            {
                Status.graphcreator.activeroutes.Clear();

                ListBox.SelectedIndexCollection ic = routesListBox.SelectedIndices;
                Status.graphcreator.Redraw(true);
                //MessageBox.Show(n.ToString());
                if (ic.Count > 0)
                {
                    foreach (int i in ic)
                    {
                        if (i != -1)
                        {
                            Status.graphcreator.DrawRoute((Route)routes[i], false);
                        }
                        Status.graphcreator.activeroutes.Add((Route)routes[i]);
                    }
                }
            }

            catch (Exception ex) {
                Console.WriteLine(ex.Message);
            }
        }
예제 #28
0
 internal static List <int> ToList([NotNull] this ListBox.SelectedIndexCollection indexCollection)
 {
     if (indexCollection == null)
     {
         throw new ArgumentNullException("indexCollection");
     }
     return(new List <int>(indexCollection.Cast <int>()));
 }
        public void ListBoxSelectedIndexCollection_Ctor_ListBox()
        {
            using var owner = new ListBox();
            var collection = new ListBox.SelectedIndexCollection(owner);

            Assert.Equal(0, collection.Count);
            Assert.True(collection.IsReadOnly);
        }
예제 #30
0
 private void RemoveUdpConnection(object sender, EventArgs e)
 {
     ListBox.SelectedIndexCollection list = UDPConnectionsList.SelectedIndices;
     foreach (int pos in list)
     {
         UDPConnectionsList.Items.RemoveAt(pos);
     }
 }