public InitialConditions(utils.Context Ctx,ref System.Windows.Forms.PictureBox pbCanvas)
        {
            try
            {
                Xmin = Xmax = Ctx.Xarr[0];
                Ymin = Ymax = Ctx.Yarr[0];
                foreach (double tmX in Ctx.Xarr)
                {
                    if (tmX > Xmax) Xmax = tmX;
                    if (tmX < Xmin) Xmin = tmX;
                }
                foreach (double tmY in Ctx.Yarr)
                {
                    if (tmY > Ymax) Ymax = tmY;
                    if (tmY < Ymin) Ymin = tmY;
                }
                if (Xmax < 0) Xmax = 0.0;
                if (Xmin > 0) Xmin = 0.0;
                if (Ymax < 0) Ymax = 0.0;
                if (Ymin > 0) Ymin = 0.0;

                numDivX = (uint)((Xmax - Xmin) / stepDiv);
                scaleX = (uint)(pbCanvas.Width / numDivX);
                numDivY = (uint)((Ymax - Ymin) / stepDiv);
                scaleY = (uint)(pbCanvas.Height / numDivY);
                this.ctx = Ctx;
            }
            catch (Exception E)
            {
                System.Windows.Forms.MessageBox.Show(E.Message);
            }
        }
Exemple #2
0
 private void button2_Click(object sender, EventArgs e)
 {
     try
     {
         if (lbX.Items.Count == 0 || lbY.Items.Count == 0)
         {
             throw new Exception("0 elements in controls");
         }
         if (lbX.Items.Count != lbY.Items.Count)
         {
             throw new Exception("Count of X elements must equils Y elements");
         }
         SaveFileDialog ofd = new SaveFileDialog();
         ofd.Filter = utils.Globals.glob_XMLfilter;
         ofd.ShowDialog();
         if (ofd.FileName.Length == 0) throw new utils.FileEx();
         utils.Globals.glob_debugFname = ofd.FileName;
             double[] tmpX = new double[lbX.Items.Count];
             double[] tmpY = new double[lbY.Items.Count];
             for (int i = 0; i < lbX.Items.Count; i++) tmpX[i] = (double)lbX.Items[i];
             for (int i = 0; i < lbY.Items.Count; i++) tmpY[i] = (double)lbY.Items[i];
             utils.Context ctx = new utils.Context(tmpX, tmpY);
             utils.Loader.saveXML(ctx, utils.Globals.glob_debugFname);
     }
     catch (Exception E)
     {
         MessageBox.Show(E.Message);
     }
 }