Freigeben über


IHelpService-Schnittstelle

Stellt Methoden zum Anzeigen von Hilfethemen sowie zum Hinzufügen und Entfernen von Hilfeschlüsselwörtern zur Entwurfszeit bereit.

Namespace: System.ComponentModel.Design
Assembly: System (in system.dll)

Syntax

'Declaration
Public Interface IHelpService
'Usage
Dim instance As IHelpService
public interface IHelpService
public interface class IHelpService
public interface IHelpService
public interface IHelpService

Hinweise

Die Entwurfszeitumgebung stellt ein Hilfesystem bereit, das nach relevanten anzuzeigenden Hilfethemen sucht, wenn ein Benutzer F1 drückt. Das Hilfesystem verwaltet eine Gruppe von aktuellen Kontextschlüsselwörtern, die zum Bezeichnen der relevanten Themen verwendet werden, wenn Hilfe angefordert wird. Schlüsselwörter sind in der Standardeinstellung ausgewählten Klassenobjekten und Eigenschaften von Objekten in der Entwurfszeitumgebung zugeordnet. Das Standardschlüsselwort für eine Komponente oder Eigenschaft ist der entsprechende voll gekennzeichnete Klassen- oder Eigenschaftenname. Außerdem sind spezielle Schlüsselwörter bestimmten Modi zugeordnet, z. B. der Auswahl von mehreren Objekten. Wenn eine benutzerdefinierte Hilfeauflistung durch die Konfiguration für einen externen Hilfeanbieter in die Entwurfszeitumgebung integriert wird, kann ein Dokumentationsprovider ein Thema für eine bestimmte Komponentenklasse oder Eigenschaft einem Schlüsselwort zuordnen, das aus dem voll gekennzeichneten Typ- oder Membernamen besteht.

Sie können den IHelpService verwenden, um den Hilfedienst unter Verwendung der ShowHelpFromKeyword-Methode mit einem angegebenen Schlüsselwort aufzurufen oder um mit der ShowHelpFromUrl-Methode ein Hilfethema von einem angegebenen URL aufzurufen.

Mit dem IHelpService können Sie außerdem Hilfeschlüsselwörter zur Entwurfszeit hinzufügen oder entfernen. Wenn Sie zur Entwurfszeit eine Komponente oder Eigenschaft auswählen, wird ein Standardkontextschlüsselwort festgelegt, das aus dem voll gekennzeichneten Typ- oder Membernamen der Auswahl besteht, und die Schlüsselwörter für alle zuvor ausgewählten und nicht mehr ausgewählten Komponenten oder Eigenschaften werden entfernt.

Da das Hilfesystem benutzerdefinierte Hilfeschlüsselwörter nicht automatisch entfernt, müssen Sie ein nicht mehr zutreffendes benutzerdefiniertes Schlüsselwort explizit entfernen. Sie können die von der ISelectionService-Schnittstelle definierten Ereignisse überwachen, um zu bestimmen, wann sich eine Komponentenauswahl ändert. Auf der Grundlage dieser Ereignisse können Sie ein Hilfekontextattribut für eine Komponente hinzufügen, wenn diese ausgewählt ist, und das Hilfekontextattribut entfernen, wenn die Komponente nicht mehr in der Auswahl enthalten ist.

Beispiel

Im folgenden Beispiel wird ein Designer veranschaulicht, der den IHelpService verwendet, um Hilfekontextattribute für das enthaltene Steuerelement hinzuzufügen und zu entfernen. Um dieses Beispiel zu verwenden, kompilieren Sie es in eine Klassenbibliothek, und fügen Sie einem Form eine Instanz des Steuerelements hinzu. Wenn in der Entwurfsansicht eine Komponente ausgewählt und F1 gedrückt wird, werden relevante Hilfethemen auf der Grundlage der aktuellen Hilfekontext-Schlüsselwörter gesucht. Klicken Sie mit der rechten Maustaste auf die Komponente, und im Kontextmenü werden Befehle angezeigt, einschließlich der beiden benutzerdefinierten DesignerVerb-Befehle Add IHelpService Help Keyword und Remove IHelpService Help Keyword. Mit diesen Befehlen kann ein Hilfekontext-Schlüsselwort mit dem Wert "IHelpService" hinzugefügt oder entfernt werden. Nach Hinzufügen dieses Schlüsselwortes wird bei Drücken von F1 versucht, das IHelpService-Thema aufzurufen.

Imports System
Imports System.ComponentModel
Imports System.ComponentModel.Design
Imports System.Drawing
Imports System.IO
Imports System.Windows.Forms
Imports System.Windows.Forms.Design

Namespace IHelpServiceSample

    Public Class HelpDesigner
        Inherits System.Windows.Forms.Design.ControlDesigner

        Public Sub New()
        End Sub 'New

        Public Overrides ReadOnly Property Verbs() As System.ComponentModel.Design.DesignerVerbCollection
            Get
                Return New DesignerVerbCollection(New DesignerVerb() {New DesignerVerb("Add IHelpService Help Keyword", AddressOf Me.addKeyword), New DesignerVerb("Remove IHelpService Help Keyword", AddressOf Me.removeKeyword)})
            End Get
        End Property

        Private Sub addKeyword(ByVal sender As Object, ByVal e As EventArgs)
            Dim hs As IHelpService = CType(Me.Control.Site.GetService(GetType(IHelpService)), IHelpService)
            hs.AddContextAttribute("keyword", "IHelpService", HelpKeywordType.F1Keyword)
        End Sub 'addKeyword

        Private Sub removeKeyword(ByVal sender As Object, ByVal e As EventArgs)
            Dim hs As IHelpService = CType(Me.Control.Site.GetService(GetType(IHelpService)), IHelpService)
            hs.RemoveContextAttribute("keyword", "IHelpService")
        End Sub 'removeKeyword
    End Class 'HelpDesigner

    <Designer(GetType(HelpDesigner))> _
    Public Class HelpTestControl
        Inherits System.Windows.Forms.UserControl

        Public Sub New()
            Me.Size = New Size(320, 100)
            Me.BackColor = Color.White
        End Sub 'New

        Protected Overrides Sub OnPaint(ByVal e As System.Windows.Forms.PaintEventArgs)
            Dim brush As New SolidBrush(Color.Blue)
            e.Graphics.DrawString("IHelpService Example Designer Control", New Font(FontFamily.GenericMonospace, 10), brush, 5, 5)
            e.Graphics.DrawString("Right-click this component for", New Font(FontFamily.GenericMonospace, 8), brush, 5, 25)
            e.Graphics.DrawString("add/remove Help context keyword commands.", New Font(FontFamily.GenericMonospace, 8), brush, 5, 35)
            e.Graphics.DrawString("Press F1 while this component is", New Font(FontFamily.GenericMonospace, 8), brush, 5, 55)
            e.Graphics.DrawString("selected to raise Help topics for", New Font(FontFamily.GenericMonospace, 8), brush, 5, 65)
            e.Graphics.DrawString("the current keyword or keywords", New Font(FontFamily.GenericMonospace, 8), brush, 5, 75)
        End Sub 'OnPaint
    End Class 'HelpTestControl
End Namespace 'IHelpServiceSample
using System;
using System.ComponentModel;
using System.ComponentModel.Design;
using System.Drawing;
using System.IO;
using System.Windows.Forms;
using System.Windows.Forms.Design;

namespace IHelpServiceSample
{
    public class HelpDesigner : System.Windows.Forms.Design.ControlDesigner
    {
        public HelpDesigner()
        {           
        }

        public override System.ComponentModel.Design.DesignerVerbCollection Verbs
        {
            get
            {
                return new DesignerVerbCollection( new DesignerVerb[] { 
                        new DesignerVerb("Add IHelpService Help Keyword", new EventHandler(this.addKeyword)),
                        new DesignerVerb("Remove IHelpService Help Keyword", new EventHandler(this.removeKeyword))
                } );
            }
        }
        
        private void addKeyword(object sender, EventArgs e)
        {
            IHelpService hs = (IHelpService) this.Control.Site.GetService(typeof(IHelpService));            
            hs.AddContextAttribute("keyword", "IHelpService", HelpKeywordType.F1Keyword);   
        }
        
        private void removeKeyword(object sender, EventArgs e)
        {
            IHelpService hs = (IHelpService) this.Control.Site.GetService(typeof(IHelpService));            
            hs.RemoveContextAttribute("keyword", "IHelpService");
        }
    }

    [Designer(typeof(HelpDesigner))]
    public class HelpTestControl : System.Windows.Forms.UserControl
    {
        public HelpTestControl()
        {
            this.Size = new Size(320, 100);
            this.BackColor = Color.White;
        }

        protected override void OnPaint(System.Windows.Forms.PaintEventArgs e)
        {           
            Brush brush = new SolidBrush(Color.Blue);
            e.Graphics.DrawString("IHelpService Example Designer Control", new Font( FontFamily.GenericMonospace, 10 ), brush, 5, 5);
            e.Graphics.DrawString("Right-click this component for", new Font( FontFamily.GenericMonospace, 8 ), brush, 5, 25);
            e.Graphics.DrawString("add/remove Help context keyword commands.", new Font( FontFamily.GenericMonospace, 8 ), brush, 5, 35);           
            e.Graphics.DrawString("Press F1 while this component is", new Font( FontFamily.GenericMonospace, 8 ), brush, 5, 55);
            e.Graphics.DrawString("selected to raise Help topics for", new Font( FontFamily.GenericMonospace, 8 ), brush, 5, 65);           
            e.Graphics.DrawString("the current keyword or keywords", new Font( FontFamily.GenericMonospace, 8 ), brush, 5, 75);         
        }       
    }
}
#using <System.Windows.Forms.dll>
#using <System.Drawing.dll>
#using <System.Design.dll>
#using <System.dll>

using namespace System;
using namespace System::ComponentModel;
using namespace System::ComponentModel::Design;
using namespace System::Drawing;
using namespace System::IO;
using namespace System::Windows::Forms;
using namespace System::Windows::Forms::Design;

public ref class HelpDesigner: public System::Windows::Forms::Design::ControlDesigner
{
public:
   HelpDesigner(){}

   property System::ComponentModel::Design::DesignerVerbCollection^ Verbs 
   {
      virtual System::ComponentModel::Design::DesignerVerbCollection^ get() override
      {
         array<DesignerVerb^>^temp0 = {gcnew DesignerVerb( "Add IHelpService Help Keyword",gcnew EventHandler( this, &HelpDesigner::addKeyword ) ),gcnew DesignerVerb( "Remove IHelpService Help Keyword",gcnew EventHandler( this, &HelpDesigner::removeKeyword ) )};
         return gcnew DesignerVerbCollection( temp0 );
      }
   }

private:
   void addKeyword( Object^ /*sender*/, EventArgs^ /*e*/ )
   {
      IHelpService^ hs = dynamic_cast<IHelpService^>(this->Control->Site->GetService( IHelpService::typeid ));
      hs->AddContextAttribute( "keyword", "IHelpService", HelpKeywordType::F1Keyword );
   }

   void removeKeyword( Object^ /*sender*/, EventArgs^ /*e*/ )
   {
      IHelpService^ hs = dynamic_cast<IHelpService^>(this->Control->Site->GetService( IHelpService::typeid ));
      hs->RemoveContextAttribute( "keyword", "IHelpService" );
   }
};


[Designer(HelpDesigner::typeid)]
public ref class HelpTestControl: public System::Windows::Forms::UserControl
{
public:
   HelpTestControl()
   {
      this->Size = System::Drawing::Size( 320, 100 );
      this->BackColor = Color::White;
   }

protected:
   virtual void OnPaint( System::Windows::Forms::PaintEventArgs^ e ) override
   {
      Brush^ brush = gcnew SolidBrush( Color::Blue );
      e->Graphics->DrawString( "IHelpService Example Designer Control", gcnew System::Drawing::Font( FontFamily::GenericMonospace,10 ), brush, 5, 5 );
      e->Graphics->DrawString( "Right-click this component for", gcnew System::Drawing::Font( FontFamily::GenericMonospace,8 ), brush, 5, 25 );
      e->Graphics->DrawString( "add/remove Help context keyword commands.", gcnew System::Drawing::Font( FontFamily::GenericMonospace,8 ), brush, 5, 35 );
      e->Graphics->DrawString( "Press F1 while this component is", gcnew System::Drawing::Font( FontFamily::GenericMonospace,8 ), brush, 5, 55 );
      e->Graphics->DrawString( "selected to raise Help topics for", gcnew System::Drawing::Font( FontFamily::GenericMonospace,8 ), brush, 5, 65 );
      e->Graphics->DrawString( "the current keyword or keywords", gcnew System::Drawing::Font( FontFamily::GenericMonospace,8 ), brush, 5, 75 );
   }
};
package IHelpServiceSample; 
import System.*;
import System.ComponentModel.*;
import System.ComponentModel.Design.*;
import System.Drawing.*;
import System.IO.*;
import System.Windows.Forms.*;
import System.Windows.Forms.Design.*;

public class HelpDesigner extends System.Windows.Forms.Design.ControlDesigner
{
    public HelpDesigner()
    {
    } //HelpDesigner

    /** @property 
     */
    public System.ComponentModel.Design.DesignerVerbCollection get_Verbs()
    {
        return new DesignerVerbCollection(new DesignerVerb[] { 
            new DesignerVerb("Add IHelpService Help Keyword", 
            new EventHandler(this.AddKeyword)), new DesignerVerb(
            "Remove IHelpService Help Keyword", new EventHandler(
            this.RemoveKeyword)) });
    } //get_Verbs

    private void AddKeyword(Object sender, EventArgs e)
    {
        IHelpService hs = (IHelpService)(this.get_Control().get_Site().
            GetService(IHelpService.class.ToType()));
        hs.AddContextAttribute("keyword", "IHelpService", 
            HelpKeywordType.F1Keyword);
    } //AddKeyword

    private void RemoveKeyword(Object sender, EventArgs e)
    {
        IHelpService hs = (IHelpService)(this.get_Control().get_Site().
            GetService(IHelpService.class.ToType()));
        hs.RemoveContextAttribute("keyword", "IHelpService");
    } //RemoveKeyword
} //HelpDesigner

/** @attribute Designer(HelpDesigner.class)
 */
public class HelpTestControl extends System.Windows.Forms.UserControl
{
    public HelpTestControl()
    {
        this.set_Size(new Size(320, 100));
        this.set_BackColor(Color.get_White());
    } //HelpTestControl

    protected void OnPaint(System.Windows.Forms.PaintEventArgs e)
    {
        Brush brush = new SolidBrush(Color.get_Blue());

        e.get_Graphics().DrawString("IHelpService Example Designer Control",
            new Font(FontFamily.get_GenericMonospace(), 10), brush, 5, 5);
        e.get_Graphics().DrawString("Right-click this component for", 
            new Font(FontFamily.get_GenericMonospace(), 8), brush, 5, 25);
        e.get_Graphics().DrawString("add/remove Help context keyword commands.",
            new Font(FontFamily.get_GenericMonospace(), 8), brush, 5, 35);
        e.get_Graphics().DrawString("Press F1 while this component is", 
            new Font(FontFamily.get_GenericMonospace(), 8), brush, 5, 55);
        e.get_Graphics().DrawString("selected to raise Help topics for", 
            new Font(FontFamily.get_GenericMonospace(), 8), brush, 5, 65);
        e.get_Graphics().DrawString("the current keyword or keywords", 
            new Font(FontFamily.get_GenericMonospace(), 8), brush, 5, 75);
    } //OnPaint
} //HelpTestControl

Plattformen

Windows 98, Windows 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

.NET Framework unterstützt nicht alle Versionen sämtlicher Plattformen. Eine Liste der unterstützten Versionen finden Sie unter Systemanforderungen.

Versionsinformationen

.NET Framework

Unterstützt in: 2.0, 1.1, 1.0

Siehe auch

Referenz

IHelpService-Member
System.ComponentModel.Design-Namespace
HelpKeywordType-Enumeration
HelpContextType-Enumeration