private void btnAddSnd_Click(object sender, System.EventArgs e) { _Sound oS=new _Sound((txtSndName.Text==""?"Sound "+(lstSounds.Items.Count+1):txtSndName.Text),txtSndFile.Text); if(oS.sName==NONE) { MessageBox.Show("You may not use the name \""+NONE+"\"","Error (Tea Timer)",MessageBoxButtons.OK,MessageBoxIcon.Error); return; } if(hasDupName(oS.sName,lstSounds)) { MessageBox.Show("Please choose a unique name.","Error (Tea Timer)",MessageBoxButtons.OK,MessageBoxIcon.Error); return; } //if this is a midi file, warn the user that it may be slow if(oS.sFile.ToLower().EndsWith(".mid") || oS.sFile.ToLower().EndsWith(".midi")) MessageBox.Show("Warning: Midi files are a little slow to begin playing on some systems.","Midi warning (Tea Timer)",MessageBoxButtons.OK,MessageBoxIcon.Warning); lstSounds.Items.Add(oS); resetForm(); }
private void readConfig() { //visual alert cbxVisualAlert.Checked=Convert.ToBoolean(_oConfig.getValue("general","alerts","visual","true")); lstIcons.Items.Clear(); string[] sIconFiles=_oConfig.getValues("general","alerts","iconfiles",new string[] {"teapot.gif","beaker.gif","clock.gif","coffee.gif"}); string[] sIconNames=_oConfig.getValues("general","alerts","iconnames",new string[] {"Teapot","Beaker","Clock","Coffee Cup"}); for(int i=0;i<sIconFiles.Length;i++) { _Icon oI=new _Icon(sIconNames[i],sIconFiles[i]); lstIcons.Items.Add(oI); } _iAlertX=Convert.ToInt32(_oConfig.getValue("general","alerts","visualX","-1")); _iAlertY=Convert.ToInt32(_oConfig.getValue("general","alerts","visualY","-1")); //sound alert cbxPlaySnd.Checked=Convert.ToBoolean(_oConfig.getValue("general","alerts","audible","true")); lstSounds.Items.Clear(); string[] sSndFiles=_oConfig.getValues("general","alerts","soundfiles",new string[] {"teapot_long.wav","teapot_short.wav"}); string[] sSndNames=_oConfig.getValues("general","alerts","soundnames",new string[] {"Teapot Long","Teapot Short"}); for(int i=0;i<sSndFiles.Length;i++) { _Sound oS=new _Sound(sSndNames[i],sSndFiles[i]); lstSounds.Items.Add(oS); } //process alert cbxVisualProcessAlert.Checked=Convert.ToBoolean(_oConfig.getValue("general","alerts","processvisual","true")); cbxAudibleProcessAlert.Checked=Convert.ToBoolean(_oConfig.getValue("general","alerts","processaudible","true")); cbxPlaySnd.Checked=Convert.ToBoolean(_oConfig.getValue("general","alerts","audible","true")); lstProcesses.Items.Clear(); string[] sProcessFiles=_oConfig.getValues("general","alerts","processfiles",new string[] {}); string[] sProcessNames=_oConfig.getValues("general","alerts","processnames",new string[] {}); for(int i=0;i<sProcessFiles.Length;i++) { _Process oP=new _Process(sProcessNames[i],sProcessFiles[i]); lstProcesses.Items.Add(oP); } //Time format cbx24hour.Checked=Convert.ToBoolean(_oConfig.getValue("general","time format","hour24","false")); _b24hour=cbx24hour.Checked; //stopwatch _iStopwatchOpacity=Convert.ToInt32(_oConfig.getValue("general","stopwatch","opacity","80")); cbxShowStopwatch.Checked=Convert.ToBoolean(_oConfig.getValue("general","stopwatch","show","false")); //presets int iPresetsIdx=iconMenu.MenuItems.IndexOf(menPresets); while(_iIconMenuPresets>0) { iconMenu.MenuItems.RemoveAt(iPresetsIdx+(_iIconMenuPresets--)); } for(int i=0; i<6; i++) { Button btnPre=null; string sDefName="", sDefSnd="", sDefIcon="", sDefProcess=""; int iDefDay=0, iDefHour=0, iDefMin=0, iDefSec=0; bool bDefSnd=true, bDefIcon=true, bRecurring=false; switch(i+1) { case 1: btnPre=btnPre1; sDefName="Boil Water"; iDefMin=5; iDefSec=30; sDefIcon="clock.gif"; bDefIcon=false; break; case 2: btnPre=btnPre2; sDefName="Earl Grey"; iDefMin=4; break; case 3: btnPre=btnPre3; sDefName="Green Tea"; iDefMin=2; break; case 4: btnPre=btnPre4; sDefName="Brew Coffee"; iDefMin=8; sDefIcon="coffee.gif"; bDefIcon=false; break; case 5: btnPre=btnPre5; break; case 6: btnPre=btnPre6; break; } btnPre.Text=_oPresets[i].sName=_oConfig.getValue("presets",i.ToString(),"name",sDefName); btnPre.Enabled=(_oPresets[i].sName==""?false:true); MenuItem oMI=new MenuItem("#"+(i+1)+" "+(_oPresets[i].sName==""?"not set":_oPresets[i].sName),new EventHandler(btnPre_Click)); oMI.Enabled=(_oPresets[i].sName==""?false:true); iconMenu.MenuItems.Add(iPresetsIdx+(++_iIconMenuPresets),oMI); _oPresets[i].iDay=Convert.ToInt32(_oConfig.getValue("presets",i.ToString(),"days",iDefDay.ToString())); _oPresets[i].iHour=Convert.ToInt32(_oConfig.getValue("presets",i.ToString(),"hours",iDefHour.ToString())); _oPresets[i].iMin=Convert.ToInt32(_oConfig.getValue("presets",i.ToString(),"minutes",iDefMin.ToString())); _oPresets[i].iSec=Convert.ToInt32(_oConfig.getValue("presets",i.ToString(),"seconds",iDefSec.ToString())); _oPresets[i].sSnd=_oConfig.getValue("presets",i.ToString(),"sound",sDefSnd); _oPresets[i].bDefSnd=Convert.ToBoolean(_oConfig.getValue("presets",i.ToString(),"defsound",bDefSnd.ToString())); _oPresets[i].sIcon=_oConfig.getValue("presets",i.ToString(),"icon",sDefIcon); _oPresets[i].bDefIcon=Convert.ToBoolean(_oConfig.getValue("presets",i.ToString(),"deficon",bDefIcon.ToString())); _oPresets[i].sProcess=_oConfig.getValue("presets",i.ToString(),"process",sDefProcess); _oPresets[i].bRecurring=Convert.ToBoolean(_oConfig.getValue("presets",i.ToString(),"recurring",bRecurring.ToString())); } }