コード例 #1
0
        private void listBox1_SelectedIndexChanged(object sender, EventArgs e)
        {
            // DB sélectionnés
            string        sTemp;
            int           numDB        = 0;
            List <string> listTemp     = new List <string>();
            List <string> selectedList = new List <string>();

            // A GARDER
            selectList.Clear();
            foreach (var item in listBox1.SelectedItems)
            {
                selectList.Add(item.ToString());
            }

            if (selectedList.Count > 1)
            {
                return;
            }

            listBox2.Items.Clear();


            for (int i = 0; i < selectedList.Count; i++)
            {
                sTemp = selectedList[i];
                sTemp = sTemp.Substring(14);
                numDB = Int32.Parse(sTemp);

                listTemp = Fonctions.ExtractDBFromFile(sTemp, arALL);

                for (int j = 0; j < listTemp.Count; j++)
                {
                    listBox2.Items.Add(listTemp[j]);
                }
            }
            ecriture1 = true;
        }
コード例 #2
0
        private void bw_DoWork(object sender, System.ComponentModel.DoWorkEventArgs e)
        {
            BackgroundWorker worker = sender as BackgroundWorker;


            // ****************************
            // TEST
            // ****************************
            int    numDB;
            string sTemp;

            // DB sélectionnés

            if (ecriture1)
            {
                ecriture1 = false;
                compteur  = 0;
                listToto.Clear();
                if (selectList.Count == 1)
                {
                    for (int i = 0; i < 1; i++)
                    {
                        sTemp = selectList[i];
                        sTemp = sTemp.Substring(14);
                        numDB = Int32.Parse(sTemp);

                        listToto = Fonctions.ExtractDBFromFile(sTemp, arALL);
                    }

                    // Progression dans la lecture
                    //bw.ReportProgress(listToto.Count, "100");
                }
            }

            // ****************************
            // TEST 2
            // ****************************
            List <string> listTemp = new List <string>();
            List <string> valuesList = new List <string>();
            List <string> typeList = new List <string>();
            int           iTemp, k = 0, nbLecture = 0;

            if (ecriture2)
            {
                // Compteur
                cnt1     = DateTime.Now;
                go       = true;
                compteur = 0;

                ecriture2 = false;
                listToto.Clear();
                nbLecture = selectList.Count;
                progress  = 0;
                for (int i = 0; i < selectList.Count; i++)
                {
                    sTemp = selectList[i];
                    sTemp = sTemp.Substring(14);
                    numDB = Int32.Parse(sTemp);

                    listTemp = Fonctions.ExtractDBFromFile(sTemp, arALL);
                    iTemp    = Fonctions.CalculSizeDB(listTemp);
                    listTemp = Fonctions.ReplaceCharacters(listTemp, out typeList);

                    // Lecture DB
                    int    size   = iTemp;
                    byte[] Buffer = new byte[size];
                    Buffer     = Siemens.ReadDB(numDB, size);
                    valuesList = GestionAWL.ReplaceCharByValues(Buffer, typeList);

                    // Doublage des valeurs
                    int limit = valuesList.Count;
                    for (int j = 0; j < limit; j++)
                    {
                        valuesList.Add(valuesList[j]);
                    }

                    for (int j = 0; j < listTemp.Count; j++)
                    {
                        // Replace uLolo
                        string s = listTemp[j];
                        if (s.Contains("µlolo"))
                        {
                            StringBuilder b = new StringBuilder(s);
                            b.Replace("µlolo", valuesList[k]);
                            //listBox2.Items.Add(b);
                            listToto.Add(b.ToString());
                            k++;
                        }
                        else
                        {
                            //listBox2.Items.Add(listTemp[j]);
                            listToto.Add(listTemp[j]);
                        }
                    }

                    // Progression dans la lecture
                    // Progressbar
                    if (i > 0)
                    {
                        progress = Convert.ToInt32((i * 100) / nbLecture);
                    }
                    if (i == (nbLecture - 1))
                    {
                        progress = 100;
                    }
                    //bw.ReportProgress(listToto.Count);
                    bw.ReportProgress(progress);

                    // Nettoyage
                    valuesList.Clear();
                    typeList.Clear();
                    listTemp.Clear();
                    k = 0;


                    //progress++;
                }
            }
        }