private void ShowCharacters()
 {
     listView2.Items.Clear();
     if (_areaIndex > -1)
     {
         Array.Sort(_configuration.Areas[_areaIndex].Characters);
         for (int i = 0; i < _configuration.Areas[_areaIndex].Characters.Length; i++)
         {
             LCDCharacter c    = _configuration.Areas[_areaIndex].Characters[i];
             ListViewItem item = new ListViewItem((c.Order + 1).ToString());
             item.Tag = c;
             item.SubItems.Add(c.LCD.ID);
             item.SubItems.Add(c.Row.ToString());
             item.SubItems.Add(c.Column.ToString());
             listView2.Items.Add(item);
         }
     }
     else
     {
         for (int i = 0; i < _characters.Count; i++)
         {
             LCDCharacter c    = _characters[i];
             ListViewItem item = new ListViewItem((c.Order + 1).ToString());
             item.Tag = c;
             item.SubItems.Add(c.LCD.ID);
             item.SubItems.Add(c.Row.ToString());
             item.SubItems.Add(c.Column.ToString());
             listView2.Items.Add(item);
         }
     }
     Test();
 }
        private void button4_Click(object sender, EventArgs e)
        {
            if (listView2.SelectedIndices.Count > 0 && listView2.SelectedIndices[0] < listView2.Items.Count - 1)
            {
                LCDCharacter c = null;
                if (_areaIndex > -1)
                {
                    LPTLCDCharacter c1 = null;
                    LPTLCDCharacter c2 = null;

                    if (listView2.SelectedItems[0].Tag is LPTLCDCharacter)
                    {
                        c1 = (LPTLCDCharacter)listView2.SelectedItems[0].Tag;
                    }
                    else
                    {
                        c1 = new LPTLCDCharacter((LCDCharacter)listView2.SelectedItems[0].Tag);
                        _configuration.Areas[_areaIndex].Characters[listView2.SelectedIndices[0]] = c1;
                    }

                    if (listView2.Items[listView2.SelectedIndices[0] + 1].Tag is LPTLCDCharacter)
                    {
                        c2 = (LPTLCDCharacter)listView2.Items[listView2.SelectedIndices[0] + 1].Tag;
                    }
                    else
                    {
                        c2 = new LPTLCDCharacter((LCDCharacter)listView2.Items[listView2.SelectedIndices[0] + 1].Tag);
                        _configuration.Areas[_areaIndex].Characters[listView2.SelectedIndices[0] + 1] = c2;
                    }

                    int tmp = c1.Order;
                    c1.Set(c2.Order);
                    c2.Set(tmp);
                    c = c1;
                }
                else
                {
                    LPTLCDCharacter c1 = _characters[listView2.SelectedIndices[0]];
                    LPTLCDCharacter c2 = _characters[listView2.SelectedIndices[0] + 1];

                    int tmp = c1.Order;
                    c1.Set(c2.Order);
                    c2.Set(tmp);
                    ArrangeCharacters();
                    c = c1;
                }
                ShowCharacters();
                ShowCharactersOnLCD();

                listView2.SelectedItems.Clear();
                for (int i = 0; i < listView2.Items.Count; i++)
                {
                    if ((LCDCharacter)listView2.Items[i].Tag == c)
                    {
                        listView2.Items[i].Selected = true;
                        break;
                    }
                }
            }
        }
 public LPTLCDCharacter(LCDCharacter character)
 {
     LCD    = character.LCD;
     Row    = character.Row;
     Column = character.Column;
     Order  = character.Order;
 }
 private void listView2_SelectedIndexChanged(object sender, EventArgs e)
 {
     if (listView2.SelectedItems.Count > 0)
     {
         LCDCharacter c = listView2.SelectedItems[0].Tag as LCDCharacter;
         if (c != null)
         {
             if (comboBox4.SelectedItem == null || (comboBox4.SelectedItem != null && (LCD)comboBox4.SelectedItem != c.LCD))
             {
                 comboBox4.SelectedItem = c.LCD;
             }
             lcdViewCtrl1.Mark(c.Row, c.Column);
         }
     }
     else
     {
         lcdViewCtrl1.Unmark();
     }
 }