コード例 #1
0
ファイル: Form1.cs プロジェクト: Ejik007/Lab1-2
        private void button1_Click(object sender, EventArgs e)
        {
            string filename = "data.txt";
            FileStream fs = File.Create(filename);
            fs.Close();
            int n = (Int16)ValueN.Value;
            int m = (Int16)ValueM.Value;
            double lyamda = (double)ValueLyamda.Value;
            double mu = (double)ValueMu.Value;

            PrintingDynamicData dynamic = new PrintingDynamicData(n, m, lyamda, mu, filename, zedGraphControl1);
            dynamic.PrintPk_t();
            dynamic.PrintTube();
            dynamic.PrintProperties();
            PrintStationaryData stat = new PrintStationaryData(n, m, lyamda, mu, filename);
            stat.PrintFull();

            XmlSerializer xml2 = new XmlSerializer(typeof(PrintingDynamicData));
            using (var fStream = new FileStream("DynamicData.xml", FileMode.Create, FileAccess.Write, FileShare.None))
            {
                xml2.Serialize(fStream, dynamic);
            }

            if (radioButtonM.Checked)
            {
                int[] mass_of_m = new int[6];
                mass_of_m[0] = m;
                mass_of_m[1] = (int)m1.Value;
                mass_of_m[2] = (int)m2.Value;
                mass_of_m[3] = (int)m3.Value;
                mass_of_m[4] = (int)m4.Value;
                mass_of_m[5] = (int)m5.Value;
                mass_of_m = mass_of_m.Distinct().ToArray(); //удаляем повторяющиеся элементы
                mass_of_m = mass_of_m.OrderBy(x => x).ToArray(); //сортируем по возрастанию
                PrintStationaryData[] variations = new PrintStationaryData[mass_of_m.Length];
                List<PrintStationaryData> variation = new List<PrintStationaryData>();

                for (int i = 0; i < mass_of_m.Length; i++)
                {
                    variations[i] = new PrintStationaryData(n, mass_of_m[i], lyamda, mu, filename);
                    variations[i].PrintShort();
                    variation.Add(variations[i]);
                }
                XmlSerializer xml3 = new XmlSerializer(variation.GetType());
                using (var fStream = new FileStream("Variation.xml", FileMode.Create, FileAccess.Write, FileShare.None))
                {
                    xml3.Serialize(fStream, variation);
                }
            }
            else
            {
                int[] mass_of_n = new int[6];
                mass_of_n[0] = n;
                mass_of_n[1] = (int)n1.Value;
                mass_of_n[2] = (int)n2.Value;
                mass_of_n[3] = (int)n3.Value;
                mass_of_n[4] = (int)n4.Value;
                mass_of_n[5] = (int)n5.Value;
                mass_of_n = mass_of_n.Distinct().ToArray();
                mass_of_n = mass_of_n.OrderBy(x => x).ToArray();
                PrintStationaryData[] variations = new PrintStationaryData[mass_of_n.Length];
                List<PrintStationaryData> variation = new List<PrintStationaryData>();

                for (int i = 0; i < mass_of_n.Length; i++)
                {
                    if (lyamda / mu / mass_of_n[i] != 1)
                    {
                        variations[i] = new PrintStationaryData(mass_of_n[i], m, lyamda, mu, filename);
                        variations[i].PrintShort();
                        variation.Add(variations[i]);
                    }
                }
                XmlSerializer xml3 = new XmlSerializer(variation.GetType());
                using (var fStream = new FileStream("Variation.xml", FileMode.Create, FileAccess.Write, FileShare.None))
                {
                    xml3.Serialize(fStream, variation);
                }
            }
        }
コード例 #2
0
        private void button1_Click(object sender, EventArgs e)
        {
            string     filename = "data.txt";
            FileStream fs       = File.Create(filename);

            fs.Close();
            int    n      = (Int16)ValueN.Value;
            int    m      = (Int16)ValueM.Value;
            double lyamda = (double)ValueLyamda.Value;
            double mu     = (double)ValueMu.Value;

            PrintingDynamicData dynamic = new PrintingDynamicData(n, m, lyamda, mu, filename, zedGraphControl1);

            dynamic.PrintPk_t();
            dynamic.PrintTube();
            dynamic.PrintProperties();
            PrintStationaryData stat = new PrintStationaryData(n, m, lyamda, mu, filename);

            stat.PrintFull();

            XmlSerializer xml2 = new XmlSerializer(typeof(PrintingDynamicData));

            using (var fStream = new FileStream("DynamicData.xml", FileMode.Create, FileAccess.Write, FileShare.None))
            {
                xml2.Serialize(fStream, dynamic);
            }



            if (radioButtonM.Checked)
            {
                int[] mass_of_m = new int[6];
                mass_of_m[0] = m;
                mass_of_m[1] = (int)m1.Value;
                mass_of_m[2] = (int)m2.Value;
                mass_of_m[3] = (int)m3.Value;
                mass_of_m[4] = (int)m4.Value;
                mass_of_m[5] = (int)m5.Value;
                mass_of_m    = mass_of_m.Distinct().ToArray();      //удаляем повторяющиеся элементы
                mass_of_m    = mass_of_m.OrderBy(x => x).ToArray(); //сортируем по возрастанию
                PrintStationaryData[]      variations = new PrintStationaryData[mass_of_m.Length];
                List <PrintStationaryData> variation  = new List <PrintStationaryData>();

                for (int i = 0; i < mass_of_m.Length; i++)
                {
                    variations[i] = new PrintStationaryData(n, mass_of_m[i], lyamda, mu, filename);
                    variations[i].PrintShort();
                    variation.Add(variations[i]);
                }
                XmlSerializer xml3 = new XmlSerializer(variation.GetType());
                using (var fStream = new FileStream("Variation.xml", FileMode.Create, FileAccess.Write, FileShare.None))
                {
                    xml3.Serialize(fStream, variation);
                }
            }
            else
            {
                int[] mass_of_n = new int[6];
                mass_of_n[0] = n;
                mass_of_n[1] = (int)n1.Value;
                mass_of_n[2] = (int)n2.Value;
                mass_of_n[3] = (int)n3.Value;
                mass_of_n[4] = (int)n4.Value;
                mass_of_n[5] = (int)n5.Value;
                mass_of_n    = mass_of_n.Distinct().ToArray();
                mass_of_n    = mass_of_n.OrderBy(x => x).ToArray();
                PrintStationaryData[]      variations = new PrintStationaryData[mass_of_n.Length];
                List <PrintStationaryData> variation  = new List <PrintStationaryData>();

                for (int i = 0; i < mass_of_n.Length; i++)
                {
                    if (lyamda / mu / mass_of_n[i] != 1)
                    {
                        variations[i] = new PrintStationaryData(mass_of_n[i], m, lyamda, mu, filename);
                        variations[i].PrintShort();
                        variation.Add(variations[i]);
                    }
                }
                XmlSerializer xml3 = new XmlSerializer(variation.GetType());
                using (var fStream = new FileStream("Variation.xml", FileMode.Create, FileAccess.Write, FileShare.None))
                {
                    xml3.Serialize(fStream, variation);
                }
            }
        }