Пример #1
0
        private async void button2_Click(object sender, EventArgs e)
        {
            Algo       obj        = new Algo();
            int        maxsize    = Convert.ToInt16(textBox1.Text);
            List <Map> folders    = new List <Map>(obj.worst_fit(arr, maxsize));
            string     filename   = "";
            string     foldername = @"C:\Users\SherifMounir\Documents";
            string     filePath   = System.IO.Path.Combine(foldername, "worst_fit" + c.ToString());
            int        total      = 0;

            for (int j = 0; j < folders.Count; j++)
            {
                filename = "f" + c.ToString();
                FileInfo     fileusername = new FileInfo(filename);
                StreamWriter namewriter   = fileusername.CreateText();
                //namewriter.WriteLine(folders[j].L.Count.ToString());
                namewriter.WriteLine(folders[j].name);
                for (int k = 0; k < folders[j].L.Count; k++)
                {
                    total += folders[j].L[k];
                    namewriter.Write(folders[j].index[k]);
                    namewriter.Write("." + "mp3 ");

                    namewriter.WriteLine(obj.converttosec(folders[j].L[k]));
                }
                //  namewriter.Write("total size : ");
                namewriter.WriteLine(obj.converttosec(total));
                total = 0;
                namewriter.Close();
                System.IO.File.Move(filename, filePath);
                c++;
                filePath = System.IO.Path.Combine(foldername, "worst_fit" + c.ToString());
            }
            MessageBox.Show("saved");
        }
Пример #2
0
        private void button4_Click(object sender, EventArgs e)
        {
            Algo obj     = new Algo();
            int  maxsize = Convert.ToInt16(textBox1.Text);

            arr.Sort();
            arr.Reverse();
            Dictionary <int, Map> pr = obj.worst_fit_priority(arr, maxsize);

            List <int> keyList    = new List <int>(pr.Keys);
            string     filename   = "";
            string     foldername = @"C:\Users\SherifMounir\Documents";
            string     filePath   = System.IO.Path.Combine(foldername, "worst_fit_priority_dec" + c.ToString());
            int        total      = 0;

            for (int j = 0; j < keyList.Count; j++)
            {
                int z = keyList[j];
                filename = "f" + c.ToString();
                FileInfo     fileusername = new FileInfo(filename);
                StreamWriter namewriter   = fileusername.CreateText();
                //namewriter.WriteLine(pr[z].L.Count);
                namewriter.WriteLine(pr[z].name);

                for (int k = 0; k < pr[z].L.Count; k++)
                {
                    total += pr[z].L[k];
                    namewriter.Write(pr[z].index[k]);
                    namewriter.Write("." + "mp3 ");
                    namewriter.WriteLine(obj.converttosec(pr[z].L[k]));
                }
                // namewriter.Write("total size : ");
                namewriter.WriteLine(obj.converttosec(total));
                total = 0;
                namewriter.Close();
                System.IO.File.Move(filename, filePath);
                c++;
                filePath = System.IO.Path.Combine(foldername, "worst_fit_priority_dec" + c.ToString());
            }
            MessageBox.Show("saved");
        }
Пример #3
0
        private void button5_Click(object sender, EventArgs e)
        {
            Algo obj     = new Algo();
            int  maxsize = Convert.ToInt16(textBox1.Text);

            arr.Sort();
            arr.Reverse();
            // dict = dict.OrderBy(x => x.Value).ToDictionary(x => x.Key, x => x.Value);

            List <Map> folders    = new List <Map>(obj.first_fit_decreasing_usinglinearsearch(arr, maxsize, dict));
            string     filename   = "";
            string     foldername = @"C:\Users\SherifMounir\Documents";
            string     filePath   = System.IO.Path.Combine(foldername, "FirstFitDecreasingOrder" + c.ToString());
            int        total      = 0;

            for (int j = 0; j < folders.Count; j++)
            {
                filename = "f" + c.ToString();
                FileInfo     fileusername = new FileInfo(filename);
                StreamWriter namewriter   = fileusername.CreateText();
                //namewriter.WriteLine(folders[j].L.Count.ToString());
                namewriter.WriteLine(folders[j].name);
                for (int k = 0; k < folders[j].L.Count; k++)
                {
                    total += folders[j].L[k];

                    namewriter.Write(folders[j].index[k]);
                    namewriter.Write("." + "mp3 ");
                    namewriter.WriteLine(obj.converttosec(folders[j].L[k]));
                }
                //  namewriter.Write("total size : ");
                namewriter.WriteLine(obj.converttosec(total));
                total = 0;
                namewriter.Close();
                System.IO.File.Move(filename, filePath);
                c++;
                filePath = System.IO.Path.Combine(foldername, "FirstFitDecreasingOrder" + c.ToString());
            }
            MessageBox.Show("saved");
        }