Пример #1
0
        private void buttonOption(Control c)
        {
            DisableButtons();
            if (c.BackColor != butColor)
            {
                gintButtonsPushed += 1;

                c.BackColor = butColor;


                if (gintButtonsPushed == 4)
                {
                    ShowAnswerButton();
                }
            }
            else
            {
                if (gintButtonsPushed >= 4)
                {
                    gintButtonsPushed++;
                }
            }

            gboolGuessButPushed = true;

            TheChart chrt = TheChart.GetInstance();

            t = new Thread(() => chrt.Animation(this, DrawPoint, double.Parse(c.Text), IncreaseSubgraphs, DrawSubGraphs, FinishAnimation, gboolGuessButPushed, StartMessageConfirm));
            t.Start();
        }
Пример #2
0
        //For multi use
        private void FinishApplyChanges(bool lessThanAnimation, double oldKStar)
        {
            gboolLessThanAnimation = lessThanAnimation;

            //btnSkip.Enabled = true;
            btnSkip.Visible = true;
            btnSkip.Select();
            TheChart chrt = TheChart.GetInstance();

            t = new Thread(() => chrt.Animation(this, DrawPoint, oldKStar, IncreaseSubgraphs, DrawSubGraphs, FinishAnimation, gboolGuessButPushed, StartMessageConfirm));
            t.Start();
        }
Пример #3
0
        private void nudN_ValueChanged(object sender, EventArgs e)
        {
            if (gboolInitialAnimationComplete)
            {
                btnApplyChanges.Visible = true;
                if (t.IsAlive)
                {
                    t.Join();
                }
                //TheChart chrt = TheChart.GetInstance();


                TheChart.GetInstance().DrawNewLine(this, DrawNewLine, 6, (double)nudN.Value);
            }
        }
Пример #4
0
        private void btnApplyChanges_Click(object sender, EventArgs e)
        {
            btnApplyChanges.Visible = false;
            DisableFields();


            //This is to make sure that the thread has compeleted its work
            if (t.IsAlive)
            {
                t.Join();
            }


            t = new Thread(() => TheChart.GetInstance().ApplyChange(this, ApplyChangesMessage, (double)nudS.Value, (double)nudN.Value, setAnswerText, btnAnswer.Enabled, setMaxAndMinBounds, MultiThreadDraw, chrtLines.ChartAreas[0].AxisX.Maximum, FinishApplyChanges));
            t.Start();
        }
Пример #5
0
        private bool IsFractionOkay()
        {
            int numerator, denom;

            if (!(string.IsNullOrEmpty(txtKNumerator.Text) || string.IsNullOrEmpty(txtKDenominator.Text)))
            {
                if (int.TryParse(txtKNumerator.Text, out numerator) && int.TryParse(txtKDenominator.Text, out denom))
                {
                    if (numerator == 0 || denom == 0)
                    {
                        return(false);
                    }
                    else if (numerator >= denom)
                    {
                        //Print message that the numberator must be smaller than denominator
                        return(false);
                    }
                    else
                    {
                        Calculations.GreatestCommonD(ref numerator, ref denom);


                        TheChart.GetInstance().setNumAndDenom(numerator, denom);

                        txtKNumerator.Text      = numerator.ToString();
                        txtKDenominator.Text    = denom.ToString();
                        txtSmlKNumerator.Text   = numerator.ToString();
                        txtSmlKDenominator.Text = denom.ToString();
                        txtLDenominator.Text    = denom.ToString();
                        txtLNumerator.Text      = (denom - numerator).ToString();
                        return(true);
                    }
                }
                else
                {
                    //Print message that they are not numbers
                    //Maybe add a error box to display error messages
                    return(false);
                }
            }
            else
            {
                return(false);
            }
        }
Пример #6
0
 //For multi use
 private void FinishAnimation(double kStar, double yStar)
 {
     //btnSkip.Enabled = false;
     btnSkip.Visible = false;
     //aTimer.Enabled = false;
     //gboolZoomAnimationComplete = false;
     if (gboolLessThanAnimation)
     {
         ClearCertainLines();
         //gdblK = 0;
         //DrawAllLines();
         //TheChart.GetInstance().DrawAllLines(this, setAnswerText, btnAnswer.Enabled, setMaxAndMinBounds, MultiThreadDraw);
         t = new Thread(() => TheChart.GetInstance().DrawAllLines(this, setAnswerText, btnAnswer.Enabled, setMaxAndMinBounds, MultiThreadDraw));
         t.Start();
         gboolLessThanAnimation = false;
     }
     if (gboolInitialAnimationComplete)
     {
         EnableFields();
     }
     else
     {
         EnableButtons();
     }
     //Console.WriteLine($"Here the value of buttons pushed is {gintButtonsPushed}");
     if (gintButtonsPushed == 4)
     {
         //MessageBox.Show("The middle box displays steady state capital per worker and income per worker for the production function you selected and the values for the saving rate, population growth rate, and depreciation rate you selected. Click on the box.");
         lblMsgbox.Text = "The middle box displays steady state capital per worker and income per worker for the production function you selected and the values for the saving rate and population growth rate you selected. Click on the box.";
     }
     else if (!btnOption1.Visible)
     {
         lblMsgbox.Text = "Notice that the economy has transitioned to new steady state level of capital per worker and income per worker. Convince yourself that the change in the parameter(s) you made resulted in the transition shown.";
     }
     else
     {
         lblMsgbox.Text = "Select another value for initial k.";
     }
     btnAnswer.Text = "k* = " + Calculations.RoundTo3Decimals(kStar) + "\n y* = " + Calculations.RoundTo3Decimals(yStar);
 }
Пример #7
0
        //Skip button sets the interrupt boolean inside the TheChart
        //If there is currently a timer going it will dispose of the timer and set the appropriate mrse

        private void BtnSkip_Click(object sender, EventArgs e)
        {
            btnSkip.Visible = false;

            //For multi use
            TheChart.GetInstance().gboolInterrupt = true;

            if (cTimer != null)
            {
                if (cTimer.Enabled)
                {
                    cTimer.Dispose();
                    if (gMrse != null)
                    {
                        gMrse.Set();
                    }
                    else if (gApplyMrse != null)
                    {
                        gApplyMrse.Set();
                    }
                }
            }
        }
Пример #8
0
        private void BtnStart_Click(object sender, EventArgs e)
        {
            //Checks if the fraction that is currently entered is okay see that function (IsFractionOkay) it also sets some values
            if (IsFractionOkay())
            {
                TheChart chrt = TheChart.GetInstance();


                chrt.gdblN     = (double)nudN.Value;
                chrt.gdblS     = (double)nudS.Value;
                chrt.gdblDelta = 0.1;

                btnStart.Visible        = false;
                txtKNumerator.Enabled   = false;
                txtKDenominator.Enabled = false;
                DisableFields();

                t = new Thread(() => chrt.DrawAllLines(this, setAnswerText, btnAnswer.Enabled, setMaxAndMinBounds, MultiThreadDraw));
                t.Start();

                //Update UI
                ShowGuessButtons();
                btnOption1.Select();
                chrtC.ChartAreas[0].AxisX.Minimum = 0;
                chrtC.ChartAreas[0].AxisX.Maximum = 15;
                chrtI.ChartAreas[0].AxisX.Minimum = 0;
                chrtI.ChartAreas[0].AxisX.Maximum = 15;
                chrtY.ChartAreas[0].AxisX.Minimum = 0;
                chrtY.ChartAreas[0].AxisX.Maximum = 15;

                //Generates the buttons
                altThread = new Thread(() => chrt.GenerateGuessButtons(this, PrintGuessButttons));
                altThread.Start();

                lblMsgbox.Text = "The four boxes you see represent potential choices for initial capital per worker. Click on a box and observe transition to steady state capital per worker. Repeat for each choice. Notice that each choice is not steady state capital per worker.";
            }
        }
Пример #9
0
        //Sets all values back to default
        private void BtnReset_Click(object sender, EventArgs e)
        {
            if (cTimer != null)
            {
                cTimer.Dispose();
            }

            if (t != null)
            {
                if (t.IsAlive)
                {
                    t.Abort();
                }
            }

            if (altThread != null)
            {
                if (altThread.IsAlive)
                {
                    altThread.Abort();
                }
            }
            txtKNumerator.Enabled   = true;
            txtKDenominator.Enabled = true;
            txtKNumerator.Text      = "";
            txtKDenominator.Text    = "";
            txtLNumerator.Text      = "";
            txtLDenominator.Text    = "";
            txtSmlKNumerator.Text   = "";
            txtSmlKDenominator.Text = "";
            nudS.Value = 0.1m;
            nudN.Value = 0m;



            btnStart.Visible = true;
            nudS.Enabled     = true;
            nudN.Enabled     = true;


            EnableButtons();
            //ShowGuessButtons();
            HideGuessButtons();
            btnOption1.BackColor = Color.FromArgb(224, 122, 95);
            btnOption2.BackColor = Color.FromArgb(224, 122, 95);
            btnOption3.BackColor = Color.FromArgb(224, 122, 95);
            btnOption4.BackColor = Color.FromArgb(224, 122, 95);

            btnAnswer.Visible = false;

            btnSkip.Visible         = false;
            lblMsgbox.Text          = "Enter a value for the exponent on capital.Remember that our production function must exhibit constant returns to scale.Also, enter initial values for the saving rate and population growth rate.";
            btnOk.Visible           = false;
            btnApplyChanges.Visible = false;
            chrtC.Visible           = false;
            chrtI.Visible           = false;
            chrtY.Visible           = false;

            ClearAllUpperLines();
            ClearLowerLines();

            gApplyMrse                    = null;
            gMrse                         = null;
            gboolApplyChanges             = false;
            gboolGuessButPushed           = false;
            gboolLessThanAnimation        = false;
            gboolInitialAnimationComplete = false;
            gintMid                       = 0;
            gintButtonsPushed             = 0;



            TheChart.MakeNewInstance();

            //This is a easier way of reseting but window size will revert to default.
            //Application.Restart();
        }
Пример #10
0
 //For Restart Use
 public static void MakeNewInstance()
 {
     obj = new TheChart();
 }