public static void Bind(HelpProvider localHelpProvider, Control control)
 {
     IHelpProviderContext context = control.FindForm() as IHelpProviderContext;
     if (context != null)
     {
         if (localHelpProvider.GetShowHelp(control))
         {
             string helpString = localHelpProvider.GetHelpString(control);
             if (helpString != null)
             {
                 context.HelpProvider.SetShowHelp(control, true);
                 context.HelpProvider.SetHelpString(control, helpString);
             }
         }
     }
 }
示例#2
0
		public void BasicPropertiesTest ()
		{
			SWF.HelpProvider swfHelpProvider = new SWF.HelpProvider ();
			
			SWF.Button swfButton = new SWF.Button ();
			swfButton.Location = new SD.Point (3, 3);
			swfButton.Size = new SD.Size (272, 72);
			swfButton.Text = "With help";
			
			SWF.Button swfButtonNoHelp = new SWF.Button ();
			swfButtonNoHelp.Location = new SD.Point (3, 30);
			swfButtonNoHelp.Size = new SD.Size (272, 72);
			swfButtonNoHelp.Text = "No help";
			
			//We have to use an event to fake the user click
			swfButton.Click += new System.EventHandler (OnControlClicked);

			swfHelpProvider.SetShowHelp (swfButton, true);
			swfHelpProvider.SetHelpString (swfButton, "I'm showing a button tooltip.");
			
			Form.Controls.Add (swfButton);
			Form.Controls.Add (swfButtonNoHelp);
			
			//Testing ToolTipOpenedEvent
			bridge.ResetEventLists ();
			swfButton.PerformClick (); //Clicking the button will fake the event!

			StructureChangedEventTuple eventTuple 
				= bridge.GetStructureChangedEventAt (0, StructureChangeType.ChildAdded);
			Assert.IsNotNull (eventTuple, "GetAutomationEventAt (0)");
			
			//We have the HelpProvider!
			IRawElementProviderFragment helpProvider = eventTuple.provider as IRawElementProviderFragment;
			
			Assert.IsNotNull (helpProvider, "helpProvider is null");
			
			TestProperty (helpProvider,
			              AutomationElementIdentifiers.IsControlElementProperty,
			              true);
			
			TestProperty (helpProvider,
			              AutomationElementIdentifiers.IsContentElementProperty,
			              false);			

			TestProperty (helpProvider,
			              AutomationElementIdentifiers.HelpTextProperty,
			              null);

			TestProperty (helpProvider,
			              AutomationElementIdentifiers.LocalizedControlTypeProperty,
			              "tool tip");
			
			TestProperty (helpProvider,
			              AutomationElementIdentifiers.ControlTypeProperty,
			              ControlType.ToolTip.Id);
			
			TestProperty (helpProvider,
			              AutomationElementIdentifiers.LabeledByProperty,
			              null);
			
			TestProperty (helpProvider,
			              AutomationElementIdentifiers.NameProperty,
			              swfHelpProvider.GetHelpString (swfButton));
			
			TestProperty (helpProvider,
			              AutomationElementIdentifiers.IsKeyboardFocusableProperty,
			              false);
			
			TestProperty (helpProvider,
			              AutomationElementIdentifiers.ClickablePointProperty,
			              null);

			// TODO: How to allow it?
//			bridge.ResetEventLists ();
//
//			swfButtonNoHelp.PerformClick (); //Clicking this button will close the tooltip
//			
//			Assert.AreEqual (1,
//			                 bridge.GetAutomationEventCount (InvokePatternIdentifiers.InvokedEvent),
//			                 "AutomationElementIdentifiers.InvokedEvent");
//	
//			Assert.IsNotNull (bridge.GetStructureChangedEventAt (0, StructureChangeType.ChildRemoved),
//			                 "AutomationElementIdentifiers.ChildRemoved");
		}
示例#3
0
    private void ProcessEntry(object sender, KeyEventArgs e)
    {
        // Cast the sender back to a TextBox.
        Control textBoxSender = (TextBox)sender;

        // Set the error description to an empty string ().
        ErrorProvider1.SetError(textBoxSender, "");

        // Declare the variable to hold the new balance.
        double newBalance = 0;

        // Wrap the code in a Try/Catch block to catch
        // errors that can occur when converting the string
        // to a double.

        try
        {
            if (e.KeyCode == Keys.Enter)

            // Switch on the text box that received
            // the KeyPress event. Convert the text to type double,
            // and compute the new balance.
            {
                switch (textBoxSender.Name)
                {
                case "withdrawal":
                    newBalance = Double.Parse(balance.Text)
                                 - Double.Parse(withdrawal.Text);
                    withdrawal.Text = "";
                    break;

                case "deposit":
                    newBalance = Double.Parse(balance.Text)
                                 + Double.Parse(deposit.Text);
                    deposit.Text = "";
                    break;
                }

                // Check the value of new balance and set the
                // Forecolor property accordingly.
                if (newBalance < 0)
                {
                    balance.ForeColor = Color.Red;
                }
                else
                {
                    balance.ForeColor = Color.Black;
                }

                // Set the text of the balance text box
                // to the newBalance value.
                balance.Text = newBalance.ToString();
            }
        }
        catch (FormatException)
        {
            // If a FormatException is thrown, set the
            // error string to the HelpString message for
            // the control.
            ErrorProvider1.SetError(textBoxSender,
                                    HelpProvider1.GetHelpString(textBoxSender));
        }
    }
示例#4
0
        public void BasicPropertiesTest()
        {
            SWF.HelpProvider swfHelpProvider = new SWF.HelpProvider();

            SWF.Button swfButton = new SWF.Button();
            swfButton.Location = new SD.Point(3, 3);
            swfButton.Size     = new SD.Size(272, 72);
            swfButton.Text     = "With help";

            SWF.Button swfButtonNoHelp = new SWF.Button();
            swfButtonNoHelp.Location = new SD.Point(3, 30);
            swfButtonNoHelp.Size     = new SD.Size(272, 72);
            swfButtonNoHelp.Text     = "No help";

            //We have to use an event to fake the user click
            swfButton.Click += new System.EventHandler(OnControlClicked);

            swfHelpProvider.SetShowHelp(swfButton, true);
            swfHelpProvider.SetHelpString(swfButton, "I'm showing a button tooltip.");

            Form.Controls.Add(swfButton);
            Form.Controls.Add(swfButtonNoHelp);

            //Testing ToolTipOpenedEvent
            bridge.ResetEventLists();
            swfButton.PerformClick();              //Clicking the button will fake the event!

            StructureChangedEventTuple eventTuple
                = bridge.GetStructureChangedEventAt(0, StructureChangeType.ChildAdded);

            Assert.IsNotNull(eventTuple, "GetAutomationEventAt (0)");

            //We have the HelpProvider!
            IRawElementProviderFragment helpProvider = eventTuple.provider as IRawElementProviderFragment;

            Assert.IsNotNull(helpProvider, "helpProvider is null");

            TestProperty(helpProvider,
                         AutomationElementIdentifiers.IsControlElementProperty,
                         true);

            TestProperty(helpProvider,
                         AutomationElementIdentifiers.IsContentElementProperty,
                         false);

            TestProperty(helpProvider,
                         AutomationElementIdentifiers.HelpTextProperty,
                         null);

            TestProperty(helpProvider,
                         AutomationElementIdentifiers.LocalizedControlTypeProperty,
                         "tool tip");

            TestProperty(helpProvider,
                         AutomationElementIdentifiers.ControlTypeProperty,
                         ControlType.ToolTip.Id);

            TestProperty(helpProvider,
                         AutomationElementIdentifiers.LabeledByProperty,
                         null);

            TestProperty(helpProvider,
                         AutomationElementIdentifiers.NameProperty,
                         swfHelpProvider.GetHelpString(swfButton));

            TestProperty(helpProvider,
                         AutomationElementIdentifiers.IsKeyboardFocusableProperty,
                         false);

            TestProperty(helpProvider,
                         AutomationElementIdentifiers.ClickablePointProperty,
                         null);

            // TODO: How to allow it?
//			bridge.ResetEventLists ();
//
//			swfButtonNoHelp.PerformClick (); //Clicking this button will close the tooltip
//
//			Assert.AreEqual (1,
//			                 bridge.GetAutomationEventCount (InvokePatternIdentifiers.InvokedEvent),
//			                 "AutomationElementIdentifiers.InvokedEvent");
//
//			Assert.IsNotNull (bridge.GetStructureChangedEventAt (0, StructureChangeType.ChildRemoved),
//			                 "AutomationElementIdentifiers.ChildRemoved");
        }