Exemple #1
0
        private void saveHistoryData()
        {
            string         hash  = Utf8Sha1(tbSend.Text);
            string         name  = sendNameBox.Text;
            SendDataStruct sd    = new SendDataStruct(hash, name, tbSend.Text, cfg.send_encode);
            int            index = sds.IndexOf(hash);

            if (-1 == index)
            {
                sds.dataList.Insert(0, sd);
                sds.Save();
                addHistoryBox(sd, true);
            }
            else
            {
                SendDataStruct sd0 = sds.dataList[index];
                if (sd0.name != sd.name)
                {
                    sd0.name = sd.name;
                    sds.Save();
                    ListViewItem item = historyDataBox.Items[index];
                    item.Text = sd.name;
                }
            }
        }
Exemple #2
0
        private void btnDownData_Click(object sender, EventArgs e)
        {
            if (historyDataBox.SelectedItems.Count < 1)
            {
                showRedTip("需要选择一个调整项目");
                return;
            }
            ListViewItem lvi = historyDataBox.SelectedItems[0];

            if (lvi.Index == historyDataBox.Items.Count - 1)
            {
                showRedTip("项已经在最底部");
                return;
            }
            int index = lvi.Index;             //一旦lvi被移除,Index属性就会被置为-1,保存这个索引值

            historyDataBox.BeginUpdate();
            historyDataBox.Items.RemoveAt(index);
            historyDataBox.Items.Insert(index + 1, lvi);
            historyDataBox.EndUpdate();

            SendDataStruct sd = sds.dataList[index];

            sds.dataList.RemoveAt(index);
            sds.dataList.Insert(index + 1, sd);
            sds.Save();
        }
 public int IndexOf(string hash)
 {
     for (int i = 0; i < dataList.Count; i++)
     {
         SendDataStruct sd = dataList[i];
         if (sd.hash == hash)
         {
             return(i);
         }
     }
     return(-1);
 }
Exemple #4
0
        private void addHistoryBox(SendDataStruct sd, bool before = false)
        {
            ListViewItem lvi = new ListViewItem();

            lvi.Text = sd.name;
            lvi.SubItems.Add(sd.data);
            if (before)
            {
                historyDataBox.Items.Insert(0, lvi);
            }
            else
            {
                historyDataBox.Items.Add(lvi);
            }
        }
Exemple #5
0
        private void loadData(string conf)
        {
            conf = confNameToDataName(conf);
            if (conf == null)
            {
                return;
            }
            SendDataStorage s = SendDataStorage.Load(conf);

            if (s == null)
            {
                s           = new SendDataStorage();
                s.file_name = conf;
                s.Save();
            }
            sds = s;
            historyDataBox.BeginUpdate();
            for (int i = 0; i < sds.dataList.Count; i++)
            {
                SendDataStruct sd = sds.dataList[i];
                addHistoryBox(sd);
            }
            historyDataBox.EndUpdate();
        }