Exemplo n.º 1
0
        private CalcData convertSaveData2CalcData(SaveData inputdata)
        {
            CalcData sdata = new CalcData();

            sdata.Xmax = inputdata.Xmax;
            sdata.Xmin = inputdata.Xmin;
            sdata.Dx   = inputdata.Dx;

            var t_firstExpr = new Dictionary <double, double>();
            var t_secExpr   = new Dictionary <double, double>();


            for (int i = 0; i < inputdata.firstArrFunc.Length; i++)
            {
                t_firstExpr.Add(inputdata.firstArrX[i], inputdata.firstArrFunc[i]);
            }
            for (int i = 0; i < inputdata.secArrFunc.Length; i++)
            {
                t_secExpr.Add(inputdata.secArrX[i], inputdata.secArrFunc[i]);
            }
            sdata.FirstExpr = t_firstExpr;
            sdata.SecExpr   = t_secExpr;

            return(sdata);
        }
Exemplo n.º 2
0
        private CalcDictTO convertCalcData2ClcDictTO(CalcData data)
        {
            var dict = new CalcDictTO();

            dict.FirstExpr = data.FirstExpr;
            dict.SecExpr   = data.SecExpr;
            return(dict);
        }
Exemplo n.º 3
0
        private void m_loadfromfile_Click(object sender, EventArgs e)
        {
            if (openFileDialog1.ShowDialog() == DialogResult.Cancel)
            {
                return;
            }
            // получаем выбранный файл
            string filename = openFileDialog1.FileName;
            // читаем файл в строку

            var upload = new SaveData();

            using (var stream = new FileStream(filename, FileMode.Open))
            {
                var serializer = new XmlSerializer(typeof(SaveData));
                upload = serializer.Deserialize(stream) as SaveData;
            }

            data = convertSaveData2CalcData(upload);
            l_firstFuncText.Items.Clear();
            l_secFuncText.Items.Clear();


            foreach (KeyValuePair <double, double> keyValue in data.FirstExpr)
            {
                l_firstFuncText.Items.Add(String.Format("x = {0:f2}, f(x) = {1:f2}", keyValue.Key, keyValue.Value));
            }

            foreach (KeyValuePair <double, double> keyValue in data.SecExpr)
            {
                l_secFuncText.Items.Add(String.Format("x = {0:f2}, f(x) = {1:f2}", keyValue.Key, keyValue.Value));
            }

            t_dx.Text                    = upload.Dx.ToString();
            t_xmax.Text                  = upload.Xmax.ToString();
            t_xmin.Text                  = upload.Xmin.ToString();
            l_firstFuncText.Visible      = true;
            l_secFuncText.Visible        = true;
            b_showFirstFuncGraph.Visible = true;
            b_showSecFuncGraph.Visible   = true;
            p_f1.Visible                 = true;
            p_f2.Visible                 = true;

            if (!isResazed)
            {
                Size      = new System.Drawing.Size(648, 305);
                isResazed = true;
            }

            MessageBox.Show("Loaded from file!");
        }
Exemplo n.º 4
0
        private SaveData convertCalcDatatoSaveData(CalcData inputdata)
        {
            SaveData sdata = new SaveData();

            sdata.Xmax = inputdata.Xmax;
            sdata.Xmin = inputdata.Xmin;
            sdata.Dx   = inputdata.Dx;

            double[] arrF1 = new double[inputdata.FirstExpr.Count];
            double[] arrF2 = new double[inputdata.SecExpr.Count];

            double[] arrX1 = new double[inputdata.FirstExpr.Count];
            double[] arrX2 = new double[inputdata.SecExpr.Count];

            int i = 0;

            foreach (KeyValuePair <double, double> keyValue in data.FirstExpr)
            {
                arrF1[i] = keyValue.Value;
                arrX1[i] = keyValue.Key;
                i++;
            }
            i = 0;
            foreach (KeyValuePair <double, double> keyValue in data.SecExpr)
            {
                arrF2[i] = keyValue.Value;
                arrX2[i] = keyValue.Key;
                i++;
            }

            sdata.firstArrX    = arrX1;
            sdata.secArrX      = arrX2;
            sdata.firstArrFunc = arrF1;
            sdata.secArrFunc   = arrF2;

            return(sdata);
        }