Task Schedular

How to make a Task schedular with custom colored progress bars and interchanging wallpaper according to time.

 

Using the timestruct, the timestruct method takes the time from the computer and uses it in the program.

tsk schdler

The main label Displaying the current system time and date

{
label4.Text = DateTime.Now.ToLongTimeString();
}

{
label5.Text = DateTime.Now.ToString(“ddd,d MMM,yyyy”);

}

The progress bar displaying the seconds time and integrating it with the progress bar, the rest can be edited the same way

{
label3.Text = DateTime.Now.ToString(“ss”);
}

{
progressBar1.BackColor = Color.PowderBlue; // seconds progress bar design
progressBar1.ForeColor = Color.Navy;
progressBar1.Style = System.Windows.Forms.ProgressBarStyle.Continuous;
string sec = DateTime.Now.ToString(“ss”);  // taking the system seconds, converting them to int and integrating it to the progress bar
int se = Convert.ToInt16(sec);
progressBar1.Value = se;
progressBar1.Update();
}

Opening the Dialog to select the file

dlg = new OpenFileDialog(); // on clicking the button opens the file dialog
dlg.DefaultExt = “.exe”; // file dialog default extension, i chose .exe
dlg.Filter = “All Files|”; // dialog box filter
dlg.FilterIndex = 0; // number of files that can be selected in the dialog box
dlg.Multiselect = false; // multi-select option not available
dlg.InitialDirectory = Directory.GetCurrentDirectory(); // the initial directory when file dialog is opened
if (dlg.ShowDialog(this) == DialogResult.OK) // gets the address of the selected file
{

if (dlg.FileName != string.Empty) // condition on the selected file, gets selected file name and address
{
textBox3.Text = dlg.FileName; // shows the selected file’s address and name
fn = textBox3.Text; // taking the file name string named ‘ fn’ for later use
}

After selecting the file,setting the time from the date-time dropdown box and comparing it with the current time, the set date and time is displayed in the header.

 

if (checkBox1.Checked == true) // condition if the checkBox is checked
{
if (fn != null) // if string ‘ fn ‘ is not empty
{
this.Text = “Task – Set: (” + dateTimePicker1.Value.ToShortDateString() + “)_(” + dateTimePicker2.Value.ToShortTimeString() + “)”; // the task is set and the scheduled time and date is displayed on the header

if
(DateTime.Now >= dateTimePicker1.Value) // condition to compare the scheduled and current time
{ f = 2; }
else
{ f = 0; };

if
(DateTime.Now >= dateTimePicker2.Value)// condition to compare the scheduled and current date
{ g = 2; }
else
{ g = 3; };

if (f == g)
{
checkBox1.Checked = false; // if the conditions have been fulfilled,the checkbox is unchecked so as to break loop
System.Diagnostics.Process.Start(@fn);// using system diagnostics, the selected file starts
MessageBox.Show(“Task Activated”);
textBox3.Clear(); // textbox is restarted
}
else { };
}
else
{
checkBox1.Checked = false;  // if no file is selected, shows this message
MessageBox.Show(“Please select an App to run”);

}
}
}

Changing the desktop walpaper and the progress bar colour, the pre-defined walpapers are stored in the resources folder and picked up from there.

{ string hour = DateTime.Now.ToString(“hh”);
int hr = Convert.ToInt16(hour);

int h = 1;
int i = 3;
int j = 6;
int k = 9;
int l = 12;
if (h<=2)
{
if (hr<=i)
{ this.BackgroundImage = Properties.Resources.tsk4; }
else
{
if ( hr <= j)
{ this.BackgroundImage = Properties.Resources.tsk1; }
else{
if ( hr <= k)
{ this.BackgroundImage = Properties.Resources.ts2; }
else{

if ( hr <= l)
{ this.BackgroundImage = Properties.Resources.tsk5; }

}}}
}

}

 

Hope this help’s. Thank you.