.


:




:

































 

 

 

 


frmCalculations ,




1. frmCalculations .

2. public partial class frmCalculations. { :

Calculator Calculator1;

3. . } .

// Creates a new instance of Calculator.

Calculator1 = new Calculator();

4. , Click .

Click .

// Passes the value typed in the txtValue to Calculator.varFact1.

private void btnFactorial1_Click(object sender, System.EventArgs e)

{

Calculator1.varFact1 = int.Parse(txtValue.Text);

// Disables the btnFactorial1 until this calculation is complete.

btnFactorial1.Enabled = false;

Calculator1.Factorial();

}

 

private void btnFactorial2_Click(object sender, System.EventArgs e)

{

Calculator1.varFact2 = int.Parse(txtValue.Text);

btnFactorial2.Enabled = false;

Calculator1.FactorialMinusOne();

}

private void btnAddTwo_Click(object sender, System.EventArgs e)

{

Calculator1.varAddTwo = int.Parse(txtValue.Text);

btnAddTwo.Enabled = false;

Calculator1.AddTwo();

}

private void btnRunLoops_Click(object sender, System.EventArgs e)

{

Calculator1.varLoopValue = int.Parse(txtValue.Text);

btnRunLoops.Enabled = false;

// Lets the user know that a loop is running

lblRunLoops.Text = "Looping";

Calculator1.RunALoop();

}

5. , , , Calculator1.

private void FactorialHandler(double Value, double Calculations)

// Displays the returned value in the appropriate label.

{

lblFactorial1.Text = Value.ToString();

// Re-enables the button so it can be used again.

btnFactorial1.Enabled = true;

// Updates the label that displays the total calculations performed

lblTotalCalculations.Text = "TotalCalculations are " +

Calculations.ToString();

}

 

private void FactorialMinusHandler(double Value, double Calculations)

{

lblFactorial2.Text = Value.ToString();

btnFactorial2.Enabled = true;

lblTotalCalculations.Text = "TotalCalculations are " +

Calculations.ToString();

}

 

private void AddTwoHandler(int Value, double Calculations)

{

lblAddTwo.Text = Value.ToString();

btnAddTwo.Enabled = true;

lblTotalCalculations.Text = "TotalCalculations are " +

Calculations.ToString();

}

 

private void LoopDoneHandler(double Calculations, int Count)

{

btnRunLoops.Enabled = true;

lblRunLoops.Text = Count.ToString();

lblTotalCalculations.Text = "TotalCalculations are " +

Calculations.ToString();

}

6. frmCalculations } , Calculator1.

Calculator1.FactorialComplete += new

Calculator.FactorialCompleteHandler(this.FactorialHandler);

Calculator1.FactorialMinusOneComplete += new

Calculator.FactorialCompleteHandler(this.FactorialMinusHandler);

Calculator1.AddTwoComplete += new

Calculator.AddTwoCompleteHandler(this.AddTwoHandler);

Calculator1.LoopComplete += new

Calculator.LoopCompleteHandler(this.LoopDoneHandler);

, , . , .





:


: 2016-09-03; !; : 462 |


:

:

.
==> ...

1694 - | 1643 -


© 2015-2024 lektsii.org - -

: 0.01 .