none
Make a Alarm In CLR/Windows Forms RRS feed

  • Question

  • hi 

    i star making a alarm in my form its work well but i need the alarm work witch files check all the files in the day and tourn on when is the time.

    and also when the form its open and check the files and verifies all the information and the event pass send a messagebox.

    this is the code i have

    private: System::Void timer1_Tick(System::Object^  sender, System::EventArgs^  e) {
    			
    			 	
    			    DateTime^ today = DateTime::Now;
    				toolStripStatusLabel1->Text = today->ToShortDateString();
    				toolStripStatusLabel2->Text = today->ToShortTimeString();
    				
    		try{
    		
    			
    		      Stream^ tr = File::OpenRead("alarm.wav");
    		      if(!bandera){
    			 if(this->maskedTextBox1->Text==today->ToString("hh:mm")&&this->maskedTextBox2->Text==today->ToString("dd/MM/yyyy"))
    				{
    				bandera=true;
    				SoundPlayer^ player = gcnew SoundPlayer();
    				player->Stream = tr;
    				player->Load();
    				player->PlayLooping();
    				if (MessageBox::Show(maskedTextBox1->Text+"\n"+textHora->Text,"ALARMA!!!!!!!!!!!!!",MessageBoxButtons::OK,MessageBoxIcon::Exclamation)==Windows::Forms::DialogResult::OK)
    				{
    			     player->Stop();
    				}
    				
    				}
    		}
    		}
    		catch(Exception^ err){MessageBox::Show("Error: " + err->Message,"Play", MessageBoxButtons::OK, MessageBoxIcon::Error);}
    			}
    and this one load the informacion in the listbox
    private: System::Void listBox2_SelectedIndexChanged(System::Object^  sender, System::EventArgs^  e) {
    			 try{
    			            String^ fr = this->listBox2->SelectedItem->ToString();
    						String^ fq = this->Diaselect->Value.ToString("dd..MM..yyyy");
    				        this->folderBrowserDialog2->SelectedPath = ("c:\\eventos"+"\\"+fq);
    						String^ fw = this->folderBrowserDialog2->SelectedPath->ToString();
    						StreamReader^ rf = File::OpenText( fw + "\\" + fr );
    						
    
    						this->maskedTextBox1->Text = rf->ReadLine();
    						this->maskedTextBox2->Text = rf->ReadLine();
    						this->textHora->Text = rf->ReadLine();
    						
    						
    
    						rf->Close();}
    			 catch(Exception^ err){}
    		 
    		 }

    Tuesday, April 9, 2013 7:00 PM

Answers

All replies