跳到主要內容

C# cheat sheet

how-do-i-generate-a-random-int-number

Random rnd = new Random();
int month = rnd.Next(1, 13);  // month: >= 1 and < 13

chart library




WindowsMediaPlayer pause

AxWindowsMediaPlayer1.Ctlcontrols.pause()

implement-keyboard-shortcuts-in-a-windows-forms-application

protected override bool ProcessCmdKey(ref Message msg, Keys keyData) {
  if (keyData == (Keys.Control | Keys.F)) {
    MessageBox.Show("What the Ctrl+F?");
    return true;
  }
  return base.ProcessCmdKey(ref msg, keyData);
}

play-video-files

// [ C# ]
WMPLib.WindowsMediaPlayer Player;

private void PlayFile(String url)
{
    Player = new WMPLib.WindowsMediaPlayer();
    Player.PlayStateChange +=
        new WMPLib._WMPOCXEvents_PlayStateChangeEventHandler(Player_PlayStateChange);
    Player.MediaError +=
        new WMPLib._WMPOCXEvents_MediaErrorEventHandler(Player_MediaError);
    Player.URL = url;
    Player.controls.play();
}

private void Form1_Load(object sender, System.EventArgs e)
{
    // TODO  Insert a valid path in the line below.
    PlayFile(@"c:\myaudio.wma");
}

private void Player_PlayStateChange(int NewState)
{
    if ((WMPLib.WMPPlayState)NewState == WMPLib.WMPPlayState.wmppsStopped)
    {
        this.Close();
    }
}

private void Player_MediaError(object pMediaObject)
{
    MessageBox.Show("Cannot play media file.");
    this.Close();
}
//http://msdn.microsoft.com/en-us/library/dd564582(VS.85).aspx
//https://www.codeproject.com/Articles/844451/Audio-and-Video-Player-Csharp-Winform

留言

這個網誌中的熱門文章

如何學習英語聽的技能

有三個理由需要考慮: 1. 甚麼令你難以理解? 很多音相似 舉例: boat -bought mad -mud hurt -heart men-main than-then bit-bet live-leave 有很多音會黏再一起 how is it going? -> how 'zit going? 語言模式1 合同動詞和否定 i'm he's they'll we've won't can't  O.K. I'll do it. (不強調I'll:無特殊情緒) I will do it. nothing can stop me. (強調will:顯示決心) 在正式的文件儘量用完整的句子,不要用縮寫 語言模式2 弱形式 例子 I can ski -> I kn ski 母音消失 here's my book->here's m[ə]   book it's for you -> it's f[ə] you 語言模式3 子音連結 he works as an engineer-> he work sazanen gineer she is interested in it->she (y)isinterestedinit . they went to an amazing place->they went to(w)anamazing place 聽寫,比對影片上的字幕是否一樣 2.改善你的發音 發音的陷阱1: 一樣的拼音不等於一樣的發音 ea -> /i:/ (jean)  -great  -hear  -learn  -instead 發音的陷阱2: 字的重音 哪個音節是重音? DEV elopment or de VEL opment or deve LOP ment or develop MENT 第二個才正確 下面的字發音可能相同 propose & purpose pro POSE & PUR pose 3.用耳朵聽,而不是用眼...