AXForum  
Вернуться   AXForum > Microsoft Dynamics CRM > Dynamics CRM: Blogs
DAX
Забыли пароль?
Зарегистрироваться Правила Справка Пользователи Сообщения за день Поиск Все разделы прочитаны

 
 
Опции темы Поиск в этой теме Опции просмотра
Старый 10.07.2010, 02:37   #1  
Blog bot is offline
Blog bot
Участник
 
25,459 / 846 (79) +++++++
Регистрация: 28.10.2006
In this blog you will find the source code (below) to “let NAV speak.” You would have a wide range of possibilities to use this simple Add-in and enlarge this project.

If you want to know more about Client Add-ins you can refer to this MSDN link:

Extending the RoleTailored Client Using Control Add-ins and Microsoft Dynamics NAV 2009 SP1

This simple Client Add-In is based on System.Speech namespace:

Microsoft.Speech.Synthesis Namespace

Step by step creation of the NSpeech Add-In

(Remember the ‘DodgeBall’ rules: Develop, Sign, Place, Register and Develop)
  1. DEVELOP your add-in (in Visual Studio)
  2. Strong SIGN and build
  3. PLACE DLLs into Add-ins folder
  4. REGISTER the add-in in Table 2000000069, Client Add-in
  5. DEVELOP your C/AL code (in Object Designer)
A. Create a New Class Project
  1. Open Visual Studio (in this example I am using Visual Studio 2010)
  2. Create a New Project (CTRL+SHIFT+N) with these parameters
    • Visual C# – Windows
    • Class library
    • .NET Framework 3.5
    • Name: NSpeech
    • Location: C:TMP (or whatever location you like)
    • Solution Name: NSpeech
    • Create directory for solution


B. Create a Strong Name Key (SNK)
  1. Go to Project > Properties (NSpeech Properties&hellip
  2. From the Project Properties form go to the Signing tab
  3. Tick the Sign the assembly option
  4. Create a New SNK (e.g. TestSpeechNav.snk)


C. Add References to the Project
  1. Click on the Class1.cs tab (return to the project)
  2. In the Solution Explorer window select Reference, right Click, Add Reference
  3. Add reference to
    • Microsoft.Dynamics.Framework.UI.Extensibility (Version 1.3.0.0) (By default, the path to the assembly is C:Program FilesMicrosoft Dynamics NAV60RoleTailored Client)
    • System.Drawing (Version 2.0.0.0)
    • System.Speech (Version 3.0.0.0)
    • System.Windows.Forms (Version 2.0.0.0)


D. Develop your NSpeech Project

(You can simply copy and paste this code into your Class project.)

using System;

using System.Collections.Generic;

using System.Text;

using System.ComponentModel;



//Add a reference to the Add-in API (see the solution explorer) and all relevant references

//Use all relevant references

using System.Drawing;

using System.Windows.Forms;

using Microsoft.Dynamics.Framework.UI.Extensibility;

using Microsoft.Dynamics.Framework.UI.Extensibility.WinForms;



//this is to let this add-in speech

//http://msdn.microsoft.com/en-us/library/dd146744(v=office.13).aspx

using System.Speech;

using System.Speech.Synthesis;

namespace NSpeech

{

//Develop the control add-in class.

//Assign a name to the control add-in <a name="OLE_LINK1">(MyCompany.MyProduct.MyAddIn)

[ControlAddInExport("Cronus.DynamicsNAV.NSpeech")]

[Description("Let this Add-in Speak")]



//Select a base class as a starting point.

//Select interfaces to implement features, such as data binding or event handling.

public class Class1 : StringControlAddInBase

{

//Implement control creation

protected override Control CreateControl()

{

//Create a brand new TextBox

TextBox control = new TextBox();



//Define TextBox size

control.MinimumSize = new Size(50, 0);

control.MaximumSize = new Size(500, Int32.MaxValue);



//Add a DoubleClick event for the TextBox

control.DoubleClick += new EventHandler(control_DoubleClick);

return control;

}

//Define a voice synth

private SpeechSynthesizer synth;

private void control_DoubleClick(object sender, EventArgs e)

{

//create a new speech synth and set default audio device

synth = new SpeechSynthesizer();

synth.SetOutputToDefaultAudioDevice();



//Pass TextBox content in a string variable

string data = this.Control.Text;



//... and let NAV speak it!

synth.SpeakAsync(data);

}

}

}

E. Build the NSpeech.dll
  1. Once you have all setup, you are ready to build your Client Add-In. Go to Build > Build NSpeech
F. Place DLL into Add-in folder
  1. Locate/copy/paste NSpeech.dll (should be in your C:TMPNSpeechNSpeechbinDebug folder) to the Add-ins folder of a machine where the RoleTailored client has been installed
(typically the Add-ins folder is here: C:Program FilesMicrosoft Dynamics NAV60RoleTailored ClientAdd-ins)

G. Determine the PKT (Public Key Token) of NSpeech
  1. Launch the Visual Studio Command Prompt
  2. In the VSCP:
[indent]Sn &ndash;T &ldquo;C:TMPNSpeechNSpeechbinDebugNSpeech.dll&rdquo;

In the following example, 250f71f35a467631 is the PKT (Public Key Token) needed to register the Add-in into NAV. (You will have another value.)

[url="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-00-84-65-metablogapi/5126.NSpeechSn_5F00_2.jpg"][*]Run Table 2000000069 Client Add-in[*]Insert a new line with these values:[/list]FieldValueControl Add-in NameCronus.DynamicsNAV.NSpeechPublic Key Token250f71f35a467631 (this is an example)Version1.0.0.0DescriptionLet this Add-in SpeakHow to Use This Add-in

As an example, you can just let NAV speak the content of the field &ldquo;Name&rdquo; in Customer Card page (Page 21).
  1. Open Classic Client
  2. Go to Object Designer (SHIFT+F12)
  3. Select Page object (ALT+G)
  4. Design Page 21 Customer Card
  5. Go to Name Field and Edit properties (SHIFT+F4)
  6. Fill the ControlAddIn property with this value Cronus.DynamicsNAV.NSpeech;PublicKeyToken=250f71f35a467631 (change the PublickKeyToken value to the one that you have determined at step G.)
  7. Save and compile the page (CTRL+S)
Now&hellip;you are ready to let NAV speak the Customer Name from the customer card by simply double clicking on on the Name!

This simple Client Add-in project may be used in, e.g.
  • Speak an alert if the availability of an Item is lower than expected in a document page (e.g. sales quote)
  • Speak an alert if a Customer exceeds assigned Credit Limit
  • Speak internal comments for an item, a vendor, a customer, wherever this is needed
  • &hellip; and many more
This simple Client Add-in project may be enlarged, e.g.
  • It could be possible to set the volume of the voice
  • It could be possible to set the rate of the voice
  • It could be possible to select another voice instead of &ldquo;Microsoft Anne&rdquo; default in order to speak words with proper accent language
  • It could be possible to save a .wav file instead of speaking it or even perform both activities
  • &hellip; and many more
These postings are provided "AS IS" with no warranties and confer no rights. You assume all risk for your use.

Best Regards,

Duilio Tacconi (dtacconi)

Microsoft Dynamics Italy

Microsoft Customer Service and Support (CSS) EMEA



Источник: http://feedproxy.google.com/~r/Micro...nt-add-in.aspx
__________________
Расскажите о новых и интересных блогах по Microsoft Dynamics, напишите личное сообщение администратору.
 

Опции темы Поиск в этой теме
Поиск в этой теме:

Расширенный поиск
Опции просмотра

Ваши права в разделе
Вы не можете создавать новые темы
Вы не можете отвечать в темах
Вы не можете прикреплять вложения
Вы не можете редактировать свои сообщения

BB коды Вкл.
Смайлы Вкл.
[IMG] код Вкл.
HTML код Выкл.
Быстрый переход

Рейтинг@Mail.ru
Часовой пояс GMT +3, время: 17:13.
Powered by vBulletin® v3.8.5. Перевод: zCarot
Контактная информация, Реклама.