Пример #1
0
        private void getBoundsManually()
        {
            double X0, X1, Y0, Y1, nX0, nX1, nY0, nY1;

            plotCntrl.getBounds(out X0, out X1, out Y0, out Y1);

            if (!InputBoxForm.GetDouble("Leftmost x", X0, out nX0))
            {
                return;
            }
            if (!InputBoxForm.GetDouble("Rightmost x", X1, out nX1))
            {
                return;
            }
            if (!InputBoxForm.GetDouble("Lowest y", Y0, out nY0))
            {
                return;
            }
            if (!InputBoxForm.GetDouble("Greatest y", Y1, out nY1))
            {
                return;
            }

            if (!(nY1 > nY0 && nX1 > nX0))
            {
                MessageBox.Show("Invalid bounds."); return;
            }

            this.plotCntrl.setBounds(nX0, nX1, nY0, nY1);
            this.plotCntrl.redraw();
        }
Пример #2
0
        private void mnuFileAnimate_Click(object sender, EventArgs e)
        {
            double d, c0_0, c0_1, c1_0, c1_1; string s; int nframes;
            double param1 = plotCntrl.param1, param2 = plotCntrl.param2;

            s = InputBoxForm.GetStrInput("Initial c1:", param1.ToString(CultureInfo.InvariantCulture));
            if (s == null || s == "" || !double.TryParse(s, out d))
            {
                return;
            }
            c0_0 = d;
            s    = InputBoxForm.GetStrInput("Final c1:", param1.ToString(CultureInfo.InvariantCulture));
            if (s == null || s == "" || !double.TryParse(s, out d))
            {
                return;
            }
            c0_1 = d;
            s    = InputBoxForm.GetStrInput("Initial c2:", param2.ToString(CultureInfo.InvariantCulture));
            if (s == null || s == "" || !double.TryParse(s, out d))
            {
                return;
            }
            c1_0 = d;
            s    = InputBoxForm.GetStrInput("Final c2:", param2.ToString(CultureInfo.InvariantCulture));
            if (s == null || s == "" || !double.TryParse(s, out d))
            {
                return;
            }
            c1_1 = d;
            s    = InputBoxForm.GetStrInput("Number of frames:", "50");
            if (s == null || s == "" || !int.TryParse(s, out nframes))
            {
                return;
            }
            SaveFileDialog saveFileDialog1 = new SaveFileDialog();

            saveFileDialog1.Filter           = "png files (*.png)|*.png";
            saveFileDialog1.RestoreDirectory = true;
            if (!(saveFileDialog1.ShowDialog() == System.Windows.Forms.DialogResult.OK && saveFileDialog1.FileName.Length > 0))
            {
                return;
            }
            string sfilename = saveFileDialog1.FileName;
            double c0_inc    = (c0_1 - c0_0) / nframes;
            double c1_inc    = (c1_1 - c1_0) / nframes;

            for (int i = 0; i < nframes; i++)
            {
                plotCntrl.param1 = c0_0;
                plotCntrl.param2 = c1_0;
                plotCntrl.renderToDiskSave(400, 400, sfilename.Replace(".png", "_" + i.ToString("000") + ".png"));
                c0_0 += c0_inc;
                c1_0 += c1_inc;
            }
        }
Пример #3
0
        private bool _getBounds(string sName, double fCurrent, out double dOut)
        {
            dOut = 0.0;
            string s = InputBoxForm.GetStrInput(sName, fCurrent.ToString(CultureInfo.InvariantCulture));

            if (s == null || s == "")
            {
                return(false);
            }
            return(double.TryParse(s, out dOut));
        }
Пример #4
0
        private void mnuAdvSetParamRange_Click(object sender, EventArgs e)
        {
            double v;
            string s = InputBoxForm.GetStrInput("The trackbars allow c1 to be set to a value between -a to a. Choose value of a:", "1.0");

            if (s == null || s == "" || !double.TryParse(s, out v))
            {
                return;
            }
            this.paramRange = v * 2.0; //so that 1.0 becomes range of 2
            setSliderToValue(plotCntrl.param1, tbParam1);
            setSliderToValue(plotCntrl.param2, tbParam2);
        }
Пример #5
0
        private bool manSetValue(Label lbl, TrackBar tb, out double v)
        {
            v = 0.0;
            string s = InputBoxForm.GetStrInput("Value:", lbl.Text);

            if (s == null || s == "" || !double.TryParse(s, out v))
            {
                return(false);
            }
            setSliderToValue(v, tb);
            lbl.Text = v.ToString();
            return(true);
        }
Пример #6
0
        private void mnuAdvSetParamRange_Click(object sender, EventArgs e)
        {
            double v;

            if (!InputBoxForm.GetDouble("The trackbars allow c1 to be set to a value between -a to a. Choose value of a:", 1.0, out v))
            {
                return;
            }

            this.paramRange = v * 2.0; //so that 1.0 becomes range of 2
            setSliderToValue(plotCntrl.param1, tbParam1);
            setSliderToValue(plotCntrl.param2, tbParam2);
        }
Пример #7
0
        public static string GetStrInput(string strPrompt, string strCurrent)
        {
            InputBoxForm myForm = new InputBoxForm();

            myForm.label1.Text     = strPrompt;
            myForm.txtMessage.Text = strCurrent;
            myForm.ShowDialog(new Form());
            if (myForm.DialogResult == DialogResult.OK)
            {
                return(myForm.Message);
            }
            else
            {
                return(null);
            }
        }
Пример #8
0
        private void mnuFileAnimate_Click(object sender, EventArgs e)
        {
            double c0_0, c0_1, c1_0, c1_1; int nframes;
            double param1 = plotCntrl.param1, param2 = plotCntrl.param2;

            if (!InputBoxForm.GetDouble("Initial c1:", param1, out c0_0))
            {
                return;
            }
            if (!InputBoxForm.GetDouble("Final c1:", param1, out c0_1))
            {
                return;
            }
            if (!InputBoxForm.GetDouble("Initial c2:", param2, out c1_0))
            {
                return;
            }
            if (!InputBoxForm.GetDouble("Final c2:", param2, out c1_1))
            {
                return;
            }
            if (!InputBoxForm.GetInt("Number of frames:", 50, out nframes))
            {
                return;
            }

            SaveFileDialog saveFileDialog1 = new SaveFileDialog();

            saveFileDialog1.Filter           = "png files (*.png)|*.png";
            saveFileDialog1.RestoreDirectory = true;
            if (!(saveFileDialog1.ShowDialog() == System.Windows.Forms.DialogResult.OK && saveFileDialog1.FileName.Length > 0))
            {
                return;
            }
            string sfilename = saveFileDialog1.FileName;
            double c0_inc    = (c0_1 - c0_0) / nframes;
            double c1_inc    = (c1_1 - c1_0) / nframes;

            for (int i = 0; i < nframes; i++)
            {
                plotCntrl.param1 = c0_0;
                plotCntrl.param2 = c1_0;
                plotCntrl.renderToDiskSave(400, 400, sfilename.Replace(".png", "_" + i.ToString("000") + ".png"));
                c0_0 += c0_inc;
                c1_0 += c1_inc;
            }
        }
Пример #9
0
        private bool manSetValue(Label lbl, TrackBar tb, out double v)
        {
            double current; if (!double.TryParse(lbl.Text, out current))

            {
                current = 0.0;
            }

            v = 0.0;
            if (!InputBoxForm.GetDouble("Value:", current, out v))
            {
                return(false);
            }
            setSliderToValue(v, tb);
            lbl.Text = v.ToString();
            return(true);
        }
Пример #10
0
        private void mnuAdvancedRenderSize_Click(object sender, EventArgs e)
        {
            int width, height;

            if (!InputBoxForm.GetInt("Render Width:", nRenderWidth, out width))
            {
                return;
            }
            if (!InputBoxForm.GetInt("Render Height:", nRenderHeight, out height))
            {
                return;
            }
            if (width > 0 && height > 0)
            {
                nRenderHeight = height; nRenderWidth = width;
            }
        }