Providing Help

Introduction

When you have created an application, you should assist your users in figuring out how to use your application. You may think about training the users, which is good but may require your physical presence. Online Help is the ability to provide documents that can guide people about your application. Those file should be easily accessible to the users. One to make this possible to attach the files to your application.

There are various small but effective techniques you can use to provide help for your application.

Practical LearningPractical Learning: Introducing Help

  1. Start Microsoft Visual Studio
  2. Create a new Windows Forms App named BusinessAccounting3
  3. In the Solution Explorer, right-click Form1.cs and click Rename
  4. Type CompoundedInterest (to get CompoundedInterest.cs) and press Enter twice
  5. In the Toolbox, expand Containers. Click GroupBox and click the form
  6. Complete the design of the form as follows:

    Business Accounting - Compounded Interest

    Control (Name) Text Other Properties
    GroupBox Group Box   Loan Preparation  
    Label Label   Principal
    TextBox ListBox txtPrincipal   TextAlign: Right
    Label Label   Interest Rate:  
    TextBox ListBox txtInterestRate   TextAlign: Right
    Label Label   %  
    Label Label   Number of Periods:  
    TextBox ListBox txtPeriods   TextAlign: Right
    ComboBox Combo Box cbxPeriods   Items: Days
    Years
    Months
    GroupBox Group Box   Compound Frequency  
    RadioButton Radio Button rdoDaily Daily  
    RadioButton Radio Button rdoWeekly Weekly  
    RadioButton Radio Button rdoMonthly Monthly  
    RadioButton Radio Button rdoQuaterly Quaterly  
    RadioButton Radio Button rdoSemiannualy Semiannualy  
    RadioButton Radio Button rdoAnnualy Annualy  
    Button Button btnCalculate Calculate  
    GroupBox Group Box   Loan Evaluation  
    Label Label   Interest Earned:  
    TextBox ListBox txtInterestEarned   TextAlign: Right
    Label Label   Future Value:  
    TextBox ListBox txtFutureValue   TextAlign: Right
    Button Button btnClose Close  

Status Bar Messages

One way you can provide simple help consists of displaying short indicative messages on a status bar. To do this, you can first create sections, called panels, on a status bar and then display the necessary messages in the section of your choice. The message can be anything but it should consist of just a few words to fit in its section without going over board.

Practical LearningPractical Learning: Helping Through a Status Bar

  1. Expand the bottom border of the form a little bit
  2. On the Toolbox, expand Menus & Toolbars
  3. Click StatusStrip and click the bottom section of the form
  4. In the Properties window, change the (Name) to ssStatusBar
  5. Still in the Properties window, click Items and click its ellipsis button Ellipsis
  6. In the Select Item and Add to List Below combo box, select StatusLabel if necessary and click Add
    On the right side, set the Text to Ready

  7. Click OK
  8. Click an unoccupied area of the form
  9. In the Properties window, click the Events button Events
  10. Double-click MouseMove
  11. Return to the form
  12. On the form, click the txtPrincipal control; that is, the text box on the right side of the Principal label
  13. Return to the form
  14. In the same way, initiate the MouseMove event for the Interest Rate and the Periods text boxes
  15. Return to the form and initiate the MouseMove event for the Periods combo box
  16. Return to the form and initiate the MouseMove event for the Daily, the Weekly, the Monthly, the Quaterly, the Semiannually, and the Annually radio buttons
  17. Return to the form and initiate the MouseMove event for the Calculate button
  18. Return to the form and double-click the Calculate button
  19. Return to the form and initiate the MouseMove event for the Interest Earned and the Future Value text boxes
  20. Return to the form and initiate the MouseMove event for the Close button
  21. Return to the form and double-click the Close button
  22. Change the document as follows:
    namespace BusinessAccounting30
    {
        public partial class CompoundedInterest : Form
        {
            public CompoundedInterest()
            {
                InitializeComponent();
            }
    
            private void CompoundedInterest_MouseMove(object sender, MouseEventArgs e)
            {
                ssStatusBar.Items[0].Text = "Ready.";
            }
    
            private void txtPrincipal_MouseMove(object sender, MouseEventArgs e)
            {
                ssStatusBar.Items[0].Text = "Amount financed or loan amount borrowed.";
            }
    
            private void txtInterestRate_MouseMove(object sender, MouseEventArgs e)
            {
                ssStatusBar.Items[0].Text = "The factor by which the principal grows over a period.";
            }
    
            private void txtPeriods_MouseMove(object sender, MouseEventArgs e)
            {
                ssStatusBar.Items[0].Text = "The length of the loan in term of months, years, etc.";
            }
    
            private void cbxPeriods_MouseMove(object sender, MouseEventArgs e)
            {
                ssStatusBar.Items[0].Text = "The types of the number of periods.";
            }
    
            private void rdoDaily_MouseMove(object sender, MouseEventArgs e)
            {
                ssStatusBar.Items[0].Text = "Applied when accrued interest is evaluated daily.";
            }
    
            private void rdoWeekly_MouseMove(object sender, MouseEventArgs e)
            {
                ssStatusBar.Items[0].Text = "Interest earned calculated on a weekly basis.";
            }
    
            private void rdoMonthly_MouseMove(object sender, MouseEventArgs e)
            {
                ssStatusBar.Items[0].Text = "The interest earned is evaluated every month.";
            }
    
            private void rdoQuarterly_MouseMove(object sender, MouseEventArgs e)
            {
                ssStatusBar.Items[0].Text = "Calculation of the accrued interest once in three months.";
            }
    
            private void rdoSemiannually_MouseMove(object sender, MouseEventArgs e)
            {
                ssStatusBar.Items[0].Text = "The accrued interest is evaluated once in six months.";
            }
    
            private void rdoAnnually_MouseMove(object sender, MouseEventArgs e)
            {
                ssStatusBar.Items[0].Text = "Once in a year, the accrued or earned interest is evaluated.";
            }
    
            private void btnCalculate_MouseMove(object sender, MouseEventArgs e)
            {
                ssStatusBar.Items[0].Text = "When values are ready, click this buttong to evaluate the loan.";
            }
    
            private void btnCalculate_Click(object sender, EventArgs e)
            {
                /* A compound type specifies the frequency by which 
                 * the interest is evaluated. The options are that 
                 * the evaluation be made hourly, daily, weekly, biweekly, 
                 * semi-monthly, monthly, quaterly, semi-annually, or annually. */
                double compoundType;
                // The principal is the amount invested in getting a loan or the amount of money borrowed.
                double principal = 0d;
                // The interest rate is the fraction that influence the amount owned by the lender
                double iRate = 0d;
                // The period is the number of units by which the interest accrued is evaluated
                double per = 0d;
    
                if (string.IsNullOrEmpty(txtPrincipal.Text))
                {
                    MessageBox.Show("You must provide a valid number for the principal.",
                                    "Business Accounting", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    return;
                }
    
                if (string.IsNullOrEmpty(txtInterestRate.Text))
                {
                    MessageBox.Show("Please type a valid decimal number for the interest rate.",
                                    "Business Accounting", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    return;
                }
    
                if (string.IsNullOrEmpty(txtPeriods.Text))
                {
                    MessageBox.Show("You are supposed to type a valid number for " +
                                    "the number of days, weeks, months, quarters, or years.",
                                    "Business Accounting", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    return;
                }
    
                try
                {
                    // Retrieve the value of the principal
                    principal = double.Parse(txtPrincipal.Text);
                }
                catch (FormatException fe)
                {
                    MessageBox.Show("There is a problem with the value you provided " +
                                    "for the principal." + Environment.NewLine +
                                    "Please report the error as: " + fe.Message,
                                    "Business Accounting", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
    
                try
                {
                    // Retrieve the interest rate
                    iRate = double.Parse(txtInterestRate.Text);
                }
                catch (FormatException fe)
                {
                    MessageBox.Show("You must provide a valid fractional number for the interest rate." + Environment.NewLine +
                                    "You can present the error as: " + fe.Message,
                                    "Business Accounting", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
    
                try
                {
                    // Get the number of periods
                    per = double.Parse(txtPeriods.Text);
                }
                catch (FormatException fe)
                {
                    MessageBox.Show("Please type the number of days, weeks, months, quarters, or years." + Environment.NewLine +
                                    "The error resulting is: " + fe.Message,
                                    "Business Accounting", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
    
                // Find out what radio button was clicked to apply the compound frequency
                if (rdoDaily.Checked == true)
                    compoundType = 360d;
                else if (rdoWeekly.Checked == true)
                    compoundType = 52d;
                else if (rdoMonthly.Checked)
                    compoundType = 12d;
                else if (rdoQuarterly.Checked)
                    compoundType = 4d;
                else if (rdoSemiannually.Checked)
                    compoundType = 2d;
                else
                {
                    compoundType = 1d;
                    rdoAnnually.Checked = true;
                }
    
                double periods;
    
                if (cbxPeriods.Text == "Days")
                    periods = per / 360d;
                else if (cbxPeriods.Text == "Months")
                    periods = per / 12d;
                else
                {
                    periods = per;
                    cbxPeriods.Text = "Years";
                }
    
                // These values will make the calculation easier to read
                double interestRate = iRate / 100d;
                double i = interestRate / compoundType;
                double n = compoundType * periods;
    
                // Perform the necessary calculations
                // double ratePerPeriod = interestRate / periods;
                double futureValue = principal * Math.Pow(1 + i, n);
                double interestEarned = futureValue - principal;
    
                // Display the values in the appropriate text boxes
                txtInterestEarned.Text = interestEarned.ToString("C");
                txtFutureValue.Text = futureValue.ToString("C");
            }
    
            private void txtInterestEarned_MouseMove(object sender, MouseEventArgs e)
            {
                ssStatusBar.Items[0].Text = "The amount acculumated as interest.";
            }
    
            private void txtFutureValue_MouseMove(object sender, MouseEventArgs e)
            {
                ssStatusBar.Items[0].Text = "The total amount paied or accumulated at the end of the loan.";
            }
    
            private void btnClose_MouseMove(object sender, MouseEventArgs e)
            {
                ssStatusBar.Items[0].Text = "To end the application, click this button.";
            }
    
            private void btnClose_Click(object sender, EventArgs e)
            {
                Close();
            }
        }
    }
  23. To execute the application, press Ctrl + F5

    Business Accounting - Compounded Interest - Providing Help

  24. Position the mouse on some of the controls:

    Business Accounting - Compounded Interest - Providing Help

    Business Accounting - Compounded Interest - Providing Help

    Business Accounting - Compounded Interest - Providing Help

  25. After using it, close the form and return to your programming environment
  26. From Lesson 11, you should have the following graphics already in your computer; if not, save them:
    Blocking a Thread Blocking a Thread
    Blocking a Thread Blocking a Thread

    Create a Windows Forms App named ObliqueTriangles2
  27. In the Solution Explorer, right-click Form1.cs and click Rename
  28. Type ObliqueTriangles (to get ObliqueTriangles.cs) and press Enter
  29. Read the message on the message box and click Yes
  30. Design the form as follows:

    Introducing Panels

    Control (Name) Text Other Properties
    Panel Panel pnlCategories    
    Label Label   Select the Category of Known Values Font: Times New Roman, 9.75pt, style=Bold
    RadioButton Radio Button rdoAAS AAS - Known Values: Two angles and a side opposite one of them  
    RadioButton Radio Button rdoASA ASA - Known Values: Two angles and the side between them  
    RadioButton Radio Button rdoSAS SAS - Known Values: Two sides and the angle between them  
    RadioButton Radio Button rdoSSS SSS - Known Values: All three sides  
    Panel Panel pnlAAS    
    PictureBox Picture Box pbxAAS   SizeMode: AutoSize
    Label Label     BackColor: Blue
    AutoSize: False
    Label Label   Known Values Font: Times New Roman, 12pt, style=Bold
    Label Label   ______________________  
    Label Label   Angle 1:  
    TextBox ListBox txtAASAngle1   TextAlign: Right
    Label Label   Angle 2:  
    TextBox ListBox txtAASAngle2   TextAlign: Right
    Label Label   Side 1  
    TextBox ListBox txtAASSide1   TextAlign: Right
    Button Button btnAASCalculate Calculate  
    Label Label   Unknown Values Font: Times New Roman, 12pt, style=Bold
    Label Label   ______________________  
    Label Label   Angle 3:  
    TextBox ListBox txtAASAngle3   TextAlign: Right
    Label Label   Side 2:  
    TextBox ListBox txtAASSide2   TextAlign: Right
    Label Label   Side 3  
    TextBox ListBox txtAASSide3   TextAlign: Right
    Panel Panel pnlASA    
    PictureBox Picture Box pbxASA   Image: asa
    SizeMode: AutoSize
    Label Label   Known Values Font: Times New Roman, 12pt, style=Bold
    Label Label   Angle 1:  
    TextBox ListBox txtASAAngle1   TextAlign: Right
    Label Label   Angle 2:  
    TextBox ListBox txtASAAngle2   TextAlign: Right
    Label Label   Side 1:  
    TextBox ListBox txtASASide1   TextAlign: Right
    Button Button btnASACalculate Calculate  
    Label Label   Unknown Values Font: Times New Roman, 12pt, style=Bold
    Label Label   Angle 3:  
    TextBox ListBox txtASAAngle3   TextAlign: Right
    Label Label   Side 2:  
    TextBox ListBox txtASASide2   TextAlign: Right
    Label Label   Side 3:  
    TextBox ListBox txtASASide3   TextAlign: Right
    Button Button btnClose Close  
    Panel Panel pnlSAS    
    PictureBox Picture Box pbxSAS   Image: sas
    SizeMode: AutoSize
    Label Label   Known Values Font: Times New Roman, 12pt, style=Bold
    Label Label   Side 1:  
    TextBox ListBox txtSASSide1   TextAlign: Right
    Label Label   Angle 1:  
    TextBox ListBox txtSASAngle1   TextAlign: Right
    Label Label   Side 2:  
    TextBox ListBox txtSASSide2   TextAlign: Right
    Button Button btnSASCalculate Calculate  
    Label Label   Unknown Values Font: Times New Roman, 12pt, style=Bold
    Label Label   Side 3:  
    TextBox ListBox txtSASSide3   TextAlign: Right
    Label Label   Angle 2:  
    TextBox ListBox txtSASAngle2   TextAlign: Right
    Label Label   Angle 3:  
    TextBox ListBox txtSASAngle3   TextAlign: Right
    Panel Panel pnlSSS    
    PictureBox Picture Box pbxSSS   Image: sss
    SizeMode: AutoSize
    Label Label   Known Values Font: Times New Roman, 12pt, style=Bold
    Label Label   Side 1:  
    TextBox ListBox txtSSSSide1   TextAlign: Right
    Label Label   Side 2:  
    TextBox ListBox txtSSSSide2   TextAlign: Right
    Label Label   Side 3:  
    TextBox ListBox txtSSSSide3   TextAlign: Right
    Button Button btnSSSCalculate Calculate  
    Label Label   Unknown Values Font: Times New Roman, 12pt, style=Bold
    Label Label   Angle 1:  
    TextBox ListBox txtSSSAngle1   TextAlign: Right
    Label Label   Angle 2:  
    TextBox ListBox txtSSSAngle2   TextAlign: Right
    Label Label   Angle 3:  
    TextBox ListBox txtSSSAngle3   TextAlign: Right
  31. Double-click an unoccupied area of the form
  32. Return to the form and double-click the AAS radio button
  33. Return to the form and double-click the ASA radio button
  34. Return to the form and double-click the SAS radio button
  35. Return to the form and double-click the SSS radio button
  36. Return to the form and double-click the Calculate button in the AAS panel
  37. Return to the form and double-click the Calculate button in the ASA panel
  38. Return to the form and double-click the Calculate button in the SAS panel
  39. Return to the form and double-click the Calculate button in the SSS panel
  40. Return to the form and double-click the Close button
  41. Change the document as follows:
    namespace ObliqueTriangles2
    {
        public partial class ObliqueTriangles : Form
        {
            public ObliqueTriangles()
            {
                InitializeComponent();
            }
    
            private void ObliqueTriangles_Load(object sender, EventArgs e)
            {
                pnlSSS.Location = pnlSAS.Location = pnlASA.Location = pnlAAS.Location;
                rdoAAS.Checked  = true;
                rdoAAS_CheckedChanged(sender, e);
            }
    
            private void rdoAAS_CheckedChanged(object sender, EventArgs e)
            {
                pnlAAS.BringToFront();
            }
    
            private void rdoASA_CheckedChanged(object sender, EventArgs e)
            {
                pnlASA.BringToFront();
            }
    
            private void rdoSAS_CheckedChanged(object sender, EventArgs e)
            {
                pnlSAS.BringToFront();
            }
    
            private void rdoSSS_CheckedChanged(object sender, EventArgs e)
            {
                pnlSSS.BringToFront();
            }
    
            private void btnAASCalculate_Click(object sender, EventArgs e)
            {
                double angle1 = 0.00, angle2 = 0.00, side1 = 0.00;
    
                try
                {
                    angle1 = double.Parse(txtAASAngle1.Text);
                }
                catch (FormatException)
                {
                    MessageBox.Show("You must type a value for the lower left angle of the AAS shape.", "Obliques Triangles");
                }
    
                try
                {
                    angle2 = double.Parse(txtAASAngle2.Text);
                }
                catch (FormatException)
                {
                    MessageBox.Show("You must type a value for the lower right angle of the AAS shape.", "Obliques Triangles");
                }
    
                try
                {
                    side1 = double.Parse(txtAASSide1.Text);
                }
                catch (FormatException)
                {
                    MessageBox.Show("You must type a value for the right side of the AAS shape.", "Obliques Triangles");
                }
    
                // Here, we use the law of sines
                double angle3 = 180 - (angle1 + angle2);
                double side2  = side1 * Math.Sin(angle2 * Math.PI / 180) / Math.Sin(angle1 * Math.PI / 180);
                double side3  = side1 * Math.Sin(angle3 * Math.PI / 180) / Math.Sin(angle1 * Math.PI / 180);
    
                txtAASAngle3.Text = angle3.ToString();
                txtAASSide2.Text  = side2.ToString();
                txtAASSide3.Text  = side3.ToString();
            }
    
            private void btnASACalculate_Click(object sender, EventArgs e)
            {
                double angle1 = 0.00, side1 = 0.00, angle2 = 0.00;
    
                try
                {
                    angle1 = double.Parse(txtASAAngle1.Text);
                }
                catch (FormatException)
                {
                    MessageBox.Show("You must type a value for the lower left angle of the ASA shape.", "Obliques Triangles");
                }
    
                try
                {
                    side1 = double.Parse(txtASASide1.Text);
                }
                catch (FormatException)
                {
                    MessageBox.Show("You must type a value for the bottom side of the AAS shape.", "Obliques Triangles");
                }
    
                try
                {
                    angle2 = double.Parse(txtASAAngle2.Text);
                }
                catch (FormatException)
                {
                    MessageBox.Show("You must type a value for the lower right angle of the ASA shape.", "Obliques Triangles");
                }
    
                double angle3 = 180 - (angle1 + angle2);
                double side2  = side1 * Math.Sin(angle2 * Math.PI / 180) / Math.Sin(angle1 * Math.PI / 180);
                double side3  = side1 * Math.Sin(angle3 * Math.PI / 180) / Math.Sin(angle1 * Math.PI / 180);
    
                txtASAAngle3.Text = angle3.ToString();
                txtASASide2.Text = side3.ToString();
                txtASASide3.Text = side2.ToString();
            }
    
            private void btnSASCalculate_Click(object sender, EventArgs e)
            {
                double side1 = 0.00, angle1 = 0.00, side2 = 0.00;
    
                try
                {
                    side1 = double.Parse(txtSASSide1.Text);
                }
                catch (FormatException)
                {
                    MessageBox.Show("You must type a value for the left side of the SAS shape.", "Obliques Triangles");
                }
    
                try
                {
                    angle1 = double.Parse(txtSASAngle1.Text);
                }
                catch (FormatException)
                {
                    MessageBox.Show("You must type a value for the top angle of the SAS shape.", "Obliques Triangles");
                }
    
                try
                {
                    side2 = double.Parse(txtSASSide2.Text);
                }
                catch (FormatException)
                {
                    MessageBox.Show("You must type a value for the right side of the SAS shape.", "Obliques Triangles");
                }
    
                // Here, we use the law of cosines
                double side3 = Math.Sqrt((side1 * side1) +
                                         (side2 * side2) -
                                         (2 * side1 * side2 * Math.Cos(angle1 * Math.PI / 180)));
                double angle2 = Math.Acos(((side3 * side3) +
                                           (side2 * side2) -
                                           (side1 * side1)
                                          ) / (2 * side3 * side2)) * 180 / Math.PI;
                double angle3 = 180 - (angle1 + angle2);
    
    
                txtSASSide3.Text  = side3.ToString();
                txtSASAngle2.Text = angle2.ToString();
                txtSASAngle3.Text = angle3.ToString();
            }
    
            private void btnSSSCalculate_Click(object sender, EventArgs e)
            {
                double side1 = 0.00, side2 = 0.00, side3 = 0.00;
    
                try
                {
                    side1 = double.Parse(txtSSSSide1.Text);
                }
                catch (FormatException)
                {
                    MessageBox.Show("You must type a value for the left side of the SSS shape.", "Obliques Triangles");
                }
    
                try
                {
                    side2 = double.Parse(txtSSSSide2.Text);
                }
                catch (FormatException)
                {
                    MessageBox.Show("You must type a value for the right side of the SSS shape.", "Obliques Triangles");
                }
    
                try
                {
                    side3 = double.Parse(txtSSSSide3.Text);
                }
                catch (FormatException)
                {
                    MessageBox.Show("You must type a value for the bottom side of the SSS shape.", "Obliques Triangles");
                }
    
                // Here, we use the law of cosines
                double angle1 = Math.Acos(((side3 * side3) +
                                           (side2 * side2) -
                                           (side1 * side1)
                                          ) / (2 * side3 * side2)) * 180 / Math.PI;
                double angle2 = Math.Acos(((side3 * side3) +
                                           (side1 * side1) -
                                           (side2 * side2)
                                          ) / (2 * side3 * side1)) * 180 / Math.PI;
                double angle3 = 180 - (angle1 + angle2);
    
    
                txtSSSAngle1.Text = angle1.ToString();
                txtSSSAngle2.Text = angle2.ToString();
                txtSSSAngle3.Text = angle3.ToString();
            }
    
            private void btnClose_Click(object sender, EventArgs e)
            {
                Close();
            }
        }
    }
  42. Return to the form

Tool Tips

A tool tip is a small yellow box that displays a word or a group of words when the user positions the mouse on top of a control:

tool tip example

To create a tool tip system in a Windows Forms application, first add a ToolTip control to a form. After adding a ToolTip control, the form and all controls on it receive a new field in the Properties window. If the new ToolTip control is called ToolTip1, the new field in the Properties window for each control is ToolTip on ToolTip1. To display a tool tip for a control, first click it on the form. Then, in the Properties window, click ToolTip on ToolTip1, and type the desired tool tip.

Practical LearningPractical Learning: Adding Tool Tips

  1. To prepare for tool tips, in the Common Controls section of the Toolbox, click ToolTip Tool Tip and click the form
  2. In the Properties window, change the (Name) to ttObliqueTriangles
  3. On the form, click each control and, in the Properties window, set its ToolTip On ttObliqueTriangles property as follows:
    Control ToolTip On ttObliqueTriangles
    rdoAAS Selection to make if the value of one side, the angle oppsosite to that side, and another angle are known. The law of Sines is used to calculate the unknown values.
    rdoASA In this option, two angles are known. Also, the side between those angles is known. Use the law of Sines to find the unknown angle and the other two unknown sides.
    rdoSAS With SAS, the values of two sides and the angle between them are known. Use the law of Cosines to calculate the unknown side and the values of the other two angles.
    rdoSSS Knowing the values of all three sides of a triangle (SSS), use the law of Cosines to calculate the unknown values of the angles.
    txtAASAngle1 Value for one of the known angles
    txtAASAngle2 Value for one of the known angles
    txtAASSide1 Value for the known side
    btnAASCalculate Make sure you first provide the values for the known angles and the known side.
    txtAASAngle3 Calculated value for the unknown angle
    txtAASSide2 Calculated value for one of the unknown sides
    txtAASSide3 Calculated value for one of the unknown sides
    txtASAAngle1 In this ASA situation, type the value of one of the known angles.
    txtASASide1 In this ASA situation, type the value for the known side.
    txtASAAngle2 Type the value of the other known angle.
    btnASACalculate Make sure you provide the values for the known angles and the known side.
    txtASAAngle3 Calculated value for the unknown angle.
    txtASASide2 Calculated value for one of the unknown sides.
    txtASASide3 Calculated value for one of the unknown sides.
    txtSASSide1 Knowing the angle included in two known sides, type the value of one of the available sides.
    txtSASAngle1 Type the known value of the angle between two known sides.
    txtSASSide2 Enter the value of the second known sides.
    btnSASCalculate Make sure you first provide the values for the known sides and the known angle.
    txtSASSide3 Calculated value for the unknown side
    txtSASAngle2 Calculated value for one of the unknown angles.
    txtSASAngle3 Calculated value for one of the unknown angles.
    txtSSSSide1 All three sides are known. Type the value of one of them.
    txtSSSSide2 The values of all three sides must be available. Type one of them.
    txtSSSSide3 Enter the third known side
    btnSSSCalculate Make sure you first provide the values for the known sides
    txtSSSAngle1 Calculated value for one of the angles.
    txtSSSAngle2 Calculated value for one of the angles.
    txtSSSAngle3 Calculated value for one of the angles.
    btnClose Click here to close the form
  4. Resize the form as follows:

    Oblique Triangles - Tool Tips

  5. To execute, on the main menu, click Debug -> Start Without Debugging
  6. Position the mouse on different controls on the form:

    Oblique Triangles - Tool Tips

    Oblique Triangles - Tool Tips

  7. Close the form and return to your programming environment

Online Help

Introduction

Online help is the system of providing help files with an application. Online help is usually available from the main menu through a menu group created under a Help category.

In the past, the techniques to provide or program online help were not always easy. The early implementations of help were created in a system called WinHelp. This required using a Rich Text Format (rtf) file and appropriately formatting it. It is possible that, when folks at Microsoft developed WinHelp, they had only Microsoft Word in mind. It was difficult to get the required file ready if you were using another application such as WordPad or WordPerfect... Creating the help file was not enough. Once the file was ready, it had to be added to the application, and appropriately. This back and forth gymnastic was a great motivation for neglect. As if these difficulties were not enough, or because of these difficulties, Microsoft created another system called HTML Help. This neither solved most problems nor created an easier solution. At this time, this HTML Help is widely used and many companies, such as AutoDesk (AutoCAD) and Macromedia to name just two, have adopted it . Many companies such as Borland, Jasc, just to name two, are still using WinHelp. This indicates that HTML Help didn't solve all problems and was not anonymously adopted.

Because HTML Help is the most supported help system by Microsoft, we will use it. Also, it is easier to use HTML Help in a Microsoft Visual Studio 2010 application than to use WinHelp.

The Help Provider

Context-sensitive help allows the user to get local help on a particular control. This works by the user who can first click a control and then press Shift+F1. This displays a yellow box with a word or a group of words:

Microsoft Access - Context-Sensitive Help

This help is easier to provide in a dialog box because a dialog has a feature not available on a form. It consists of adding a button with a question mark and then creating the words that would display eventually. When you create this type of dialog box, the user can click the question marked button and click a control. The user can also press Shift+F1. This causes the mouse pointer to be equipped with a question mark. The user can then click a control and a yellow box would appear for that control, providing help.

Help

To make it easy to provide online help in a Visual Studio 2010application, the .NET Framework provides the HelpProvider control. After adding this control to the application, the form and all controls on it receive a new property labeled HelpString On HelpProvider1. You can then type the desired string in the field of the Properties window for each control that would display context-sensitive help.

Practical LearningPractical Learning: Using Context-Sensitive Help

  1. In the Solution Explorer, double-click Calculation.cs to display that form

    Clarksville Ice Scream - Difference Calculation
  2. Change the following values of the form in the Properties window:
    FormBorderStyle: FixedDialog
    HelpButton: True
    MaximizeBox: False
    MinimizeBox: False
    ShowInTaskbar: False
  3. In the Components section of the Toolbox, click HelpProvider and click the form
  4. Using the Properties window, change the following values for the indicated controls:
    Control HelpString On HelpProvider1
    txtOrderTotal This is the total amount of the current order
    txtAmountTended This is the amount the customer tended
    btnCalculate Click here to calculate the difference between the amount tended and the total price of the order
    txtDifference This displays the difference between the amount tended and the total of the order
    btnClose Click here to close the dialog box
  5. Execute the application
  6. When it displays, process an order and click the Calculate Difference button
  7. In the Calculation dialog box, click the question mark button in the title bar and click on the text boxes or buttons
    Ice Cream Ice Cream
  8. After using the application, close the forms and return to your programming environment
  9. To display the main form, click the ClarksvilleIceCream.cs [Design] label
  10. To add a menu to the application, on the Toolbox, click MenuStrip and click the form
  11. On the form, click Type Here. Type &File and press the down arrow key
  12. Type E&xit and press Enter
  13. On the right side of File (on the form), click Type Here
  14. Type &Help and press the down arrow key
  15. Type &Contents... and press the down arrow key
  16. Type &Index... and press the down arrow key
  17. Type &Search... and press Enter

    Ice Cream
  18. On the form, click FILE and double-click Exit
  19. Implement its event as follows:
    private void exitToolStripMenuItem_Click(object sender, EventArgs e)
    {
        Close();
    }
  20. Test the application then close it and return to Visual Studio

Introduction to HTML Help

The online help we described above provides only small yellow boxes. It is called context-sensitive help because it provides its assistance on only a control of the form. Another technique, in fact highly supported with any commercial program, consists of providing an external application that resembles a book. This allows the user to get more detailed information about almost any aspect of the application.

To provide online help in a Microsoft Visual Studio application, you can use an external system. This consists of creating a complete application whose only purpose is to describe another application. This means that, in the beginning, both applications are not related in any way. This is the job of the HTML Help application. With HTML Help, you must first create HTML files. You create these files anyway you like but, in this case, they are meant to provide support for a specific application. Therefore, when creating the files, try to divide them by issues. For example, you can create a file for each form of your application and use that file to describe what the form or dialog box is used for. You still can use any approach to create the files you would need. Experience will guide you eventually into knowing what to put in those files.

After creating the HTML files, you can open HTML Help Workshop which is a complete but separate application.

Practical LearningPractical Learning: Creating an HTML Help File

  1. Using Windows Explorer or My Computer, create a folder named cic
  2. Inside of the cic folder, create a folder named images
  3. Save the following pictures in the cic\images folder:
    Order Form
    Main Form
    Customer Processing Order Form
    Difference Calculation
  4. Start Notepad and create a Cascading Style Sheet file to format the body tag and the main title of the pages. Here is an example:
    body
    {
    	font-size: 10pt;
    	color: black;
    	margin-top: 0pt;
    	margin-left: 0pt;
    	font-family: Verdana, Tahoma, Arial, Sans-Serif;
    }
    
    .maintitle
    {
    	font-weight: bold;
    	font-size: 24pt;
    	color: blue;
    	font-family: Garamond, Georgia, 'Times New Roman' , Serif;
    }
  5. Save the file as cic.css in the cic folder you created
  6. Start another file with the following contents
    <html>
    
    <head>
    
    <link rel="stylesheet" type="text/css" href="cic.css">
    
    <title>Overview of Clarksville Ice Cream</title>
    </head>
    
    <body>
    
    <table border="0" width="100%" cellspacing="0" cellpadding="0">
      <tr>
        <td width="100%" align="center">
          <p class="maintitle">Overview of Clarksville Ice Cream</p></td>
      </tr>
      <tr>
        <td width="100%" bgcolor="#0000FF" height="2"></td>
      </tr>
    </table>
    
    <p>&nbsp;</p>
    <center><img border="0" src="images/order.gif"
             alt="The main window of the application"
    	 width="416" height="284"></center>
    <p>Clarksville Ice Cream is a computer application used to process customers
    orders. It allows an employee to receive requests from a customer, based on what
    is available in the menu. When the order is complete, an ice cream is
    &quot;prepared&quot; and handed to the customer. As a commercial business, the
    application calculates the total amount. The amount is read to the customer who
    hands money to the clerk to complete the transaction</p>
    
    </body>
    
    </html>
  7. Save it as introduction.htm
  8. Start another file with the following contents
    <html>
    
    <head>
    
    <link rel="stylesheet" type="text/css" href="cic.css">
    
    <title>Customer Order Form</title>
    </head>
    
    <body>
    
    <table border="0" width="100%" cellspacing="0" cellpadding="0">
      <tr>
        <td width="100%" align="center">
          <p class="maintitle">Customer Order Form</p>
        </td>
      </tr>
      <tr>
        <td width="100%" bgcolor="#0000FF" height="2"></td>
      </tr>
    </table>
    
    <p>&nbsp;</p>
    <p>The main or opening window of this application displays a form used to
    process customers orders. The top section of the form, also called the title
    bar, is equipped with a menu called the main menu. this menu allows the user to
    start a new order or to close the application. To use this main menu, you can
    click one of the top-level words such as File. This causes the menu category of
    your choice to expand:</p>
    <center>
      <img border="0" src="images/mainmenu.gif"
       alt="The main menu" width="416" height="284"></center>
    <p>After using a menu item, you can click it or click somewhere else to collapse
    it.</p>
    
    <p>The other objects on the main form allow the user to process an order by
    selecting items from the Windows controls. Once an order is ready, the user can
    click the Calculate Total button. This evaluates the total price of the order
    and displays it in the text box on the right side of Order Total.</p>
    
    <p>To start a new customer order, the user can click the New Order button. This
    resets all controls on the form:</p>
    
    <center>
       <img border="0" src="images/empty.gif" 
        alt="Customer Form Reset" width="416" height="284"></center>
    
    <p>When an order has been calculated, the user can click the Calculate
    Difference button to evaluate the difference.</p>
    
    </body>
    
    </html>
  9. Save it as mainform.htm
  10. Start another file with the following contents
    <html>
    
    <head>
    
    <link rel="stylesheet" type="text/css" href="cic.css">
    
    <title>Difference Calculation</title>
    </head>
    
    <body>
    
    <table border="0" width="100%" cellspacing="0" cellpadding="0">
      <tr>
        <td width="100%" align="center">
          <p class="maintitle">Difference Calculation</p>
        </td>
      </tr>
      <tr>
        <td width="100%" bgcolor="#0000FF" height="2"></td>
      </tr>
    </table>
    
    <p>&nbsp;</p>
    <p>The Calculation dialog box allows a user to easily calculate the amount of
    money owed to a customer. After a customer has placed an order and given money
    to the clerk, the user can display this dialog box. When it comes up, the top
    text box of this window already displays the amount of the customer's order. The
    user can then simply enter the amount the customer gave in the Amount Tended
    text box. Then the user can click Calculate</p>
    <center>
      <img border="0" src="images/calculation.gif"
       width="304" height="152"></center>
    <p>When the user has clicked the Calculate button, it calculates the difference
    and displays it in the Difference text box. After using this dialog box, the
    user can close it by clicking Close.</p>
    <p>&nbsp;</p>
    
    </body>
    
    </html>
  11. Save it as calculation.htm
  12. Start another file with the following contents
    <html>
    
    <head>
    
    <title>Clarksville Ice Cream - Home</title></head>
    
    <body>
    <h1>Clarksville Ice Cream</h1>
    <p><a href="introduction.htm">Introduction</a></p>
    <p><a href="mainform.htm">The Main Form</a></p>
    <p><a href="calculation.htm">The Difference Calculation Dialog Box</a></p>
    </body>
    
    </html>
  13. Save it as index.htm
  14. Start HTML Help Workshop
  15. On the main menu of HTML Help Workshop, click File -> New

    HTML Help Workshop - New

  16. In the New dialog box, make sure Project is selected and click OK

    New Project Wizard - First Page

  17. In the first page of the New Project wizard, click Next

    New Project - Destination

  18. In the second page of the wizard, click Browse
  19. Locate the cic folder you created and display its contents
  20. Set the File Name to IceCream

    The Open Dialog Box

  21. Click Open

    New Project - Destination

  22. In the second page, click Next
  23. In the third page, read the text. Click the HTML files (.htm) check box and click Next:

    New Project - Existing Files

  24. In the fourth page, click Add
  25. In the Open dialog box, press and hold Ctrl. Then click each htm file to select them all:

    The Open Dialog Box - Selecting the HTML files

  26. Click Open:

  27. In the fourth page, click Next
  28. In the last page of the wizard, click Finish
  29. In the HTML Help Workshop, click the Contents tab
    In the dialog box that displays, make sure the first radio button is selected:

  30. Click OK
  31. In the Save As dialog box, accept the suggested name:

    Save As

  32. Click Save
  33. Click the Insert a Heading button Insert a Heading
  34. In the Table Of Contents Entry dialog box, in the Entry Title text box, type Clarksville Ice Cream
  35. Click Add
  36. In the Path Or URL dialog box, select the Clarksville Ice Cream - Home
  37. Click OK

    Table of Contents Entry

  38. Click OK
  39. Click the Insert A Page button Insert A Page
  40. In the message box that displays, read it and click No
  41. In the Entry Title text box, type Introduction
  42. Click Add
  43. In the Path Or URL dialog box, select the Overview of Clarksville Ice Cream
  44. Click OK

    Table Of Contents Entry - New File

  45. In the Table Of Contents Entry dialog box, click OK
  46. In the same way, create new pages under the Introduction heading using the following table
    New Page Title Page or URL
    Customer Order Form Customer Order Form
    Difference Calculation Difference Calculation
  47. In the HTML Help Workshop, click the Index tab. In the dialog box that comes up, make sure the top radio button is selected

    HTML Help

  48. Click OK
  49. Accept the suggested name of the file and press Enter
  50. Click Insert A Keyword Insert A Keyword
  51. In the Keyword text box, type Calculation
  52. Click Add
  53. In the Path Or URL dialog box, click Difference Calculation and click OK twice
  54. In the same way, create new keywords using the following table (sometimes you may receive a message box asking whether you want to create the keyword above the other; it doesn't matter, for this exercise, whether you click Yes or No):
    New Keyword Page or URL
    amount Difference Calculation
    money Difference Calculation
    customer Difference Calculation
    order Difference Calculation
    clerk Difference Calculation
    window Difference Calculation
    Amount Tended Difference Calculation
    Calculate Difference Calculation
    Close Difference Calculation
    computer Overview of Clarksville Ice Cream
    Application Overview of Clarksville Ice Cream
    employee Overview of Clarksville Ice Cream
    menu Overview of Clarksville Ice Cream
    commercial Overview of Clarksville Ice Cream
    business Overview of Clarksville Ice Cream
    transaction Overview of Clarksville Ice Cream
    Main Menu Customer Order Form
    category Customer Order Form
    choice Customer Order Form
  55. Click the Sort Keywords Alphabetically button

  56. Click the Project tab
  57. Click the Add/Modify Window Definitions button Add/Modify Window Definitions

  58. Set the name to MainWnd
  59. Press Enter
  60. Set the Title Bar Text to Oblique Triangles
  61. Click the Buttons tab then click the Home and the Locate check boxes

    Window Types - Buttons

  62. Click the Position tab
  63. Set the Width to 800
  64. Set the Height to 600

  65. Click the Files tab
  66. Set the Default and the Home choices to index.htm

  67. Click Navigation Pane
  68. Click the Search Tab and the Advanced check boxes

  69. Click OK

  70. When the Resolve Window Definition wizard comes up, in the first page, make sure the window defined previously is selected in the Window Type and click Next
  71. Click Compile Full-Text Information

    Resolve Window Definition - Finish

  72. Click Next
  73. In the second page, accept the defaults and click Next
  74. In the third page, accept the default and click Finish
  75. To create the help file, click the Save All Files And Compile button

    HTML Help

  76. When the compilation is over, close the HTML Help Workshop window

HTML Help and Windows Applications

After creating the HTML Help application, you can use an HelpProvider control to connect it to your application. The HelpProvider control is equipped with the HelpNamespace provider. This property allows you to specify the application that contains the help application. Besides the HelpNamespace property, the HelpProvider control provides various methods to manage help.

HTML Help can be provided to a Microsoft Visual Studio application through the Help class. The overloaded ShowHelp() method is used to specify the help file to display and possibly additional information. Notice that all versions take a first argument as a Control type. This is the parent control from where the online help will be provided.

The first version of the ShowHelp() method allows you to specify the help file. It can be the help file specified in the HelpProvider.HelpNamespace property mentioned above.

The second and the fourth versions of the ShowHelp() method allow you to specify the tab of the HTML Help window to display when the method is called. This is done through the HelpNavigator enumerator that has a value for each tab of the HTML Help window. the fourth version can be used to open the HTML Help window from its Find tab and specify a keyword to search for.

The third version of the ShowHelp() method can be used to open a help file based on a keyword.

The ShowHelpIndex() method can be used to open the Index tab of the HTML Help window.

Practical LearningPractical Learning: Providing Online Help to an Application

  1. Open Windows Explorer or My Computer
  2. In the cic folder, copy the IceCream.chm file to the clipboard and paste it in the folder of the current project (ClarckvilleIceCream1)
  3. In Microsoft Visual Studio, display the main form
  4. In the Components section of the Toolbox, click HelpProvider Help Provider and click the form
  5. In the Properties window, change its Name to hpvIceCream and click HelpNamespace
  6. Click the ellipsis button of the HelpNamespace property
  7. From the folder of the current project, select the IceCream.chm file
    Open Help File
  8. Click Open
  9. On the main menu of the form, click Help and double-click Contents
  10. Implement the event as follows:
    private void contentsToolStripMenuItem_Click(object sender, EventArgs e)
    {
        Help.ShowHelp(this, hpvIceCream.HelpNamespace);
    }
  11. Display the ClarksvilleIceCream form
  12. On the main menu of the form, double-click Index
  13. Implement the event as follows:
    private void indexToolStripMenuItem_Click(object sender, EventArgs e)
    {
        Help.ShowHelpIndex(this, hpvIceCream.HelpNamespace);
    }
  14. Return to the form
  15. On the main menu of the form, double-click Search
  16. Implement the event as follows:
    private void searchToolStripMenuItem_Click(object sender, EventArgs e)
    {
        Help.ShowHelp(this, hpvIceCream.HelpNamespace, HelpNavigator.Find, "");
    }
  17. Execute the application
  18. When it displays, click the Help menu of the form and click one of the menu items

    HTML Help
  19. After using it, close the online help window, close the form, and return to your programming environment
  20. Close Microsoft Visual Studio. If you are asked whether you want to save the project, click Yes

Previous Copyright © 2004-2023, FunctionX, Inc. Monday 08 May 2023 Next