public MainForm() { InitializeComponent(); SettingsManager.Load(); this.Icon = Properties.Resources.logo1; wplayer = new WindowsMediaPlayer(); wplayerSongCalls = new WindowsMediaPlayer(); wplayer.settings.volume = SettingsManager.VolumeMain; wplayerSongCalls.settings.volume = SettingsManager.VolumeSpeech; trackBar1.Value = SettingsManager.VolumeMain; trackBar2.Value = SettingsManager.VolumeSpeech; notifyIcon1.Icon = this.Icon; notifyIcon1.Visible = true; notifyIcon1.Text = "WeAreOne Infos"; notifyIcon1.DoubleClick += notifyIcon1_DoubleClick; notifyIcon1.ContextMenu = new ContextMenu(); notifyIcon1.ContextMenu.MenuItems.Add(new MenuItem("Erstellt von Johnny") { Enabled = false }); notifyIcon1.ContextMenu.MenuItems.Add(new MenuItem("-")); notifyIcon1.ContextMenu.MenuItems.Add(new MenuItem("Beenden", (sender, e) => this.Close()) { DefaultItem = true }); timer = new Timer(); timer.Interval = 3000; timer.SynchronizingObject = this; timer.Elapsed += timer_callback; timer.AutoReset = true; timer.Start(); icontimer = new Timer(); icontimer.Interval = 500; icontimer.SynchronizingObject = this; icontimer.Elapsed += icontimer_Elapsed; icontimer.AutoReset = true; icontimer.Start(); wao = new WeAreOne(); wao.OnResponseReceived += wao_OnResponseReceived; wao.OnImageReceived += wao_OnImageReceived; linkLabel1.Click += (sender, e) => Process.Start(current.release); loadingscreen = new LoadingForm(); loadingscreen.ShowDialog(); }
void wao_OnResponseReceived(ResponseReceiveEventArgs e) { if (!timer.Enabled) timer.Start(); if (loadingscreen != null) { loadingscreen.Invoke(new Action(() => loadingscreen.Close())); loadingscreen.Invoke(new Action(() => loadingscreen.Dispose())); loadingscreen = null; comboBox1.SelectedItem = SettingsManager.Station; } if (comboBox1.InvokeRequired) { comboBox1.Invoke(new Action(() => wao_OnResponseReceived(e))); return; } foreach(Radio rad in e.response.radio) { if(rad.name == (String)comboBox1.SelectedItem) { if(current == null) { current = rad; wplayerSongCalls.URL = "http://translate.google.com/translate_tts?tl=en&q=" + WebUtility.UrlEncode(Translate(rad.song + " by " + rad.artist)); wplayerSongCalls.controls.play(); UpdateGUI(rad); return; } if (current.song != rad.song && current.name == rad.name) Trigger(TriggerTypes.SONG, rad); if (current.show != rad.show && current.name == rad.name) Trigger(TriggerTypes.SHOW, rad); if (current.picture != rad.picture) Trigger(TriggerTypes.PICTURE, rad); UpdateGUI(rad); current = rad; } } }