private void MoverItem(bool arriba) { if (LisVieColores.SelectedItems.Count <= 0) { return; } int index = LisVieColores.Items.IndexOf(LisVieColores.SelectedItems[0]); int nIndex = arriba ? index - 1 : index + 1; if ((index == 0) && arriba) { return; } if (nIndex >= LisVieColores.Items.Count) { return; } var old = LisVieColores.Items[index].Clone() as ListViewItem; LisVieColores.Items.RemoveAt(index); LisVieColores.Items.Insert(nIndex, old); LisVieColores.Items[nIndex].Selected = true; LisVieColores.Select(); }
private void BtnAñadir_Click(object sender, EventArgs e) { string rgba = $"{NumR.Value},{NumG.Value},{NumB.Value},{NumA.Value}"; var colorLista = new ListViewItem(""); colorLista.SubItems.Add(rgba); colorLista.SubItems.Add(TbRGBA.Text); colorLista.UseItemStyleForSubItems = false; LisVieColores.Items.Add(colorLista); LisVieColores.ColoresListView(); }
private void BtnCargar_Click(object sender, EventArgs e) { var dialogo = new OpenFileDialog { Filter = "Text File (*.Txt)|*.txt" }; if (dialogo.ShowDialog() != DialogResult.OK) { return; } LisVieColores.Items.Clear(); string[] contenido = File.ReadAllLines(dialogo.FileName); foreach (string s in contenido) { string[] codigo = s.Split('|'); string rgba = codigo[0]; string hex; if (codigo.Length == 2) { hex = codigo[1]; } else { string[] cT = rgba.Split(','); int r = int.Parse($"{cT[0]}"); int g = int.Parse($"{cT[1]}"); int b = int.Parse($"{cT[2]}"); int a = int.Parse($"{cT[3]}"); Color color = Funciones.TextoArgba(a, r, g, b); hex = color.ColorATexto(); } var colorLista = new ListViewItem(""); colorLista.SubItems.Add(rgba); colorLista.SubItems.Add(hex); colorLista.UseItemStyleForSubItems = false; LisVieColores.Items.Add(colorLista); } LisVieColores.ColoresListView(); }