Exemplo n.º 1
0
        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;
                    }
                }
            }
        }
Exemplo n.º 2
0
        private void lcdViewCtrl1_SelectingCharPositionEvent(object sender, LCDViewCtrl.SelectEventArgs e)
        {
            e.Proceed = false;
            LCD lcd = comboBox4.SelectedItem as LCD;

            if (lcd == null)
            {
                return;
            }
            e.Proceed = true;
            if (e.Select)
            {
                LCDCharacter c = new LPTLCDCharacter((LPTLCD)lcd, (byte)e.CharPosition.Row, (byte)e.CharPosition.Column, listView2.Items.Count);
                if (_areaIndex > -1)
                {
                    List <LCDCharacter> cs = new List <LCDCharacter>();
                    cs.AddRange(_configuration.Areas[_areaIndex].Characters);
                    cs.Add(c);
                    ((LPTLCDArea)_configuration.Areas[_areaIndex]).Set(cs.ToArray());
                    _configuration.Areas[_areaIndex].ArrangeCharacters();
                }
                else
                {
                    _characters.Add((LPTLCDCharacter)c);
                    ArrangeCharacters();
                }
            }
            else
            {
                if (_areaIndex > -1)
                {
                    List <LCDCharacter> cs = new List <LCDCharacter>();
                    cs.AddRange(_configuration.Areas[_areaIndex].Characters);
                    int index = cs.Count;
                    while (index-- > 0)
                    {
                        if (cs[index].LCD == lcd && cs[index].Row == e.CharPosition.Row && cs[index].Column == e.CharPosition.Column)
                        {
                            cs.RemoveAt(index);
                            break;
                        }
                    }
                    ((LPTLCDArea)_configuration.Areas[_areaIndex]).Set(cs.ToArray());
                    _configuration.Areas[_areaIndex].ArrangeCharacters();
                }
                else
                {
                    List <LPTLCDCharacter> cs = _characters;
                    int index = cs.Count;
                    while (index-- > 0)
                    {
                        if (cs[index].LCD == lcd && cs[index].Row == e.CharPosition.Row && cs[index].Column == e.CharPosition.Column)
                        {
                            cs.RemoveAt(index);
                            break;
                        }
                    }
                    _characters = cs;
                    ArrangeCharacters();
                }
            }
            ShowCharacters();
            ShowCharactersOnLCD();
        }