hehe jo kan jeg godt :)
Her er koden så :)
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.IO;
namespace John
{
public partial class Form1 : Form
{
//WMPLib.WindowsMediaPlayer Player;
private NotifyIcon m_notifyicon;
private ContextMenu m_menu;
protected struct Station
{
public string Name { get; set; }
public string Link { get; set; }
}
public Form1()
{
InitializeComponent();
List<Station> stations = new List<Station>();
Text = "WebRadio - MiniMode";
m_menu = new ContextMenu();
m_menu.MenuItems.Add(0,
new MenuItem("Show", new System.EventHandler(Show_Click)));
m_menu.MenuItems.Add(1,
new MenuItem("Hide", new System.EventHandler(Hide_Click)));
m_menu.MenuItems.Add(2,
new MenuItem("Play", new System.EventHandler(Play_Click)));
m_menu.MenuItems.Add(3,
new MenuItem("Stop", new System.EventHandler(Stop_Click)));
m_menu.MenuItems.Add(4,
new MenuItem("Exit", new System.EventHandler(Exit_Click)));
m_notifyicon = new NotifyIcon();
m_notifyicon.Text = "Right click for menu";
m_notifyicon.Visible = true;
m_notifyicon.Icon = new Icon(GetType(), "Icon1.ico");
m_notifyicon.ContextMenu = m_menu;
}
protected void LoadStations()
{
List<Station> stations = new List<Station>();
string path = @"c:\Stations.txt";
using (StreamReader sr = File.OpenText(path))
{
string s = "";
while ((s = sr.ReadLine()) != null)
{
string[] arr = s.Split(',');
Station station = new Station();
station.Name = arr[0];
station.Link = arr[1];
stations.Add(station);
}
}
}
protected void SaveStations()
{
List<Station> stations = new List<Station>();
string path = @"c:\Stations.txt";
using (StreamWriter sw = new StreamWriter(path, true))
{
sw.WriteLine(textBox1.Text + "," + textbox2.Text);
}
}
protected void Form1_Load(object sender, EventArgs e)
{
string path = @"c:\Stations.txt";
if (!File.Exists(path))
{
// Create a file to write to.
using (StreamWriter sw = File.CreateText(path))
{
sw.WriteLine("P1,
http://www.dr.dk/netradio/metafiler/asx/DR_P1_32.asx");
sw.WriteLine("P2,
http://www.dr.dk/netradio/metafiler/asx/DR_P2_32.asx");
sw.WriteLine("P3,
http://www.dr.dk/netradio/metafiler/asx/DR_P3_32.asx");
sw.WriteLine("DR POP,
http://www.dr.dk/netradio/metafiler/asx/DR_Pop_DK_32.asx");
sw.WriteLine("DR Hit,
http://www.dr.dk/netradio/metafiler/asx/DR_Hit_128.asx");
sw.WriteLine("DR Evergreen,
http://www.dr.dk/netradio/metafiler/asx/DR_Evergreen_32.asx");
sw.WriteLine("DR Folk,
http://www.dr.dk/netradio/metafiler/asx/DR_Folk_32.asx");
sw.WriteLine("DR Rock,
http://www.dr.dk/netradio/metafiler/asx/DR_Rock_32.asx");
sw.WriteLine("DR Soft,
http://www.dr.dk/netradio/metafiler/asx/DR_soft_32.asx");
sw.WriteLine("DR Jazz,
http://www.dr.dk/netradio/metafiler/asx/DR_Jazz_32.asx");
sw.WriteLine("DR Moden Rock,
http://www.dr.dk/netradio/metafiler/asx/DR_Modern_Rock_32.asx");
sw.WriteLine("DR RogB,
http://www.dr.dk/netradio/metafiler/asx/DR_RogB_32.asx");
sw.WriteLine("DR Boogie,
http://www.dr.dk/netradio/metafiler/asx/DR_Boogie_32.asx");
sw.WriteLine("DR HipHop,
http://www.dr.dk/netradio/metafiler/asx/DR_HipHop_32.asx");
sw.WriteLine("DR Spillemand,
http://www.dr.dk/netradio/metafiler/asx/DR_Spillemand_32.asx");
sw.WriteLine("DR Dansk Top,
http://www.dr.dk/netradio/metafiler/asx/DR_Dansktop_32.asx");
sw.WriteLine("DR Allegro,
http://www.dr.dk/netradio/metafiler/asx/DR_Allegro_32.asx");
sw.WriteLine("DR Contry,
http://www.dr.dk/netradio/metafiler/asx/DR_Country_32.asx");
sw.WriteLine("DR Klassisk,
http://www.dr.dk/netradio/metafiler/asx/DR_Klassisk_32.asx");
sw.WriteLine("DR World,
http://www.dr.dk/netradio/metafiler/asx/DR_World_32.asx");
sw.WriteLine("DR Oline,
http://www.dr.dk/netradio/metafiler/asx/DR_Oline_32.asx");
sw.WriteLine("DR Electronica,
http://www.dr.dk/netradio/metafiler/asx/DR_Electronica_32.asx");
sw.WriteLine("DR Barometer,
http://www.dr.dk/netradio/metafiler/asx/DR_Barometer_32.asx");
sw.WriteLine("P5000,
http://www.dr.dk/netradio/metafiler/asx/DR_P5000_32.asx");
sw.WriteLine("NOVA FM,
mms://stream.ventelo.dk/FM5");
sw.WriteLine("RadioSoft,
http://radiosoft.dk/netradio/soft.asx");
sw.WriteLine("Radio100 FM,
http://radio100fm.dk/netradio/asx");
sw.WriteLine("Radio sydhavsøerne,
mms://media.xstream.dk/Radio_Sydhavsoerene");
sw.WriteLine("GULDfm,
http://mediamaker.dk/radiostationer/asxGenerator.php?ID[]=56");
sw.WriteLine("Radio2,
http://dix.media.webpartner.dk/radio2-96?MSWMExt=.asf");
sw.WriteLine("NERadio Nonstop,
http://www.neradio.fm/listen.asx");
sw.WriteLine("Oldies,
http://www.sky.fm/wma/oldies.asx");
sw.WriteLine("NRJ,
mms://85.233.229.254:8000/NRJ");
sw.WriteLine("COOLfm,
http://www.coolfm.dk/Cool%20FM%20128%20KB.asx");
sw.WriteLine("MMRADIO,
mms://media3.xstream.dk/mmradio");
sw.WriteLine("Radio Jazz,
http://83.133.64.106:8000/");
sw.WriteLine("DI HOUSE,
http://www.di.fm/wma/house.asx");
sw.WriteLine("DI TRANCE,
http://repc-1.adinjector.net/amtmsvc/gateway.asp?stationid=109&adformat=3");
sw.WriteLine("Radio 3,
mms://media.xstream.dk/Radio_3");
sw.WriteLine("Radio Alfa,
mms://media.xstream.dk/Radio_Alfa");
sw.WriteLine("Radio Skive,
mms://media.xstream.dk/Radio_Skive");
sw.WriteLine("SPECIFIC RADIO,
http://specific.dk/listen.wvx");
sw.WriteLine("Radio Mojn,
mms://media.xstream.dk/Radio_Mojn");
sw.WriteLine("The Voise,
http://dix.media.webpartner.dk/voice128");
sw.WriteLine("SKY.fm - Roots Reggae,
http://www.sky.fm/wma/rootsreggae.asx");
sw.WriteLine("SKY.fm - Classical & Flamenco Guitar,
http://repc-1.adinjector.net/amtmsvc/gateway.asp?stationid=1334&adformat=3");
sw.WriteLine("SKY.fm - Da tempo lounge,
http://www.sky.fm/wma/datempolounge.asx");
sw.WriteLine("Radio ABC,
mms://media.xstream.dk/radio_abc_low");
}
}
List<Station> stations = new List<Station>();
// Open the file to read from.
using (StreamReader sr = File.OpenText(path))
{
string s = "";
while ((s = sr.ReadLine()) != null)
{
string[] arr = s.Split(',');
Station station = new Station();
station.Name = arr[0];
station.Link = arr[1];
stations.Add(station);
}
}
dropdown.DisplayMember = "Name";
dropdown.ValueMember = "Link";
dropdown.DataSource = stations;
}
protected void Exit_Click(Object sender, System.EventArgs e)
{
Close();
}
protected void Hide_Click(Object sender, System.EventArgs e)
{
Hide();
}
protected void Show_Click(Object sender, System.EventArgs e)
{
Show();
}
protected void Stop_Click(Object sender, System.EventArgs e)
{
axWindowsMediaPlayer1.Ctlcontrols.stop();
}
protected void Play_Click(Object sender, System.EventArgs e)
{
axWindowsMediaPlayer1.Ctlcontrols.play();
}
protected void axWindowsMediaPlayer1_Enter(object sender, EventArgs e)
{
axWindowsMediaPlayer1.URL = dropdown.SelectedValue.ToString();
}
protected override void Dispose(bool disposing)
{
if (disposing)
{
this.m_notifyicon.Dispose();
}
base.Dispose(disposing);
}
protected void button1_Click(object sender, EventArgs e)
{
List<Station> stations = new List<Station>();
string path = @"c:\Stations.txt";
//Tjekker om der er tekst i linkboxen
if (textBox1.Text == "")
{
MessageBox.Show("Skriv en station");
}
else
{
if (textBox1.Text.Contains(",") || textbox2.Text.Contains(","))
{
MessageBox.Show("Feltet må ikke indholde komma!");
}
else
{
//Indsætter linket i textfilen
SaveStations();
}
//Henter linksene fra textfilen til dropdown
LoadStations();
textBox1.Text = "";
textbox2.Text = "";
}
}
private void button2_about_Click(object sender, EventArgs e)
{
AboutBox1 about = new AboutBox1();
about.Show();
}
private void button2_Click(object sender, EventArgs e)
{
Form_help help = new Form_help();
help.Show();
}
}
}