C # Small Memo

Source: Internet
Author: User
Tags add time

First, brief

Memo, I believe that everyone in life have been used, such as notes, cell phone memos, and so on, these are the records of their own ideas, and regularly want to do things, as if irrelevant, say my memo, my Memo function is to add and remove changes to the operation, plus to remind, voice playback content, very simple, but practical , well, want to see the design point.

Second, the design

1. Database design

The database uses SQLite.

Database tables: Sys_kind, Memorandum

Sys_kind is a universal dictionary table, which is useful for beginners, such as:

Parsing: ID Needless to say, the self-increasing identity, K_name: dictionary name, K_parent: The parent type identifier, that is, if the k_parent is 0, then it is a type, then the sub-dictionary as the parent class, this field type the parent class ID value can be, K_ Sort sorting is a single type of sorting, or you can also use all the data as a sort, k_addtime add time, K_desc dictionary description, so that later people can see what this is used to do, K_state dictionary state, this, can be applied flexibly, is used to show a dictionary or other multi-state can, K_code dictionary code value, this is very important, this is used as a dictionary value, many people may ask, why not self-increment ID, because if the type of a lot of cases, the ID value will become larger, you define the type value itself is not a few, And its value is so big, why, next to this table is the memo table, I do not explain, I slowly realized.

2. Program Design ()

This, we all know Kazakhstan, is ordinary to delete and change, no big technical content

Third, the core technology

1. Automatic Query Memo

This piece, I believe we all know, can use the timer this control, indeed can use a timer, of course, here, I am not using a Timer control, But System.Threading.Timer this class, of course, need to understand the relevant usage, we can search Baidu, can also go here https://msdn.microsoft.com/zh-cn/library/ System.Threading.Timer (v=vs.110). aspx look, of course I also posted the code, let everyone refer to.

//declaring a delegatePrivate Delegate voidSettimerlogiccallback ();//declaring a class for a timerPrivateSystem.Threading.Timer Threadtimer;//The method of executing the delegate, Showmemoranduminfo is the method of querying the databasePrivate voidThreadmethod (Objectobj) {Settimerlogiccallback Timerlogic=NewSettimerlogiccallback (Showmemoranduminfo);  This.        Invoke (timerlogic); } /// <summary>        ///Timer settings, this method or this code can be written in the form when the load/// </summary>        Private voidTimerset () {Threadtimer=NewSystem.Threading.Timer (NewSystem.Threading.TimerCallback (Threadmethod),NULL,0, +); }

2. Voice Broadcast content

I've used two techniques in this piece, One is Microsoft's own System.Speech.Synthesis.SpeechSynthesizer speech recognition class, the second is the voice recognition provided by Baidu interface, why use two, if we do not have a network of users, then you can use Microsoft's own voice recognition function, if the user machine is not installed Micro Soft speech recognition, then you can use Baidu's speech recognition interface, if no network, machine also does not install Microsoft's speech recognition, then you can package the program automatically installed Microsoft's own speech recognition of the installation package or other plug-ins or components, of course, this installation package is certainly much larger than your program, estimated now in addition to XP, Win7 not a few not automatically installed speech recognition, OK, here is the code:

        /// <summary>        ///Microsoft speech Recognition/// </summary>        /// <param name= "Content" >Prompt Content</param>         Public Static voidSpeakasync (stringcontent) {            Try            {                if(Synth! =NULL) Synth.                Dispose (); Synth=NewSystem.Speech.Synthesis.SpeechSynthesizer (); Synth.                Speakasynccancelall (); Synth.            Speakasync (content); }            Catch(Exception ex) {Throwex; }        }        /// <summary>        ///Baidu Speech Synthesis (document website:http://yuyin.baidu.com/docs/tts/197)        /// </summary>        Private voidBaidutts (stringAudiotext) {_ttsclient=NewBaidu.Aip.Speech.Tts ("Api_key","Secret_key"); //Optional Parameters            varoption =Newdictionary<string,Object>()                {                    {"SPD",5},//Speed{"Vol.",7},//Volume{"per",4}//pronunciation person, 4: Emotional degrees Ya ya Boys                }; varresult =_ttsclient.synthesis (audiotext, option); if(result.) ErrorCode = =0)            {                stringFileName = Application.startuppath +"\\"+ Guid.NewGuid (). ToString () +". mp3"; System.IO.File.WriteAllBytes (FileName, result.                Data); Axwindowsmediaplayer1.url=FileName;                AxWindowsMediaPlayer1.Ctlcontrols.play ();            System.IO.File.Delete (FileName); }            Else{utils.logmessage ("Baidu speech synthesis Anomaly", result.            ERRORMSG); }        }

Summary: This is a simple memo procedure, welcome beginners to learn, the great God will casually look on the line, welcome everyone to praise forward

C # Small Memo

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

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.