Sdílet prostřednictvím


Action – rozhraní

Akce inteligentních značek v dokumentu aplikace Word, který je přizpůsoben pomocí nástroje Office vývoj v Visual Studiopředstavuje.

Obor názvů:  Microsoft.Office.Tools.Word
Sestavení:  Microsoft.Office.Tools.Word (v Microsoft.Office.Tools.Word.dll)

Syntaxe

'Deklarace
<GuidAttribute("1886a0c6-4e1a-4b8f-8304-5143462fe2b6")> _
Public Interface Action _
    Inherits ActionBase
[GuidAttribute("1886a0c6-4e1a-4b8f-8304-5143462fe2b6")]
public interface Action : ActionBase

Typ Action zveřejňuje následující členy.

Vlastnosti

  Název Popis
Veřejná vlastnost Caption Získá nebo nastaví název akce, jako je zobrazena v nabídkainteligentní značky. (Zděděno z ActionBase.)

Na začátek

Události

  Název Popis
Veřejná událost BeforeCaptionShow Dochází poté, co uživatel klepne na ikonu inteligentní značky a před inteligentní značky se zobrazí nabídka .
Veřejná událost Click Dojde po klepnutí na akci v nabídka inteligentní značky.

Na začátek

Poznámky

Akce jsou dostupné v zástupce nabídka inteligentní značky možnosti rozpoznané inteligentní značky určitého typu. Akce vytvoříte Globals.Factory.CreateAction Metoda vytvoření Action objektu. Další informace naleznete v tématu Smart Tags Architecture.

Poznámka

Toto rozhraní je implementováno modulem runtime nástrojů Visual Studio Tools for Office. Rozhraní není určeno k implementaci do vašeho kódu. Další informace naleznete v tématu Visual Studio Tools for Office Runtime Overview.

Použití

Tento typ je určen pro použití pouze v projektech aplikace Word 2007. Inteligentní značky jsou v roce 2010 slovo zastaralý . Další informace naleznete v tématu Smart Tags Overview.

Tato dokumentace popisuje verzi tohoto typu, který je používán v projektech systému Office cílených na rozhraní .NET Framework 4. V projektech cílených na rozhraní .NET Framework 3.5 může mít tento typ rozdílné členy a příklady kódů pro tento typ nemusí fungovat. Dokumentaci k tomuto typu v projektech cílených na rozhraní .NET Framework 3.5 naleznete v následující informační části dokumentace k aplikaci Visual Studio 2008: https://go.microsoft.com/fwlink/?LinkId=160658.

Příklady

Následující příklad kódu ukazuje, jak vytvořit inteligentní značku s akcí. Akce inteligentních značek upraví titulek nabídka akce v době běhu a zobrazuje umístění rozpoznaného textu.

Private WithEvents displayAddress As Microsoft.Office.Tools.Word.Action

Private Sub AddSmartTag()

    ' Create the smart tag for .NET Framework 4 projects.
    Dim smartTagDemo As Microsoft.Office.Tools.Word.SmartTag = Globals.Factory.CreateSmartTag(
        "www.microsoft.com/Demo#DemoSmartTag",
        "Demonstration Smart Tag")

    ' For .NET Framework 3.5 projects, use the following code to create the smart tag.
    ' Dim smartTagDemo As New  _
    '     Microsoft.Office.Tools.Word.SmartTag( _
    '     "www.microsoft.com/Demo#DemoSmartTag", _
    '     "Demonstration Smart Tag")

    ' Specify the terms to recognize.
    smartTagDemo.Terms.Add("term")
    smartTagDemo.Terms.Add("recognize")

    ' Create the action for .NET Framework 4 projects.
    displayAddress = Globals.Factory.CreateAction("To be replaced")

    ' For .NET Framework 3.5 projects, use the following code to create the action.
    ' displayAddress = New Microsoft.Office.Tools.Word.Action("To be replaced")

    ' Add the action to the smart tag.
    smartTagDemo.Actions = New Microsoft.Office.Tools.Word.Action() { _
            displayAddress}

    ' Add the smart tag.
    Me.VstoSmartTags.Add(smartTagDemo)
End Sub

Private Sub DisplayAddress_BeforeCaptionShow(ByVal sender As Object, _
    ByVal e As Microsoft.Office.Tools.Word.ActionEventArgs) _
    Handles displayAddress.BeforeCaptionShow

    Dim clickedAction As Microsoft.Office.Tools.Word.Action = _
        TryCast(sender, Microsoft.Office.Tools.Word.Action)

    If clickedAction IsNot Nothing Then
        clickedAction.Caption = "Display the location of " & e.Text
    End If
End Sub

Private Sub DisplayAddress_Click(ByVal sender As Object, _
    ByVal e As Microsoft.Office.Tools.Word.ActionEventArgs) _
    Handles displayAddress.Click

    Dim termStart As Integer = e.Range.Start
    Dim termEnd As Integer = e.Range.End
    MsgBox("The recognized text '" & e.Text & _
            "' begins at position " & termStart & _
            " and ends at position " & termEnd)
End Sub
private Microsoft.Office.Tools.Word.Action displayAddress;

private void AddSmartTag()
{
    // Create the smart tag for .NET Framework 4 projects.
    Microsoft.Office.Tools.Word.SmartTag smartTagDemo =
        Globals.Factory.CreateSmartTag(
        "www.microsoft.com/Demo#DemoSmartTag",
        "Demonstration Smart Tag");

    // For .NET Framework 3.5 projects, use the following code to create the smart tag.
    // Microsoft.Office.Tools.Word.SmartTag smartTagDemo =
        // new Microsoft.Office.Tools.Word.SmartTag(
        //     "www.microsoft.com/Demo#DemoSmartTag",
        //     "Demonstration Smart Tag");

    // Specify the terms to recognize.
    smartTagDemo.Terms.Add("term");
    smartTagDemo.Terms.Add("recognize");

    // Create the action for .NET Framework 4 projects.
    displayAddress = Globals.Factory.CreateAction("To be replaced"); 

    // For .NET Framework 3.5 projects, use the following code to create the action.
    // displayAddress = new Microsoft.Office.Tools.Word.Action("To be replaced");

    // Add the action to the smart tag.
    smartTagDemo.Actions = new Microsoft.Office.Tools.Word.Action[] { 
        displayAddress };

    // Add the smart tag.
    this.VstoSmartTags.Add(smartTagDemo);

    displayAddress.BeforeCaptionShow += new
        Microsoft.Office.Tools.Word.BeforeCaptionShowEventHandler(
        displayAddress_BeforeCaptionShow);

    displayAddress.Click += new
        Microsoft.Office.Tools.Word.ActionClickEventHandler(
        displayAddress_Click);
}

void displayAddress_BeforeCaptionShow(object sender,
    Microsoft.Office.Tools.Word.ActionEventArgs e)
{
    Microsoft.Office.Tools.Word.Action clickedAction =
        sender as Microsoft.Office.Tools.Word.Action;

    if (clickedAction != null)
    {
        clickedAction.Caption = "Display the location of " +
            e.Text;
    }
}

void displayAddress_Click(object sender,
    Microsoft.Office.Tools.Word.ActionEventArgs e)
{
    int termStart = e.Range.Start;
    int termEnd = e.Range.End;
    System.Windows.Forms.MessageBox.Show("The recognized text '" + e.Text +
        "' begins at position " + termStart.ToString() +
        " and ends at position " + termEnd.ToString());
}

Viz také

Odkaz

Microsoft.Office.Tools.Word – obor názvů

SmartTag

Další zdroje

Smart Tags Architecture

How to: Add Smart Tags to Word Documents

How to: Create Smart Tags With Custom Recognizers in Word

Walkthrough: Creating a Smart Tag by Using a Document-Level Customization