c# advanced l01-intro and warmup

13
Mohammad Shaker mohammadshaker.com @ZGTRShaker 2011, 2012, 2013, 2014 C# Advanced L01 Intro

Upload: mohammad-shaker

Post on 13-Jan-2015

274 views

Category:

Software


2 download

DESCRIPTION

C# Advanced L01-Intro and Warmup

TRANSCRIPT

Page 1: C# Advanced L01-Intro and Warmup

Mohammad Shaker

mohammadshaker.com

@ZGTRShaker

2011, 2012, 2013, 2014

C# AdvancedL01 – Intro

Page 2: C# Advanced L01-Intro and Warmup

Topics in This Course

1. Utilities: Speech, Windows Voice Recognition, Regular Expressions, Internationalization.

2. Operator Overloading, Indexers and User-Defined Conversion

3. Parallel Programming and Threading

4. Attributes and Reflection

5. WPF: Windows Presentation Foundation

6. Database: XML, LINQ to XML, SQL Server, LINQ to SQL

7. Design Patterns: Element of Reusable Objects

8. WF: Windows Workflow Foundation

9. Networking and WCF: Windows Communication Foundation

10. Web Development: HTML5, ASP.NET, ASP.NET MVC

11. Mobile Development: Windows Phone, Stores and Games

Page 3: C# Advanced L01-Intro and Warmup

Speech with .NET

Page 4: C# Advanced L01-Intro and Warmup

Speech

• Add: using System.Speech.Synthesis;

• Now, just write the following and listen for “Hello”

• You can output speech asynchronously to allow processing to continue whilst the

audio is played using synth.SpeakAsync

private void SayHello(){

var synth = new SpeechSynthesizer();synth.Speak("Hello");Console.WriteLine("Finished");Console.ReadLine();

}

private void SayHello(){

var synth = new SpeechSynthesizer();synth.SpeakAsync("Hello");Console.WriteLine("Finished");Console.ReadLine();

}

Page 5: C# Advanced L01-Intro and Warmup

Speech Recognition

Page 6: C# Advanced L01-Intro and Warmup

Speech RecognitionDead easy with .NET!

Page 7: C# Advanced L01-Intro and Warmup

Speech Recognition

• Adding References

• Using: System.Speech.Recognition Namespace

• Recognition: as easy as event handling

using System.Speech.Recognition;

public void SpeechRecognizer_SpeechRecognized(object sender, SpeechRecognizedEventArgs e){

textBox1.Text = e.Result.Text;}

Page 8: C# Advanced L01-Intro and Warmup

Speech Recognitionclass SpeechEngine {

private SpeechRecognizer _speechRecognizer;public SpeechEngine(){

this._speechRecognizer = new SpeechRecognizer();this.BuildGrammars();this._speechRecognizer.SpeechRecognized += SpeechRecognizer_SpeechRecognized;

}

private void BuildGrammars(){

Choices choices = new Choices();List<string> listOfStudentNames = new List<string>() {“Mohammad”, “Hamza”, “Mariam”, “Amal”};foreach (string studentName in listOfStudentNames){

choices.Add(studentName);}GrammarBuilder grammarBuilder = new GrammarBuilder(choices);Grammar grammmars = new Grammar(grammarBuilder);_speechRecognizer.LoadGrammar(grammmars);

}

public void SpeechRecognizer_SpeechRecognized(object sender, SpeechRecognizedEventArgs e){ textBox1.Text = e.Result.Text; }

}

Page 9: C# Advanced L01-Intro and Warmup

Regular Expressions

Page 10: C# Advanced L01-Intro and Warmup

Regexusing System;using System.Text.RegularExpressions;

class MainClass{

public static void Main(){

string s = "A, B,cCCC, D";Regex regex = new Regex(@" |, ");foreach (string sub in regex.Split(s)){

Console.WriteLine("Word: {0}", sub);}

}}

Word: A

Word: B,cCCC

Word: D

Page 11: C# Advanced L01-Intro and Warmup

Internationalization

Page 12: C# Advanced L01-Intro and Warmup

Cultures

using System;using System.Globalization;using System.Threading;

class MainClass{public static void Main(){Console.WriteLine(Thread.CurrentThread.CurrentCulture.Name);

}}

en-CA

Page 13: C# Advanced L01-Intro and Warmup

http://www.mohammadshaker.com

[email protected]

https://twitter.com/ZGTRShaker @ZGTRShaker

https://de.linkedin.com/pub/mohammad-shaker/30/122/128/

http://www.slideshare.net/ZGTRZGTR

https://www.goodreads.com/user/show/11193121-mohammad-shaker

https://plus.google.com/u/0/+MohammadShaker/

https://www.youtube.com/channel/UCvJUfadMoEaZNWdagdMyCRA

http://mohammadshakergtr.wordpress.com/