vs C# wpf 如何引入(匯入)庫、dll

來源:互聯網
上載者:User

標籤:c#wpf   vs c# wpf 如何引入匯入庫d   

vs  C# wpf  如何引入(匯入)庫、dll說明:一般需要在兩個地方引入,

1.程式集火項目中引入;

2.在cs或xaml檔案中引入

1.程式集或項目中引入

例如:引入DotNetSpeech.dll庫

 

2.在cs或xaml檔案中引入

添加:

using DotNetSpeech;//cs檔案中引入庫

 

using System;using System.Collections.Generic;using System.Linq;using System.Text;using System.Threading.Tasks;using System.Windows;using System.Windows.Controls;using System.Windows.Data;using System.Windows.Documents;using System.Windows.Input;using System.Windows.Media;using System.Windows.Media.Imaging;using System.Windows.Navigation;using System.Windows.Shapes;using DotNetSpeech;//cs檔案中引入庫namespace WpfSpeechDemo{    /// <summary>    /// MainWindow.xaml 的互動邏輯    /// </summary>    public partial class MainWindow : Window    {        SpVoice speech = new SpVoice();        int speechRate = 0;        int volume = 70;        public MainWindow()        {            InitializeComponent();            init();        }        private void init()        {            //初始化語音引擎列表            foreach (ISpeechObjectToken Token in speech.GetVoices(string.Empty, string.Empty))            {                cmbVoices.Items.Add(Token.GetDescription(49));            }            //取得音訊輸出列表            foreach (ISpeechObjectToken AudioOut in speech.GetAudioOutputs(string.Empty, string.Empty))            {                cmbAudioOut.Items.Add(AudioOut.GetDescription(49));            }            cmbVoices.SelectedIndex = 0;            cmbAudioOut.SelectedIndex = 0;            tbarRate.Value = speechRate;            trbVolume.Value = volume;        }        private void tbarRate_Scroll(object sender, EventArgs e)        {            speech.Rate = (int)tbarRate.Value;        }        private void trbVolume_Scroll(object sender, EventArgs e)        {            speech.Volume = (int)trbVolume.Value;        }        private void cmbVoices_SelectionChanged(object sender, SelectionChangedEventArgs e)        {            speech.Voice = speech.GetVoices(string.Empty, string.Empty).Item(cmbVoices.SelectedIndex);        }        private void cmbAudioOut_SelectionChanged(object sender, SelectionChangedEventArgs e)        {            speech.AudioOutput = speech.GetAudioOutputs(string.Empty, string.Empty).Item(cmbAudioOut.SelectedIndex);        }        private void bt_speek_Click(object sender, EventArgs e)        {            //終止先前朗讀,如果有            speech.Speak(" ", SpeechVoiceSpeakFlags.SVSFlagsAsync);            speech.Speak(tbspeech.Text, SpeechVoiceSpeakFlags.SVSFlagsAsync);        }        private void bt_stop_Click(object sender, EventArgs e)        {            speech.Speak("", SpeechVoiceSpeakFlags.SVSFlagsAsync);        }        private void tbarRate_ValueChanged(object sender, RoutedPropertyChangedEventArgs<double> e)        {            speech.Rate = (int)e.NewValue;        }        private void trbVolume_ValueChanged(object sender, RoutedPropertyChangedEventArgs<double> e)        {            speech.Volume = (int)e.NewValue;        }    }}

 

vs C# wpf 如何引入(匯入)庫、dll

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.