StateChangedEventArgs 类

定义

StateChanged 事件返回数据。

public ref class StateChangedEventArgs : EventArgs
public class StateChangedEventArgs : EventArgs
type StateChangedEventArgs = class
    inherit EventArgs
Public Class StateChangedEventArgs
Inherits EventArgs
继承
StateChangedEventArgs

示例

以下示例演示了有关 StateChanged 事件的可用信息。

using System;  
using System.Speech.Synthesis;  

namespace SampleSynthesis  
{  
  class Program  
  {  

    static void Main(string[] args)  
    {  

      // Initialize a new instance of the SpeechSynthesizer.  
      using (SpeechSynthesizer synth = new SpeechSynthesizer())  
      {  

        // Configure the audio output.   
        synth.SetOutputToDefaultAudioDevice();  

        // Subscribe to StateChanged event.  
        synth.StateChanged += new EventHandler<StateChangedEventArgs>(synth_StateChanged);  

        // Subscribe to the SpeakProgress event.  
        synth.SpeakProgress += new EventHandler<SpeakProgressEventArgs>(synth_SpeakProgress);  

        // Speak the prompt.  
        synth.Speak("What is your favorite color?");  

        // Pause the SpeechSynthesizer object.  
        synth.Pause();  

        // Resume the SpeechSynthesizer object.  
        synth.Resume();  
      }  

      Console.WriteLine("\nPress any key to exit...");  
      Console.ReadKey();  
    }  

    // Write the state of the SpeechSynthesizer to the console.  
    static void synth_StateChanged(object sender, StateChangedEventArgs e)  
    {  
      Console.WriteLine("State: {0}    Previous State: {1}\n", e.State, e.PreviousState);  
    }  

    // Write the speak progress of the SpeechSynthesizer to the console.  
    static void synth_SpeakProgress(object sender, SpeakProgressEventArgs e)  
    {  
      Console.WriteLine(e.Text);  
    }  
  }  
}  

注解

当 对象引发 事件时SpeechSynthesizer,会创建 的StateChanged实例StateChangedEventArgs。 若要获取新和上 SynthesizerState一个 的值,请在 事件的处理程序中访问 StatePreviousState 属性。

属性

PreviousState

获取 SpeechSynthesizer 事件前的 StateChanged 的状态。

State

获取 SpeechSynthesizer 事件前的 StateChanged 的状态。

方法

Equals(Object)

确定指定对象是否等于当前对象。

(继承自 Object)
GetHashCode()

作为默认哈希函数。

(继承自 Object)
GetType()

获取当前实例的 Type

(继承自 Object)
MemberwiseClone()

创建当前 Object 的浅表副本。

(继承自 Object)
ToString()

返回表示当前对象的字符串。

(继承自 Object)

适用于