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)
- DEVELOP your add-in (in Visual Studio)
- Strong SIGN and build
- PLACE DLLs into Add-ins folder
- REGISTER the add-in in Table 2000000069, Client Add-in
- DEVELOP your C/AL code (in Object Designer)
A. Create a New Class Project
- Open Visual Studio (in this example I am using Visual Studio 2010)
- 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)
- Go to Project > Properties (NSpeech Properties&hellip
- From the Project Properties form go to the Signing tab
- Tick the Sign the assembly option
- Create a New SNK (e.g. TestSpeechNav.snk)
C. Add References to the Project
- Click on the Class1.cs tab (return to the project)
- In the Solution Explorer window select Reference, right Click, Add Reference
- 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
- 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
- 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
- Launch the Visual Studio Command Prompt
- In the VSCP:
[indent]Sn –T “C:TMPNSpeechNSpeechbinDebugNSpeech.dll”
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 Speak
How to Use This Add-in
As an example, you can just let NAV speak the content of the field “Name” in Customer Card page (Page 21).
- Open Classic Client
- Go to Object Designer (SHIFT+F12)
- Select Page object (ALT+G)
- Design Page 21 Customer Card
- Go to Name Field and Edit properties (SHIFT+F4)
- 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.)
- Save and compile the page (CTRL+S)
Now…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
- … 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 “Microsoft Anne” 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
- … 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